diff --git a/src/gfx.c b/src/gfx.c index 8d95219..c47f560 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -216,14 +216,26 @@ float2_t gfx_get_offset(void) { return gfx.offset; } +float gfx_min_scale(void) { + return 1.0f; +} + +float gfx_max_scale(void) { + return 100.0f; +} + void gfx_add_scale(float scale_add) { assert(gfx.valid); - gfx.scale += scale_add; - if (gfx.scale < 1.0f) { - gfx.scale = 1.0f; + gfx_set_scale(gfx.scale + scale_add); +} + +void gfx_set_scale(float scale) { + gfx.scale = scale; + if (gfx.scale < gfx_min_scale()) { + gfx.scale = gfx_min_scale(); } - else if (gfx.scale > 100.0f) { - gfx.scale = 100.0f; + else if (gfx.scale > gfx_max_scale()) { + gfx.scale = gfx_max_scale(); } } diff --git a/src/gfx.h b/src/gfx.h index 7692efe..baa3669 100644 --- a/src/gfx.h +++ b/src/gfx.h @@ -49,7 +49,10 @@ void gfx_end(void); float2_t gfx_get_display_size(void); void gfx_set_offset(float2_t offset); float2_t gfx_get_offset(void); +float gfx_min_scale(void); +float gfx_max_scale(void); void gfx_add_scale(float scale_add); +void gfx_set_scale(float scale); float gfx_get_scale(void); float gfx_get_aspect(void); void gfx_highlight_node(int node_index); diff --git a/src/ui.cc b/src/ui.cc index 15388d7..221473b 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -845,6 +845,10 @@ static void ui_floating_controls(void) { pick_set_layer_enabled(i, false); } } + float scale = gfx_get_scale(); + if (ImGui::SliderFloat("Scale", &scale, gfx_min_scale(), gfx_max_scale(), "%.2f", ImGuiSliderFlags_Logarithmic)) { + gfx_set_scale(scale); + } } ImGui::End(); }