Threepipe Tweakpane Editor Plugin
    Preparing search index...

    Class EditorModeBar

    A vertical bar of mode buttons on the right of the page, for the modes of the TweakpaneEditorPlugin (Viewer, Interaction, Export...), instead of the tabs at the bottom.

    • Each mode has its own colour and icon (EditorModeBar.Looks), like the property tabs of Blender: a mode is quicker to find, and easy to name ("the green export tab").
    • A click on a mode shows its panels. A click on the open mode hides the panel, and the canvas takes its room.
    • The button at the bottom steps through three states (cycle): the names next to the icons (like a sidebar) and the panel; the icons and the panel; the icons only, the panel hidden. Ctrl+\ (Cmd+) does the same (in EditorFrame).
    • Without the names, each button has a tooltip (tippy.js, the editor theme of the editor).

    The bar sets the CSS variable --mb-width on the root element, and the class mb-panel-hidden on the body when the panel is hidden, for the page layout (EditorFrame).

    Index
    • Parameters

      • editor: EditorModeBarHost

        the editor with the modes

      • host: HTMLElement

        the element the bar is added to

      • Optionalpanel: () => HTMLElement | null

        returns the element that is hidden when the open mode is clicked again (the Tweakpane container)

      • storageKey: string | null = EditorModeBar.StorageKey

        the localStorage key that keeps the names shown or hidden, or null to not keep it. Default: EditorModeBar.StorageKey. At the first visit, the names are shown in a window 920 px wide or more (EditorModeBar.WideQuery); a narrower window (a phone) has no room for them.

      Returns EditorModeBar

    the editor with the modes

    element: HTMLDivElement
    onExpandedChange?: (expanded: boolean) => void

    Called when the names are shown or hidden, with the new state (the toggle button, or setExpanded)

    onLayoutChange?: () => void

    Called when the panel or the names show or hide, so the room next to the mode bar changes (for the frame)

    panel?: () => HTMLElement | null

    returns the element that is hidden when the open mode is clicked again (the Tweakpane container)

    storageKey: string | null = EditorModeBar.StorageKey

    the localStorage key that keeps the names shown or hidden, or null to not keep it. Default: EditorModeBar.StorageKey. At the first visit, the names are shown in a window 920 px wide or more (EditorModeBar.WideQuery); a narrower window (a phone) has no room for them.

    Looks: Record<string, EditorModeLook> = ...

    The colour and icon of each mode name. A mode that is not here gets a grey dot. Read when the bar is made: set it before TweakpaneEditorPlugin.loadPlugins.

    StorageKey: string | null = 'tpEditorModeBarExpanded'

    The default localStorage key that keeps the names shown or hidden, or null to not keep them

    WideQuery: string = '(min-width: 920px)'

    The media query of a window wide enough to show the names at the first visit (nothing stored)

    Widths: { narrow: number; wide: number } = ...

    Width of the bar without and with the names, in px

    • Adds a tooltip to a button of the bar (not a mode), shown with the others when the names are hidden

      Parameters

      • button: HTMLElement
      • content: string

      Returns void

    • One step of the collapse states, as the button at the bottom and Ctrl+\ do: the names and the panel → the icons and the panel → the icons only (the panel hidden) → the names and the panel again. A window without room for the names (EditorModeBar.WideQuery) skips the names. A click on the open mode still hides or shows the panel.

      Returns void

    • Hides the tooltips of the bar and keeps them off while held is true, for a menu that a button of the bar opened (the layout menu of EditorFrame): the tooltip would cover the menu. Then they show again, when the names are hidden.

      Parameters

      • held: boolean

      Returns void

    • Shows or hides the names next to the icons

      Parameters

      • expanded: boolean

        the names are shown

      • keep: boolean = false

        the person picked it (the toggle, Ctrl+, a UI): it is kept in localStorage (storageKey). A change from code is not, so the person's pick, or the default of the window width, comes back at the next visit.

      Returns void