change all frame properties disallows root/nulls in some cases

This commit is contained in:
2025-12-28 18:41:37 -05:00
parent c0b4aaa63e
commit f7109c24d0
5 changed files with 34 additions and 14 deletions

View File

@@ -126,7 +126,7 @@ namespace anm2ed::anm2
return frame; return frame;
} }
void Item::frames_change(FrameChange change, ChangeType type, std::set<int>& selection) void Item::frames_change(FrameChange change, anm2::Type itemType, ChangeType changeType, std::set<int>& selection)
{ {
const auto clamp_identity = [](auto value) { return value; }; const auto clamp_identity = [](auto value) { return value; };
const auto clamp01 = [](auto value) { return glm::clamp(value, 0.0f, 1.0f); }; const auto clamp01 = [](auto value) { return glm::clamp(value, 0.0f, 1.0f); };
@@ -139,7 +139,7 @@ namespace anm2ed::anm2
if (!optionalValue) return; if (!optionalValue) return;
auto value = *optionalValue; auto value = *optionalValue;
switch (type) switch (changeType)
{ {
case ADJUST: case ADJUST:
target = clampFunc(value); target = clampFunc(value);
@@ -176,17 +176,20 @@ namespace anm2ed::anm2
apply_scalar(frame.rotation, change.rotation); apply_scalar(frame.rotation, change.rotation);
apply_scalar_with_clamp(frame.duration, change.duration, clamp_duration); apply_scalar_with_clamp(frame.duration, change.duration, clamp_duration);
if (itemType == LAYER)
{
apply_scalar(frame.crop.x, change.cropX); apply_scalar(frame.crop.x, change.cropX);
apply_scalar(frame.crop.y, change.cropY); apply_scalar(frame.crop.y, change.cropY);
apply_scalar(frame.pivot.x, change.pivotX); apply_scalar(frame.pivot.x, change.pivotX);
apply_scalar(frame.pivot.y, change.pivotY); apply_scalar(frame.pivot.y, change.pivotY);
apply_scalar(frame.position.x, change.positionX);
apply_scalar(frame.position.y, change.positionY);
apply_scalar(frame.size.x, change.sizeX); apply_scalar(frame.size.x, change.sizeX);
apply_scalar(frame.size.y, change.sizeY); apply_scalar(frame.size.y, change.sizeY);
}
apply_scalar(frame.position.x, change.positionX);
apply_scalar(frame.position.y, change.positionY);
apply_scalar(frame.scale.x, change.scaleX); apply_scalar(frame.scale.x, change.scaleX);
apply_scalar(frame.scale.y, change.scaleY); apply_scalar(frame.scale.y, change.scaleY);

View File

@@ -20,7 +20,7 @@ namespace anm2ed::anm2
std::string to_string(Type, int = -1); std::string to_string(Type, int = -1);
int length(Type); int length(Type);
Frame frame_generate(float, Type); Frame frame_generate(float, Type);
void frames_change(FrameChange, ChangeType, std::set<int>&); void frames_change(FrameChange, anm2::Type, ChangeType, std::set<int>&);
bool frames_deserialize(const std::string&, Type, int, std::set<int>&, std::string*); bool frames_deserialize(const std::string&, Type, int, std::set<int>&, std::string*);
void frames_bake(int, int, bool, bool); void frames_bake(int, int, bool, bool);
void frames_generate_from_grid(glm::ivec2, glm::ivec2, glm::ivec2, int, int, int); void frames_generate_from_grid(glm::ivec2, glm::ivec2, glm::ivec2, int, int, int);

View File

@@ -746,7 +746,7 @@ namespace anm2ed::imgui
if (tool == tool::SCALE && isMouseRightDown) useTool = tool::MOVE; if (tool == tool::SCALE && isMouseRightDown) useTool = tool::MOVE;
auto frame_change_apply = [&](anm2::FrameChange frameChange, anm2::ChangeType changeType = anm2::ADJUST) auto frame_change_apply = [&](anm2::FrameChange frameChange, anm2::ChangeType changeType = anm2::ADJUST)
{ item->frames_change(frameChange, changeType, frames); }; { item->frames_change(frameChange, reference.itemType, changeType, frames); };
auto& toolInfo = tool::INFO[useTool]; auto& toolInfo = tool::INFO[useTool];
auto& areaType = toolInfo.areaType; auto& areaType = toolInfo.areaType;

View File

@@ -302,7 +302,7 @@ namespace anm2ed::imgui
}; };
auto frame_change_apply = [&](anm2::FrameChange frameChange, anm2::ChangeType changeType = anm2::ADJUST) auto frame_change_apply = [&](anm2::FrameChange frameChange, anm2::ChangeType changeType = anm2::ADJUST)
{ item->frames_change(frameChange, changeType, frames); }; { item->frames_change(frameChange, reference.itemType, changeType, frames); };
if (isMouseMiddleDown) useTool = tool::PAN; if (isMouseMiddleDown) useTool = tool::PAN;
if (tool == tool::MOVE && isMouseRightDown) useTool = tool::CROP; if (tool == tool::MOVE && isMouseRightDown) useTool = tool::CROP;

View File

@@ -50,6 +50,7 @@ namespace anm2ed::imgui::wizard
auto& isInterpolated = settings.changeIsInterpolated; auto& isInterpolated = settings.changeIsInterpolated;
auto& isFlipX = settings.changeIsFlipX; auto& isFlipX = settings.changeIsFlipX;
auto& isFlipY = settings.changeIsFlipY; auto& isFlipY = settings.changeIsFlipY;
auto& itemType = document.reference.itemType;
#define PROPERTIES_WIDGET(body, checkboxLabel, isEnabled) \ #define PROPERTIES_WIDGET(body, checkboxLabel, isEnabled) \
ImGui::Checkbox(checkboxLabel, &isEnabled); \ ImGui::Checkbox(checkboxLabel, &isEnabled); \
@@ -183,30 +184,46 @@ namespace anm2ed::imgui::wizard
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImGui::GetStyle().ItemInnerSpacing); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImGui::GetStyle().ItemInnerSpacing);
ImGui::BeginDisabled(itemType != anm2::LAYER);
float2_value("##Is Crop X", "##Is Crop Y", "##Crop X", localize.get(BASIC_CROP), isCropX, isCropY, crop); float2_value("##Is Crop X", "##Is Crop Y", "##Crop X", localize.get(BASIC_CROP), isCropX, isCropY, crop);
float2_value("##Is Size X", "##Is Size Y", "##Size X", localize.get(BASIC_SIZE), isSizeX, isSizeY, size); float2_value("##Is Size X", "##Is Size Y", "##Size X", localize.get(BASIC_SIZE), isSizeX, isSizeY, size);
ImGui::EndDisabled();
float2_value("##Is Position X", "##Is Position Y", "##Position X", localize.get(BASIC_POSITION), isPositionX, float2_value("##Is Position X", "##Is Position Y", "##Position X", localize.get(BASIC_POSITION), isPositionX,
isPositionY, position); isPositionY, position);
ImGui::BeginDisabled(itemType != anm2::LAYER);
float2_value("##Is Pivot X", "##Is Pivot Y", "##Pivot X", localize.get(BASIC_PIVOT), isPivotX, isPivotY, pivot); float2_value("##Is Pivot X", "##Is Pivot Y", "##Pivot X", localize.get(BASIC_PIVOT), isPivotX, isPivotY, pivot);
ImGui::EndDisabled();
float2_value("##Is Scale X", "##Is Scale Y", "##Scale X", localize.get(BASIC_SCALE), isScaleX, isScaleY, scale); float2_value("##Is Scale X", "##Is Scale Y", "##Scale X", localize.get(BASIC_SCALE), isScaleX, isScaleY, scale);
float_value("##Is Rotation", localize.get(BASIC_ROTATION), isRotation, rotation); float_value("##Is Rotation", localize.get(BASIC_ROTATION), isRotation, rotation);
duration_value("##Is Duration", localize.get(BASIC_DURATION), isDuration, duration); duration_value("##Is Duration", localize.get(BASIC_DURATION), isDuration, duration);
color4_value("##Is Tint R", "##Is Tint G", "##Is Tint B", "##Is Tint A", "##Tint R", "##Tint G", "##Tint B", color4_value("##Is Tint R", "##Is Tint G", "##Is Tint B", "##Is Tint A", "##Tint R", "##Tint G", "##Tint B",
"##Tint A", localize.get(BASIC_TINT), isTintR, isTintG, isTintB, isTintA, tint); "##Tint A", localize.get(BASIC_TINT), isTintR, isTintG, isTintB, isTintA, tint);
color3_value("##Is Color Offset R", "##Is Color Offset G", "##Is Color Offset B", "##Color Offset R", color3_value("##Is Color Offset R", "##Is Color Offset G", "##Is Color Offset B", "##Color Offset R",
"##Color Offset B", "##Color Offset G", localize.get(BASIC_COLOR_OFFSET), isColorOffsetR, "##Color Offset B", "##Color Offset G", localize.get(BASIC_COLOR_OFFSET), isColorOffsetR,
isColorOffsetG, isColorOffsetB, colorOffset); isColorOffsetG, isColorOffsetB, colorOffset);
bool_value("##Is Visible", localize.get(BASIC_VISIBLE), isVisibleSet, isVisible); bool_value("##Is Visible", localize.get(BASIC_VISIBLE), isVisibleSet, isVisible);
ImGui::SameLine(); ImGui::SameLine();
bool_value("##Is Interpolated", localize.get(BASIC_INTERPOLATED), isInterpolatedSet, isInterpolated); bool_value("##Is Interpolated", localize.get(BASIC_INTERPOLATED), isInterpolatedSet, isInterpolated);
bool_value("##Is Flip X", localize.get(LABEL_FLIP_X), isFlipXSet, isFlipX); bool_value("##Is Flip X", localize.get(LABEL_FLIP_X), isFlipXSet, isFlipX);
ImGui::SameLine(); ImGui::SameLine();
bool_value("##Is Flip Y", localize.get(LABEL_FLIP_Y), isFlipYSet, isFlipY); bool_value("##Is Flip Y", localize.get(LABEL_FLIP_Y), isFlipYSet, isFlipY);
ImGui::PopStyleVar(); ImGui::PopStyleVar();
auto frame_change = [&](anm2::ChangeType type) auto frame_change = [&](anm2::ChangeType changeType)
{ {
anm2::FrameChange frameChange; anm2::FrameChange frameChange;
if (isCropX) frameChange.cropX = crop.x; if (isCropX) frameChange.cropX = crop.x;
@@ -234,7 +251,7 @@ namespace anm2ed::imgui::wizard
if (isFlipYSet) frameChange.isFlipY = std::make_optional(isFlipY); if (isFlipYSet) frameChange.isFlipY = std::make_optional(isFlipY);
DOCUMENT_EDIT(document, localize.get(EDIT_CHANGE_FRAME_PROPERTIES), Document::FRAMES, DOCUMENT_EDIT(document, localize.get(EDIT_CHANGE_FRAME_PROPERTIES), Document::FRAMES,
document.item_get()->frames_change(frameChange, type, frames)); document.item_get()->frames_change(frameChange, itemType, changeType, frames));
isChanged = true; isChanged = true;
}; };