wesnoth/data/gui/widget/label_story_screen_title.cfg
Charles Dang 7188781f91 GUI2: made link_aware a per-instance config option rather than per-definition
Back when link awareness was first added (https://github.com/wesnoth/wesnoth/pull/300), this key was added
globally to label definitions alongside link_color. This had the unintended side effect of making *all* labels
link aware, leading to issues such as being able to open a do-you-want-to-open prompt from an instance of the
same ad-infinitum.

This became an active issue after 213453e6cf78371360471ac4d110602aafecd9f3, since now that labels could capture
focus if link_aware was true - which it always was for most labels - labels in toggle panels would always
grab mouse_motion events and no longer allow their parent toggle panels to gain their hovered states. That
appears to be in keeping with the design of GUI2, and a further evaluation of that issue is needed at a later
time. However, the fact remains that almost every single label was marked as link-aware, even when in almost every
case that was not the desired behavior.

This change move the link_aware config option to individual label and scroll_label instances. The following uses
had this explicitly enabled:

- Addon license prompt
- Addon descriptions
- Campaign descriptions
- The Server Info popup
- The chatbox
2020-12-12 03:03:09 +11:00

97 lines
2.0 KiB
INI

#textdomain wesnoth-lib
###
### Definition of the title label for the story viewer.
###
# We can't get the exact size of the text outside a [text] element, so estimate it instead.
# Using an average character width of 12 seems to give good results.
# Then we centre the text in the estimated width rather than in the entire width.
#define _GUI_ESTIMATE_TEXT_WIDTH
(length(text) * 12)#enddef
#define _GUI_CENTER_STORY_TEXT
(10 + max((box_width - text_width) / 2, 0)
where box_width = {_GUI_ESTIMATE_TEXT_WIDTH})#enddef
#define _GUI_BACKGROUND
[round_rectangle]
x = 10
y = 10
w = "{_GUI_ESTIMATE_TEXT_WIDTH}"
h = "(height - 20)"
corner_radius = 5
fill_color = "0, 0, 0, 96"
[/round_rectangle]
[round_rectangle]
x = 13
y = 13
w = "(text_width - 6 where text_width = {_GUI_ESTIMATE_TEXT_WIDTH})"
h = "(height - 26)"
corner_radius = 5
fill_color = "0, 0, 0, 96"
[/round_rectangle]
#enddef
#define _GUI_TEXT MODE
[text]
#x = "{_GUI_CENTER_STORY_TEXT}"
x = 20
#y = {GUI__TEXT_VERTICALLY_CENTRED}
y = 20
w = "(width)"
h = "(text_height)"
maximum_width = "(width)"
font_size = {GUI_FONT_SIZE_LARGE}
color = {GUI__FONT_COLOR_{MODE}__DEFAULT}
text = "(text)"
text_markup = "(text_markup)"
text_alignment = "(text_alignment)"
text_link_aware = "(text_link_aware)"
text_link_color = "(text_link_color)"
[/text]
#enddef
[label_definition]
id = "story_screen_title"
description = "Large label with translucent background for story screen"
[resolution]
min_width = 0
min_height = 0
default_width = 0
default_height = 100
max_width = 0
max_height = 0
text_font_size = {GUI_FONT_SIZE_LARGE}
[state_enabled]
[draw]
#{_GUI_BACKGROUND}
{_GUI_TEXT ENABLED}
[/draw]
[/state_enabled]
[state_disabled]
[draw]
#{_GUI_BACKGROUND}
{_GUI_TEXT DISABLED}
[/draw]
[/state_disabled]
[/resolution]
[/label_definition]
#undef _GUI_ESTIMATE_TEXT_WIDTH
#undef _GUI_CENTER_STORY_TEXT
#undef _GUI_BACKGROUND
#undef _GUI_TEXT