LayoutEngine

@objcMembers open class LayoutEngine: NSObject

Core object that is required by Layout instances in order to provide:

  • Unit scaling between Blockly’s Workspace coordinate system and the UIView coordinate system
  • UI configuration

All Layout instances in a single Layout tree should share the same single instance of LayoutEngine. If any of the nodes in a single tree use different instances of LayoutEngine, unexpected results may occur.

  • The minimum scale that the engine can have, relative to the Workspace coordinate system.

    Declaration

    Swift

    public fileprivate(set) final var minimumScale: CGFloat = 0.5
  • The maximum scale that the engine can have, relative to the Workspace coordinate system.

    Declaration

    Swift

    public fileprivate(set) final var maximumScale: CGFloat = 2.0
  • The current scale of the UI, relative to the Workspace coordinate system. eg. scale = 2.0 means that a (10, 10) UIView point scales to a (5, 5) Workspace point.

    Declaration

    Swift

    public final var scale: CGFloat = 1.0
  • The scale that should be used inside popovers

    Declaration

    Swift

    public final var popoverScale: CGFloat
  • rtl

    Flag determining if Layout instances associated with this layout engine should be rendered in right-to-left (true) or left-to-right (false)..

    Declaration

    Swift

    public final var rtl: Bool
  • The UI configuration to use for this layout engine

    Declaration

    Swift

    public final var config: LayoutConfig
  • Using the current scale value, this method scales a point from the UIView coordinate system to the Workspace coordinate system.

    Note

    This does not translate a UIView point directly into a Workspace point, it only scales the magnitude of a UIView point into the Workspace coordinate system. For example, in RTL, more calculation would need to be done to get the UIView point’s translated Workspace point.

    Declaration

    Swift

    public final func scaledWorkspaceVectorFromViewVector(_ point: CGPoint) -> WorkspacePoint

    Return Value

    A point in the Workspace coordinate system.

  • Using the current scale value, this method scales a size from the UIView coordinate system to the Workspace coordinate system.

    Declaration

    Swift

    public final func workspaceSizeFromViewSize(_ size: CGSize) -> WorkspaceSize

    Return Value

    A size in the Workspace coordinate system.

  • Using the current scale value, this method scales a unit value from the UIView coordinate system to the Workspace coordinate system.

    Declaration

    Swift

    public final func workspaceUnitFromViewUnit(_ unit: CGFloat) -> CGFloat

    Return Value

    A unit value in the Workspace coordinate system.

  • Using the current scale value, this method scales a unit value from the Workspace coordinate system to the UIView coordinate system.

    Declaration

    Swift

    public final func viewUnitFromWorkspaceUnit(_ unit: CGFloat) -> CGFloat

    Return Value

    A unit value in the UIView coordinate system.

  • Using the current scale value, this method scales a left-to-right point from the Workspace coordinate system to the UIView coordinate system.

    Declaration

    Swift

    public final func viewPointFromWorkspacePoint(_ point: WorkspacePoint) -> CGPoint

    Return Value

    A point in the UIView coordinate system.

  • Using the current scale value, this method scales a (x, y) point from the Workspace coordinate system to the UIView coordinate system.

    Declaration

    Swift

    public final func viewPointFromWorkspacePoint(_ x: CGFloat, _ y: CGFloat) -> CGPoint

    Return Value

    A point in the UIView coordinate system.

  • Using the current scale value, this method scales a size from the Workspace coordinate system to the UIView coordinate system.

    Declaration

    Swift

    public final func viewSizeFromWorkspaceSize(_ size: WorkspaceSize) -> CGSize

    Return Value

    A size in the UIView coordinate system.