WorkspaceLayoutCoordinator

@objcMembers open class WorkspaceLayoutCoordinator: NSObject

Object that is responsible for managing a worksapce layout. This includes maintaining the layout hierarchy of the workspace and ensuring that model and layout objects under this workspace layout remains in-sync.

  • The workspace layout whose layout hierarchy is being managed by this object

    Declaration

    Swift

    open let workspaceLayout: WorkspaceLayout
  • Builder for constructing layouts under self.workspaceLayout

    Declaration

    Swift

    public final let layoutBuilder: LayoutBuilder
  • Manager for tracking all connection positions under self.workspaceLayout. If this value is nil, connection positions aren’t being tracked.

    Declaration

    Swift

    public fileprivate(set) final var connectionManager: ConnectionManager?
  • Object responsible for bumping blocks away from each other

    Declaration

    Swift

    open let blockBumper = BlockBumper()
  • Manager responsible for keeping track of all variable names under this workspace

    Declaration

    Swift

    public weak var variableNameManager: NameManager?
  • The factory for building blocks dynamically. Currently only used for building variable blocks for the toolbox.

    Declaration

    Swift

    public var blockFactory: BlockFactory?
  • Adds a block tree (a block and its children) to the workspace handled by the workspace layout coordinator. The layout heirarchy is automatically updated to reflect this change.

    Throws

    BlocklyError: If the block to be added would put the workspace into an illegal state.

    Declaration

    Swift

    open func addBlockTree(_ rootBlock: Block) throws
  • Disconnects a given block from its previous/output connections, and removes it and all of its connected blocks from the workspace.

    Throws

    BlocklyError: Thrown if the tree of blocks could not be removed from the workspace.

    Declaration

    Swift

    open func removeBlockTree(_ rootBlock: Block) throws
  • Disconnects a single block from all connections, and removes it. This function will also reconnect next blocks to the previous block.

    Throws

    BlocklyError: Thrown if the block could not be removed from the workspace, or if the connections can’t be reconnected.

    Declaration

    Swift

    open func removeSingleBlock(_ block: Block) throws
  • Deep copies a block and adds all of the copied blocks into the workspace.

    Throws

    BlocklyError: Thrown if the block could not be copied

    Declaration

    Swift

    open func copyBlockTree(_ rootBlock: Block, editable: Bool,
                              position: WorkspacePoint = WorkspacePoint.zero) throws -> Block

    Return Value

    The root block that was copied

  • Connects a pair of connections, disconnecting and possibly reattaching any existing connections, depending on the operation.

    Declaration

    Swift

    open func connectPair(_ connectionPair: ConnectionManager.ConnectionPair)
  • Disconnects a specified connection. The layout hierarchy is automatically updated to reflect this change.

    Throws

    BlocklyError: Thrown if the connection is not attached to a source block.

    Declaration

    Swift

    open func disconnect(_ connection: Connection) throws
  • Disconnects the shadow connection for a specified connection. The layout hierarchy is automatically updated to reflect this change.

    Throws

    BlocklyError: Thrown if the connection is not attached to a source block.

    Declaration

    Swift

    open func disconnectShadow(_ connection: Connection) throws
  • Connects a pair of connections. The layout hierarchy is automatically updated to reflect this change.

    Throws

    BlocklyError: Thrown if either connection is not attached to a source block or if the connections were unable to connect.

    Declaration

    Swift

    open func connect(_ connection1: Connection, _ connection2: Connection) throws
  • Re-builds the layout hierarchy for a block that is already associated with a layout.

    Throws

    BlocklyError: Thrown if the specified block is not associated with a layout yet.

    Declaration

    Swift

    open func rebuildLayoutTree(forBlock block: Block) throws