diff options
author | quou <quou@disroot.org> | 2025-01-18 17:05:25 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2025-01-18 17:05:25 +1100 |
commit | dd4829eb05c9193e37e8dfa952bae967c6ca60c8 (patch) | |
tree | 71c614457cd9b3bc9339a80633bbc9b6a480f567 /ui.cpp | |
parent | 092248465a980e7ccf13b19d3d447e78443ac911 (diff) |
functions to set labels to int, float and hex numbers
Diffstat (limited to 'ui.cpp')
-rw-r--r-- | ui.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -1287,6 +1287,24 @@ void UI::Label::set_text(const char* s) { ui->layout_dirty = 1; } +void UI::Label::set_int(int v) { + char buf[32]; + sprintf(buf, "%d", v); + set_text(buf); +} + +void UI::Label::set_hex(uint64_t v) { + char buf[32]; + sprintf(buf, "0x%lx", v); + set_text(buf); +} + +void UI::Label::set_float(float v) { + char buf[32]; + sprintf(buf, "%g", v); + set_text(buf); +} + static int title_handler(UI::Modal* modal, const UI::Message& msg) { switch (msg.type) { case UI::Message::Type::activate: { |