yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
layout_helpers.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GUI_LAYOUT_HELPERS_H
2#define YAZE_APP_GUI_LAYOUT_HELPERS_H
3
4#include <vector>
5
6#include "absl/strings/str_format.h"
8#include "imgui/imgui.h"
9
10namespace yaze {
11namespace gui {
12
20 public:
21 // Core sizing functions (respect theme compact_factor + multipliers)
22 static float GetStandardWidgetHeight();
23 static float GetStandardSpacing();
24 static float GetToolbarHeight();
25 static float GetPanelPadding();
26 static float GetStandardInputWidth();
27 static float GetButtonPadding();
28 static float GetTableRowHeight();
29 static float GetCanvasToolbarHeight();
30
31 // Layout utilities
32 static void BeginPaddedPanel(const char* label, float padding = -1.0f);
33 static void EndPaddedPanel();
34
35 static bool BeginTableWithTheming(const char* str_id, int columns,
36 ImGuiTableFlags flags = 0,
37 const ImVec2& outer_size = ImVec2(0, 0),
38 float inner_width = 0.0f);
39 static void EndTableWithTheming();
40 static void EndTable() { ImGui::EndTable(); }
41
42 static void BeginCanvasPanel(const char* label,
43 ImVec2* canvas_size = nullptr);
44 static void EndCanvasPanel();
45
46 // Input field helpers
47 static bool AutoSizedInputField(const char* label, char* buf, size_t buf_size,
48 ImGuiInputTextFlags flags = 0);
49 static bool AutoSizedInputInt(const char* label, int* v, int step = 1,
50 int step_fast = 100,
51 ImGuiInputTextFlags flags = 0);
52 static bool AutoSizedInputFloat(const char* label, float* v,
53 float step = 0.0f, float step_fast = 0.0f,
54 const char* format = "%.3f",
55 ImGuiInputTextFlags flags = 0);
56
57 // Input preset functions for common patterns
58 static bool InputHexRow(const char* label, uint8_t* data);
59 static bool InputHexRow(const char* label, uint16_t* data);
60 static void BeginPropertyGrid(const char* label);
61 static void EndPropertyGrid();
62 static bool InputToolbarField(const char* label, char* buf, size_t buf_size);
63
64 // Toolbar helpers
65 static void BeginToolbar(const char* label);
66 static void EndToolbar();
67 static void ToolbarSeparator();
68 static bool ToolbarButton(const char* label,
69 const ImVec2& size = ImVec2(0, 0));
70
71 // Common layout patterns
72 static void PropertyRow(const char* label,
73 std::function<void()> widget_callback);
74 static void SectionHeader(const char* label);
75 static void HelpMarker(const char* desc);
76
77 // Get current theme
78 static const Theme& GetTheme() {
80 }
81
82 private:
83 static float GetBaseFontSize() { return ImGui::GetFontSize(); }
84 static float ApplyCompactFactor(float base_value) {
85 return base_value * GetTheme().compact_factor;
86 }
87};
88
89} // namespace gui
90} // namespace yaze
91
92#endif // YAZE_APP_GUI_LAYOUT_HELPERS_H
Theme-aware sizing helpers for consistent UI layout.
static void SectionHeader(const char *label)
static float GetPanelPadding()
static void BeginToolbar(const char *label)
static float GetCanvasToolbarHeight()
static void EndTableWithTheming()
static float ApplyCompactFactor(float base_value)
static void HelpMarker(const char *desc)
static float GetTableRowHeight()
static const Theme & GetTheme()
static float GetStandardInputWidth()
static void BeginPropertyGrid(const char *label)
static bool AutoSizedInputFloat(const char *label, float *v, float step=0.0f, float step_fast=0.0f, const char *format="%.3f", ImGuiInputTextFlags flags=0)
static bool AutoSizedInputInt(const char *label, int *v, int step=1, int step_fast=100, ImGuiInputTextFlags flags=0)
static bool InputToolbarField(const char *label, char *buf, size_t buf_size)
static void BeginCanvasPanel(const char *label, ImVec2 *canvas_size=nullptr)
static void PropertyRow(const char *label, std::function< void()> widget_callback)
static float GetBaseFontSize()
static float GetButtonPadding()
static float GetToolbarHeight()
static void BeginPaddedPanel(const char *label, float padding=-1.0f)
static bool ToolbarButton(const char *label, const ImVec2 &size=ImVec2(0, 0))
static bool InputHexRow(const char *label, uint8_t *data)
static float GetStandardWidgetHeight()
static float GetStandardSpacing()
static bool BeginTableWithTheming(const char *str_id, int columns, ImGuiTableFlags flags=0, const ImVec2 &outer_size=ImVec2(0, 0), float inner_width=0.0f)
static bool AutoSizedInputField(const char *label, char *buf, size_t buf_size, ImGuiInputTextFlags flags=0)
const Theme & GetCurrentTheme() const
static ThemeManager & Get()
Comprehensive theme structure for YAZE.