change all frame properties disallows root/nulls in some cases
This commit is contained in:
@@ -126,7 +126,7 @@ namespace anm2ed::anm2
|
||||
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 clamp01 = [](auto value) { return glm::clamp(value, 0.0f, 1.0f); };
|
||||
@@ -139,7 +139,7 @@ namespace anm2ed::anm2
|
||||
if (!optionalValue) return;
|
||||
auto value = *optionalValue;
|
||||
|
||||
switch (type)
|
||||
switch (changeType)
|
||||
{
|
||||
case ADJUST:
|
||||
target = clampFunc(value);
|
||||
@@ -176,18 +176,21 @@ namespace anm2ed::anm2
|
||||
apply_scalar(frame.rotation, change.rotation);
|
||||
apply_scalar_with_clamp(frame.duration, change.duration, clamp_duration);
|
||||
|
||||
apply_scalar(frame.crop.x, change.cropX);
|
||||
apply_scalar(frame.crop.y, change.cropY);
|
||||
if (itemType == LAYER)
|
||||
{
|
||||
apply_scalar(frame.crop.x, change.cropX);
|
||||
apply_scalar(frame.crop.y, change.cropY);
|
||||
|
||||
apply_scalar(frame.pivot.x, change.pivotX);
|
||||
apply_scalar(frame.pivot.y, change.pivotY);
|
||||
apply_scalar(frame.pivot.x, change.pivotX);
|
||||
apply_scalar(frame.pivot.y, change.pivotY);
|
||||
|
||||
apply_scalar(frame.size.x, change.sizeX);
|
||||
apply_scalar(frame.size.y, change.sizeY);
|
||||
}
|
||||
|
||||
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.y, change.sizeY);
|
||||
|
||||
apply_scalar(frame.scale.x, change.scaleX);
|
||||
apply_scalar(frame.scale.y, change.scaleY);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace anm2ed::anm2
|
||||
std::string to_string(Type, int = -1);
|
||||
int length(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*);
|
||||
void frames_bake(int, int, bool, bool);
|
||||
void frames_generate_from_grid(glm::ivec2, glm::ivec2, glm::ivec2, int, int, int);
|
||||
|
||||
@@ -746,7 +746,7 @@ namespace anm2ed::imgui
|
||||
if (tool == tool::SCALE && isMouseRightDown) useTool = tool::MOVE;
|
||||
|
||||
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& areaType = toolInfo.areaType;
|
||||
|
||||
@@ -302,7 +302,7 @@ namespace anm2ed::imgui
|
||||
};
|
||||
|
||||
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 (tool == tool::MOVE && isMouseRightDown) useTool = tool::CROP;
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace anm2ed::imgui::wizard
|
||||
auto& isInterpolated = settings.changeIsInterpolated;
|
||||
auto& isFlipX = settings.changeIsFlipX;
|
||||
auto& isFlipY = settings.changeIsFlipY;
|
||||
auto& itemType = document.reference.itemType;
|
||||
|
||||
#define PROPERTIES_WIDGET(body, checkboxLabel, isEnabled) \
|
||||
ImGui::Checkbox(checkboxLabel, &isEnabled); \
|
||||
@@ -183,30 +184,46 @@ namespace anm2ed::imgui::wizard
|
||||
|
||||
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 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,
|
||||
isPositionY, position);
|
||||
|
||||
ImGui::BeginDisabled(itemType != anm2::LAYER);
|
||||
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);
|
||||
|
||||
float_value("##Is Rotation", localize.get(BASIC_ROTATION), isRotation, rotation);
|
||||
|
||||
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",
|
||||
"##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",
|
||||
"##Color Offset B", "##Color Offset G", localize.get(BASIC_COLOR_OFFSET), isColorOffsetR,
|
||||
isColorOffsetG, isColorOffsetB, colorOffset);
|
||||
|
||||
bool_value("##Is Visible", localize.get(BASIC_VISIBLE), isVisibleSet, isVisible);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
bool_value("##Is Interpolated", localize.get(BASIC_INTERPOLATED), isInterpolatedSet, isInterpolated);
|
||||
|
||||
bool_value("##Is Flip X", localize.get(LABEL_FLIP_X), isFlipXSet, isFlipX);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
bool_value("##Is Flip Y", localize.get(LABEL_FLIP_Y), isFlipYSet, isFlipY);
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
auto frame_change = [&](anm2::ChangeType type)
|
||||
auto frame_change = [&](anm2::ChangeType changeType)
|
||||
{
|
||||
anm2::FrameChange frameChange;
|
||||
if (isCropX) frameChange.cropX = crop.x;
|
||||
@@ -234,7 +251,7 @@ namespace anm2ed::imgui::wizard
|
||||
if (isFlipYSet) frameChange.isFlipY = std::make_optional(isFlipY);
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user