This commit is contained in:
2025-12-28 14:46:15 -05:00
parent 23fac343a9
commit cd0f6e9438
2 changed files with 26 additions and 25 deletions

View File

@@ -739,7 +739,7 @@ namespace anm2ed::imgui
auto item = document.item_get(); auto item = document.item_get();
auto useTool = tool; auto useTool = tool;
auto step = isMod ? STEP_FAST : STEP; auto step = isMod ? STEP_FAST : STEP;
mousePos = position_translate(zoom, pan, to_vec2(ImGui::GetMousePos()) - to_vec2(cursorScreenPos)); mousePos = position_translate(zoom, pan, to_ivec2(ImGui::GetMousePos()) - to_ivec2(cursorScreenPos));
if (isMouseMiddleDown) useTool = tool::PAN; if (isMouseMiddleDown) useTool = tool::PAN;
if (tool == tool::MOVE && isMouseRightDown) useTool = tool::SCALE; if (tool == tool::MOVE && isMouseRightDown) useTool = tool::SCALE;
@@ -771,12 +771,12 @@ namespace anm2ed::imgui
if (isMouseClicked) if (isMouseClicked)
{ {
moveOffset = settings.inputIsMoveToolSnapToMouse ? vec2() : mousePos - frame->position; moveOffset = settings.inputIsMoveToolSnapToMouse ? vec2() : mousePos - frame->position;
moveOffset = ivec2(moveOffset);
isMoveDragging = true; isMoveDragging = true;
} }
} }
if (isMouseDown && isMoveDragging) if (isMouseDown && isMoveDragging)
frame_change_apply( frame_change_apply({.positionX = mousePos.x - moveOffset.x, .positionY = mousePos.y - moveOffset.y});
{.positionX = (int)(mousePos.x - moveOffset.x), .positionY = (int)(mousePos.y - moveOffset.y)});
if (isLeftPressed) frame_change_apply({.positionX = step}, anm2::SUBTRACT); if (isLeftPressed) frame_change_apply({.positionX = step}, anm2::SUBTRACT);
if (isRightPressed) frame_change_apply({.positionX = step}, anm2::ADD); if (isRightPressed) frame_change_apply({.positionX = step}, anm2::ADD);
@@ -803,8 +803,8 @@ namespace anm2ed::imgui
{ {
frame->scale += vec2(mouseDelta.x, mouseDelta.y); frame->scale += vec2(mouseDelta.x, mouseDelta.y);
if (isMod) frame->scale = {frame->scale.x, frame->scale.x}; if (isMod) frame->scale = {frame->scale.x, frame->scale.x};
frame->scale = ivec2(frame->scale);
frame_change_apply({.scaleX = (int)frame->scale.x, .scaleY = (int)frame->scale.y}); frame_change_apply({.scaleX = frame->scale.x, .scaleY = frame->scale.y});
} }
if (isLeftPressed) frame_change_apply({.scaleX = step}, anm2::SUBTRACT); if (isLeftPressed) frame_change_apply({.scaleX = step}, anm2::SUBTRACT);

View File

@@ -277,7 +277,7 @@ namespace anm2ed::imgui
auto stepX = isGridSnap ? step * gridSize.x : step; auto stepX = isGridSnap ? step * gridSize.x : step;
auto stepY = isGridSnap ? step * gridSize.y : step; auto stepY = isGridSnap ? step * gridSize.y : step;
previousMousePos = mousePos; previousMousePos = mousePos;
mousePos = position_translate(zoom, pan, to_vec2(ImGui::GetMousePos()) - to_vec2(cursorScreenPos)); mousePos = position_translate(zoom, pan, to_ivec2(ImGui::GetMousePos()) - to_ivec2(cursorScreenPos));
auto snap_rect = [&](glm::vec2 minPoint, glm::vec2 maxPoint) auto snap_rect = [&](glm::vec2 minPoint, glm::vec2 maxPoint)
{ {
@@ -332,14 +332,17 @@ namespace anm2ed::imgui
if (!item || frames.empty()) break; if (!item || frames.empty()) break;
if (isBegin) document.snapshot(localize.get(EDIT_FRAME_PIVOT)); if (isBegin) document.snapshot(localize.get(EDIT_FRAME_PIVOT));
if (isMouseDown) if (isMouseDown)
frame_change_apply( {
{.pivotX = (int)(mousePos.x - frame->crop.x), .pivotY = (int)(mousePos.y - frame->crop.y)}); frame->crop = ivec2(frame->crop);
frame_change_apply({.pivotX = mousePos.x - frame->crop.x, .pivotY = mousePos.y - frame->crop.y});
}
if (isLeftPressed) frame_change_apply({.pivotX = step}, anm2::SUBTRACT); if (isLeftPressed) frame_change_apply({.pivotX = step}, anm2::SUBTRACT);
if (isRightPressed) frame_change_apply({.pivotX = step}, anm2::ADD); if (isRightPressed) frame_change_apply({.pivotX = step}, anm2::ADD);
if (isUpPressed) frame_change_apply({.pivotY = step}, anm2::SUBTRACT); if (isUpPressed) frame_change_apply({.pivotY = step}, anm2::SUBTRACT);
if (isDownPressed) frame_change_apply({.pivotY = step}, anm2::ADD); if (isDownPressed) frame_change_apply({.pivotY = step}, anm2::ADD);
frame_change_apply({.pivotX = (int)frame->pivot.x, .pivotY = (int)frame->pivot.y}); frame->pivot = ivec2(frame->pivot);
frame_change_apply({.pivotX = frame->pivot.x, .pivotY = frame->pivot.y});
if (isDuring) if (isDuring)
{ {
@@ -366,20 +369,18 @@ namespace anm2ed::imgui
if (isMouseDown) if (isMouseDown)
{ {
auto [minPoint, maxPoint] = snap_rect(glm::min(cropAnchor, mousePos), glm::max(cropAnchor, mousePos)); auto [minPoint, maxPoint] = snap_rect(glm::min(cropAnchor, mousePos), glm::max(cropAnchor, mousePos));
frame_change_apply({.cropX = (int)minPoint.x, frame_change_apply({.cropX = minPoint.x,
.cropY = (int)minPoint.y, .cropY = minPoint.y,
.sizeX = (int)maxPoint.x - minPoint.x, .sizeX = maxPoint.x - minPoint.x,
.sizeY = (int)maxPoint.y - minPoint.y}); .sizeY = maxPoint.y - minPoint.y});
} }
if (isLeftPressed) frame_change_apply({.cropX = stepX}, anm2::SUBTRACT); if (isLeftPressed) frame_change_apply({.cropX = stepX}, anm2::SUBTRACT);
if (isRightPressed) frame_change_apply({.cropX = stepX}, anm2::ADD); if (isRightPressed) frame_change_apply({.cropX = stepX}, anm2::ADD);
if (isUpPressed) frame_change_apply({.cropY = stepY}, anm2::SUBTRACT); if (isUpPressed) frame_change_apply({.cropY = stepY}, anm2::SUBTRACT);
if (isDownPressed) frame_change_apply({.cropY = stepY}, anm2::ADD); if (isDownPressed) frame_change_apply({.cropY = stepY}, anm2::ADD);
frame_change_apply({.cropX = (int)frame->crop.x, frame_change_apply(
.cropY = (int)frame->crop.y, {.cropX = frame->crop.x, .cropY = frame->crop.y, .sizeX = frame->size.x, .sizeY = frame->size.y});
.sizeX = (int)frame->size.x,
.sizeY = (int)frame->size.y});
if (isDuring) if (isDuring)
{ {
@@ -388,19 +389,19 @@ namespace anm2ed::imgui
auto minPoint = glm::min(frame->crop, frame->crop + frame->size); auto minPoint = glm::min(frame->crop, frame->crop + frame->size);
auto maxPoint = glm::max(frame->crop, frame->crop + frame->size); auto maxPoint = glm::max(frame->crop, frame->crop + frame->size);
frame_change_apply({.cropX = (int)minPoint.x, frame_change_apply({.cropX = minPoint.x,
.cropY = (int)minPoint.y, .cropY = minPoint.y,
.sizeX = (int)maxPoint.x - minPoint.x, .sizeX = maxPoint.x - minPoint.x,
.sizeY = (int)maxPoint.y - minPoint.y}); .sizeY = maxPoint.y - minPoint.y});
if (isGridSnap) if (isGridSnap)
{ {
auto [snapMin, snapMax] = snap_rect(frame->crop, frame->crop + frame->size); auto [snapMin, snapMax] = snap_rect(frame->crop, frame->crop + frame->size);
frame_change_apply({.cropX = (int)snapMin.x, frame_change_apply({.cropX = snapMin.x,
.cropY = (int)snapMin.y, .cropY = snapMin.y,
.sizeX = (int)snapMax.x - snapMin.x, .sizeX = snapMax.x - snapMin.x,
.sizeY = (int)snapMax.y - snapMin.y}); .sizeY = snapMax.y - snapMin.y});
} }
} }
if (ImGui::BeginTooltip()) if (ImGui::BeginTooltip())