Merge pull request #3332 from TaxiService/cyclehotkey2

CycleHotkey: small tweak to `val_gap` + rename to `option_gap`
develop
Myk 2023-05-02 09:54:56 -07:00 committed by GitHub
commit a2d85b5095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

@ -70,7 +70,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Lua
- ``widgets.RangeSlider``: new mouse-controlled two-headed slider widget
- ``gui.ZScreenModal``: ZScreen subclass for modal dialogs
- ``widgets.CycleHotkeyLabel``: exposed "key_sep" and "val_gap" attributes for improved stylistic control.
- ``widgets.CycleHotkeyLabel``: exposed "key_sep" and "option_gap" attributes for improved stylistic control.
## Removed
- `title-version`: replaced by an `overlay` widget

@ -4918,11 +4918,11 @@ It has the following attributes:
hotkey.
:label_width: The number of spaces to allocate to the ``label`` (for use in
aligning a column of ``CycleHotkeyLabel`` labels).
:label_below: If ``true``, then the option value will apear below the label
:label_below: If ``true``, then the option value will appear below the label
instead of to the right of it. Defaults to ``false``.
:val_gap: The size of the gap between the label text and the option value.
:option_gap: The size of the gap between the label text and the option value.
Default is ``1``. If set to ``0``, there'll be no gap between the strings.
Note that ``val_gap`` is ignored if ``label_below`` is set to ``true``.
If ``label_below`` == ``true``, negative values will shift the value leftwards.
:options: A list of strings or tables of
``{label=string or fn, value=val[, pen=pen]}``. String options use the same
string for the label and value and use the default pen. The optional ``pen``

@ -1491,7 +1491,7 @@ CycleHotkeyLabel.ATTRS{
key=DEFAULT_NIL,
key_back=DEFAULT_NIL,
key_sep=': ',
val_gap=1,
option_gap=1,
label=DEFAULT_NIL,
label_width=DEFAULT_NIL,
label_below=false,
@ -1504,7 +1504,7 @@ function CycleHotkeyLabel:init()
self:setOption(self.initial_option)
if self.label_below then
self.val_gap = 0 + (self.key_back and 1 or 0) + (self.key and 3 or 0)
self.option_gap = self.option_gap + (self.key_back and 1 or 0) + (self.key and 2 or 0)
end
self:setText{
@ -1512,7 +1512,7 @@ function CycleHotkeyLabel:init()
{key=self.key, key_sep=self.key_sep, text=self.label, width=self.label_width,
on_activate=self:callback('cycle')},
self.label_below and NEWLINE or '',
{gap=self.val_gap, text=self:callback('getOptionLabel'),
{gap=self.option_gap, text=self:callback('getOptionLabel'),
pen=self:callback('getOptionPen')},
}
end