WorkbenchViewController

@objcMembers open class WorkbenchViewController: UIViewController

View controller for editing a workspace.

  • The style of the workbench

    Declaration

    Swift

    public enum Style: Int
  • Set of UIStateValue values representing the workbench state.

    Declaration

    Swift

    public typealias UIState = Set<UIStateValue>
  • Underlying type for a UI state value.

    Declaration

    Swift

    public typealias UIStateValue = Int
  • State indicating the trash can is open.

    Declaration

    Swift

    public let stateTrashCanOpen = WorkbenchViewController.newUIStateValue()
  • State indicating the trash can is highlighted

    Declaration

    Swift

    public let stateTrashCanHighlighted = WorkbenchViewController.newUIStateValue()
  • State indicating the toolbox category is open.

    Declaration

    Swift

    public let stateCategoryOpen = WorkbenchViewController.newUIStateValue()
  • State indicating a text field is being edited.

    Declaration

    Swift

    public let stateEditingTextField = WorkbenchViewController.newUIStateValue()
  • State indicating a block is currently being dragged.

    Declaration

    Swift

    public let stateDraggingBlock = WorkbenchViewController.newUIStateValue()
  • State indicating a popover is being presented.

    Declaration

    Swift

    public let statePresentingPopover = WorkbenchViewController.newUIStateValue()
  • State indicating the user panned the workspace.

    Declaration

    Swift

    public let stateDidPanWorkspace = WorkbenchViewController.newUIStateValue()
  • State indicating the user tapped the workspace.

    Declaration

    Swift

    public let stateDidTapWorkspace = WorkbenchViewController.newUIStateValue()
  • The main workspace view controller

    Declaration

    Swift

    public private(set) lazy var workspaceViewController: WorkspaceViewController =
  • The trash can view.

    Declaration

    Swift

    open fileprivate(set) lazy var trashCanView: TrashCanView =
  • The undo button

    Declaration

    Swift

    open fileprivate(set) lazy var undoButton: UIButton =
  • The redo button

    Declaration

    Swift

    open fileprivate(set) lazy var redoButton: UIButton =
  • The toolbox category view controller.

    Declaration

    Swift

    open fileprivate(set) lazy var toolboxCategoryViewController: ToolboxCategoryViewController =
  • The layout engine to use for all views

    Declaration

    Swift

    public final let engine: LayoutEngine
  • The layout builder to create layout hierarchies

    Declaration

    Swift

    public final let layoutBuilder: LayoutBuilder
  • The factory for creating blocks under this workbench. Any block added to the workbench should be able to be re-created using this factory.

    Declaration

    Swift

    public final let blockFactory: BlockFactory
  • The factory for creating views

    Declaration

    Swift

    public final let viewFactory: ViewFactory
  • The style of workbench

    Declaration

    Swift

    public final let style: Style
  • The main workspace.

    Declaration

    Swift

    open var workspace: Workspace?
  • The toolbox that has been loaded via loadToolbox(:)

    Declaration

    Swift

    open var toolbox: Toolbox?
  • The NameManager that controls the variables in this workbench’s scope.

    Declaration

    Swift

    public let variableNameManager: NameManager
  • Coordinator that handles logic for managing procedure functionality

    Declaration

    Swift

    public var procedureCoordinator: ProcedureCoordinator?
  • Displays (true) or hides (false) a trash can. By default, this value is set to true.

    Declaration

    Swift

    open var enableTrashCan: Bool = true
  • If true, blocks dragged into trash are kept in memory and can be recalled by tapping the trash can. If false, blocks are not kept in memory and tapping the trash can is disabled. Defaults to false.

    Declaration

    Swift

    open var keepTrashedBlocks: Bool = false
  • Enables or disables pinch zooming of the workspace. Defaults to true.

    Declaration

    Swift

    open var allowZoom: Bool
  • Enables or disables the ability to undo/redo actions in the workspace. Defaults to true.

    Declaration

    Swift

    open var allowUndoRedo: Bool = true
  • Enables or disables the interactivePopGestureRecognizer on self.navigationController (i.e. the backswipe gesture on UINavigationController). Defaults to false.

    Declaration

    Swift

    open var allowInteractivePopGestureRecognizer: Bool = false
  • The background color to use for the main workspace.

    Declaration

    Swift

    public var workspaceBackgroundColor: UIColor?
  • Flag for whether the toolbox drawer should stay visible once it has been opened (true) or if it should automatically close itself when the user does something else (false). By default, this value is set to false.

    Declaration

    Swift

    open var toolboxDrawerStaysOpen: Bool = false
  • A set containing all active states of the UI.

    Declaration

    Swift

    open fileprivate(set) var state = WorkbenchViewController.UIState()
  • The delegate for events that occur in the workbench

    Declaration

    Swift

    open weak var delegate: WorkbenchViewControllerDelegate?
  • Controller for listing the toolbox categories

    Declaration

    Swift

    open fileprivate(set) lazy var toolboxCategoryListViewController:
  • Controller for managing the trash can workspace

    Declaration

    Swift

    open fileprivate(set) lazy var trashCanViewController: TrashCanViewController =
  • Flag determining if this view controller should be recording events for undo/redo purposes.

    Declaration

    Swift

    open fileprivate(set) var shouldRecordEvents = true
  • Stack of events to run when applying undo actions. The events are sorted in chronological order, where the first event to undo is at the end of the array.

    Declaration

    Swift

    open var undoStack = [BlocklyEvent]()
  • Stack of events to run when applying redo actions. The events are sorted in reverse chronological order, where the first event to redo is at the end of the array.

    Declaration

    Swift

    open var redoStack = [BlocklyEvent]()
  • The pan gesture recognizer attached to the main workspace.

    Declaration

    Swift

    public var workspacePanGesetureRecognizer: UIPanGestureRecognizer!
  • The tap gesture recognizer attached to the main workspace.

    Declaration

    Swift

    public private(set) lazy var workspaceTapGestureRecognizer: UITapGestureRecognizer =
  • Automatically creates a WorkspaceLayout and WorkspaceLayoutCoordinator for a given workspace (using both the self.engine and self.layoutBuilder instances). The workspace is then rendered into the view controller.

    Note

    All blocks in workspace must have corresponding BlockBuilder objects in self.blockFactory, based on their associated block name. This is needed for things like handling undo/redo and automatic creation of variable blocks.

    Note

    A ConnectionManager is automatically created for the WorkspaceLayoutCoordinator.

    Throws

    BlocklyError: Thrown if an associated WorkspaceLayout could not be created for the workspace, or if no corresponding BlockBuilder could be found in self.blockFactory for at least one of the blocks in workspace.

    Declaration

    Swift

    open func loadWorkspace(_ workspace: Workspace) throws
  • Automatically creates a WorkspaceLayout and WorkspaceLayoutCoordinator for a given workspace (using both the self.engine and self.layoutBuilder instances). The workspace is then rendered into the view controller.

    Note

    All blocks in workspace must have corresponding BlockBuilder objects in self.blockFactory, based on their associated block name. This is needed for things like handling undo/redo and automatic creation of variable blocks.

    Throws

    BlocklyError: Thrown if an associated WorkspaceLayout could not be created for the workspace, or if no corresponding BlockBuilder could be found in self.blockFactory for at least one of the blocks in workspace.

    Declaration

    Swift

    open func loadWorkspace(_ workspace: Workspace, connectionManager: ConnectionManager) throws
  • Automatically creates a ToolboxLayout for a given Toolbox (using both the self.engine and self.layoutBuilder instances) and loads it into the view controller.

    Note

    All blocks defined by categories in toolbox must have corresponding BlockBuilder objects in self.blockFactory, based on their associated block name. This is needed for things like handling undo/redo and automatic creation of variable blocks.

    Throws

    BlocklyError: Thrown if an associated ToolboxLayout could not be created for the toolbox, or if no corresponding BlockBuilder could be found in self.blockFactory for at least one of the blocks specified intoolbox.

    Declaration

    Swift

    open func loadToolbox(_ toolbox: Toolbox) throws
  • Refreshes the UI based on the current version of self.workspace and self.toolbox.

    Declaration

    Swift

    open func refreshView()
  • Adds custom gesture recognizers to a block view. It is automatically called by WorkbenchViewController when a block view is added to the workspace.

    Subclasses may override this to add custom gesture tracking to a block view. The default implementation does nothing.

    Declaration

    Swift

    open func addGestureTracking(forBlockView blockView: BlockView)
  • Removes all gesture recognizers and any on-going gesture data from a block view.

    Declaration

    Swift

    open func removeGestureTracking(forBlockView blockView: BlockView)
  • Highlights a block in the workspace.

    Declaration

    Swift

    public func highlightBlock(blockUUID: String)
  • Unhighlights a block in the workspace.

    • Paramater blockUUID: The UUID of the block to unhighlight.

    Declaration

    Swift

    public func unhighlightBlock(blockUUID: String)
  • Unhighlights all blocks in the workspace.

    Declaration

    Swift

    public func unhighlightAllBlocks()