diff --git a/src/imgui/window/animation_preview.cpp b/src/imgui/window/animation_preview.cpp index a6c64b6..6c520e9 100644 --- a/src/imgui/window/animation_preview.cpp +++ b/src/imgui/window/animation_preview.cpp @@ -230,7 +230,7 @@ namespace anm2ed::imgui recordPan = document.previewPan; if (auto rect = animation_render_rect_get(manager, document, animation, settings.previewIsRootTransform)) { - recordSize = glm::vec2(rect->z, rect->w) * settings.renderScale; + recordSize = glm::vec2(rect->z, rect->w) * math::percent_to_unit(settings.renderScale); auto previousSize = size; size = recordSize; set_to_rect(recordZoom, recordPan, *rect); diff --git a/src/imgui/wizard/configure.cpp b/src/imgui/wizard/configure.cpp index c516663..cbe456c 100644 --- a/src/imgui/wizard/configure.cpp +++ b/src/imgui/wizard/configure.cpp @@ -27,8 +27,8 @@ namespace anm2ed::imgui::wizard if (ImGui::BeginChild("##Tab Child", childSize, true)) { ImGui::SeparatorText(localize.get(LABEL_WINDOW_MENU)); - 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)); + input_float_range(localize.get(LABEL_UI_SCALE), temporary.uiScale, UI_SCALE_MIN, UI_SCALE_MAX, UI_SCALE_STEP, + UI_SCALE_STEP, "%.0f%%"); ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_UI_SCALE)); ImGui::Checkbox(localize.get(LABEL_VSYNC), &temporary.isVsync); ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_VSYNC)); @@ -184,7 +184,7 @@ namespace anm2ed::imgui::wizard ImGui::GetIO().KeyRepeatDelay = settings.keyboardRepeatDelay; ImGui::GetIO().KeyRepeatRate = settings.keyboardRepeatRate; - ImGui::GetStyle().FontScaleMain = settings.uiScale; + ImGui::GetStyle().FontScaleMain = math::percent_to_unit(settings.uiScale); SnapshotStack::max_size_set(settings.fileSnapshotStackSize); imgui::theme_set((theme::Type)settings.theme); localize.language = (Language)settings.language; diff --git a/src/imgui/wizard/render_animation.cpp b/src/imgui/wizard/render_animation.cpp index 476505d..93e6901 100644 --- a/src/imgui/wizard/render_animation.cpp +++ b/src/imgui/wizard/render_animation.cpp @@ -229,7 +229,8 @@ namespace anm2ed::imgui::wizard ImGui::BeginDisabled(!isUseAnimationBounds); { - input_percent_range(localize.get(BASIC_SCALE), scale, RENDER_SCALE_MIN, RENDER_SCALE_MAX); + input_float_range(localize.get(BASIC_SCALE), scale, RENDER_SCALE_MIN, RENDER_SCALE_MAX, RENDER_SCALE_STEP, + RENDER_SCALE_STEP, "%.0f%%"); ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_SCALE_OUTPUT)); } ImGui::EndDisabled(); diff --git a/src/loader.cpp b/src/loader.cpp index 0860567..2cd8141 100644 --- a/src/loader.cpp +++ b/src/loader.cpp @@ -30,7 +30,7 @@ using namespace anm2ed::util; namespace anm2ed { constexpr auto WINDOW_4K_SIZE = glm::ivec2(3840, 2160); - constexpr auto UI_SCALE_4K_DEFAULT = 1.5f; + constexpr auto UI_SCALE_4K_DEFAULT = 150.0f; constexpr auto WINDOW_DEFAULT_SIZE_MULTIPLIER = 0.90f; constexpr auto SOCKET_ADDRESS = "127.0.0.1"; @@ -249,7 +249,7 @@ namespace anm2ed io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; io.KeyRepeatDelay = settings.keyboardRepeatDelay; io.KeyRepeatRate = settings.keyboardRepeatRate; - ImGui::GetStyle().FontScaleMain = settings.uiScale; + ImGui::GetStyle().FontScaleMain = math::percent_to_unit(settings.uiScale); io.ConfigWindowsMoveFromTitleBarOnly = true; if (auto imguiData = Settings::imgui_data_load(settings_path()); !imguiData.empty()) diff --git a/src/settings.cpp b/src/settings.cpp index 587fed8..a85eb70 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -264,6 +264,10 @@ DockSpace ID=0x123F8F08 Window=0x6D581B32 Pos=8,62 Size=1902,991 SETTINGS_MEMBERS SETTINGS_SHORTCUTS SETTINGS_WINDOWS #undef X } + + // Scales saved as multipliers (before they were percents) read as tiny percents and clamp to the minimum. + uiScale = std::clamp(uiScale, UI_SCALE_MIN, UI_SCALE_MAX); + renderScale = std::clamp(renderScale, RENDER_SCALE_MIN, RENDER_SCALE_MAX); } Options Settings::anm2_options_get() const { return {.isExtendedFormat = isFileExtendedFormat}; } diff --git a/src/settings.hpp b/src/settings.hpp index 1f304ad..398eb48 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -25,11 +25,13 @@ namespace anm2ed constexpr auto OUTPUT_PATH_DEFAULT = "./output.gif"; #endif - 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; + // Scales are percents. + constexpr auto UI_SCALE_MIN = 50.0f; + constexpr auto UI_SCALE_MAX = 200.0f; + constexpr auto UI_SCALE_STEP = 25.0f; + constexpr auto RENDER_SCALE_MIN = 25.0f; + constexpr auto RENDER_SCALE_MAX = 1000.0f; + constexpr auto RENDER_SCALE_STEP = 25.0f; #define SETTINGS_TYPES \ X(INT, int) \ @@ -53,7 +55,7 @@ namespace anm2ed X(WINDOW_SIZE, windowSize, STRING_UNDEFINED, IVEC2_WH, {1200, 720}) \ X(WINDOW_POSITION, windowPosition, STRING_UNDEFINED, IVEC2, glm::ivec2()) \ X(IS_VSYNC, isVsync, STRING_UNDEFINED, BOOL, true) \ - X(UI_SCALE, uiScale, STRING_UNDEFINED, FLOAT, 1.0f) \ + X(UI_SCALE, uiScale, STRING_UNDEFINED, FLOAT, 100.0f) \ X(THEME, theme, STRING_UNDEFINED, INT, imgui::theme::DARK) \ X(LANGUAGE, language, STRING_UNDEFINED, INT, ENGLISH) \ \ @@ -202,7 +204,7 @@ namespace anm2ed X(RENDER_FORMAT, renderFormat, STRING_UNDEFINED, PATH, "{}.png") \ X(RENDER_IS_USE_ANIMATION_BOUNDS, renderIsUseAnimationBounds, STRING_UNDEFINED, BOOL, true) \ X(RENDER_IS_USE_ISOLATED_ANIMATION, renderIsUseIsolatedAnimation, STRING_UNDEFINED, BOOL, false) \ - X(RENDER_SCALE, renderScale, STRING_UNDEFINED, FLOAT, 1.0f) \ + X(RENDER_SCALE, renderScale, STRING_UNDEFINED, FLOAT, 100.0f) \ X(RENDER_FPS_MODE, renderFpsMode, STRING_UNDEFINED, INT, render::FPS_ANIMATION) \ X(RENDER_FFMPEG_PATH, renderFFmpegPath, STRING_UNDEFINED, PATH, FFMPEG_PATH_DEFAULT) diff --git a/src/state.cpp b/src/state.cpp index 3e2712a..47f7961 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -8,6 +8,7 @@ #include #include "log.hpp" +#include "math.hpp" #include "path.hpp" #include "strings.hpp" #include "texture.hpp" @@ -187,7 +188,7 @@ namespace anm2ed if (uiScaleDelta != 0.0f) { settings.uiScale = std::clamp(settings.uiScale + uiScaleDelta, UI_SCALE_MIN, UI_SCALE_MAX); - ImGui::GetStyle().FontScaleMain = settings.uiScale; + ImGui::GetStyle().FontScaleMain = math::percent_to_unit(settings.uiScale); } } diff --git a/src/util/imgui/input.cpp b/src/util/imgui/input.cpp index 93d0d0f..46ceb56 100644 --- a/src/util/imgui/input.cpp +++ b/src/util/imgui/input.cpp @@ -6,7 +6,6 @@ #include -#include "math.hpp" #include "path.hpp" using namespace anm2ed::types; @@ -226,14 +225,4 @@ 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 ff1b4ba..4759b28 100644 --- a/src/util/imgui/input.hpp +++ b/src/util/imgui/input.hpp @@ -23,7 +23,6 @@ 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 = {},