docs
Loading...
Searching...
No Matches
ForegroundPanelOptions

#include <AppCore/layout/Options.h>

Overview

Configuration options for a floating panel.

Pass ForegroundPanelOptions to Foreground::AddPanel() or Foreground::AdoptPanel() to configure an overlay that floats above a window's tiled layout. A floating panel displays content such as a dialog or dropdown menu without shifting the layout beneath it.

Passing empty options creates a panel that fills the entire window.

This creates a centered dialog that closes like a native menu and takes keyboard focus:

RefPtr<Panel> dialog = window->foreground()->AddPanel(
{ .key = "confirm", .width = "400px", .height = "240px",
.placement = Anchor::WindowCenter(), .dismiss = Dismiss::Auto,
.focus = FocusPolicy::Grab });
dialog->view()->LoadURL("file:///confirm.html");
static Anchor WindowCenter()
Center the panel in the window.
Definition Anchor.h:157
A nullable smart pointer.
Definition RefPtr.h:126
@ Grab
Takes keyboard focus when created (unless hidden) and each time it is shown, even from inside a click...
Definition Options.h:40
@ Auto
The library also hides it the way the OS closes a native menu.
Definition Options.h:29

Size and Placement

Set width and height using logical pixels (eg, "400px") or a percentage of the window (eg, "50%").

The placement option sets where the panel sits in the window (see Anchor), defaulting to the window origin.

Note
A floating panel's size and placement are fixed at creation. To move or resize a panel, keep a reference to its View with Panel::view() before calling Foreground::Remove()– Panel::view() returns null once the panel is removed. Pass that View to Foreground::AdoptPanel() with updated options so the page doesn't reload.

Dismissal and Focus

By default, a floating panel uses Dismiss::Manual and stays open until you hide it. Set dismiss = Dismiss::Auto to close the panel automatically like a native menu (see Dismiss). Call Panel::OnDismiss() to respond when the library dismisses the panel automatically.

By default, a floating panel uses FocusPolicy::Auto and takes keyboard focus only when clicked. Set focus = FocusPolicy::Grab for dialogs and dropdown menus that need focus immediately upon appearing (see FocusPolicy).

Starting Hidden

Set hidden = true to create the panel hidden, then call Panel::Show() once its page has loaded.

See also
Foreground::AddPanel(), Anchor, Dismiss, FocusPolicy, Panel::OnDismiss()

Public Attributes

String key
 Optional identity for lookup and diagnostics.
Size width
 The panel's width, in logical px or as a percent of the window's width.
Size height
 The panel's height, in logical px or as a percent of the window's height.
Anchor placement
 Where the panel sits in the window (see Anchor).
Dismiss dismiss = Dismiss::Manual
 The auto-dismiss policy.
FocusPolicy focus = FocusPolicy::Auto
 The keyboard-focus policy (see FocusPolicy).
bool hidden = false
 Whether or not the panel starts hidden (create hidden, then Show() once its content has loaded).

Member Data Documentation

◆ dismiss

The auto-dismiss policy.

Auto hides the panel the way native menus close, ie. when:

  • a press lands outside it
  • Esc is pressed
  • the user moves, resizes, minimizes, maximizes, or deactivates the window (or presses its title bar or borders)

Panel::OnDismiss() fires each time. Scrolling never dismisses a floating panel, and Manual panels hide only when you hide them.

Note
A press on another floating panel overlapping this one's rect still counts as inside (the outside test is against this panel's own rect).

◆ focus

The keyboard-focus policy (see FocusPolicy).

◆ height

Size height

The panel's height, in logical px or as a percent of the window's height.

Unset means 100%.

Note
A flex factor (fr) is not meaningful here and is treated as unset with a warning.

◆ hidden

bool hidden = false

Whether or not the panel starts hidden (create hidden, then Show() once its content has loaded).

◆ key

String key

Optional identity for lookup and diagnostics.

Empty means unkeyed.

◆ placement

Anchor placement

Where the panel sits in the window (see Anchor).

The default is the window origin, which with the default sizes gives a full-window panel.

◆ width

Size width

The panel's width, in logical px or as a percent of the window's width.

Unset means 100%.

Note
A flex factor (fr) is not meaningful here and is treated as unset with a warning.

The documentation for this struct was generated from the following file: