Commit Graph

106 Commits (f993c23d755c473535beffaea0634b1d70fb81dd)

Author SHA1 Message Date
Myk 89d3d45e87
Allow EditField widgets to manage their own activation and keyboard focus (#2147)
* use new focus subsystem in widgets.EditField

* always eat the enter key if we have an on_submit

* add modal attribute

* give EditFields a default height of 1

so they can be autoarranged
2022-06-01 21:48:21 -07:00
myk002 ea7fe2b926
account for scroll bars when sizing message boxes 2022-05-27 15:38:13 -07:00
Timur Kelman 07f54deb0b
fix wrong `Label.frame_body.x2` value (#2134)
* fix wrong `Label.frame_body.x2` value

`update_scroll_inset` might change `frame_inset`, i.e. we need to `computeFrame` with the new values.

* add tests for Label

* add missing `local`, remove code in comments

* move `TestFramedScreen` outside test functions
2022-05-27 15:25:17 -07:00
myk002 18628ff5b8 make key_sep more configurable
and add more configuration to HotkeyLabel and EditField to take
advantage of it
2022-05-18 16:46:33 -07:00
myk002 53609db1f9 let CycleHotkeyLabels take numeric initial_options
even if all of the option values are non-numeric
2022-05-18 15:39:52 -07:00
Myk e2fb15a3a5
add dwarfmode.MenuOverlay:renderMapOverlay() (#2119)
* add dwarfmode.MenuOverlay:renderMapOverlay()

* ensure we move with the viewport when bounds_rect is nil
2022-04-29 20:32:22 -07:00
myk002 e603fee3ce
move sidebar mode management code to init
from onAboutToShow(). this allows the frames to be calculated correctly
during widget instantiation. otherwise widgets can end up with -1 width
2022-04-29 12:10:05 -07:00
myk002 af47434f52
protect against 0 width in string:wrap() 2022-04-29 11:29:19 -07:00
Timur Kelman f08a268e8a
add scroll icons to Label widget (#2101)
* WIP: add scroll icons to Label widget

It's an opt-out. The icons are rendered in the right-most column of the 1st and last row. They are only rendered when text can actually be scrolled in the corresponding direction.

WIP: Currently, the icons might overlay text characters, there is no mechanism preventing it

* gui.lua: expose the `parse_inset()` function

* refactor Label's scroll icon code

* since `render_scroll_icons` only works with a label, it's now a class function
* `update_scroll_inset` ensures `frame_inset.r` or `.l` is at least 1, according to `show_scroll_icons`
* `show_scroll_icons` has 4 possible values: `false` for no icons, `left` for icons on the first column on the left (also ensuring `frame_inset.l >= 1`), `right` - last column on the right, `DEFAULT_NIL` - same as `right` if text height greater than `frame_body.height`, else same as `false`.

* make `render_scroll_icons` always draw icons

The check now happens in `onRenderFrame`

* draw frame's background

calling `Label.super.onRenderFrame(self, dc, rect)` makes frame's background invisible for some reason

* remove trailing spaces

* fix scroll icons placed far above/below text

 With `Label.frame_inset = 1` the text could be vertically centered with plenty of space below and above,
but not all rendered. Before this change, the scroll icons would be at the very top and bottom of the frame
instead of near the first and last rendered text line.

* always `update_scroll_inset` to react to resized window

* draw scroll icons next to text

* update `Lua API.rst` with new `Label` parameters

* move comment separator up

This way every scroll related parameter is in one group

* list default values for new parameters in docs

* add missing description of `Label.scroll_keys`
2022-04-29 06:55:08 -07:00
myk002 6ad362d698
return a reference to the created dialogs 2022-04-27 11:51:46 -07:00
myk002 ed5523152c
factor text wrapping out of TooltipLabel into WrappedLabel 2022-04-22 09:53:10 -07:00
myk002 809f9316fd
make frame inset configurable for ListBox list 2022-04-22 08:30:53 -07:00
myk002 07761e1d5d add some more handy widgets to the library
TooltipLabel
HotkeyLabel
CycleHotkeyLabel
ToggleHotkeyLabel
2022-04-18 17:37:11 -07:00
Myk fd1ee233a2
automatically manage sidebar modes in MenuOverlay (#2083) 2022-04-11 20:58:54 -07:00
Myk 10f22ecc27
add ResizingPanel class and autolayout for Panels (#2086)
* add autolayout for Panels and new ResizingPanel
2022-04-11 18:25:00 -07:00
Myk e6299700bf
Handle punctuation in FilteredList filter matching (#2085)
* allow punctuation to be typed into a filter

and allow the filter to match keys with punctuation
2022-04-11 18:22:31 -07:00
Myk 9a8fd12785
ensure ListBoxes always have enough height (#2084)
so they can always display an error message if the filter doesn't match anything
2022-04-11 16:15:50 -07:00
myk002 db5e7d55c1 fix guidm.enterSidebarMode(DesignateMine)
it would end up in DesignateChopTrees if you happened to be looking at
the surface z-level.
2022-03-28 16:57:24 -07:00
Tachytaenius 19c0a4fe06
Added (chain) for [CHAIN_METAL_TEXT] armours in library/gui/materials.lua used by the gui/create-item script (#2037) 2022-03-19 15:32:16 -07:00
myk002 42ae45dd5f support designate for enterSidebarMode 2021-10-02 09:26:32 -07:00
Timur Kelman 15d8a0bea2
rename `dismiss_on_submit|2` to `dismiss_on_select|2`
to avoid confusion
2021-07-30 17:25:01 +02:00
Timur Kelman ffecdf3b53
ListBox attributes controlling self:dismiss()
`dismiss_on_submit = false` makes it easier to implement toggleable options, where we don't want the list to disappear on selection. Like work order conditions' trait selection.
2021-07-29 19:00:19 +02:00
lethosor 898d4621da
Merge remote-tracking branch 'myk002/myk_view_unit' into develop 2021-07-05 20:42:49 -04:00
myk002 87c7d02e09
support view unit mode for guidm.enterSidebarMode 2021-07-05 16:02:19 -07:00
myk002 f62ff3ecc0
migrate existing lua code to use new library fns 2021-07-05 15:48:51 -07:00
lethosor 2f36404da7
Merge remote-tracking branch 'origin/lua_label_input_fix' into develop 2021-07-05 15:42:06 -04:00
lethosor fb7560d8bf
Merge remote-tracking branch 'wolfboyft/patch-2' into develop 2021-07-05 11:41:37 -04:00
myk002 000b589e3a
add dwarfmode library function: enterSidebarMode()
refactored from quickfort. this common implementation will replace the
now redundant functions in quickfort, gui/mass-remove, and gui/blueprint
2021-06-23 12:29:37 -07:00
Warmist b7069a5ebd
Fix label early key detection in scrolling logic
Current logic is because @myk002 fixed it so label would allow other widgets control when label(s) are present. However that breaks label key detection for default scroll keys. This can be worked around by setting scrollkeys to empty.

TBH: label is quite complicated and used everwhere so i'm reluctant to touch it and would love for someone to look over if i'm correct.
2021-06-22 11:31:00 +03:00
Tachytaenius 990c153a9a
Show adjective in item prompt
Useful for high boot/low boot etc.
2021-06-19 13:59:38 +01:00
lethosor 7e12f3fd3d
Fix off-by-one, adjust changelog, move scroll keys to consistent place
Ref #1748
2021-01-30 19:40:15 -05:00
myk002 5a2181d55e
don't render overflow text 2021-01-13 22:02:22 -08:00
myk002 d4fbf4261f
address review comments 2021-01-12 23:27:14 -08:00
myk002 dac9538fd9
let navigation keys propagate
so other components can use them for simultaneous control
2021-01-11 15:02:12 -08:00
Myk Taylor 2797061b04
scroll Label text when height exceeds viewrect 2021-01-11 14:47:05 -08:00
lethosor 3b5a82cc05
Change color of ListBox.select2_hint to grey to indicate enabled
Ref dfhack/scripts#185
2020-08-27 00:08:28 -04:00
lethosor c034276af5
Merge remote-tracking branch 'myk002/quickfort_filter' into develop 2020-08-21 00:34:34 -04:00
Myk Taylor 9a3e9d5b12 listbox filter can match strings after punctuation 2020-08-17 21:15:33 -07:00
Myk Taylor 8a438c2a55 allow row_height to be set from the ListBox class 2020-08-17 21:14:05 -07:00
nicolasayala 141928ead0 Fix gui.FilteredList widget search on plain string choices 2020-02-27 07:56:30 +01:00
lethosor 49563b4618 Merge remote-tracking branch 'warmist/FilteredListFix' into develop 2019-11-02 16:28:06 -04:00
Warmist a2b5c1ddd9
lua/widgets filtered list input fix
FilteredList was not consuming input events.
2019-09-30 22:00:06 +03:00
lethosor e5eade1ad7 Make gui.dwarfmode.{get_movement_delta,get_hotkey_target} public 2019-04-30 16:53:09 -04:00
Pauli 98b25e3462 Allow calling List:setChoices() to clear choices 2018-06-20 17:46:24 +03:00
Pauli ed23d2c4e2 Change gui.widgets.List:setChoices to keep state in internal table
Fixes #1171
2018-06-20 17:23:57 +03:00
grubsteak 7e3c8c9965
added fast keys for workshop gui overlay 2018-05-19 20:25:24 -05:00
Quietust 88c7e493b8 Merge ui_area_map_width into ui_menu_width, now a 2-byte array 2017-12-03 20:34:59 -06:00
lethosor cc0220f030 Add a "key" option to EditField and FilteredList 2017-06-27 21:10:14 -04:00
lethosor db375ae83b Add a Pages:getSelectedPage() helper
Equivalent to select(2, pages:getSelected()), but more readable.
2017-06-23 12:46:46 -04:00
lethosor ae809afde7 Add Gui::refreshSidebar()
This handles feeding CURSOR_DOWN_Z and CURSOR_UP_Z properly, avoiding issues
when on the lowest z-level.
2017-06-23 00:02:21 -04:00