terminology change: locked -> pinned

develop
Myk Taylor 2023-01-13 16:07:27 -08:00
parent 99350bdb73
commit 21d160c478
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
3 changed files with 39 additions and 39 deletions

@ -4111,13 +4111,13 @@ through to the underlying viewscreen.
If :kbd:`Esc` or the right mouse button is pressed, and the ZScreen widgets If :kbd:`Esc` or the right mouse button is pressed, and the ZScreen widgets
don't otherwise handle them, then the top ZScreen is dismissed. If the ZScreen don't otherwise handle them, then the top ZScreen is dismissed. If the ZScreen
is "locked", then the screen is not dismissed and the input is passed on to the is "pinned", then the screen is not dismissed and the input is passed on to the
underlying DF viewscreen. :kbd:`Alt`:kbd:`L` toggles the locked status if the underlying DF viewscreen. :kbd:`Alt`:kbd:`L` toggles the pinned status if the
ZScreen widgets don't otherwise handle that key sequence. If you have a ZScreen widgets don't otherwise handle that key sequence. If you have a
``Panel`` with the ``lockable`` attribute set and a frame that has pens defined ``Panel`` with the ``pinnable`` attribute set and a frame that has pens defined
for the lock icon (like ``Window`` widgets have by default), then a lock icon for the pin icon (like ``Window`` widgets have by default), then a pin icon
will appear in the upper right corner of the frame. Clicking on this icon will will appear in the upper right corner of the frame. Clicking on this icon will
toggle the ZScreen ``locked`` status just as if :kbd:`Alt`:kbd:`L` had been toggle the ZScreen ``pinned`` status just as if :kbd:`Alt`:kbd:`L` had been
pressed. pressed.
Keyboard input goes to the top ZScreen, as usual. If the subviews of the top Keyboard input goes to the top ZScreen, as usual. If the subviews of the top
@ -4146,10 +4146,10 @@ ZScreen provides the following functions:
when the tool command is run and raise the existing dialog if it exists or when the tool command is run and raise the existing dialog if it exists or
show a new dialog if it doesn't. See the sample code below for an example. show a new dialog if it doesn't. See the sample code below for an example.
* ``zscreen:toggleLocked()`` * ``zscreen:togglePinned()``
Toggles whether the window closes on :kbd:`ESC` or r-click (unlocked) or not Toggles whether the window closes on :kbd:`ESC` or r-click (unpinned) or not
(locked). (pinned).
* ``zscreen:isMouseOver()`` * ``zscreen:isMouseOver()``
@ -4341,9 +4341,9 @@ Has attributes:
hitting :kbd:`Esc` (while resizing with the mouse or keyboard), or by calling hitting :kbd:`Esc` (while resizing with the mouse or keyboard), or by calling
``Panel:setKeyboardResizeEnabled(false)`` (while resizing with the keyboard). ``Panel:setKeyboardResizeEnabled(false)`` (while resizing with the keyboard).
* ``lockable = bool`` (default: ``false``) * ``pinnable = bool`` (default: ``false``)
Determines whether the panel will draw a lock icon in its frame. See Determines whether the panel will draw a pin icon in its frame. See
`ZScreen class`_ for details. `ZScreen class`_ for details.
* ``autoarrange_subviews = bool`` (default: ``false``) * ``autoarrange_subviews = bool`` (default: ``false``)
@ -4407,7 +4407,7 @@ Window class
------------ ------------
Subclass of Panel; sets Panel attributes to useful defaults for a top-level Subclass of Panel; sets Panel attributes to useful defaults for a top-level
framed, lockable, draggable window. framed, pinnable, draggable window.
ResizingPanel class ResizingPanel class
------------------- -------------------

@ -708,8 +708,8 @@ function ZScreen:isOnTop()
return dfhack.gui.getCurViewscreen(true) == self._native return dfhack.gui.getCurViewscreen(true) == self._native
end end
function ZScreen:toggleLocked() function ZScreen:togglePinned()
self.locked = not self.locked self.pinned = not self.pinned
end end
function ZScreen:onInput(keys) function ZScreen:onInput(keys)
@ -734,11 +734,11 @@ function ZScreen:onInput(keys)
end end
if keys.CUSTOM_ALT_L then if keys.CUSTOM_ALT_L then
self:toggleLocked() self:togglePinned()
return return
end end
if (self:isMouseOver() or not self.locked) if (self:isMouseOver() or not self.pinned)
and (keys.LEAVESCREEN or keys._MOUSE_R_DOWN) then and (keys.LEAVESCREEN or keys._MOUSE_R_DOWN) then
self:dismiss() self:dismiss()
-- ensure underlying DF screens don't also react to the click -- ensure underlying DF screens don't also react to the click
@ -814,11 +814,11 @@ GREY_LINE_FRAME = {
title_pen = to_pen{ fg=COLOR_BLACK, bg=COLOR_GREY }, title_pen = to_pen{ fg=COLOR_BLACK, bg=COLOR_GREY },
inactive_title_pen = to_pen{ fg=COLOR_GREY, bg=COLOR_BLACK }, inactive_title_pen = to_pen{ fg=COLOR_GREY, bg=COLOR_BLACK },
signature_pen = to_pen{ fg=COLOR_GREY, bg=COLOR_BLACK }, signature_pen = to_pen{ fg=COLOR_GREY, bg=COLOR_BLACK },
locked_pen = to_pen{tile=779, ch=216, fg=COLOR_GREY, bg=COLOR_GREEN}, pinned_pen = to_pen{tile=779, ch=216, fg=COLOR_GREY, bg=COLOR_GREEN},
unlocked_pen = to_pen{tile=782, ch=216, fg=COLOR_GREY, bg=COLOR_BLACK}, unpinned_pen = to_pen{tile=782, ch=216, fg=COLOR_GREY, bg=COLOR_BLACK},
} }
function paint_frame(dc,rect,style,title,show_lock,locked,inactive) function paint_frame(dc,rect,style,title,show_pin,pinned,inactive)
local pen = style.frame_pen local pen = style.frame_pen
local x1,y1,x2,y2 = dc.x1+rect.x1, dc.y1+rect.y1, dc.x1+rect.x2, dc.y1+rect.y2 local x1,y1,x2,y2 = dc.x1+rect.x1, dc.y1+rect.y1, dc.x1+rect.x2, dc.y1+rect.y2
dscreen.paintTile(style.lt_frame_pen or pen, x1, y1) dscreen.paintTile(style.lt_frame_pen or pen, x1, y1)
@ -843,26 +843,26 @@ function paint_frame(dc,rect,style,title,show_lock,locked,inactive)
x, y1, tstr) x, y1, tstr)
end end
if show_lock then if show_pin then
if locked and style.locked_pen then if pinned and style.pinned_pen then
local pin_texpos = dfhack.textures.getGreenPinTexposStart() local pin_texpos = dfhack.textures.getGreenPinTexposStart()
if pin_texpos == -1 then if pin_texpos == -1 then
dscreen.paintTile(style.locked_pen, x2-1, y1) dscreen.paintTile(style.pinned_pen, x2-1, y1)
else else
dscreen.paintTile(style.locked_pen, x2-2, y1-1, nil, pin_texpos+0) dscreen.paintTile(style.pinned_pen, x2-2, y1-1, nil, pin_texpos+0)
dscreen.paintTile(style.locked_pen, x2-1, y1-1, nil, pin_texpos+1) dscreen.paintTile(style.pinned_pen, x2-1, y1-1, nil, pin_texpos+1)
dscreen.paintTile(style.locked_pen, x2-2, y1, nil, pin_texpos+2) dscreen.paintTile(style.pinned_pen, x2-2, y1, nil, pin_texpos+2)
dscreen.paintTile(style.locked_pen, x2-1, y1, nil, pin_texpos+3) dscreen.paintTile(style.pinned_pen, x2-1, y1, nil, pin_texpos+3)
end end
elseif not locked and style.unlocked_pen then elseif not pinned and style.unpinned_pen then
local pin_texpos = dfhack.textures.getRedPinTexposStart() local pin_texpos = dfhack.textures.getRedPinTexposStart()
if pin_texpos == -1 then if pin_texpos == -1 then
dscreen.paintTile(style.unlocked_pen, x2-1, y1) dscreen.paintTile(style.unpinned_pen, x2-1, y1)
else else
dscreen.paintTile(style.unlocked_pen, x2-2, y1-1, nil, pin_texpos+0) dscreen.paintTile(style.unpinned_pen, x2-2, y1-1, nil, pin_texpos+0)
dscreen.paintTile(style.unlocked_pen, x2-1, y1-1, nil, pin_texpos+1) dscreen.paintTile(style.unpinned_pen, x2-1, y1-1, nil, pin_texpos+1)
dscreen.paintTile(style.unlocked_pen, x2-2, y1, nil, pin_texpos+2) dscreen.paintTile(style.unpinned_pen, x2-2, y1, nil, pin_texpos+2)
dscreen.paintTile(style.unlocked_pen, x2-1, y1, nil, pin_texpos+3) dscreen.paintTile(style.unpinned_pen, x2-1, y1, nil, pin_texpos+3)
end end
end end
end end

@ -81,7 +81,7 @@ Panel.ATTRS {
resize_min = DEFAULT_NIL, resize_min = DEFAULT_NIL,
on_resize_begin = DEFAULT_NIL, on_resize_begin = DEFAULT_NIL,
on_resize_end = DEFAULT_NIL, on_resize_end = DEFAULT_NIL,
lockable = false, pinnable = false,
autoarrange_subviews = false, -- whether to automatically lay out subviews autoarrange_subviews = false, -- whether to automatically lay out subviews
autoarrange_gap = 0, -- how many blank lines to insert between widgets autoarrange_gap = 0, -- how many blank lines to insert between widgets
} }
@ -280,7 +280,7 @@ local function panel_is_on_pin(self)
end end
local function panel_is_pinnable(self) local function panel_is_pinnable(self)
return self.lockable and self.parent_view and self.parent_view.toggleLocked return self.pinnable and self.parent_view and self.parent_view.togglePinned
end end
function Panel:getMouseFramePos() function Panel:getMouseFramePos()
@ -322,7 +322,7 @@ function Panel:onInput(keys)
end end
if panel_is_pinnable(self) and keys._MOUSE_L_DOWN then if panel_is_pinnable(self) and keys._MOUSE_L_DOWN then
if panel_is_on_pin(self) then if panel_is_on_pin(self) then
self.parent_view:toggleLocked() self.parent_view:togglePinned()
return true return true
end end
end end
@ -491,14 +491,14 @@ end
function Panel:onRenderFrame(dc, rect) function Panel:onRenderFrame(dc, rect)
Panel.super.onRenderFrame(self, dc, rect) Panel.super.onRenderFrame(self, dc, rect)
if not self.frame_style then return end if not self.frame_style then return end
local locked = nil local pinned = nil
if self.lockable then if self.pinnable then
locked = self.parent_view and self.parent_view.locked pinned = self.parent_view and self.parent_view.pinned
end end
local inactive = self.parent_view and self.parent_view.isOnTop local inactive = self.parent_view and self.parent_view.isOnTop
and not self.parent_view:isOnTop() and not self.parent_view:isOnTop()
gui.paint_frame(dc, rect, self.frame_style, self.frame_title, gui.paint_frame(dc, rect, self.frame_style, self.frame_title,
self.lockable, locked, inactive) self.pinnable, pinned, inactive)
if self.kbd_get_pos then if self.kbd_get_pos then
local pos = self.kbd_get_pos() local pos = self.kbd_get_pos()
local pen = to_pen{fg=COLOR_GREEN, bg=COLOR_BLACK} local pen = to_pen{fg=COLOR_GREEN, bg=COLOR_BLACK}
@ -521,7 +521,7 @@ Window.ATTRS {
frame_background = gui.CLEAR_PEN, frame_background = gui.CLEAR_PEN,
frame_inset = 1, frame_inset = 1,
draggable = true, draggable = true,
lockable = true, pinnable = true,
} }
------------------- -------------------