mail[Wesnoth-commits] r28873 - /trunk/data/gui/default/widget/text_box_default.cfg


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by koraq on August 23, 2008 - 15:59:
Author: mordante
Date: Sat Aug 23 15:44:19 2008
New Revision: 28873

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28873&view=rev
Log:
Textbox widget definition refactoring.

Cleanedup the widget to use the new macros and also added the (not so
well) tested code for tiny gui.

Modified:
    trunk/data/gui/default/widget/text_box_default.cfg

Modified: trunk/data/gui/default/widget/text_box_default.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/widget/text_box_default.cfg?rev=28873&r1=28872&r2=28873&view=diff
==============================================================================
--- trunk/data/gui/default/widget/text_box_default.cfg (original)
+++ trunk/data/gui/default/widget/text_box_default.cfg Sat Aug 23 15:44:19 
2008
@@ -2,22 +2,80 @@
 ### Definition of a single line text box.
 ###
 
-[text_box_definition]
-       id = "default"
-       description = "Default text box"
+#define _GUI_DRAW_BORDER COLOUR
+       [rectangle]
+               x = 0
+               y = 0
+               w = "(width)"
+               h = "(height)"
 
+               border_thickness = 3
+               border_colour = "55, 55, 55, 192"
+
+       [ /rectangle]
+
+       [rectangle]
+               x = 1
+               y = 1
+               w = "(width - 2)"
+               h = "(height - 2)"
+
+               border_thickness = 1
+               border_colour = {COLOUR}
+
+       [/rectangle]
+#enddef
+
+#define _GUI_DRAW_TEXT SIZE COLOUR
+       [rectangle]
+               x = "(text_x_offset + selection_offset)"
+               y = "(text_y_offset)"
+               w = "(selection_width)"
+               h = "(text_font_height)"
+
+               border_thickness = 0
+               fill_colour = "21, 53, 80, 255"
+
+       [/rectangle]
+
+       [text]
+               x = "(text_x_offset)"
+               y = "(text_y_offset)"
+               w = "(text_width)"
+               h = "(text_height)"
+               font_size = {SIZE}
+               colour = {COLOUR}
+               text = "(text)"
+       [/text]
+#enddef
+
+#define _GUI_DRAW_CURSOR X_OFFSET
+       [line]
+               x1 = "(cursor_offset + " + {X_OFFSET} + ")"
+               y1 = "(text_y_offset)"
+               x2 = "(cursor_offset + " + {X_OFFSET} + ")"
+               y2 = "(text_y_offset + text_font_height)"
+               colour = "255, 255, 255, 255"
+               thickness = 1
+       [/line]
+#enddef
+
+#define _GUI_RESOLUTION RESOLUTION MIN_WIDTH DEFAULT_WIDTH HEIGHT X_OFFSET 
FONT_SIZE 
        [resolution]
-               min_width = 40
-               min_height = 22
 
-               default_width = 250
-               default_height = 22
+               {RESOLUTION}
+
+               min_width = {MIN_WIDTH}
+               min_height = {HEIGHT}
+
+               default_width = {DEFAULT_WIDTH}
+               default_height = {HEIGHT}
 
                max_width = 0
-               max_height = 22
+               max_height = {HEIGHT}
 
-               text_font_size = {FONT_SIZE_NORMAL__NORMAL}
-               text_x_offset = 5
+               text_font_size = {FONT_SIZE}
+               text_x_offset = {X_OFFSET}
                text_y_offset = "(if(text_font_height <= height, (height - 
text_font_height) / 2, 0))"
 
                [state_enabled]
@@ -26,48 +84,11 @@
 
                        [draw]
 
-                               [rectangle]
-                                       x = 0
-                                       y = 0
-                                       w = "(width)"
-                                       h = "(height)"
+                               {_GUI_DRAW_BORDER 
({GUI__FONT_COLOUR_ENABLED__TITLE}) }
 
-                                       border_thickness = 3
-                                       border_colour = "55, 55, 55, 192"
+                               {_GUI_DRAW_TEXT ({FONT_SIZE}) 
({FONT_COLOUR_ENABLED}) }
 
-                               [/rectangle]
-
-                               # selection box
-                               [rectangle]
-                                       x = "(text_x_offset + 
selection_offset)"
-                                       y = "(text_y_offset)"
-                                       w = "(selection_width)"
-                                       h = "(text_font_height)"
-
-                                       border_thickness = 0
-                                       fill_colour = "21, 53, 80, 255"
-
-                               [/rectangle]
-
-                               [text]
-                                       x = "(text_x_offset)"
-                                       y = "(text_y_offset)"
-                                       w = "(text_width)"
-                                       h = "(text_height)"
-                                       font_size = {FONT_SIZE_NORMAL__NORMAL}
-                                       colour = {FONT_COLOUR_ENABLED}
-                                       text = "(text)"
-                               [/text]
-
-                               # cursor
-                               [line]
-                                       x1 = "(cursor_offset) + 5"
-                                       y1 = "(text_y_offset)"
-                                       x2 = "(cursor_offset) + 5"
-                                       y2 = "(text_y_offset + 
text_font_height)"
-                                       colour = "255, 255, 255, 255"
-                                       thickness = 1
-                               [/line]
+                               {_GUI_DRAW_CURSOR ({X_OFFSET}) }
 
                        [/draw]
        
@@ -79,28 +100,9 @@
 
                        [draw]
 
-                               [rectangle]
-                                       x = 0
-                                       y = 0
-                                       w = "(width)"
-                                       h = "(height)"
+                               {_GUI_DRAW_BORDER 
({GUI__FONT_COLOUR_DISABLED__TITLE}) }
 
-                                       border_thickness = 3
-                                       border_colour = "55, 55, 55, 192"
-
-                               [/rectangle]
-
-                               [text]
-                                       x = "5"
-                                       y = {TEXT_V_CENTRE}
-                                       w = "(text_width)"
-                                       h = "(text_height)"
-                                       font_size = {FONT_SIZE_NORMAL__NORMAL}
-                                       colour = {FONT_COLOUR_DISABLED}
-                                       text = "(text)"
-                               [/text]
-
-                               # no cursor when disabled.
+                               {_GUI_DRAW_TEXT ({FONT_SIZE}) 
({FONT_COLOUR_DISABLED}) }
 
                        [/draw]
        
@@ -112,41 +114,31 @@
 
                        [draw]
 
-                               [rectangle]
-                                       x = 0
-                                       y = 0
-                                       w = "(width)"
-                                       h = "(height)"
+                               {_GUI_DRAW_BORDER 
({GUI__FONT_COLOUR_ENABLED__TITLE}) }
 
-                                       border_thickness = 3
-                                       border_colour = "55, 55, 55, 192"
+                               {_GUI_DRAW_TEXT ({FONT_SIZE}) 
({FONT_COLOUR_ENABLED}) }
 
-                               [/rectangle]
-
-                               [text]
-                                       x = "5"
-                                       y = {TEXT_V_CENTRE}
-                                       w = "(text_width)"
-                                       h = "(text_height)"
-                                       font_size = {FONT_SIZE_NORMAL__NORMAL}
-                                       colour = {FONT_COLOUR_ENABLED}
-                                       text = "(text)"
-                               [/text]
-
-                               # cursor
-                               [line]
-                                       x1 = "(cursor_offset) + 5"
-                                       y1 = 2
-                                       x2 = "(cursor_offset) + 5"
-                                       y2 = "(height - 4)"
-                                       colour = "0, 0, 0, 255"
-                                       thickness = 1
-                               [/line]
+                               {_GUI_DRAW_CURSOR ({X_OFFSET}) }
 
                        [/draw]
-       
+
                [/state_focussed]
 
        [/resolution]
 
+#enddef
+
+[text_box_definition]
+       id = "default"
+       description = "Default text box"
+
+       # Tiny gui sizes haven't been tested yet so might need some tuning.
+       {_GUI_RESOLUTION ({GUI_TINY__RESOLUTION}) 20 125 15  5 
({GUI_TINY__FONT_SIZE__DEFAULT})   }
+       {_GUI_RESOLUTION ()                       40 250 25  5 
({GUI_NORMAL__FONT_SIZE__DEFAULT}) }
+
 [/text_box_definition]
+
+#undef _GUI_RESOLUTION
+#undef _GUI_DRAW_CURSOR
+#undef _GUI_DRAW_TEXT
+#undef _GUI_DRAW_BORDER COLOUR




Related Messages


Powered by MHonArc, Updated Sat Aug 23 16:22:01 2008