Avara3D 0.2.0
C++ API reference
a3d::ui::Panel Class Reference

Transient immediate-mode overlay panel for application controls and status. More...

#include <a3d/ui/Panel.h>

Classes

struct  Options
 Controls panel width and its inset from the upper-right viewport corner. More...
 
struct  Padding
 Per-item padding in logical UI units. More...
 
struct  SectionConfig
 Controls the optional separator line and capitalization of section headings. More...
 

Public Member Functions

 Panel (std::string_view id, const Options &options=Options::Default())
 Begins an immediate-mode panel for the current frame. More...
 
void section (std::string_view text, SectionConfig config=SectionConfig::Default(), Padding padding={12.0f, 4.0f, 0.0f, 0.0f})
 Draws a section heading with optional separator line, capitalization, and padding. More...
 
void text (std::string_view text, Padding padding=Padding::Default())
 Draws body text, wrapping it to the available item width. More...
 
void value (std::string_view label, std::string_view value, Padding padding=Padding::Default())
 Draws a left-aligned label and right-aligned textual value. More...
 
void spacer (float height)
 Inserts vertical space of height logical UI units. More...
 
void row (unsigned itemCount)
 Arranges the next itemCount items horizontally with equal widths. More...
 
bool button (std::string_view label, Padding padding={2.0f, 0.0f, 0.0f, 0.0f})
 Draws a button and reports activation once. More...
 
bool option (std::string_view label, bool selected, Padding padding={2.0f, 0.0f, 0.0f, 0.0f})
 Draws a selectable option button and reports activation once. More...
 
bool subOption (std::string_view label, bool selected, Padding padding={2.0f, 0.0f, 0.0f, 0.0f})
 Draws a visually subordinate selectable option button and reports activation once. More...
 
bool slider (std::string_view label, float &value, float minimum, float maximum, std::string_view format="%.2f", Padding padding={2.0f, 0.0f, 0.0f, 0.0f})
 Draws a floating-point slider and reports whether value changed. More...
 
bool slider (std::string_view label, int &value, int minimum, int maximum, std::string_view format="%d", Padding padding={2.0f, 0.0f, 0.0f, 0.0f})
 Draws an integer slider and reports whether value changed. More...
 
bool toggle (std::string_view label, bool &value, Padding padding=Padding::Default())
 Draws a boolean toggle and reports whether value changed. More...
 
bool hovered () const
 Returns whether the pointer is hovering the panel during the current frame. More...
 

Detailed Description

Transient immediate-mode overlay panel for application controls and status.

Construct a Panel during Application::frameDidBegin(), emit its contents, and allow it to be destroyed before returning from the callback. The id must remain stable between frames so interactive items retain stable identities.

Items are arranged in a vertical stack by default. row() arranges the specified number of subsequent items horizontally with equal widths.

Definition at line 29 of file Panel.h.

Constructor & Destructor Documentation

◆ Panel()

a3d::ui::Panel::Panel ( std::string_view  id,
const Options options = Options::Default() 
)
explicit

Begins an immediate-mode panel for the current frame.

id is used to preserve UI identity between frames and should remain stable. Panel must be created while an A3D UI frame is active, normally from Application::frameDidBegin().

Exceptions
std::invalid_argumentif id is empty or the supplied width or margin is invalid.
std::logic_errorif no active UI context or default A3D UI font is available.

Member Function Documentation

◆ button()

bool a3d::ui::Panel::button ( std::string_view  label,
Padding  padding = {2.0f, 0.0f, 0.0f, 0.0f} 
)

Draws a button and reports activation once.

Exceptions
std::invalid_argumentif label is empty.

◆ hovered()

bool a3d::ui::Panel::hovered ( ) const

Returns whether the pointer is hovering the panel during the current frame.

◆ option()

bool a3d::ui::Panel::option ( std::string_view  label,
bool  selected,
Padding  padding = {2.0f, 0.0f, 0.0f, 0.0f} 
)

Draws a selectable option button and reports activation once.

selected controls the persistent selected appearance for this frame and is not retained by Panel.

Exceptions
std::invalid_argumentif label is empty.

◆ row()

void a3d::ui::Panel::row ( unsigned  itemCount)

Arranges the next itemCount items horizontally with equal widths.

Exceptions
std::invalid_argumentif itemCount is zero.
std::logic_errorif the previous row is incomplete.

◆ section()

void a3d::ui::Panel::section ( std::string_view  text,
SectionConfig  config = SectionConfig::Default(),
Padding  padding = {12.0f, 4.0f, 0.0f, 0.0f} 
)

Draws a section heading with optional separator line, capitalization, and padding.

◆ slider() [1/2]

bool a3d::ui::Panel::slider ( std::string_view  label,
float &  value,
float  minimum,
float  maximum,
std::string_view  format = "%.2f",
Padding  padding = {2.0f, 0.0f, 0.0f, 0.0f} 
)

Draws a floating-point slider and reports whether value changed.

Exceptions
std::invalid_argumentif label is empty or the range is not increasing.

◆ slider() [2/2]

bool a3d::ui::Panel::slider ( std::string_view  label,
int &  value,
int  minimum,
int  maximum,
std::string_view  format = "%d",
Padding  padding = {2.0f, 0.0f, 0.0f, 0.0f} 
)

Draws an integer slider and reports whether value changed.

Exceptions
std::invalid_argumentif label is empty or minimum is not less than maximum.

◆ spacer()

void a3d::ui::Panel::spacer ( float  height)

Inserts vertical space of height logical UI units.

Exceptions
std::invalid_argumentif height is negative.

◆ subOption()

bool a3d::ui::Panel::subOption ( std::string_view  label,
bool  selected,
Padding  padding = {2.0f, 0.0f, 0.0f, 0.0f} 
)

Draws a visually subordinate selectable option button and reports activation once.

selected controls the persistent selected appearance for this frame and is not retained by Panel.

Exceptions
std::invalid_argumentif label is empty.

◆ text()

void a3d::ui::Panel::text ( std::string_view  text,
Padding  padding = Padding::Default() 
)

Draws body text, wrapping it to the available item width.

◆ toggle()

bool a3d::ui::Panel::toggle ( std::string_view  label,
bool &  value,
Padding  padding = Padding::Default() 
)

Draws a boolean toggle and reports whether value changed.

Exceptions
std::invalid_argumentif label is empty.

◆ value()

void a3d::ui::Panel::value ( std::string_view  label,
std::string_view  value,
Padding  padding = Padding::Default() 
)

Draws a left-aligned label and right-aligned textual value.


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