From a440af3c957e2f760f0cf63c94a7dfcec3f30e1e Mon Sep 17 00:00:00 2001 From: shweet Date: Tue, 6 Oct 2026 01:24:05 -0400 Subject: [PATCH] Change All Frame Properties: Depth Co-Authored-By: Claude Opus 5.5 --- src/imgui/wizard/change_all_frame_properties.cpp | 14 ++++++++++++-- src/model/common.hpp | 1 + src/model/frames.cpp | 5 +++++ src/settings.hpp | 2 ++ tests/operations.cpp | 11 +++++++++++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/imgui/wizard/change_all_frame_properties.cpp b/src/imgui/wizard/change_all_frame_properties.cpp index 0fa20c5..0cd7389 100644 --- a/src/imgui/wizard/change_all_frame_properties.cpp +++ b/src/imgui/wizard/change_all_frame_properties.cpp @@ -212,6 +212,15 @@ namespace anm2ed::imgui::wizard STEP_FAST); ImGui::EndDisabled(); ImGui::PopID(); + ImGui::BeginDisabled(!isLayerPropertyAvailable); + ImGui::PushID("Depth"); + property_toggle_begin(settings.changeIsDepth); + input_int_range(localize.get(BASIC_DEPTH), settings.changeDepth, -FRAME_DEPTH_MAX, FRAME_DEPTH_MAX, STEP, + STEP_FAST); + ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_DEPTH)); + ImGui::EndDisabled(); + ImGui::PopID(); + ImGui::EndDisabled(); rows_draw(colorRows, true); ImGui::BeginDisabled(!isLayerPropertyAvailable); @@ -238,6 +247,7 @@ namespace anm2ed::imgui::wizard FRAME_CHANGE_SCALARS #undef X if (settings.changeIsDuration) frameChange.duration = settings.changeDuration; + if (settings.changeIsDepth) frameChange.depth = settings.changeDepth; if (settings.changeIsRegion) frameChange.regionId = regionId; if (settings.changeIsShader) frameChange.shaderId = shaderId; if (settings.changeIsVisibleSet) frameChange.isVisible = settings.changeIsVisible; @@ -309,8 +319,8 @@ namespace anm2ed::imgui::wizard ImGui::Separator(); } - bool isAnyProperty = settings.changeIsDuration || settings.changeIsRegion || settings.changeIsShader || - settings.changeIsVisibleSet || settings.changeIsInterpolationSet || + bool isAnyProperty = settings.changeIsDuration || settings.changeIsDepth || settings.changeIsRegion || + settings.changeIsShader || settings.changeIsVisibleSet || settings.changeIsInterpolationSet || settings.changeIsFlipXSet || settings.changeIsFlipYSet #define X(name, member, isLayerOnly, isColor, isEnabled, value) || settings.isEnabled diff --git a/src/model/common.hpp b/src/model/common.hpp index 09e3303..048cab5 100644 --- a/src/model/common.hpp +++ b/src/model/common.hpp @@ -185,6 +185,7 @@ namespace anm2ed FRAME_CHANGE_SCALARS #undef X std::optional duration{}; + std::optional depth{}; std::optional shaderId{}; std::optional isVisible{}; std::optional interpolation{}; diff --git a/src/model/frames.cpp b/src/model/frames.cpp index 7f566c3..63bd0ef 100644 --- a/src/model/frames.cpp +++ b/src/model/frames.cpp @@ -196,6 +196,11 @@ namespace anm2ed::model if (change.duration) frame.duration = std::max(FRAME_DURATION_MIN, frame.duration); if (itemType == ItemType::LAYER && change.regionId) frame.regionId = *change.regionId; if (itemType == ItemType::LAYER && change.shaderId) frame.shaderId = *change.shaderId; + if (itemType == ItemType::LAYER && change.depth) + { + apply(frame.depth, change.depth); + frame.depth = std::clamp(frame.depth, -FRAME_DEPTH_MAX, FRAME_DEPTH_MAX); + } #define X(name, member, isLayerOnly, isColor, isEnabled, value) \ if (!isLayerOnly || itemType == ItemType::LAYER) apply(frame.member, change.name); FRAME_CHANGE_SCALARS diff --git a/src/settings.hpp b/src/settings.hpp index b951442..a838796 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -91,6 +91,7 @@ namespace anm2ed X(CHANGE_IS_SHEAR_Y, changeIsShearY, STRING_UNDEFINED, BOOL, false) \ X(CHANGE_IS_ROTATION, changeIsRotation, STRING_UNDEFINED, BOOL, false) \ X(CHANGE_IS_DURATION, changeIsDuration, STRING_UNDEFINED, BOOL, false) \ + X(CHANGE_IS_DEPTH, changeIsDepth, STRING_UNDEFINED, BOOL, false) \ X(CHANGE_IS_TINT_R, changeIsTintR, STRING_UNDEFINED, BOOL, false) \ X(CHANGE_IS_TINT_G, changeIsTintG, STRING_UNDEFINED, BOOL, false) \ X(CHANGE_IS_TINT_B, changeIsTintB, STRING_UNDEFINED, BOOL, false) \ @@ -113,6 +114,7 @@ namespace anm2ed X(CHANGE_SHEAR, changeShear, STRING_UNDEFINED, VEC2, {}) \ X(CHANGE_ROTATION, changeRotation, STRING_UNDEFINED, FLOAT, 0.0f) \ X(CHANGE_DURATION, changeDuration, STRING_UNDEFINED, INT, 0) \ + X(CHANGE_DEPTH, changeDepth, STRING_UNDEFINED, INT, 0) \ X(CHANGE_TINT, changeTint, STRING_UNDEFINED, VEC4, {}) \ X(CHANGE_COLOR_OFFSET, changeColorOffset, STRING_UNDEFINED, VEC3, {}) \ X(CHANGE_REGION_ID, changeRegionId, STRING_UNDEFINED, INT, -1) \ diff --git a/tests/operations.cpp b/tests/operations.cpp index cc98497..565d50b 100644 --- a/tests/operations.cpp +++ b/tests/operations.cpp @@ -367,3 +367,14 @@ TEST_CASE("frames_split splits every selected frame that spans the time") CHECK(model.track_get({0, NULL_, 0})->frames.size() == nullCount + 1); CHECK(model.track_get({0, LAYER, 0})->frames[0].duration == 1); } + +TEST_CASE("change all frame properties changes layer depth only") +{ + auto model = fixture_load("02_items.anm2"); + Reference layer{0, LAYER, 0, 0}; + Reference null{0, NULL_, 0, 0}; + edit::frames_change_apply(model, {.references = {layer, null}}, {.depth = 2}, ChangeType::ADD); + edit::frames_change_apply(model, {.references = {layer, null}}, {.depth = 1}, ChangeType::SUBTRACT); + CHECK(model.frame_get(layer)->depth == 1); + CHECK(model.frame_get(null)->depth == 0); +}