Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gui2/tslider: Add minimal variant without a text label
The default variant's text label is both inflexible in content (can't customize the format for non-edge values) and layout (reserves way more space than it needs at a time for its text label, often resulting in huge horizontal gaps between a slider and an adjacent widget). This makes it unsuitable for use in gui2::tchat_log. This new minimal variant will be wired into gui2::tchat_log next.
- Loading branch information
Showing
1 changed file
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#textdomain wesnoth-lib | ||
### | ||
### Experimental slider variant that does not have a text label since the | ||
### default variant does have one that takes up more space than is strictly | ||
### necessary and I (shadowm) can't deal with all the magic numbers in it. | ||
### | ||
|
||
#define _GUI_STATE IMAGE_SUFFIX GROOVE_COLOR | ||
[draw] | ||
|
||
# | ||
# Groove | ||
# | ||
|
||
[line] | ||
x1 = 0 | ||
y1 = "(height / 2)" | ||
x2 = "(width - 1)" | ||
y2 = "(height / 2)" | ||
|
||
color = {GROOVE_COLOR} | ||
thickness = 1 | ||
[/line] | ||
|
||
# | ||
# Slider | ||
# | ||
|
||
[image] | ||
x = "(positioner_offset)" | ||
y = "(if (image_height < height, (height - image_height) / 2, 0))" | ||
name = "buttons/sliders/slider{IMAGE_SUFFIX}" | ||
[/image] | ||
|
||
[/draw] | ||
#enddef | ||
|
||
#define _GUI_RESOLUTION RESOLUTION MIN_WIDTH DEFAULT_WIDTH HEIGHT POSITIONER_LENGTH | ||
|
||
[resolution] | ||
|
||
{RESOLUTION} | ||
|
||
min_width = {MIN_WIDTH} | ||
min_height = {HEIGHT} | ||
|
||
default_width = {DEFAULT_WIDTH} | ||
default_height = {HEIGHT} | ||
|
||
max_width = 0 | ||
max_height = {HEIGHT} | ||
|
||
minimum_positioner_length = {POSITIONER_LENGTH} | ||
maximum_positioner_length = {POSITIONER_LENGTH} | ||
|
||
#text_font_size = 1 # placeholder | ||
|
||
[state_enabled] | ||
{_GUI_STATE | ||
".png" | ||
({GUI__FONT_COLOR_ENABLED__DEFAULT}) | ||
} | ||
[/state_enabled] | ||
|
||
[state_disabled] | ||
{_GUI_STATE | ||
".png~GS()" | ||
({GUI__FONT_COLOR_DISABLED__DEFAULT}) | ||
} | ||
[/state_disabled] | ||
|
||
[state_pressed] | ||
{_GUI_STATE | ||
"-pressed.png" | ||
({GUI__FONT_COLOR_ENABLED__DEFAULT}) | ||
} | ||
[/state_pressed] | ||
|
||
[state_focussed] | ||
{_GUI_STATE | ||
"-active.png" | ||
({GUI__FONT_COLOR_ENABLED__DEFAULT}) | ||
} | ||
[/state_focussed] | ||
|
||
[/resolution] | ||
#enddef | ||
|
||
[slider_definition] | ||
id = "minimal" | ||
description = "A slider without a value label." | ||
|
||
# Tiny gui sizes haven't been tested yet so might need some tuning. | ||
{_GUI_RESOLUTION ({GUI_TINY__RESOLUTION}) 75 125 11 8 } | ||
{_GUI_RESOLUTION () 150 250 22 16 } | ||
|
||
[/slider_definition] | ||
|
||
#undef _GUI_STATE | ||
#undef _GUI_RESOLUTION |