Scales are saved as percents, clamped on load

UI Scale (50-200%) and render Scale (25-1000%) both step by 25%. Settings
saved as multipliers read as tiny percents and clamp to the minimum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-03 20:07:53 -04:00
1 parent e6a374f571
commit 70abe366a0
9 files changed
+23 -27

No files matched your search

+1 -1
View File
@@ -230,7 +230,7 @@ namespace anm2ed::imgui
recordPan = document.previewPan; recordPan = document.previewPan;
if (auto rect = animation_render_rect_get(manager, document, animation, settings.previewIsRootTransform)) 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; auto previousSize = size;
size = recordSize; size = recordSize;
set_to_rect(recordZoom, recordPan, *rect); set_to_rect(recordZoom, recordPan, *rect);
+3 -3
View File
@@ -27,8 +27,8 @@ namespace anm2ed::imgui::wizard
if (ImGui::BeginChild("##Tab Child", childSize, true)) if (ImGui::BeginChild("##Tab Child", childSize, true))
{ {
ImGui::SeparatorText(localize.get(LABEL_WINDOW_MENU)); ImGui::SeparatorText(localize.get(LABEL_WINDOW_MENU));
input_percent_range(localize.get(LABEL_UI_SCALE), temporary.uiScale, UI_SCALE_MIN, UI_SCALE_MAX, input_float_range(localize.get(LABEL_UI_SCALE), temporary.uiScale, UI_SCALE_MIN, UI_SCALE_MAX, UI_SCALE_STEP,
math::unit_to_percent(UI_SCALE_STEP), math::unit_to_percent(UI_SCALE_STEP)); UI_SCALE_STEP, "%.0f%%");
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_UI_SCALE)); ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_UI_SCALE));
ImGui::Checkbox(localize.get(LABEL_VSYNC), &temporary.isVsync); ImGui::Checkbox(localize.get(LABEL_VSYNC), &temporary.isVsync);
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_VSYNC)); ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_VSYNC));
@@ -184,7 +184,7 @@ namespace anm2ed::imgui::wizard
ImGui::GetIO().KeyRepeatDelay = settings.keyboardRepeatDelay; ImGui::GetIO().KeyRepeatDelay = settings.keyboardRepeatDelay;
ImGui::GetIO().KeyRepeatRate = settings.keyboardRepeatRate; 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); SnapshotStack::max_size_set(settings.fileSnapshotStackSize);
imgui::theme_set((theme::Type)settings.theme); imgui::theme_set((theme::Type)settings.theme);
localize.language = (Language)settings.language; localize.language = (Language)settings.language;
+2 -1
View File
@@ -229,7 +229,8 @@ namespace anm2ed::imgui::wizard
ImGui::BeginDisabled(!isUseAnimationBounds); 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::SetItemTooltip("%s", localize.get(TOOLTIP_SCALE_OUTPUT));
} }
ImGui::EndDisabled(); ImGui::EndDisabled();
+2 -2
View File
@@ -30,7 +30,7 @@ using namespace anm2ed::util;
namespace anm2ed namespace anm2ed
{ {
constexpr auto WINDOW_4K_SIZE = glm::ivec2(3840, 2160); 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 WINDOW_DEFAULT_SIZE_MULTIPLIER = 0.90f;
constexpr auto SOCKET_ADDRESS = "127.0.0.1"; constexpr auto SOCKET_ADDRESS = "127.0.0.1";
@@ -249,7 +249,7 @@ namespace anm2ed
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
io.KeyRepeatDelay = settings.keyboardRepeatDelay; io.KeyRepeatDelay = settings.keyboardRepeatDelay;
io.KeyRepeatRate = settings.keyboardRepeatRate; io.KeyRepeatRate = settings.keyboardRepeatRate;
ImGui::GetStyle().FontScaleMain = settings.uiScale; ImGui::GetStyle().FontScaleMain = math::percent_to_unit(settings.uiScale);
io.ConfigWindowsMoveFromTitleBarOnly = true; io.ConfigWindowsMoveFromTitleBarOnly = true;
if (auto imguiData = Settings::imgui_data_load(settings_path()); !imguiData.empty()) if (auto imguiData = Settings::imgui_data_load(settings_path()); !imguiData.empty())
+4
View File
@@ -264,6 +264,10 @@ DockSpace ID=0x123F8F08 Window=0x6D581B32 Pos=8,62 Size=1902,991
SETTINGS_MEMBERS SETTINGS_SHORTCUTS SETTINGS_WINDOWS SETTINGS_MEMBERS SETTINGS_SHORTCUTS SETTINGS_WINDOWS
#undef X #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}; } Options Settings::anm2_options_get() const { return {.isExtendedFormat = isFileExtendedFormat}; }
+9 -7
View File
@@ -25,11 +25,13 @@ namespace anm2ed
constexpr auto OUTPUT_PATH_DEFAULT = "./output.gif"; constexpr auto OUTPUT_PATH_DEFAULT = "./output.gif";
#endif #endif
constexpr auto UI_SCALE_MIN = 0.5f; // Scales are percents.
constexpr auto UI_SCALE_MAX = 2.0f; constexpr auto UI_SCALE_MIN = 50.0f;
constexpr auto UI_SCALE_STEP = 0.25f; constexpr auto UI_SCALE_MAX = 200.0f;
constexpr auto RENDER_SCALE_MIN = 0.1f; constexpr auto UI_SCALE_STEP = 25.0f;
constexpr auto RENDER_SCALE_MAX = 10.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 \ #define SETTINGS_TYPES \
X(INT, int) \ X(INT, int) \
@@ -53,7 +55,7 @@ namespace anm2ed
X(WINDOW_SIZE, windowSize, STRING_UNDEFINED, IVEC2_WH, {1200, 720}) \ X(WINDOW_SIZE, windowSize, STRING_UNDEFINED, IVEC2_WH, {1200, 720}) \
X(WINDOW_POSITION, windowPosition, STRING_UNDEFINED, IVEC2, glm::ivec2()) \ X(WINDOW_POSITION, windowPosition, STRING_UNDEFINED, IVEC2, glm::ivec2()) \
X(IS_VSYNC, isVsync, STRING_UNDEFINED, BOOL, true) \ 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(THEME, theme, STRING_UNDEFINED, INT, imgui::theme::DARK) \
X(LANGUAGE, language, STRING_UNDEFINED, INT, ENGLISH) \ X(LANGUAGE, language, STRING_UNDEFINED, INT, ENGLISH) \
\ \
@@ -202,7 +204,7 @@ namespace anm2ed
X(RENDER_FORMAT, renderFormat, STRING_UNDEFINED, PATH, "{}.png") \ X(RENDER_FORMAT, renderFormat, STRING_UNDEFINED, PATH, "{}.png") \
X(RENDER_IS_USE_ANIMATION_BOUNDS, renderIsUseAnimationBounds, STRING_UNDEFINED, BOOL, true) \ X(RENDER_IS_USE_ANIMATION_BOUNDS, renderIsUseAnimationBounds, STRING_UNDEFINED, BOOL, true) \
X(RENDER_IS_USE_ISOLATED_ANIMATION, renderIsUseIsolatedAnimation, STRING_UNDEFINED, BOOL, false) \ 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_FPS_MODE, renderFpsMode, STRING_UNDEFINED, INT, render::FPS_ANIMATION) \
X(RENDER_FFMPEG_PATH, renderFFmpegPath, STRING_UNDEFINED, PATH, FFMPEG_PATH_DEFAULT) X(RENDER_FFMPEG_PATH, renderFFmpegPath, STRING_UNDEFINED, PATH, FFMPEG_PATH_DEFAULT)
+2 -1
View File
@@ -8,6 +8,7 @@
#include <imgui/backends/imgui_impl_sdl3.h> #include <imgui/backends/imgui_impl_sdl3.h>
#include "log.hpp" #include "log.hpp"
#include "math.hpp"
#include "path.hpp" #include "path.hpp"
#include "strings.hpp" #include "strings.hpp"
#include "texture.hpp" #include "texture.hpp"
@@ -187,7 +188,7 @@ namespace anm2ed
if (uiScaleDelta != 0.0f) if (uiScaleDelta != 0.0f)
{ {
settings.uiScale = std::clamp(settings.uiScale + uiScaleDelta, UI_SCALE_MIN, UI_SCALE_MAX); 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);
} }
} }
-11
View File
@@ -6,7 +6,6 @@
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
#include "math.hpp"
#include "path.hpp" #include "path.hpp"
using namespace anm2ed::types; using namespace anm2ed::types;
@@ -226,14 +225,4 @@ namespace anm2ed::imgui
value = glm::clamp(value, min, max); value = glm::clamp(value, min, max);
return isActivated; 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;
}
} }
-1
View File
@@ -23,7 +23,6 @@ namespace anm2ed::imgui
bool input_int2_range(const char*, glm::ivec2&, glm::ivec2, glm::ivec2, ImGuiInputTextFlags = 0); 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", bool input_float_range(const char*, float&, float, float, float = STEP, float = STEP_FAST, const char* = "%.3f",
ImGuiInputTextFlags = 0); 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 = {}, types::edit_state::Type drag_float_persistent(const char*, float*, float = DRAG_SPEED, float = {}, float = {},
const char* = "%.3f", ImGuiSliderFlags = 0); const char* = "%.3f", ImGuiSliderFlags = 0);
types::edit_state::Type drag_float2_persistent(const char*, glm::vec2*, float = DRAG_SPEED, float = {}, float = {}, types::edit_state::Type drag_float2_persistent(const char*, glm::vec2*, float = DRAG_SPEED, float = {}, float = {},