Skip to content

Commit

Permalink
Merge pull request #964 from MagistrumT-T/gui-design-center-point-mar…
Browse files Browse the repository at this point in the history
…k-fix

Fix `gui/design` conflicting center point behavior
  • Loading branch information
myk002 authored Feb 5, 2024
2 parents de275f0 + 21d768a commit 03cec4d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Template for new versions:
## New Features

## Fixes
- `gui/design`: fix clicking the center point when there is a mark behind it entering both mark dragging and center dragging at the same time. Now you can click once to move the shape, and click twice to move only the mark behind the center point.

## Misc Improvements

Expand Down
35 changes: 21 additions & 14 deletions gui/design.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,27 @@ function Design:onInput(keys)
self.placing_mirror = false
self.needs_update = true
else
-- Clicking center point
if #self.marks > 0 then
local center = self.shape:get_center()
if pos == center and not self.prev_center then
self.start_center = pos
self.prev_center = pos
return true
elseif self.prev_center then
--If there was no movement presume user wanted to click the mark underneath instead and let the flow through.
if pos == self.start_center then
self.start_center = nil
self.prev_center = nil
else
-- Since it moved let's just drop the shape here.
self.start_center = nil
self.prev_center = nil
return true
end
end
end

if self.shape.basic_shape and #self.marks == self.shape.max_points then
-- Clicking a corner of a basic shape
local shape_top_left, shape_bot_right = self.shape:get_point_dims()
Expand Down Expand Up @@ -1514,20 +1535,6 @@ function Design:onInput(keys)
end
end

-- Clicking center point
if #self.marks > 0 then
local center = self.shape:get_center()
if pos == center and not self.prev_center then
self.start_center = pos
self.prev_center = pos
return true
elseif self.prev_center then
self.start_center = nil
self.prev_center = nil
return true
end
end

if self.mirror_point == pos then
self.placing_mirror = true
end
Expand Down

0 comments on commit 03cec4d

Please sign in to comment.