wesnoth/data/gui/themes/default/dialogs/tooltip_floating.cfg
Subhraman Sarkar 6b8c2e15e7 theme update for modern and rename themes
include new definitions and updated versions of existing definitions
"default/classic" and "modern" has been renamed to "Parchment" and "Celes" to avoid confusion
2025-01-09 09:02:42 +05:30

250 lines
4.3 KiB
INI

#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.
###
#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 > s.x)
, 'TooBig'
, if(m.y + 25 + w.y >= s.y
, 'Above'
, 'Below'
)
)
);
def set_x(m, w, s)
(
[
if(preferred_x + w.x > s.x
, s.x - w.x
, preferred_x)
where
preferred_x = switch(
placement_method(m, w, s)
# extra offset to avoid being obscured by the mouse. #
, 'Above' , m.x + 20
, 'Below' , m.x + 20
, 'TooBig' , 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)
(
if(preferred_y < 0
, s.y - w.y
, preferred_y)
where
preferred_y = switch(
placement_method(m, w, s)
, 'Above' , m.y - (w.y + 15)
, 'Below' , m.y + 25
, 'TooBig' , 5
, #default# m.y - w.y
)
);
def get_maximum_width(w, s)
(
if(w.x = 0
# The default width upon the initial run. #
, 450
, 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 floating tooltips."
[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"
use_markup = true
wrap = true
[/label]
[/column]
[/row]
[/grid]
[/resolution]
[/window]
[window]
id = "tooltip_transparent"
description = "The tooltip popup window with floating tooltips, and transparent background."
[resolution]
definition = "tooltip_transparent"
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_transparent"
[/tooltip]
[helptip]
id = "tooltip_transparent"
[/helptip]
[grid]
[row]
[column]
[label]
id = "label"
definition = "default_small"
use_markup = true
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