diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 56d5eac5f..33b48c0a7 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -4111,13 +4111,13 @@ through to the underlying viewscreen. 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 -is "locked", 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 +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 pinned status if the 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 -for the lock icon (like ``Window`` widgets have by default), then a lock icon +``Panel`` with the ``pinnable`` attribute set and a frame that has pens defined +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 -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. 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 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 - (locked). + Toggles whether the window closes on :kbd:`ESC` or r-click (unpinned) or not + (pinned). * ``zscreen:isMouseOver()`` @@ -4341,9 +4341,9 @@ Has attributes: hitting :kbd:`Esc` (while resizing with the mouse or keyboard), or by calling ``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. * ``autoarrange_subviews = bool`` (default: ``false``) @@ -4407,7 +4407,7 @@ Window class ------------ Subclass of Panel; sets Panel attributes to useful defaults for a top-level -framed, lockable, draggable window. +framed, pinnable, draggable window. ResizingPanel class ------------------- diff --git a/library/lua/gui.lua b/library/lua/gui.lua index 8a2a406aa..e7f59a148 100644 --- a/library/lua/gui.lua +++ b/library/lua/gui.lua @@ -708,8 +708,8 @@ function ZScreen:isOnTop() return dfhack.gui.getCurViewscreen(true) == self._native end -function ZScreen:toggleLocked() - self.locked = not self.locked +function ZScreen:togglePinned() + self.pinned = not self.pinned end function ZScreen:onInput(keys) @@ -734,11 +734,11 @@ function ZScreen:onInput(keys) end if keys.CUSTOM_ALT_L then - self:toggleLocked() + self:togglePinned() return end - if (self:isMouseOver() or not self.locked) + if (self:isMouseOver() or not self.pinned) and (keys.LEAVESCREEN or keys._MOUSE_R_DOWN) then self:dismiss() -- 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 }, inactive_title_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}, - unlocked_pen = to_pen{tile=782, ch=216, fg=COLOR_GREY, bg=COLOR_BLACK}, + pinned_pen = to_pen{tile=779, ch=216, fg=COLOR_GREY, bg=COLOR_GREEN}, + 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 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) @@ -843,26 +843,26 @@ function paint_frame(dc,rect,style,title,show_lock,locked,inactive) x, y1, tstr) end - if show_lock then - if locked and style.locked_pen then + if show_pin then + if pinned and style.pinned_pen then local pin_texpos = dfhack.textures.getGreenPinTexposStart() if pin_texpos == -1 then - dscreen.paintTile(style.locked_pen, x2-1, y1) + dscreen.paintTile(style.pinned_pen, x2-1, y1) else - dscreen.paintTile(style.locked_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.locked_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-2, y1-1, nil, pin_texpos+0) + dscreen.paintTile(style.pinned_pen, x2-1, y1-1, nil, pin_texpos+1) + dscreen.paintTile(style.pinned_pen, x2-2, y1, nil, pin_texpos+2) + dscreen.paintTile(style.pinned_pen, x2-1, y1, nil, pin_texpos+3) end - elseif not locked and style.unlocked_pen then + elseif not pinned and style.unpinned_pen then local pin_texpos = dfhack.textures.getRedPinTexposStart() if pin_texpos == -1 then - dscreen.paintTile(style.unlocked_pen, x2-1, y1) + dscreen.paintTile(style.unpinned_pen, x2-1, y1) else - dscreen.paintTile(style.unlocked_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.unlocked_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-2, y1-1, nil, pin_texpos+0) + dscreen.paintTile(style.unpinned_pen, x2-1, y1-1, nil, pin_texpos+1) + dscreen.paintTile(style.unpinned_pen, x2-2, y1, nil, pin_texpos+2) + dscreen.paintTile(style.unpinned_pen, x2-1, y1, nil, pin_texpos+3) end end end diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index 5414fefaa..9293e737c 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -81,7 +81,7 @@ Panel.ATTRS { resize_min = DEFAULT_NIL, on_resize_begin = DEFAULT_NIL, on_resize_end = DEFAULT_NIL, - lockable = false, + pinnable = false, autoarrange_subviews = false, -- whether to automatically lay out subviews autoarrange_gap = 0, -- how many blank lines to insert between widgets } @@ -280,7 +280,7 @@ local function panel_is_on_pin(self) end 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 function Panel:getMouseFramePos() @@ -322,7 +322,7 @@ function Panel:onInput(keys) end if panel_is_pinnable(self) and keys._MOUSE_L_DOWN then if panel_is_on_pin(self) then - self.parent_view:toggleLocked() + self.parent_view:togglePinned() return true end end @@ -491,14 +491,14 @@ end function Panel:onRenderFrame(dc, rect) Panel.super.onRenderFrame(self, dc, rect) if not self.frame_style then return end - local locked = nil - if self.lockable then - locked = self.parent_view and self.parent_view.locked + local pinned = nil + if self.pinnable then + pinned = self.parent_view and self.parent_view.pinned end local inactive = self.parent_view and self.parent_view.isOnTop and not self.parent_view:isOnTop() 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 local pos = self.kbd_get_pos() local pen = to_pen{fg=COLOR_GREEN, bg=COLOR_BLACK} @@ -521,7 +521,7 @@ Window.ATTRS { frame_background = gui.CLEAR_PEN, frame_inset = 1, draggable = true, - lockable = true, + pinnable = true, } -------------------