DockFrame class
#include <Jazz2/UI/Windows/Dock.h>
Panel that is docked at an edge of the screen or floats over everything else.
The header of the panel is dragged to move it — out of its place, which makes it float, around the screen and back to the edge, which docks it again. The button at the end of the header does the same in one click. A floating panel is resized by its edges. On its way between the two places the panel glides, while the room it takes when docked opens or closes, see GetDockedAmount().
The owner places the panel by Arrange() with the bounds it has when docked, whether it's docked or not. Elements added to the frame after the panel (not into it) are drawn over the panel and placed by the owner.
Base classes
- class Element
- Element of the interface.
Public static variables
- static float MinFloatingWidth constexpr
- Smallest width of a floating panel in units.
- static float MinFloatingHeight constexpr
- Smallest height of a floating panel in units.
Constructors, destructors, conversion operators
- DockFrame(DockSide side, StringView tooltip)
- Creates a new instance.
Public functions
- auto GetPanel() const -> Panel*
- Returns the panel, its first child is the header.
- auto GetHeaderContent() const -> Stack*
- Returns the stack in the header between the grip and the button, for the title or tabs.
- auto IsFloating() const -> bool
- Returns
trueif the panel floats, or is going to once it got there. - void SetFloating(bool floating, bool animate = true)
- Makes the panel float or docks it, it glides there unless
animateisfalse. - auto GetDockedAmount() const -> float
- Returns how much of the room the panel takes when docked it takes now, from 0 to 1.
- auto IsLifted() const -> bool
- Returns
trueif the panel is drawn over the other panels — it floats, or it's on its way. - auto GetTargetBounds(const Context& context, const Rectf& dockBounds) const -> Rectf
- Returns the bounds the panel will have, as Arrange() would place it.
- void SetDrawerMode(bool drawer)
- Makes the panel a drawer, for a small screen, or docks it again.
- auto IsDrawer() const -> bool
- Returns
trueif the panel is a drawer. - void SetDrawerOpen(bool open)
- Opens or closes the drawer, it slides.
- auto IsDrawerOpen() const -> bool
- Returns
trueif the drawer is open, or opening. - void DrawDockPreview(Painter& painter)
- Draws where the panel would be docked if it was let go now, under all floating panels.
- auto GetTitle() const -> StringView override
- Returns the title of the element as a window, the system shows it on the taskbar while it's in a window of its own.
- void Arrange(const Context& context, const Rectf& bounds) override
- Places the element and its children.
- void Draw(Painter& painter) override
- Draws the element and its children.
- void Update(float timeMult) override
- Advances animations of the element and its children.
- auto HitTest(Vector2f pos) -> Element* override
- Returns the element under a position that takes the pointer, or
nullptr. - auto GetHitBounds() const -> Rectf override
- With the edges a floating panel is resized by, which reach a little outside of it.
- auto AcceptsPointer() const -> bool override
- Returns
trueif the element takes the pointer itself. - auto OnPointerDown(const PointerEvent& event) -> bool override
- Called when the pointer is pressed over the element, returns
trueto keep getting it until released. - void OnPointerDownInside(const PointerEvent& event) override
- Called before the pointer is pressed over an element inside of this one, on each of its parents.
- void OnPointerMove(const PointerEvent& event) override
- Called when the pointer moves while pressed over the element.
- void OnPointerUp(const PointerEvent& event, bool inside) override
- Called when the pointer is released,
insidetells whether it's still over the element.
Public variables
- Rectf FloatingBounds
- Bounds of the floating panel in units, the width is 0 if it hasn't floated yet.
- String Title
- Title of the panel, shown on the taskbar while it's in a window of its own, see Surface::
PlaceDetachable(). - bool Detached
- Whether the floating panel is in a window of its own outside of the main window.
- Function<void()> OnChanged
- Called when the panel was docked, made float, moved or resized.
- Function<void()> OnActivated
- Called when the panel is pressed anywhere, it should come in front of the other floating panels.
Function documentation
void Jazz2:: UI:: Windows:: DockFrame:: SetDrawerMode(bool drawer)
Makes the panel a drawer, for a small screen, or docks it again.
A drawer takes no room, it slides over the view from its edge when it's opened and out when it's closed. It doesn't float then, the header only closes it.
Variable documentation
bool Jazz2:: UI:: Windows:: DockFrame:: Detached
Whether the floating panel is in a window of its own outside of the main window.
Kept while the panel is hidden or the interface is built again, so it gets its window back where FloatingBounds is, also after a restart if it's remembered with the bounds.