gui2: Refactor widget frame code used for buttons and comboboxes
This commit is contained in:
parent
00fbce5872
commit
847b70ab4c
4 changed files with 85 additions and 183 deletions
49
data/gui/macros/button.cfg
Normal file
49
data/gui/macros/button.cfg
Normal file
|
@ -0,0 +1,49 @@
|
|||
#textdomain wesnoth-lib
|
||||
|
||||
# Push button canvas macros
|
||||
|
||||
#define GUI__BUTTON_NORMAL_FRAME BACKGROUND_IMAGE_PATH BORDER_COLOR BORDER_COLOR_DARK HIGHLIGHT_LINE_COLOR IPF
|
||||
[image]
|
||||
x = 2
|
||||
y = 2
|
||||
w = "(width - 2)"
|
||||
h = "(height - 2)"
|
||||
name = "{BACKGROUND_IMAGE_PATH}.png{IPF}"
|
||||
[/image]
|
||||
|
||||
#
|
||||
# Dark background borders
|
||||
#
|
||||
|
||||
{GUI_LINE 0 1 0 "(height - 2)" "1, 10, 16, 255"}
|
||||
{GUI_LINE 2 1 "(width - 2)" 1 "1, 10, 16, 255"}
|
||||
{GUI_LINE 1 "(height - 1)" "(width - 2)" "(height - 1)" "1, 10, 16, 255"}
|
||||
{GUI_LINE "(width - 2)" 1 "(width - 2)" "(height - 1)" "1, 10, 16, 255"}
|
||||
|
||||
#
|
||||
# Gold colored borders
|
||||
#
|
||||
|
||||
{GUI_LINE 2 0 "(width - 2)" 0 {BORDER_COLOR}}
|
||||
{GUI_LINE "(width - 1)" 1 "(width - 1)" "(height - 3)" {BORDER_COLOR}}
|
||||
|
||||
{GUI_LINE 1 1 1 "(height - 3)" {BORDER_COLOR_DARK}}
|
||||
{GUI_LINE 2 "(height - 2)" "(width - 2)" "(height - 2)" {BORDER_COLOR_DARK}}
|
||||
|
||||
#
|
||||
# Blue tint lines on the top and right
|
||||
#
|
||||
|
||||
{GUI_LINE 3 2 "(width - 3)" 2 {HIGHLIGHT_LINE_COLOR}}
|
||||
{GUI_LINE "(width - 3)" 2 "(width - 3)" "(height - 4)" {HIGHLIGHT_LINE_COLOR}}
|
||||
|
||||
#
|
||||
# Round the corners
|
||||
#
|
||||
|
||||
{GUI_POINT 2 1 {BORDER_COLOR_DARK}}
|
||||
{GUI_POINT 2 "(height - 3)" {BORDER_COLOR_DARK}}
|
||||
|
||||
{GUI_POINT "(width - 2)" 1 {BORDER_COLOR}}
|
||||
{GUI_POINT "(width - 2)" "(height - 3)" {BORDER_COLOR}}
|
||||
#enddef
|
|
@ -22,53 +22,12 @@
|
|||
#enddef
|
||||
|
||||
#define _GUI_STATE BACKGROUND_IMAGE BORDER_COLOR BORDER_COLOR_DARK HIGHLIGHT_LINE_COLOR IPF
|
||||
#
|
||||
# Background
|
||||
#
|
||||
|
||||
[image]
|
||||
x = 2
|
||||
y = 2
|
||||
w = "(width)"
|
||||
h = "(height)"
|
||||
name = "buttons/button_normal/{BACKGROUND_IMAGE}.png{IPF}"
|
||||
[/image]
|
||||
|
||||
#
|
||||
# Dark background borders
|
||||
#
|
||||
|
||||
{GUI_LINE 0 1 0 "(height - 2)" "1, 10, 16, 255"}
|
||||
{GUI_LINE 2 1 "(width - 2)" 1 "1, 10, 16, 255"}
|
||||
{GUI_LINE 1 "(height - 1)" "(width - 2)" "(height - 1)" "1, 10, 16, 255"}
|
||||
{GUI_LINE "(width - 2)" 1 "(width - 2)" "(height - 1)" "1, 10, 16, 255"}
|
||||
|
||||
#
|
||||
# Gold colored borders
|
||||
#
|
||||
|
||||
{GUI_LINE 2 0 "(width - 2)" 0 {BORDER_COLOR}}
|
||||
{GUI_LINE "(width - 1)" 1 "(width - 1)" "(height - 3)" {BORDER_COLOR}}
|
||||
|
||||
{GUI_LINE 1 1 1 "(height - 3)" {BORDER_COLOR_DARK}}
|
||||
{GUI_LINE 2 "(height - 2)" "(width - 2)" "(height - 2)" {BORDER_COLOR_DARK}}
|
||||
|
||||
#
|
||||
# Blue tint lines on the top and right
|
||||
#
|
||||
|
||||
{GUI_LINE 3 2 "(width - 3)" 2 {HIGHLIGHT_LINE_COLOR}}
|
||||
{GUI_LINE "(width - 3)" 2 "(width - 3)" "(height - 4)" {HIGHLIGHT_LINE_COLOR}}
|
||||
|
||||
#
|
||||
# Round the corners
|
||||
#
|
||||
|
||||
{GUI_POINT 2 1 {BORDER_COLOR_DARK}}
|
||||
{GUI_POINT 2 "(height - 3)" {BORDER_COLOR_DARK}}
|
||||
|
||||
{GUI_POINT "(width - 2)" 1 {BORDER_COLOR}}
|
||||
{GUI_POINT "(width - 2)" "(height - 3)" {BORDER_COLOR}}
|
||||
{GUI__BUTTON_NORMAL_FRAME buttons/button_normal/{BACKGROUND_IMAGE}
|
||||
({BORDER_COLOR})
|
||||
({BORDER_COLOR_DARK})
|
||||
({HIGHLIGHT_LINE_COLOR})
|
||||
({IPF})
|
||||
}
|
||||
#enddef
|
||||
|
||||
#define _GUI_RESOLUTION RESOLUTION MIN_WIDTH DEFAULT_WIDTH HEIGHT EXTRA_WIDTH EXTRA_HEIGHT FONT_SIZE IPF ALPHA
|
||||
|
@ -313,6 +272,7 @@
|
|||
|
||||
[/button_definition]
|
||||
|
||||
#undef _GUI_BUTTON_FONT_SIZE
|
||||
#undef _GUI_BUTTON_TEXT
|
||||
#undef _GUI_STATE
|
||||
#undef _GUI_RESOLUTION
|
||||
|
|
|
@ -3,44 +3,6 @@
|
|||
### Definition of the default button.
|
||||
###
|
||||
|
||||
#define _GUI_DRAW_BORDER BORDER_COLOR BORDER_COLOR_DARK HIGHLIGHT_LINE_COLOR IPF
|
||||
#
|
||||
# Dark background borders
|
||||
#
|
||||
|
||||
{GUI_LINE 0 1 0 "(height - 2)" "1, 10, 16, 255"}
|
||||
{GUI_LINE 2 1 "(width - 2)" 1 "1, 10, 16, 255"}
|
||||
{GUI_LINE 1 "(height - 1)" "(width - 2)" "(height - 1)" "1, 10, 16, 255"}
|
||||
{GUI_LINE "(width - 2)" 1 "(width - 2)" "(height - 1)" "1, 10, 16, 255"}
|
||||
|
||||
#
|
||||
# Gold colored borders
|
||||
#
|
||||
|
||||
{GUI_LINE 2 0 "(width - 2)" 0 {BORDER_COLOR}}
|
||||
{GUI_LINE "(width - 1)" 1 "(width - 1)" "(height - 3)" {BORDER_COLOR}}
|
||||
|
||||
{GUI_LINE 1 1 1 "(height - 3)" {BORDER_COLOR_DARK}}
|
||||
{GUI_LINE 2 "(height - 2)" "(width - 2)" "(height - 2)" {BORDER_COLOR_DARK}}
|
||||
|
||||
#
|
||||
# Blue tint lines on the top and right
|
||||
#
|
||||
|
||||
{GUI_LINE 3 2 "(width - 3)" 2 {HIGHLIGHT_LINE_COLOR}}
|
||||
{GUI_LINE "(width - 3)" 2 "(width - 3)" "(height - 4)" {HIGHLIGHT_LINE_COLOR}}
|
||||
|
||||
#
|
||||
# Round the corners
|
||||
#
|
||||
|
||||
{GUI_POINT 2 1 {BORDER_COLOR_DARK}}
|
||||
{GUI_POINT 2 "(height - 3)" {BORDER_COLOR_DARK}}
|
||||
|
||||
{GUI_POINT "(width - 2)" 1 {BORDER_COLOR}}
|
||||
{GUI_POINT "(width - 2)" "(height - 3)" {BORDER_COLOR}}
|
||||
#enddef
|
||||
|
||||
#define _GUI_TEXT FONT_SIZE FONT_COLOR
|
||||
[text]
|
||||
x = 8 # 3px border + 5px padding inside
|
||||
|
@ -55,6 +17,15 @@
|
|||
[/text]
|
||||
#enddef
|
||||
|
||||
#define _GUI_BUTTON_FRAME BACKGROUND_IMAGE BORDER_COLOR BORDER_COLOR_DARK HIGHLIGHT_LINE_COLOR IPF
|
||||
{GUI__BUTTON_NORMAL_FRAME buttons/button_dropdown/button_dropdown{BACKGROUND_IMAGE}
|
||||
({BORDER_COLOR})
|
||||
({BORDER_COLOR_DARK})
|
||||
({HIGHLIGHT_LINE_COLOR})
|
||||
({IPF})
|
||||
}
|
||||
#enddef
|
||||
|
||||
#define _GUI_RESOLUTION RESOLUTION MIN_WIDTH DEFAULT_WIDTH HEIGHT EXTRA_WIDTH EXTRA_HEIGHT FONT_SIZE BASE_NAME IPF
|
||||
[resolution]
|
||||
|
||||
|
@ -77,13 +48,7 @@
|
|||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
w = "(width)"
|
||||
h = "(height)"
|
||||
name = "buttons/{BASE_NAME}.png{IPF}"
|
||||
[/image]
|
||||
|
||||
{_GUI_DRAW_BORDER ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("21, 79, 109, 255") {IPF}}
|
||||
{_GUI_BUTTON_FRAME () ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("21, 79, 109, 255") {IPF}}
|
||||
|
||||
{_GUI_TEXT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__TITLE})}
|
||||
|
||||
|
@ -100,13 +65,7 @@
|
|||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
w = "(width)"
|
||||
h = "(height)"
|
||||
name = "buttons/{BASE_NAME}.png~GS(){IPF}"
|
||||
[/image]
|
||||
|
||||
{_GUI_DRAW_BORDER ({GUI__FONT_COLOR_DISABLED__DEFAULT}) ("89, 89, 89, 255") ("60, 60, 60, 255") "~GS(){IPF}"}
|
||||
{_GUI_BUTTON_FRAME () ({GUI__FONT_COLOR_DISABLED__DEFAULT}) ("89, 89, 89, 255") ("60, 60, 60, 255") "~GS(){IPF}"}
|
||||
|
||||
{_GUI_TEXT ({FONT_SIZE}) ({GUI__FONT_COLOR_DISABLED__TITLE})}
|
||||
|
||||
|
@ -123,13 +82,7 @@
|
|||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
w = "(width)"
|
||||
h = "(height)"
|
||||
name = "buttons/{BASE_NAME}.png{IPF}"
|
||||
[/image]
|
||||
|
||||
{_GUI_DRAW_BORDER ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("1, 10, 16, 255") {IPF}}
|
||||
{_GUI_BUTTON_FRAME () ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("1, 10, 16, 255") {IPF}}
|
||||
|
||||
{_GUI_TEXT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__TITLE})}
|
||||
|
||||
|
@ -146,14 +99,8 @@
|
|||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
w = "(width)"
|
||||
h = "(height)"
|
||||
# Doesn't have its own 'active' variation image
|
||||
name = "buttons/{BASE_NAME}-pressed.png{IPF}"
|
||||
[/image]
|
||||
|
||||
{_GUI_DRAW_BORDER ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("12, 108, 157, 255") {IPF}}
|
||||
# Doesn't have its own 'active' variation image
|
||||
{_GUI_BUTTON_FRAME -pressed ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("12, 108, 157, 255") {IPF}}
|
||||
|
||||
{_GUI_TEXT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__TITLE})}
|
||||
|
||||
|
@ -180,6 +127,6 @@
|
|||
|
||||
[/menu_button_definition]
|
||||
|
||||
#undef _GUI_BUTTON_FRAME
|
||||
#undef _GUI_RESOLUTION
|
||||
#undef _GUI_DRAW_BORDER
|
||||
#undef _GUI_TEXT
|
||||
|
|
|
@ -3,44 +3,6 @@
|
|||
### Definition of the default button.
|
||||
###
|
||||
|
||||
#define _GUI_DRAW_BORDER BORDER_COLOR BORDER_COLOR_DARK HIGHLIGHT_LINE_COLOR IPF
|
||||
#
|
||||
# Dark background borders
|
||||
#
|
||||
|
||||
{GUI_LINE 0 1 0 "(height - 2)" "1, 10, 16, 255"}
|
||||
{GUI_LINE 2 1 "(width - 2)" 1 "1, 10, 16, 255"}
|
||||
{GUI_LINE 1 "(height - 1)" "(width - 2)" "(height - 1)" "1, 10, 16, 255"}
|
||||
{GUI_LINE "(width - 2)" 1 "(width - 2)" "(height - 1)" "1, 10, 16, 255"}
|
||||
|
||||
#
|
||||
# Gold colored borders
|
||||
#
|
||||
|
||||
{GUI_LINE 2 0 "(width - 2)" 0 {BORDER_COLOR}}
|
||||
{GUI_LINE "(width - 1)" 1 "(width - 1)" "(height - 3)" {BORDER_COLOR}}
|
||||
|
||||
{GUI_LINE 1 1 1 "(height - 3)" {BORDER_COLOR_DARK}}
|
||||
{GUI_LINE 2 "(height - 2)" "(width - 2)" "(height - 2)" {BORDER_COLOR_DARK}}
|
||||
|
||||
#
|
||||
# Blue tint lines on the top and right
|
||||
#
|
||||
|
||||
{GUI_LINE 3 2 "(width - 3)" 2 {HIGHLIGHT_LINE_COLOR}}
|
||||
{GUI_LINE "(width - 3)" 2 "(width - 3)" "(height - 4)" {HIGHLIGHT_LINE_COLOR}}
|
||||
|
||||
#
|
||||
# Round the corners
|
||||
#
|
||||
|
||||
{GUI_POINT 2 1 {BORDER_COLOR_DARK}}
|
||||
{GUI_POINT 2 "(height - 3)" {BORDER_COLOR_DARK}}
|
||||
|
||||
{GUI_POINT "(width - 2)" 1 {BORDER_COLOR}}
|
||||
{GUI_POINT "(width - 2)" "(height - 3)" {BORDER_COLOR}}
|
||||
#enddef
|
||||
|
||||
#define _GUI_TEXT FONT_SIZE FONT_COLOR
|
||||
[text]
|
||||
x = 8 # 3px border + 5px padding inside
|
||||
|
@ -55,6 +17,15 @@
|
|||
[/text]
|
||||
#enddef
|
||||
|
||||
#define _GUI_BUTTON_FRAME BACKGROUND_IMAGE BORDER_COLOR BORDER_COLOR_DARK HIGHLIGHT_LINE_COLOR IPF
|
||||
{GUI__BUTTON_NORMAL_FRAME buttons/button_dropdown/button_dropdown{BACKGROUND_IMAGE}
|
||||
({BORDER_COLOR})
|
||||
({BORDER_COLOR_DARK})
|
||||
({HIGHLIGHT_LINE_COLOR})
|
||||
({IPF})
|
||||
}
|
||||
#enddef
|
||||
|
||||
#define _GUI_RESOLUTION RESOLUTION MIN_WIDTH DEFAULT_WIDTH HEIGHT EXTRA_WIDTH EXTRA_HEIGHT FONT_SIZE BASE_NAME IPF
|
||||
[resolution]
|
||||
|
||||
|
@ -77,13 +48,7 @@
|
|||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
w = "(width)"
|
||||
h = "(height)"
|
||||
name = "buttons/{BASE_NAME}.png{IPF}"
|
||||
[/image]
|
||||
|
||||
{_GUI_DRAW_BORDER ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("21, 79, 109, 255") {IPF}}
|
||||
{_GUI_BUTTON_FRAME () ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("21, 79, 109, 255") {IPF}}
|
||||
|
||||
{_GUI_TEXT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__TITLE})}
|
||||
|
||||
|
@ -100,13 +65,7 @@
|
|||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
w = "(width)"
|
||||
h = "(height)"
|
||||
name = "buttons/{BASE_NAME}.png~GS(){IPF}"
|
||||
[/image]
|
||||
|
||||
{_GUI_DRAW_BORDER ({GUI__FONT_COLOR_DISABLED__DEFAULT}) ("89, 89, 89, 255") ("60, 60, 60, 255") "~GS(){IPF}"}
|
||||
{_GUI_BUTTON_FRAME () ({GUI__FONT_COLOR_DISABLED__DEFAULT}) ("89, 89, 89, 255") ("60, 60, 60, 255") "~GS(){IPF}"}
|
||||
|
||||
{_GUI_TEXT ({FONT_SIZE}) ({GUI__FONT_COLOR_DISABLED__TITLE})}
|
||||
|
||||
|
@ -123,13 +82,7 @@
|
|||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
w = "(width)"
|
||||
h = "(height)"
|
||||
name = "buttons/{BASE_NAME}.png{IPF}"
|
||||
[/image]
|
||||
|
||||
{_GUI_DRAW_BORDER ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("1, 10, 16, 255") {IPF}}
|
||||
{_GUI_BUTTON_FRAME () ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("1, 10, 16, 255") {IPF}}
|
||||
|
||||
{_GUI_TEXT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__TITLE})}
|
||||
|
||||
|
@ -146,14 +99,8 @@
|
|||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
w = "(width)"
|
||||
h = "(height)"
|
||||
# Doesn't have its own 'active' variation image
|
||||
name = "buttons/{BASE_NAME}-pressed.png{IPF}"
|
||||
[/image]
|
||||
|
||||
{_GUI_DRAW_BORDER ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("12, 108, 157, 255") {IPF}}
|
||||
# Doesn't have its own 'active' variation image
|
||||
{_GUI_BUTTON_FRAME -pressed ({GUI__BORDER_COLOR}) ({GUI__BORDER_COLOR_DARK}) ("12, 108, 157, 255") {IPF}}
|
||||
|
||||
{_GUI_TEXT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__TITLE})}
|
||||
|
||||
|
@ -181,5 +128,4 @@
|
|||
[/multimenu_button_definition]
|
||||
|
||||
#undef _GUI_RESOLUTION
|
||||
#undef _GUI_DRAW_BORDER
|
||||
#undef _GUI_TEXT
|
||||
|
|
Loading…
Add table
Reference in a new issue