WorkbenchViewController

open class WorkbenchViewController: UIViewController

View controller for editing a workspace.

  • The style of the workbench

    Declaration

    Swift

    public enum Style: Int
  • Details the bitflags for WorkbenchViewController’s state.

    Declaration

    Swift

    public typealias UIState = WorkbenchViewControllerUIState
  • Specifies the bitflags for individual state values of WorkbenchViewController.

    Declaration

    Swift

    public typealias UIStateValue = WorkbenchViewControllerUIStateValue
  • The main workspace view controller

    Declaration

    Swift

    open fileprivate(set) var workspaceViewController: WorkspaceViewController!
  • The trash can view.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    open fileprivate(set) 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 current state of 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
  • 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
  • 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
  • The current state of the UI

    Declaration

    Swift

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

    Declaration

    Swift

    open weak var delegate: WorkbenchViewControllerDelegate?
  • 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

    Parameters

    workspace

    The Workspace to load

  • 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

    Parameters

    workspace

    The Workspace to load

    connectionManager

    A ConnectionManager to track connections in the workspace.

  • 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

    Parameters

    toolbox

    The Toolbox to load

  • Refreshes the UI based on the current version of self.workspace and self.toolbox.

    Declaration

    Swift

    open func refreshView()
  • Updates the workbench based on a BlocklyEvent.

    Declaration

    Swift

    open func update(fromEvent event: BlocklyEvent, runForward: Bool)

    Parameters

    event

    The BlocklyEvent.

    runForward

    Flag determining if the event should be run forward (true for redo operations) or run backward (false for undo operations).

  • Updates the workbench based on a BlocklyEvent.Create.

    Declaration

    Swift

    open func update(fromCreateEvent event: BlocklyEvent.Create, runForward: Bool)

    Parameters

    event

    The BlocklyEvent.Create.

    runForward

    Flag determining if the event should be run forward (true for redo operations) or run backward (false for undo operations).

  • Updates the workbench based on a BlocklyEvent.Delete.

    Declaration

    Swift

    open func update(fromDeleteEvent event: BlocklyEvent.Delete, runForward: Bool)

    Parameters

    event

    The BlocklyEvent.Delete.

    runForward

    Flag determining if the event should be run forward (true for redo operations) or run backward (false for undo operations).

  • Updates the workbench based on a BlocklyEvent.Move.

    Declaration

    Swift

    open func update(fromMoveEvent event: BlocklyEvent.Move, runForward: Bool)

    Parameters

    event

    The BlocklyEvent.Move.

    runForward

    Flag determining if the event should be run forward (true for redo operations) or run backward (false for undo operations).

  • Updates the workbench based on a BlocklyEvent.Change.

    Declaration

    Swift

    open func update(fromChangeEvent event: BlocklyEvent.Change, runForward: Bool)

    Parameters

    event

    The BlocklyEvent.Change.

    runForward

    Flag determining if the event should be run forward (true for redo operations) or run backward (false for undo operations).

  • Copies the specified block from a flyout (trash/toolbox) to the workspace.

    Declaration

    Swift

    public func copyBlockToWorkspace(_ blockView: BlockView) -> BlockView?

    Parameters

    blockView

    The BlockView to copy

    Return Value

    The new BlockView

  • Removes a BlockView from the trash, when moving it back to the workspace.

    Declaration

    Swift

    public func removeBlockFromTrash(_ blockView: BlockView)

    Parameters

    blockView

    The BlockView to remove.

  • Highlights a block in the workspace.

    Declaration

    Swift

    public func highlightBlock(blockUUID: String)

    Parameters

    blockUUID

    The UUID of the block to highlight

  • 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()