diff --git a/src/imgui/wizard/configure.cpp b/src/imgui/wizard/configure.cpp index fb6984a..c516663 100644 --- a/src/imgui/wizard/configure.cpp +++ b/src/imgui/wizard/configure.cpp @@ -1,5 +1,6 @@ #include "configure.hpp" +#include "math.hpp" #include "sdl.hpp" #include "util/imgui/input.hpp" #include "util/imgui/layout.hpp" @@ -7,6 +8,7 @@ #include "util/imgui/theme.hpp" using namespace anm2ed::types; +using namespace anm2ed::util; namespace anm2ed::imgui::wizard { @@ -25,8 +27,8 @@ namespace anm2ed::imgui::wizard if (ImGui::BeginChild("##Tab Child", childSize, true)) { ImGui::SeparatorText(localize.get(LABEL_WINDOW_MENU)); - input_float_range(localize.get(LABEL_UI_SCALE), temporary.uiScale, UI_SCALE_MIN, UI_SCALE_MAX, - UI_SCALE_STEP, UI_SCALE_STEP, "%.2fx"); + input_percent_range(localize.get(LABEL_UI_SCALE), temporary.uiScale, UI_SCALE_MIN, UI_SCALE_MAX, + math::unit_to_percent(UI_SCALE_STEP), math::unit_to_percent(UI_SCALE_STEP)); ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_UI_SCALE)); ImGui::Checkbox(localize.get(LABEL_VSYNC), &temporary.isVsync); ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_VSYNC)); diff --git a/src/imgui/wizard/render_animation.cpp b/src/imgui/wizard/render_animation.cpp index 56f10b6..476505d 100644 --- a/src/imgui/wizard/render_animation.cpp +++ b/src/imgui/wizard/render_animation.cpp @@ -229,7 +229,7 @@ namespace anm2ed::imgui::wizard ImGui::BeginDisabled(!isUseAnimationBounds); { - input_float_range(localize.get(BASIC_SCALE), scale, 0.1f, 100.0f, 1.0f, STEP_FAST, "%.1fx"); + input_percent_range(localize.get(BASIC_SCALE), scale, RENDER_SCALE_MIN, RENDER_SCALE_MAX); ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_SCALE_OUTPUT)); } ImGui::EndDisabled(); diff --git a/src/settings.hpp b/src/settings.hpp index b5a67f7..1f304ad 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -28,6 +28,8 @@ namespace anm2ed constexpr auto UI_SCALE_MIN = 0.5f; constexpr auto UI_SCALE_MAX = 2.0f; constexpr auto UI_SCALE_STEP = 0.25f; + constexpr auto RENDER_SCALE_MIN = 0.1f; + constexpr auto RENDER_SCALE_MAX = 10.0f; #define SETTINGS_TYPES \ X(INT, int) \ diff --git a/src/util/imgui/input.cpp b/src/util/imgui/input.cpp index 46ceb56..93d0d0f 100644 --- a/src/util/imgui/input.cpp +++ b/src/util/imgui/input.cpp @@ -6,6 +6,7 @@ #include +#include "math.hpp" #include "path.hpp" using namespace anm2ed::types; @@ -225,4 +226,14 @@ namespace anm2ed::imgui value = glm::clamp(value, min, max); return isActivated; } + + // Edits a multiplier (1 = 100%) as a percent; the range is in multipliers, the steps in percent. + bool input_percent_range(const char* label, float& value, float min, float max, float step, float stepFast) + { + auto percent = math::unit_to_percent(value); + auto isActivated = input_float_range(label, percent, math::unit_to_percent(min), math::unit_to_percent(max), step, + stepFast, "%.0f%%"); + if (percent != math::unit_to_percent(value)) value = math::percent_to_unit(percent); + return isActivated; + } } diff --git a/src/util/imgui/input.hpp b/src/util/imgui/input.hpp index 4759b28..ff1b4ba 100644 --- a/src/util/imgui/input.hpp +++ b/src/util/imgui/input.hpp @@ -23,6 +23,7 @@ namespace anm2ed::imgui bool input_int2_range(const char*, glm::ivec2&, glm::ivec2, glm::ivec2, ImGuiInputTextFlags = 0); bool input_float_range(const char*, float&, float, float, float = STEP, float = STEP_FAST, const char* = "%.3f", ImGuiInputTextFlags = 0); + bool input_percent_range(const char*, float&, float, float, float = STEP, float = STEP_FAST); types::edit_state::Type drag_float_persistent(const char*, float*, float = DRAG_SPEED, float = {}, float = {}, const char* = "%.3f", ImGuiSliderFlags = 0); types::edit_state::Type drag_float2_persistent(const char*, glm::vec2*, float = DRAG_SPEED, float = {}, float = {},