Story viewer: Shrink translucent background behind title to a box
This commit is contained in:
parent
1ba98d6e42
commit
e46b10af0e
1 changed files with 24 additions and 10 deletions
|
@ -3,6 +3,17 @@
|
|||
### 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.
|
||||
|
||||
#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
|
||||
|
||||
[label_definition]
|
||||
id = "story_screen_title"
|
||||
description = "Large label with translucent background for story screen"
|
||||
|
@ -28,15 +39,15 @@
|
|||
[draw]
|
||||
|
||||
[rectangle]
|
||||
x = 0
|
||||
y = 0
|
||||
w = "(width)"
|
||||
h = "(height)"
|
||||
x = 10
|
||||
y = 10
|
||||
w = "{_GUI_ESTIMATE_TEXT_WIDTH}"
|
||||
h = "(height - 20)"
|
||||
fill_color = "0, 0, 0, 128"
|
||||
[/rectangle]
|
||||
|
||||
[text]
|
||||
x = 20
|
||||
x = "{_GUI_CENTER_STORY_TEXT}"
|
||||
y = {GUI__TEXT_VERTICALLY_CENTRED}
|
||||
w = "(width)"
|
||||
h = "(text_height)"
|
||||
|
@ -59,15 +70,15 @@
|
|||
[draw]
|
||||
|
||||
[rectangle]
|
||||
x = 0
|
||||
y = 0
|
||||
w = "(width)"
|
||||
h = "(height)"
|
||||
x = 10
|
||||
y = 10
|
||||
w = "{_GUI_ESTIMATE_TEXT_WIDTH}"
|
||||
h = "(height - 20)"
|
||||
fill_color = "0, 0, 0, 128"
|
||||
[/rectangle]
|
||||
|
||||
[text]
|
||||
x = 20
|
||||
x = "{_GUI_CENTER_STORY_TEXT}"
|
||||
y = {GUI__TEXT_VERTICALLY_CENTRED}
|
||||
w = "(width)"
|
||||
h = "(text_height)"
|
||||
|
@ -88,3 +99,6 @@
|
|||
[/resolution]
|
||||
|
||||
[/label_definition]
|
||||
|
||||
#undef _GUI_ESTIMATE_TEXT_WIDTH
|
||||
#undef _GUI_CENTER_STORY_TEXT
|
||||
|
|
Loading…
Add table
Reference in a new issue