Author: mordante
Date: Thu Aug 21 19:56:33 2008
New Revision: 28828
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28828&view=rev
Log:
Cleaned up the macros and used more macros for the button.
Also add a definition for tiny gui in the button, other widgets will follow.
Modified:
trunk/data/gui/default/macros.cfg
trunk/data/gui/default/widget/button_default.cfg
Modified: trunk/data/gui/default/macros.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/macros.cfg?rev=28828&r1=28827&r2=28828&view=diff
==============================================================================
--- trunk/data/gui/default/macros.cfg (original)
+++ trunk/data/gui/default/macros.cfg Thu Aug 21 19:56:33 2008
@@ -1,7 +1,136 @@
-###
-### Contains the macros for the new widget library, not sorted yet.
-###
-
+#
+# Contains the macros for the default widgets.
+# - Global GUI macros get the GUI prefix.
+# - Local (pre file) GUI macros get the _GUI prefix and should be undefined at
+# the end of the file.
+#
+#
+# For now only TINY and NORMAL gui will be defined, once this works SMALL gui
+# will be added, need to see which parts need to change for that. Later there
+# will also be definitions for larger screens, mainly for using the extra width
+# better.
+
+
+###############################################################################
+### ###
+### Generic macros usable for all resolutions. ###
+### ###
+###############################################################################
+
+# Centers the text horizontally.
+#
+# If the text is too wide it returns the left side.
+# Rounding happens to the left side.
+#define GUI__TEXT_HORIZONTALLY_CENTRED
+ "(if(text_width < width, (width - text_width ) / 2, 0))"
+#enddef
+
+# Centers the text vertically.
+#
+# If the text is too high it returns the top side.
+# Rounding happens to the bottom side.
+#
+# NOTE the extra bug in the formula system.
+#define GUI__TEXT_VERTICALALLY_CENTRED
+ "(if(text_height < height, ((height - text_height) + 1) / 2, 0))"
+#enddef
+
+#define GUI__CENTERED_TEXT FONT_SIZE FONT_STYLE FONT_COLOUR
+ [text]
+ x = {GUI__TEXT_HORIZONTALLY_CENTRED}
+ y = {GUI__TEXT_VERTICALALLY_CENTRED}
+ w = "(text_width)"
+ h = "(text_height)"
+ font_size = {FONT_SIZE}
+ font_style = {FONT_STYLE}
+ colour = {FONT_COLOUR}
+ text = "(text)"
+ [/text]
+#enddef
+
+# This white colour is used for most texts.
+#define GUI__FONT_COLOUR_ENABLED__DEFAULT
+ "221, 221, 221, 255"
+#enddef
+
+# This gray colour is used for most text when the widget is disabled.
+#define GUI__FONT_COLOUR_DISABLED__DEFAULT
+ "128, 128, 128, 0"
+#enddef
+
+# This gold colour is used for the
+# - title labels
+# - button captions
+# - checkbox captions
+# - menu captions
+#define GUI__FONT_COLOUR_ENABLED__TITLE
+ "188, 176, 136, 255"
+#enddef
+
+# This now uses the default disabled colour but should be tiny bit lighter.
+#define GUI__FONT_COLOUR_DISABLED__TITLE
+ {GUI__FONT_COLOUR_DISABLED__DEFAULT}
+#enddef
+
+###############################################################################
+### ###
+### Macros for the tiny gui. ###
+### ###
+###############################################################################
+
+#define GUI_TINY__RESOLUTION
+ window_width = 640
+ window_height = 480
+#enddef
+
+#define GUI_TINY__FONT_SIZE__SMALL
+ 9
+#enddef
+
+#define GUI_TINY__FONT_SIZE__DEFAULT
+ 10
+#enddef
+
+#define GUI_TINY__FONT_SIZE__LARGE
+ 11
+#enddef
+
+#define GUI_TINY__FONT_SIZE__TITLE
+ 11
+#enddef
+
+###############################################################################
+### ###
+### Macros for the normal gui. ###
+### ###
+###############################################################################
+
+#define GUI_NORMAL__RESOLUTION
+ window_width = 0
+ window_height = 0
+#enddef
+
+#define GUI_NORMAL__FONT_SIZE__SMALL
+ 12
+#enddef
+
+#define GUI_NORMAL__FONT_SIZE__DEFAULT
+ 13
+#enddef
+
+#define GUI_NORMAL__FONT_SIZE__LARGE
+ 18
+#enddef
+
+#define GUI_NORMAL__FONT_SIZE__TITLE
+ 18
+#enddef
+
+###############################################################################
+### ###
+### Old test code should be deleted when no longer needed. ###
+### ###
+###############################################################################
#
#
Modified: trunk/data/gui/default/widget/button_default.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/widget/button_default.cfg?rev=28828&r1=28827&r2=28828&view=diff
==============================================================================
--- trunk/data/gui/default/widget/button_default.cfg (original)
+++ trunk/data/gui/default/widget/button_default.cfg Thu Aug 21 19:56:33 2008
@@ -2,25 +2,23 @@
### Definition of the default button.
###
-[button_definition]
-
- id = "default"
- description = "Default button"
-
+#define _GUI_RESOLUTION RESOLUTION MIN_WIDTH DEFAULT_WIDTH HEIGHT EXTRA_WIDTH
EXTRA_HEIGHT FONT_SIZE
[resolution]
- min_width = 40
- min_height = 22
+ {RESOLUTION}
- default_width = 108
- default_height = 22
+ min_width = {MIN_WIDTH}
+ min_height = {HEIGHT}
+
+ default_width = {DEFAULT_WIDTH}
+ default_height = {HEIGHT}
max_width = 0
- max_height = 22
+ max_height = {HEIGHT}
- text_extra_width = 13
- text_extra_height = 4
- text_font_size = {FONT_SIZE_NORMAL__NORMAL}
+ text_extra_width = {EXTRA_WIDTH}
+ text_extra_height = {EXTRA_HEIGHT}
+ text_font_size = {FONT_SIZE}
[state_enabled]
@@ -32,7 +30,7 @@
name = "buttons/button.png"
[/image]
- {TEXT_DEFAULT_NORMAL}
+ {GUI__CENTERED_TEXT ({FONT_SIZE}) ()
({GUI__FONT_COLOUR_ENABLED__TITLE})}
[/draw]
@@ -48,6 +46,8 @@
name = "buttons/button-disabled.png"
[/image]
+ {GUI__CENTERED_TEXT ({FONT_SIZE}) ()
({GUI__FONT_COLOUR_DISABLED__TITLE})}
+
[/draw]
[/state_disabled]
@@ -62,7 +62,7 @@
name = "buttons/button-pressed.png"
[/image]
- {TEXT_DEFAULT_NORMAL}
+ {GUI__CENTERED_TEXT ({FONT_SIZE}) ()
({GUI__FONT_COLOUR_ENABLED__TITLE})}
[/draw]
@@ -78,12 +78,24 @@
name = "buttons/button-active.png"
[/image]
- {TEXT_DEFAULT_NORMAL}
+ {GUI__CENTERED_TEXT ({FONT_SIZE}) ()
({GUI__FONT_COLOUR_ENABLED__TITLE})}
[/draw]
[/state_focussed]
[/resolution]
+#enddef
+
+[button_definition]
+
+ id = "default"
+ description = "Default button"
+
+ # Tiny gui sizes haven't been tested yet so might need some tuning.
+ {_GUI_RESOLUTION ({GUI_TINY__RESOLUTION}) 20 54 11 6 2
({GUI_TINY__FONT_SIZE__DEFAULT}) }
+ {_GUI_RESOLUTION () 40 108 22 13 4
({GUI_NORMAL__FONT_SIZE__DEFAULT}) }
[/button_definition]
+
+#undef _GUI_RESOLUTION
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits