Skip to content

Commit

Permalink
Customizable scroll label text pens
Browse files Browse the repository at this point in the history
  • Loading branch information
robob27 committed Nov 10, 2024
1 parent d459c69 commit 3ad14dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 7 additions & 2 deletions docs/dev/Lua API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
8 changes: 8 additions & 0 deletions library/lua/gui/widgets/tab_bar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 3ad14dd

Please sign in to comment.