diff options
Diffstat (limited to 'src/ui/widgets.h')
| -rw-r--r-- | src/ui/widgets.h | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/ui/widgets.h b/src/ui/widgets.h index b034357..418af8f 100644 --- a/src/ui/widgets.h +++ b/src/ui/widgets.h @@ -2,6 +2,8 @@ #include <imgui.h> +#include <string> + // a small kit of hand-drawn controls that move the ui away from stock imgui: // rounded icon buttons, ios-style toggles, pill segmented controls, rounded // selection rows and status chips. every colour is pulled from the active @@ -13,28 +15,35 @@ namespace Hsdbg::Widgets // values in mono; call once after the fonts are loaded auto set_fonts(ImFont* ui, ImFont* strong, ImFont* mono) -> void; - // a small, bold, upper-cased section label with a hairline running off to the - // right — the strong equivalent of ImGui::SeparatorText - auto section_header(const char* label) -> void; + // the theme accent (ImGuiCol_CheckMark carries it), for callers drawing + // their own accents + auto accent() -> ImVec4; + + // a small, bold, upper-cased section label, with a hairline running off to + // the right unless `rule` is off — the strong equivalent of ImGui::SeparatorText + auto section_header(const char* label, bool rule = true) -> void; // a modern slider: a thin rounded track with an accent-filled portion and a - // round grab, the value centred on the track, then the label to its right - // (like ImGui::SliderFloat). returns true on the frames the value changes. + // round grab, the value in its own column right of the track, then the label + // (like ImGui::SliderFloat; a "##" label draws none). returns true on the + // frames the value changes. auto slider_float(const char* label, float* value, float min, float max, const char* fmt) -> bool; // a rounded square button whose label is a (Phosphor) icon glyph. `active` - // fills it with the accent to mark a toggled-on tool. returns true on click. + // fills it with the accent to mark a toggled-on tool; `glyph` (alpha > 0) + // colours the icon while the button is enabled. returns true on click. auto icon_button(const char* id, const char* icon, bool active = false, const char* tooltip = nullptr, bool disabled = false, - float size = 34.0f) -> bool; + float size = 34.0f, ImVec4 glyph = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)) -> bool; // an ios-style switch bound to *value; returns true on the frame it flips auto toggle(const char* id, bool* value) -> bool; // a pill segmented control; returns the index the user ends on (unchanged - // when nothing was clicked this frame) + // when nothing was clicked this frame). segmented_width is the room it takes. auto segmented(const char* id, const char* const* labels, int count, int current) -> int; + auto segmented_width(const char* const* labels, int count) -> float; // a full-width, rounded selection row that behaves like ImGui::Selectable // but draws a rounded accent highlight; give it a label that may lead with an @@ -53,4 +62,20 @@ namespace Hsdbg::Widgets // a small borderless × for removing a row (watch, breakpoint, trace); dim at // rest, red on hover. sized to the text line so it fits inside a table cell. auto remove_button(const char* id) -> bool; + + // a text field with a dim glyph set inside its left edge (a magnifier on a + // filter, a prompt on the console); otherwise ImGui::InputTextWithHint + auto input_with_icon(const char* id, const char* icon, const char* hint, std::string* text, + ImGuiInputTextFlags flags = 0) -> bool; + + // a breakpoint-style dot that flips *value on click: filled in `on` when set, + // filled in `off` when not, hollow while `pending`. returns true on the flip. + auto dot_toggle(const char* id, bool* value, ImU32 on, ImU32 off, bool pending = false) -> bool; + + // a zero-padded hex number with its leading zeros dimmed, so the digits that + // matter stand out of a column of 0x0000… + auto hex_value(unsigned long long value, int digits) -> void; + + // text in the link colour that underlines on hover; returns true on click + auto link_text(const char* text) -> bool; } |
