Threepipe Tweakpane Editor Plugin
    Preparing search index...

    Class EditorFrame

    The frame of the page around the editor: the layout of the canvas, the Tweakpane panel and the EditorModeBar, with a title bar or a status bar (EditorFrameLayout).

    • The bars show the app name, the name of the open file or project (documentName; a click edits it with EditorFrameOptions.onRename), a light or dark button and a layout menu.
    • Shift+T switches between the light and dark theme of the same family (EditorFrameOptions.themePairs).
    • The panel has no title of its own: the mode bar names the open mode and hides the panel.

    Made by TweakpaneEditorPlugin (its layout). The actions (light or dark, layout) are at the bottom of the mode bar in each layout. The body has the class lay-frame and lay-<layout>. The canvas size follows the CSS of the layout, and the viewer follows the canvas size (the ResizeObserver of ThreeViewer).

    The frame has three fixed places (EditorFrameArea): the left sidebar, the bottom strip below the canvas, and the top of the right sidebar (above the settings of the mode, in the panel). An app adds panels to them with addPanel, and the person moves them (the Move menu of their entry); an empty place takes no room. The CSS variables --lay-left-area, --lay-right-area and --lay-bottom-area on the body are the width or the height of each area (0px when it is empty). In the floating layout the areas are cards over the canvas, and --lay-left-inset and --lay-bottom-inset are the parts of the canvas that the left and the bottom card cover with their gap: the perf pill, the bar of the sticky notes and the tool bar keep out of them.

    The left area, the bottom area and the panel have a size and can collapse (setAreaSize, setAreaCollapsed). A drag on the inner edge of the area changes its size, between the limits of AreaLimits; a drag past half of the smallest size collapses it, and a drag out of the edge opens it again. A double-click on the edge sets the default size, or opens a collapsed area. The sizes and the collapsed left and bottom areas that the person picks are kept in localStorage (AreaStorageKey). The panel collapses as the mode bar hides it, and the mode bar shows it again.

    The layout changes at the window widths of Breakpoints. Side by side (lay-side), the canvas, the panel and the mode bar are next to each other. In a portrait window under 920 px wide (a phone, lay-stack), the layout keeps its bars (floating has no gap there); the canvas is on top at full width, and the panel and the mode bar are below it, with the same height. The CSS variable --lay-split is the part of the height for the canvas: 0.45, set on body.lay-frame (a page sets another with a more specific rule, like html body.lay-frame { --lay-split: 0.5; }). When the panel is hidden there, the mode bar is a row at the bottom.

    The mode bar lists the modes, then an entry for each panel (its name and icon from addPanel). A tap on an entry shows or hides its panel (setPanelHidden), a right-click or a long press moves it (movePanel). In a narrow window (lay-single), the place of the panel shows one of them at a time (setStackedArea): a mode shows the panel there, an entry shows its area, and a tap on the one shown hides that place.

    In the floating layout, the cards move and take a part of their side (setAreaOffset, setAreaSpan), and a head at the top of the left column shows the logo, the app name and the file name.

    Index
    actions: ViewerAction[] = ...

    The keys of the frame, as actions (registered in viewer.actions of EditorFrameOptions.viewer, where a UI lists and runs them, else in an own ViewerActions): Shift+T switches between the light and the dark theme, Ctrl+\ (Cmd+\ on a Mac) steps through the collapse states of the mode bar and the panel, ? opens or closes the sheet of the keyboard shortcuts (toggleShortcuts). The place of the T key, the \ key or its place (a layout where it types another character), and the ? character (on each layout).

    modeBar: EditorModeBar
    options: EditorFrameOptions = {}

    the layout, the app name, the theme and the callbacks

    AreaLimits: Record<EditorFrameSizedArea, [number, number]> = ...

    The smallest and the largest size of each area in px (setAreaSize, a drag of its edge). The bottom area is also at most half of the window, and the left area and the panel leave MinCanvasWidth for the canvas, next to each other and the mode bar.

    AreaNames: Record<EditorFrameArea, string> = ...

    The names of the places: the default names of the entries of the panels, and the Move menu (addPanel)

    AreaStorageKey: string | null = 'tpEditorFrameAreas'

    The localStorage key that keeps the sizes and the collapsed left and bottom areas that the person picks (a drag or a double-click of an edge), or null to not keep them. Read when the frame is made.

    Breakpoints: { singleView: number; stack: number } = ...

    The window widths in px where the layout of the frame changes (read on each resize; change them before the frame is made, or call a resize):

    • stack: a portrait window narrower than this (a phone) has the canvas on top and the panel below it (the body class lay-stack); else the parts are side by side (lay-side).
    • singleView: a window narrower than this, in any orientation, has no room for the left and the bottom area next to the canvas (the smallest left area, panel, mode bar and canvas: 160 + 240 + 44 + 240 = 684 px). The areas then show in the place of the panel, one view at a time, picked with their entries in the mode bar (lay-single, also set with lay-stack, see setStackedArea).
    LongPressTime: number = 500

    The time in ms of a press on the entry of a panel, on a touch screen, that opens its Move menu (addPanel)

    MinCanvasWidth: number = 240

    The width in px that the left area and the panel leave for the canvas (AreaLimits)

    MinCardLength: number = 120

    The smallest length in px of a card of the floating layout along its side (setAreaSpan)

    MinSectionSize: number = 48

    The smallest size in px of a panel in the stack of a place, when a drag moves the split (addPanel)

    ThemePairs: [string, string][] = ...

    The default theme pairs: Shift+T goes from one to the other

    • Adds a panel to the frame, or puts a new element in the panel of this id. A panel is an element in a place of the frame, with an entry in the mode bar:

      • The places are fixed: left, the sidebar left of the canvas; bottom, the strip below the canvas; right, the top of the right sidebar, above the settings of the mode, in the panel of the Tweakpane UI. The panel starts in options.area (left), until the person moves it: a right-click on its entry (a long press on a touch screen) opens a menu of the places (movePanel).
      • The panels of a place are a stack, in the order they were added: the place is split between them, with a line between two (a gap with drag dots in the floating layout, where each panel is a card). A drag on it moves the split, at least MinSectionSize for each; a double-click makes them equal.
      • The entry, after the modes, has the name, the icon and the colour of options. A tap on it shows or hides the panel (setPanelHidden); hiding the last shown panel of a place collapses the place. In a narrow window (Breakpoints) the left and the bottom place show in the place of the panel, one view at a time (setStackedArea).
      • A place with a panel shows (the body class lay-has-<area>), and the canvas makes room for it (the floating layout: a card over the canvas); an empty place takes no room. The left place is --lay-left-area-size wide (240px), the bottom place --lay-bottom-area-size tall (160px), CSS variables on body.lay-frame.
      • The place, the hidden state and the size in the stack that the person picks are kept by id in localStorage (AreaStorageKey), with the sizes.

      The panels go with the frame: TweakpaneEditorPlugin.addPanel adds them again when the plugin makes the frame again.

      Parameters

      Returns void

    • Moves a panel to another place (left, bottom or right), at the end of its stack, and shows it (the place opens when it was collapsed, the panel when the mode bar hid it for the right place; in a narrow window, the place shows in the place of the panel). The Move menu of its entry does this.

      Parameters

      Returns void

    • Moves a card of the floating layout away from its side of the window, on the axis of its size: the left card to the right, the bottom card up, the panel with the mode bar to the left. The card stays within the room that leaves MinCanvasWidth for the canvas (the bottom card: within half of the window height); when the window gets smaller, the offset gets smaller first, then the size. It applies only in the floating layout with the areas next to the canvas (not in a narrow window, see Breakpoints); elsewhere it is kept for later. A drag of the grip of a card (a strip in the gap on its side of the window) sets it and the start of its span (setAreaSpan); a double-click of the grip puts the card back. The CSS variable --lay-<area>-offset on the body.

      Parameters

      • area: EditorFrameSizedArea

        left, bottom or right (the panel and the mode bar)

      • offset: number | null

        the offset in px, or null for none

      • keep: boolean = false

        keep it in localStorage (AreaStorageKey), as the person's pick

      Returns void

    • Sets the size of an area in px: the width of the left area or the panel (right), the height of the bottom area. It is kept between the limits of AreaLimits, and leaves room for the canvas. When the window gets smaller, or another area or the panel opens, the area gets smaller to leave that room, and its size comes back when there is room again. null sets the size of the CSS again (240 px, 160 px, and the panel width of the Tweakpane UI).

      Parameters

      • area: EditorFrameSizedArea

        left, bottom or right (the panel)

      • size: number | null

        the size in px, or null

      • keep: boolean = false

        keep it in localStorage (AreaStorageKey), as a size that the person picks

      Returns void

    • Sets the part of its side that a card of the floating layout takes: the top and the height of the left card and of the panel with the mode bar, the left end and the width of the bottom card (in its row, between the left card and the panel). The length is at least MinCardLength, and the card stays in its side. null: the whole side (the default). It applies where setAreaOffset applies. A drag of the ends of a card (the top and the bottom edge, or the left and the right end) sets it, and a double-click of an end fills the side again; a drag of the grip moves the card along its side. The CSS variables --lay-<area>-start and --lay-<area>-length on the body.

      Parameters

      Returns void

    • Hides the settings of the mode in the panel while the right place shows panels (addPanel): the right place takes the whole panel. A click on the open mode in the mode bar does this too, and a click on a mode shows them again. Without the right area, the settings always show (the mode bar hides the panel). Not kept: an app sets it, for example while something is selected (an inspector in the right area, its settings in place of the modes). A panel that leaves the right place (a move or a remove) shows them again.

      Parameters

      • hidden: boolean

      Returns void

    • Shows or hides a panel, as its entry in the mode bar does. Hiding the last shown panel of a place collapses the place instead (the panel stays shown in it, for when the place opens); showing a panel opens its place.

      Parameters

      • id: string
      • hidden: boolean
      • keep: boolean = false

        keep it in localStorage (AreaStorageKey), as the person's pick

      Returns void

    • Sets the area that shows in the place of the panel in a narrow window (below the canvas on a phone, in the right column of a narrow landscape window, see Breakpoints), where there is no room for the areas next to the canvas: the panel (right, the default), or the left or the bottom area. The mode bar stays next to it: a tap on a mode shows the panel again, a tap on the entry of an area shows that area. A left or bottom area without an element shows the panel. It opens the place of the panel when the mode bar hid it. When the areas show next to the canvas, this has no effect (it is kept for the next narrow window). The body has the class lay-stacked-left or lay-stacked-bottom.

      Parameters

      • area: EditorFrameSizedArea

        right (the panel), left or bottom

      • keep: boolean = false

        keep it in localStorage (AreaStorageKey), as the person's pick (an entry of the mode bar)

      Returns void