Skip to content

Commit 3c325cc

Browse files
committed
gui/mass-remove.toolbar: position is constrained to minimum-size interface
This limits the possible positions, but prevents a couple of problems when the overlay's "anchor edges" change (i.e., after "touching" a different interface edge while repositioning the overlay): - unexpected "jumps" of the overlay's effective position - "stale" overlay size representation in `gui/overlay` Both of these were caused by swapping the "padding" from one side of the overlay's effective position to the other when swapping anchor edges. Always apply both paddings to keep things consistent.
1 parent 70262e0 commit 3c325cc

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

gui/mass-remove.lua

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,17 @@ end
407407
-- l/r/t/b frame positioning fields). However, to preserve player-positioning,
408408
-- we take a more circuitous route.
409409

410-
-- The button and tooltip are anchored to one side of the overlay's frame (which
411-
-- one depends on which edge the overlay itself is anchored to). Then, to
412-
-- respond to different interface sizes, we adjust the width and height of the
413-
-- overlay's frame to arrange for the button to land in its expected place.
410+
-- In a minimum-size interface area, the player is allowed to place the overlay
411+
-- (a combination of the button and the tooltip) anywhere inside the interface
412+
-- area. When the interface area is resized (usually through window resizes, but
413+
-- also through interface percentage changes), placement is maintained relative
414+
-- to the "ideal" position of the button (i.e. positions are relative to the
415+
-- "ideal" position). When repositioning the overlay in a larger-than-minimum
416+
-- interface area the overlays size is artificially inflated so that the overlay
417+
-- can not be positioned (with respect to the "ideal" button position) farther
418+
-- away than is possible in a minimum-size interface area. This limits the
419+
-- positioning, but keeps the (relative) position consistent across all possible
420+
-- resizes.
414421

415422
local tb = reqscript('internal/df-bottom-toolbars')
416423

@@ -509,29 +516,17 @@ function MassRemoveToolbarOverlay:init()
509516
end
510517

511518
function MassRemoveToolbarOverlay:preUpdateLayout(parent_rect)
512-
local extra_width
513519
local offsets = mass_remove_button_offsets(parent_rect)
514-
if self.frame.l then
515-
extra_width = offsets.l - MR_MIN_OFFSETS.l
516-
self.subviews.tt_and_icon.frame.l = nil
517-
self.subviews.tt_and_icon.frame.r = 0
518-
else
519-
extra_width = offsets.r - MR_MIN_OFFSETS.r
520-
self.subviews.tt_and_icon.frame.l = 0
521-
self.subviews.tt_and_icon.frame.r = nil
522-
end
523-
local extra_height
524-
if self.frame.b then
525-
extra_height = offsets.b - MR_MIN_OFFSETS.b
526-
self.subviews.tt_and_icon.frame.t = 0
527-
self.subviews.tt_and_icon.frame.b = nil
528-
else
529-
extra_height = offsets.t - MR_MIN_OFFSETS.t
530-
self.subviews.tt_and_icon.frame.t = nil
531-
self.subviews.tt_and_icon.frame.b = 0
532-
end
533-
self.frame.w = MR_WIDTH + extra_width
534-
self.frame.h = MR_HEIGHT + extra_height
520+
local r = offsets.r - MR_MIN_OFFSETS.r
521+
local l = offsets.l - MR_MIN_OFFSETS.l
522+
local t = offsets.t - MR_MIN_OFFSETS.t
523+
local b = offsets.b - MR_MIN_OFFSETS.b
524+
self.frame.w = MR_WIDTH + l + r
525+
self.frame.h = MR_HEIGHT + t + b
526+
self.subviews.tt_and_icon.frame.l = l
527+
self.subviews.tt_and_icon.frame.r = r
528+
self.subviews.tt_and_icon.frame.t = t
529+
self.subviews.tt_and_icon.frame.b = b
535530
end
536531

537532
function MassRemoveToolbarOverlay:onInput(keys)

0 commit comments

Comments
 (0)