From 3ad14dda612c715b5a37dc3e00bc0d1351949537 Mon Sep 17 00:00:00 2001 From: Robob27 Date: Sun, 10 Nov 2024 17:52:26 -0500 Subject: [PATCH] Customizable scroll label text pens --- docs/dev/Lua API.rst | 9 +++++++-- library/lua/gui/widgets/tab_bar.lua | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 196b50465f..53adad0f71 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -6234,9 +6234,14 @@ of content. :scroll_key_back: Specifies a keybinding that can be used to scroll the tabs to the left. Defaults to ``CUSTOM_ALT_Y``. :scroll_left_text: The text to display on the left scroll label. - Defaults to ``<<<``. + Defaults to "<<<". :scroll_right_text: The text to display on the right scroll label. - Defaults to ``>>>``. + Defaults to ">>>". +:scroll_label_text_pen: The pen to use for the scroll label text. + Defaults to ``Label`` default. +:scroll_label_text_hpen: The pen to use for the scroll label text when hovered. + Defaults to ``scroll_label_text_pen`` with the background + and foreground colors swapped. :scroll_step: The number of units to scroll tabs by. Defaults to 10. :fast_scroll_multiplier: The multiplier for fast scrolling (holding shift). diff --git a/library/lua/gui/widgets/tab_bar.lua b/library/lua/gui/widgets/tab_bar.lua index cd0fe618b7..f5a113573e 100644 --- a/library/lua/gui/widgets/tab_bar.lua +++ b/library/lua/gui/widgets/tab_bar.lua @@ -142,6 +142,8 @@ end ---@field scroll_key_back string ---@field fast_scroll_modifier integer ---@field scroll_into_view_offset integer +---@field scroll_label_text_pen dfhack.pen +---@field scroll_label_text_hpen dfhack.pen ---@class widgets.TabBar.attrs.partial: widgets.TabBar.attrs @@ -170,6 +172,8 @@ TabBar.ATTRS{ scroll_key_back = 'CUSTOM_ALT_Y', fast_scroll_modifier = 3, scroll_into_view_offset = 5, + scroll_label_text_pen = DEFAULT_NIL, + scroll_label_text_hpen = DEFAULT_NIL, } ---@param self widgets.TabBar @@ -214,6 +218,8 @@ function TabBar:init() Label{ view_id='TabBar__scroll_left', frame={t=0, l=0, w=#self.scroll_left_text}, + text_pen=self.scroll_label_text_pen, + text_hpen=self.scroll_label_text_hpen, text=self.scroll_left_text, visible = false, on_click=function() @@ -223,6 +229,8 @@ function TabBar:init() Label{ view_id='TabBar__scroll_right', frame={t=0, l=0, w=#self.scroll_right_text}, + text_pen=self.scroll_label_text_pen, + text_hpen=self.scroll_label_text_hpen, text=self.scroll_right_text, visible = false, on_click=function()