fix frame size calculation when frame_inset is set

also fix error when clicking on HotkeyLabels where no on_activate
callback has been set
develop
myk002 2022-11-28 15:12:22 -08:00
parent 344ed4312b
commit adb9c5ea12
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 9 additions and 3 deletions

@ -34,7 +34,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
# Future # Future
## New Plugins ## New Plugins
- `overlay`: plugin is transformed from a single line of text that runs `gui/launcher` on click to a fully-featured overlay injection framework. See `overlay-dev-guide` for details. - `overlay`: plugin is transformed from a single line of text that runs `gui/launcher` on click to a fully-featured overlay injection framework. It now houses a popup menu for active keybindings, all the widgets provided by `dwarfmonitor` (e.g. the current date and number of happy/unhappy dwarves), the overlay that highlights suspended buildings when you pause, and others. See `overlay-dev-guide` for details.
## Fixes ## Fixes
- `automaterial`: fix the cursor jumping up a z level when clicking quickly after box select - `automaterial`: fix the cursor jumping up a z level when clicking quickly after box select
@ -113,6 +113,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- ``dfhack.constructions.findAtTile()``: exposed preexisting function to Lua. - ``dfhack.constructions.findAtTile()``: exposed preexisting function to Lua.
- ``dfhack.constructions.insert()``: exposed new function to Lua. - ``dfhack.constructions.insert()``: exposed new function to Lua.
- ``widgets.Panel``: new ``frame_style`` and ``frame_title`` attributes for drawing frames around groups of widgets - ``widgets.Panel``: new ``frame_style`` and ``frame_title`` attributes for drawing frames around groups of widgets
- ``widgets.ResizingPanel``: now accounts for frame inset when calculating frame size
- ``widgets.HotkeyLabel``: now ignores mouse clicks when ``on_activate`` is not defined
- ``widgets.EditField`` now allows other widgets to process characters that the ``on_char`` callback rejects. - ``widgets.EditField`` now allows other widgets to process characters that the ``on_char`` callback rejects.
- ``gui.Screen.show()`` now returns ``self`` as a convenience - ``gui.Screen.show()`` now returns ``self`` as a convenience
- ``gui.View.getMousePos()`` now takes an optional ``ViewRect`` parameter in case the caller wants to get the mouse pos relative to a rect that is not the frame_body (such as the frame_rect) - ``gui.View.getMousePos()`` now takes an optional ``ViewRect`` parameter in case the caller wants to get the mouse pos relative to a rect that is not the frame_body (such as the frame_rect)

@ -144,6 +144,9 @@ function ResizingPanel:postUpdateLayout(frame_body)
(s.frame and s.frame.h or frame_body.height)) (s.frame and s.frame.h or frame_body.height))
end end
end end
local l,t,r,b = gui.parse_inset(self.frame_inset)
w = w + l + r
h = h + t + b
if self.frame_style then if self.frame_style then
w = w + 2 w = w + 2
h = h + 2 h = h + 2
@ -827,7 +830,8 @@ function Label:scroll(nlines)
end end
end end
local n = self.start_line_num + nlines local n = self.start_line_num + nlines
n = math.min(n, self:getTextHeight() - self.frame_body.height + 1) local text_height = math.max(1, self:getTextHeight())
n = math.min(n, text_height - self.frame_body.height + 1)
n = math.max(n, 1) n = math.max(n, 1)
nlines = n - self.start_line_num nlines = n - self.start_line_num
self.start_line_num = n self.start_line_num = n
@ -928,7 +932,7 @@ end
function HotkeyLabel:onInput(keys) function HotkeyLabel:onInput(keys)
if HotkeyLabel.super.onInput(self, keys) then if HotkeyLabel.super.onInput(self, keys) then
return true return true
elseif keys._MOUSE_L_DOWN and self:getMousePos() then elseif keys._MOUSE_L_DOWN and self:getMousePos() and self.on_activate then
self.on_activate() self.on_activate()
return true return true
end end