Tracks widget dimensions for debugging and test automation. More...
#include <widget_measurement.h>
Public Member Functions | |
WidgetMetrics | MeasureLastItem (const std::string &widget_id, const std::string &type="unknown") |
Measure the last rendered ImGui item. | |
void | BeginToolbarMeasurement (const std::string &toolbar_id) |
Begin measuring a toolbar section. | |
void | EndToolbarMeasurement () |
End measuring a toolbar section and store total width. | |
float | GetToolbarWidth (const std::string &toolbar_id) const |
Get total measured width of a toolbar. | |
bool | WouldToolbarOverflow (const std::string &toolbar_id, float available_width) const |
Check if toolbar would overflow given window width. | |
const std::vector< WidgetMetrics > & | GetToolbarMetrics (const std::string &toolbar_id) const |
Get all measurements for a specific toolbar. | |
void | ClearFrame () |
Clear all measurements (call once per frame) | |
std::string | ExportMetricsJSON () const |
Export measurements for test automation. | |
void | SetEnabled (bool enabled) |
Enable/disable measurement (performance option) | |
bool | IsEnabled () const |
Static Public Member Functions | |
static WidgetMeasurement & | Instance () |
Private Member Functions | |
WidgetMeasurement ()=default | |
Private Attributes | |
bool | enabled_ = true |
std::string | current_toolbar_id_ |
float | current_toolbar_width_ = 0.0f |
float | current_toolbar_start_x_ = 0.0f |
std::unordered_map< std::string, std::vector< WidgetMetrics > > | toolbar_metrics_ |
std::unordered_map< std::string, float > | toolbar_widths_ |
std::vector< WidgetMetrics > | frame_metrics_ |
Tracks widget dimensions for debugging and test automation.
Integrates with ImGui Test Engine to provide accurate measurements of UI elements, helping prevent layout issues and enabling automated testing of widget sizes and positions.
Definition at line 40 of file widget_measurement.h.
|
privatedefault |
|
inlinestatic |
Definition at line 42 of file widget_measurement.h.
WidgetMetrics yaze::gui::WidgetMeasurement::MeasureLastItem | ( | const std::string & | widget_id, |
const std::string & | type = "unknown" |
||
) |
Measure the last rendered ImGui item.
widget_id | Unique identifier for this widget |
type | Widget type (button, input, etc.) |
Definition at line 10 of file widget_measurement.cc.
References yaze::gui::WidgetMetrics::content_size, current_toolbar_id_, yaze::gui::WidgetMetrics::cursor_pos_x, enabled_, frame_metrics_, yaze::gui::WidgetMetrics::position, yaze::gui::WidgetMetrics::rect_max, yaze::gui::WidgetMetrics::rect_min, yaze::gui::WidgetMetrics::size, toolbar_metrics_, yaze::gui::WidgetMetrics::type, and yaze::gui::WidgetMetrics::widget_id.
void yaze::gui::WidgetMeasurement::BeginToolbarMeasurement | ( | const std::string & | toolbar_id | ) |
Begin measuring a toolbar section.
Definition at line 48 of file widget_measurement.cc.
References current_toolbar_id_, current_toolbar_start_x_, current_toolbar_width_, and toolbar_metrics_.
void yaze::gui::WidgetMeasurement::EndToolbarMeasurement | ( | ) |
End measuring a toolbar section and store total width.
Definition at line 57 of file widget_measurement.cc.
References current_toolbar_id_, current_toolbar_start_x_, current_toolbar_width_, and toolbar_widths_.
float yaze::gui::WidgetMeasurement::GetToolbarWidth | ( | const std::string & | toolbar_id | ) | const |
Get total measured width of a toolbar.
Definition at line 73 of file widget_measurement.cc.
References toolbar_widths_.
Referenced by ExportMetricsJSON(), and WouldToolbarOverflow().
bool yaze::gui::WidgetMeasurement::WouldToolbarOverflow | ( | const std::string & | toolbar_id, |
float | available_width | ||
) | const |
Check if toolbar would overflow given window width.
Definition at line 81 of file widget_measurement.cc.
References GetToolbarWidth().
const std::vector< WidgetMetrics > & yaze::gui::WidgetMeasurement::GetToolbarMetrics | ( | const std::string & | toolbar_id | ) | const |
Get all measurements for a specific toolbar.
Definition at line 87 of file widget_measurement.cc.
References toolbar_metrics_.
void yaze::gui::WidgetMeasurement::ClearFrame | ( | ) |
Clear all measurements (call once per frame)
Definition at line 97 of file widget_measurement.cc.
References frame_metrics_.
std::string yaze::gui::WidgetMeasurement::ExportMetricsJSON | ( | ) | const |
Export measurements for test automation.
Definition at line 102 of file widget_measurement.cc.
References GetToolbarWidth(), and toolbar_metrics_.
|
inline |
Enable/disable measurement (performance option)
Definition at line 96 of file widget_measurement.h.
References enabled_.
|
inline |
Definition at line 97 of file widget_measurement.h.
References enabled_.
|
private |
Definition at line 102 of file widget_measurement.h.
Referenced by IsEnabled(), MeasureLastItem(), and SetEnabled().
|
private |
Definition at line 103 of file widget_measurement.h.
Referenced by BeginToolbarMeasurement(), EndToolbarMeasurement(), and MeasureLastItem().
|
private |
Definition at line 104 of file widget_measurement.h.
Referenced by BeginToolbarMeasurement(), and EndToolbarMeasurement().
|
private |
Definition at line 105 of file widget_measurement.h.
Referenced by BeginToolbarMeasurement(), and EndToolbarMeasurement().
|
private |
Definition at line 108 of file widget_measurement.h.
Referenced by BeginToolbarMeasurement(), ExportMetricsJSON(), GetToolbarMetrics(), and MeasureLastItem().
|
private |
Definition at line 109 of file widget_measurement.h.
Referenced by EndToolbarMeasurement(), and GetToolbarWidth().
|
private |
Definition at line 112 of file widget_measurement.h.
Referenced by ClearFrame(), and MeasureLastItem().