-
-
Notifications
You must be signed in to change notification settings - Fork 991
/
tooltip_large.cfg
238 lines (191 loc) · 4.01 KB
/
tooltip_large.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#textdomain wesnoth-lib
###
### Definition of the window used to show large tooltips.
### The placement algorithms used are described in the
### »Tooltip placement« section in the GUI2 design document.
###
### gui/dialogs/title_screen.cpp has test code, which is
### activated by defining the DEBUG_TOOLTIP macro.
###
[window]
id = "tooltip_large"
description = "The tooltip popup window with large tooltips, eg in the main menu."
[resolution]
definition = "tooltip_large"
automatic_placement = "true"
vertical_placement = "bottom"
horizontal_placement = "center"
# TODO tooltips in this window make little sense.
# Have to think of a nice solution.
[tooltip]
id = "tooltip_large"
[/tooltip]
[helptip]
id = "tooltip_large"
[/helptip]
[grid]
[row]
[column]
[label]
id = "label"
definition = "default_large"
wrap = "true"
[/label]
[/column]
[/row]
[/grid]
[/resolution]
[/window]
#define __GUI_WINDOW_HEIGHT
(
if(window_height = 0
# Determine the wanted maximum height. #
# The value should be high enough to avoid an #
# unable to place exception. #
, 100000
# Determine the height to use. #
, window_height)
)#enddef
#define __GUI_WINDOW_FUNCTIONS
def placement_method(m, w, s)
(
if((w.y > s.y) or ((w.x * 2) > s.x)
, 'V'
, if(m.y >= w.y
, if(m.x >= w.x, 'I', 'III')
, if(m.x >= w.x, 'II', 'IV')
)
)
);
def set_x(m, w, s)
(
[
switch(
placement_method(m, w, s)
, 'I' , m.x - (w.x / 2)
, 'II' , m.x - w.x
, 'III' , 5
# extra offset to avoid being obscured by the mouse. #
, 'IV' , m.x + 15
, 'V' , 5
, #default# m.x
),
#
debug_print('placement_method, mouse ', m),
debug_print('window ', w),
debug_print('screen ', s),
debug_print('y margin', s.y - (m.y + w.y)),
debug_print('result ', placement_method(m, w, s)),
#
][0]
);
def set_y(m, w, s)
(
switch(
placement_method(m, w, s)
, 'I' , m.y - (w.y + 15)
, 'II' , 5
, 'III' , m.y - w.y
, 'IV' , 5
, 'V' , 5
, #default# m.y - w.y
)
);
def get_maximum_width(w, s)
(
if(w.x = 0
# The default width upon the initial run. #
, 400
, if(w.y <= s.y
# If the window's height fits use that. #
, w.x
# Else use an increased width, which should reduce #
# the required height. #
, 2 * w.x))
);
def set_w(r, w, s)
(
switch(
r
, 'maximum', get_maximum_width(w, s)
, 'size', w.x
)
);
def reevaluate_best_size(w, s)
(
[
w.y > s.y,
#
debug_print('window ', w),
debug_print('screen ', s)
#
][0]
);
#enddef
#define __GUI_WINDOW_X
(
set_x(
loc(mouse_x, mouse_y)
, loc(window_width, window_height)
, loc(screen_width, screen_height))
)
#enddef
#define __GUI_WINDOW_Y
(
set_y(
loc(mouse_x, mouse_y)
, loc(window_width, window_height)
, loc(screen_width, screen_height))
)#enddef
#define __GUI_WINDOW_WIDTH
(
set_w(
size_request_mode
, loc(window_width, window_height)
, loc(screen_width, screen_height))
)#enddef
#define __GUI_WINDOW_REEVALUATE_BEST_SIZE
(
reevaluate_best_size(
loc(window_width, window_height)
, loc(screen_width, screen_height))
)#enddef
[window]
id = "tooltip"
description = "The tooltip popup window with large tooltips, eg in the main menu."
[resolution]
definition = "tooltip"
automatic_placement = "false"
functions = "{__GUI_WINDOW_FUNCTIONS}"
x = "{__GUI_WINDOW_X}"
y = "{__GUI_WINDOW_Y}"
width = "{__GUI_WINDOW_WIDTH}"
height = "{__GUI_WINDOW_HEIGHT}"
reevaluate_best_size = "{__GUI_WINDOW_REEVALUATE_BEST_SIZE}"
# TODO tooltips in this window make little sense.
# Have to think of a nice solution.
[tooltip]
id = "tooltip"
[/tooltip]
[helptip]
id = "tooltip"
[/helptip]
[grid]
[row]
[column]
[label]
id = "label"
definition = "default_small"
wrap = "true"
[/label]
[/column]
[/row]
[/grid]
[/resolution]
[/window]
#undef __GUI_WINDOW_REEVALUATE_BEST_SIZE
#undef __GUI_WINDOW_HEIGHT
#undef __GUI_WINDOW_WIDTH
#undef __GUI_WINDOW_Y
#undef __GUI_WINDOW_X
#undef __GUI_WINDOW_FUNCTIONS