summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui.cpp18
-rw-r--r--ui.hpp3
2 files changed, 21 insertions, 0 deletions
diff --git a/ui.cpp b/ui.cpp
index 3f2680d..6b282f9 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -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: {
diff --git a/ui.hpp b/ui.hpp
index e904cfe..ea51717 100644
--- a/ui.hpp
+++ b/ui.hpp
@@ -226,6 +226,9 @@ struct UI {
void on_render() override;
void set_text(const char* s);
+ void set_int(int v);
+ void set_hex(uint64_t v);
+ void set_float(float v);
};
struct Button : Label {