diff --git a/src/imgui/window/animation_preview.cpp b/src/imgui/window/animation_preview.cpp index c170747..75cbe27 100644 --- a/src/imgui/window/animation_preview.cpp +++ b/src/imgui/window/animation_preview.cpp @@ -739,7 +739,7 @@ namespace anm2ed::imgui auto item = document.item_get(); auto useTool = tool; 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 (tool == tool::MOVE && isMouseRightDown) useTool = tool::SCALE; @@ -771,12 +771,12 @@ namespace anm2ed::imgui if (isMouseClicked) { moveOffset = settings.inputIsMoveToolSnapToMouse ? vec2() : mousePos - frame->position; + moveOffset = ivec2(moveOffset); isMoveDragging = true; } } if (isMouseDown && isMoveDragging) - frame_change_apply( - {.positionX = (int)(mousePos.x - moveOffset.x), .positionY = (int)(mousePos.y - moveOffset.y)}); + frame_change_apply({.positionX = mousePos.x - moveOffset.x, .positionY = mousePos.y - moveOffset.y}); if (isLeftPressed) frame_change_apply({.positionX = step}, anm2::SUBTRACT); if (isRightPressed) frame_change_apply({.positionX = step}, anm2::ADD); @@ -803,8 +803,8 @@ namespace anm2ed::imgui { frame->scale += vec2(mouseDelta.x, mouseDelta.y); if (isMod) frame->scale = {frame->scale.x, frame->scale.x}; - - frame_change_apply({.scaleX = (int)frame->scale.x, .scaleY = (int)frame->scale.y}); + frame->scale = ivec2(frame->scale); + frame_change_apply({.scaleX = frame->scale.x, .scaleY = frame->scale.y}); } if (isLeftPressed) frame_change_apply({.scaleX = step}, anm2::SUBTRACT); diff --git a/src/imgui/window/spritesheet_editor.cpp b/src/imgui/window/spritesheet_editor.cpp index 7042f26..1c39685 100644 --- a/src/imgui/window/spritesheet_editor.cpp +++ b/src/imgui/window/spritesheet_editor.cpp @@ -277,7 +277,7 @@ namespace anm2ed::imgui auto stepX = isGridSnap ? step * gridSize.x : step; auto stepY = isGridSnap ? step * gridSize.y : step; 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) { @@ -332,14 +332,17 @@ namespace anm2ed::imgui if (!item || frames.empty()) break; if (isBegin) document.snapshot(localize.get(EDIT_FRAME_PIVOT)); 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 (isRightPressed) frame_change_apply({.pivotX = step}, anm2::ADD); if (isUpPressed) frame_change_apply({.pivotY = step}, anm2::SUBTRACT); 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) { @@ -366,20 +369,18 @@ namespace anm2ed::imgui if (isMouseDown) { auto [minPoint, maxPoint] = snap_rect(glm::min(cropAnchor, mousePos), glm::max(cropAnchor, mousePos)); - frame_change_apply({.cropX = (int)minPoint.x, - .cropY = (int)minPoint.y, - .sizeX = (int)maxPoint.x - minPoint.x, - .sizeY = (int)maxPoint.y - minPoint.y}); + frame_change_apply({.cropX = minPoint.x, + .cropY = minPoint.y, + .sizeX = maxPoint.x - minPoint.x, + .sizeY = maxPoint.y - minPoint.y}); } if (isLeftPressed) frame_change_apply({.cropX = stepX}, anm2::SUBTRACT); if (isRightPressed) frame_change_apply({.cropX = stepX}, anm2::ADD); if (isUpPressed) frame_change_apply({.cropY = stepY}, anm2::SUBTRACT); if (isDownPressed) frame_change_apply({.cropY = stepY}, anm2::ADD); - frame_change_apply({.cropX = (int)frame->crop.x, - .cropY = (int)frame->crop.y, - .sizeX = (int)frame->size.x, - .sizeY = (int)frame->size.y}); + frame_change_apply( + {.cropX = frame->crop.x, .cropY = frame->crop.y, .sizeX = frame->size.x, .sizeY = frame->size.y}); if (isDuring) { @@ -388,19 +389,19 @@ namespace anm2ed::imgui auto minPoint = glm::min(frame->crop, frame->crop + frame->size); auto maxPoint = glm::max(frame->crop, frame->crop + frame->size); - frame_change_apply({.cropX = (int)minPoint.x, - .cropY = (int)minPoint.y, - .sizeX = (int)maxPoint.x - minPoint.x, - .sizeY = (int)maxPoint.y - minPoint.y}); + frame_change_apply({.cropX = minPoint.x, + .cropY = minPoint.y, + .sizeX = maxPoint.x - minPoint.x, + .sizeY = maxPoint.y - minPoint.y}); if (isGridSnap) { auto [snapMin, snapMax] = snap_rect(frame->crop, frame->crop + frame->size); - frame_change_apply({.cropX = (int)snapMin.x, - .cropY = (int)snapMin.y, - .sizeX = (int)snapMax.x - snapMin.x, - .sizeY = (int)snapMax.y - snapMin.y}); + frame_change_apply({.cropX = snapMin.x, + .cropY = snapMin.y, + .sizeX = snapMax.x - snapMin.x, + .sizeY = snapMax.y - snapMin.y}); } } if (ImGui::BeginTooltip())