1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#pragma once
#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
// ImGuiStyle, so these follow the theme like everything else.
// i wonder when stock imgui will stop looking like dog shit
namespace Hsdbg::Widgets
{
// register the bundled faces so the kit can set headers in the bold face and
// values in mono; call once after the fonts are loaded
auto set_fonts(ImFont* ui, ImFont* strong, ImFont* mono) -> 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 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; `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, 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). 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
// icon glyph. returns true on click.
auto selectable_row(const char* label, bool selected,
ImGuiSelectableFlags flags = 0) -> bool;
// a small status chip: a coloured dot followed by text inside a rounded
// outline. advances the cursor like a normal item.
auto chip(const char* text, ImU32 dot_color) -> void;
// a centred, dimmed icon over a caption, filling the panel — the resting
// state for a panel that has nothing to show yet
auto empty_state(const char* icon, const char* text) -> void;
// 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;
}
|