Author: mordante
Date: Sun Apr 27 20:09:34 2008
New Revision: 26173

URL: http://svn.gna.org/viewcvs/wesnoth?rev=26173&view=rev
Log:
Add a spacer class used to align the buttons better at the left side.

Added:
    trunk/data/gui/default/widget/spacer.cfg   (with props)
    trunk/src/gui/widgets/spacer.cpp   (with props)
    trunk/src/gui/widgets/spacer.hpp   (with props)
Modified:
    trunk/data/gui/default/window/addon.cfg
    trunk/po/wesnoth-lib/POTFILES.in
    trunk/src/Makefile.am
    trunk/src/SConscript
    trunk/src/gui/widgets/settings.cpp
    trunk/src/gui/widgets/settings.hpp
    trunk/src/gui/widgets/window_builder.cpp

Added: trunk/data/gui/default/widget/spacer.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/widget/spacer.cfg?rev=26173&view=auto
==============================================================================
--- trunk/data/gui/default/widget/spacer.cfg (added)
+++ trunk/data/gui/default/widget/spacer.cfg Sun Apr 27 20:09:34 2008
@@ -1,0 +1,14 @@
+###
+### Definition of a spacer.
+###
+
+[spacer_definition]
+       id = "default"
+       description = "a spacer"
+
+       [resolution]
+               text_font_size = 1
+       [/resolution]
+
+[/spacer_definition]
+

Propchange: trunk/data/gui/default/widget/spacer.cfg
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/data/gui/default/window/addon.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/addon.cfg?rev=26173&r1=26172&r2=26173&view=diff
==============================================================================
--- trunk/data/gui/default/window/addon.cfg (original)
+++ trunk/data/gui/default/window/addon.cfg Sun Apr 27 20:09:34 2008
@@ -124,13 +124,19 @@
                                                        scale = 0
 
                                                        [column]
-
-                                                               [label]
-                                                                       # 
Dummy; empty cells aren't allowed (yet).
-                                                                       
definition = "default"
-
-                                                                       label = 
""
-                                                               [/label]
+                                                               scale = 1
+
+                                                               [spacer]
+                                                                       
definition = "default"
+                                                               [/spacer]
+
+                                                       [/column]
+
+                                                       [column]
+
+                                                               [spacer]
+                                                                       
definition = "default"
+                                                               [/spacer]
 
                                                        [/column]
 
@@ -164,6 +170,14 @@
                                                        scale = 0
                                                        
                                                        [column]
+
+                                                               [spacer]
+                                                                       
definition = "default"
+                                                               [/spacer]
+
+                                                       [/column]
+
+                                                       [column]
                                                                border = "all"
                                                                border_size = 5
                                                                
horizontal_alignment = "right"

Modified: trunk/po/wesnoth-lib/POTFILES.in
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/po/wesnoth-lib/POTFILES.in?rev=26173&r1=26172&r2=26173&view=diff
==============================================================================
--- trunk/po/wesnoth-lib/POTFILES.in (original)
+++ trunk/po/wesnoth-lib/POTFILES.in Sun Apr 27 20:09:34 2008
@@ -14,6 +14,7 @@
 src/gui/widgets/label.cpp
 src/gui/widgets/panel.cpp
 src/gui/widgets/settings.cpp
+src/gui/widgets/spacer.cpp
 src/gui/widgets/text_box.cpp
 src/gui/widgets/text.cpp
 src/gui/widgets/tooltip.cpp

Modified: trunk/src/Makefile.am
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/Makefile.am?rev=26173&r1=26172&r2=26173&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Apr 27 20:09:34 2008
@@ -76,6 +76,7 @@
        gui/widgets/label.cpp \
        gui/widgets/panel.cpp \
        gui/widgets/settings.cpp \
+       gui/widgets/spacer.cpp \
        gui/widgets/text.cpp \
        gui/widgets/text_box.cpp \
        gui/widgets/tooltip.cpp \

Modified: trunk/src/SConscript
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=26173&r1=26172&r2=26173&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Sun Apr 27 20:09:34 2008
@@ -89,6 +89,7 @@
     gui/widgets/label.cpp
     gui/widgets/panel.cpp
     gui/widgets/settings.cpp
+    gui/widgets/spacer.cpp
     gui/widgets/text.cpp
     gui/widgets/text_box.cpp
     gui/widgets/helper.cpp

Modified: trunk/src/gui/widgets/settings.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=26173&r1=26172&r2=26173&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Sun Apr 27 20:09:34 2008
@@ -22,6 +22,7 @@
 #include "gui/widgets/button.hpp"
 #include "gui/widgets/helper.hpp"
 #include "gui/widgets/label.hpp"
+#include "gui/widgets/spacer.hpp"
 #include "gui/widgets/widget.hpp"
 #include "gui/widgets/window_builder.hpp"
 #include "log.hpp"
@@ -160,6 +161,7 @@
  * @start_table = widget_definition
  *     button_definition             A push button.
  *     label_definition              A label.
+ *     spacer_definition             A spacer.
  *     text_box_definition           A single line text box.
  *     tooltip_definition            A small tooltip with help.
  *     window_definition             A window.
@@ -195,6 +197,7 @@
        /***** Control definitions *****/
        load_definitions<tbutton_definition>("button", 
cfg.get_children("button_definition"));
        load_definitions<tlabel_definition>("label", 
cfg.get_children("label_definition"));
+       load_definitions<tspacer_definition>("spacer", 
cfg.get_children("spacer_definition"));
        load_definitions<ttext_box_definition>("text_box", 
cfg.get_children("text_box_definition"));
        load_definitions<ttooltip_definition>("tooltip", 
cfg.get_children("tooltip_definition"));
 
@@ -456,6 +459,31 @@
        state.push_back(tstate_definition(cfg.child("state_disabled")));
 }
 
+tspacer_definition::tspacer_definition(const config& cfg) :
+       tcontrol_definition(cfg)
+{
+       DBG_G_P << "Parsing spacer " << id << '\n';
+
+       load_resolutions<tresolution>(cfg.get_children("resolution"));
+}
+
+
+tspacer_definition::tresolution::tresolution(const config& cfg) :
+       tresolution_definition_(cfg)
+{
+/*WIKI
+ * @page = GUIToolkitWML
+ * @order = 1_widget_spacer
+ *
+ * == Spacer ==
+ *
+ * The definition of a normal spacer.
+ *
+ * A spacer has no states so nothing to load.
+ * 
+ */
+}
+
 ttext_box_definition::ttext_box_definition(const config& cfg) :
        tcontrol_definition(cfg)
 {

Modified: trunk/src/gui/widgets/settings.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.hpp?rev=26173&r1=26172&r2=26173&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Sun Apr 27 20:09:34 2008
@@ -123,6 +123,17 @@
        };
 };
 
+struct tspacer_definition : public tcontrol_definition
+{
+
+       tspacer_definition(const config& cfg);
+
+       struct tresolution : public tresolution_definition_
+       {
+               tresolution(const config& cfg);
+       };
+};
+
 struct ttext_box_definition : public tcontrol_definition
 {
 

Added: trunk/src/gui/widgets/spacer.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/spacer.cpp?rev=26173&view=auto
==============================================================================
--- trunk/src/gui/widgets/spacer.cpp (added)
+++ trunk/src/gui/widgets/spacer.cpp Sun Apr 27 20:09:34 2008
@@ -1,0 +1,45 @@
+/* $Id$ */
+/*
+   copyright (c) 2008 by mark de wever <[EMAIL PROTECTED]>
+   part of the battle for wesnoth project http://www.wesnoth.org/
+
+   this program is free software; you can redistribute it and/or modify
+   it under the terms of the gnu general public license version 2
+   or at your option any later version.
+   this program is distributed in the hope that it will be useful,
+   but without any warranty.
+
+   see the copying file for more details.
+*/
+
+#include "gui/widgets/spacer.hpp"
+
+#include "log.hpp"
+
+#define DBG_G LOG_STREAM_INDENT(debug, gui)
+#define LOG_G LOG_STREAM_INDENT(info, gui)
+#define WRN_G LOG_STREAM_INDENT(warn, gui)
+#define ERR_G LOG_STREAM_INDENT(err, gui)
+
+#define DBG_G_D LOG_STREAM_INDENT(debug, gui_draw)
+#define LOG_G_D LOG_STREAM_INDENT(info, gui_draw)
+#define WRN_G_D LOG_STREAM_INDENT(warn, gui_draw)
+#define ERR_G_D LOG_STREAM_INDENT(err, gui_draw)
+
+#define DBG_G_E LOG_STREAM_INDENT(debug, gui_event)
+#define LOG_G_E LOG_STREAM_INDENT(info, gui_event)
+#define WRN_G_E LOG_STREAM_INDENT(warn, gui_event)
+#define ERR_G_E LOG_STREAM_INDENT(err, gui_event)
+
+#define DBG_G_P LOG_STREAM_INDENT(debug, gui_parse)
+#define LOG_G_P LOG_STREAM_INDENT(info, gui_parse)
+#define WRN_G_P LOG_STREAM_INDENT(warn, gui_parse)
+#define ERR_G_P LOG_STREAM_INDENT(err, gui_parse)
+
+namespace gui2 {
+
+
+} // namespace gui2
+
+
+

Propchange: trunk/src/gui/widgets/spacer.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/widgets/spacer.cpp
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: trunk/src/gui/widgets/spacer.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/spacer.hpp?rev=26173&view=auto
==============================================================================
--- trunk/src/gui/widgets/spacer.hpp (added)
+++ trunk/src/gui/widgets/spacer.hpp Sun Apr 27 20:09:34 2008
@@ -1,0 +1,53 @@
+/* $Id$ */
+/*
+   copyright (c) 2008 by mark de wever <[EMAIL PROTECTED]>
+   part of the battle for wesnoth project http://www.wesnoth.org/
+
+   this program is free software; you can redistribute it and/or modify
+   it under the terms of the gnu general public license version 2
+   or at your option any later version.
+   this program is distributed in the hope that it will be useful,
+   but without any warranty.
+
+   see the copying file for more details.
+*/
+
+#ifndef __GUI_WIDGETS_SPACER_HPP_INCLUDED__
+#define __GUI_WIDGETS_SPACER_HPP_INCLUDED__
+
+#include "gui/widgets/control.hpp"
+
+#include "gui/widgets/settings.hpp"
+
+namespace gui2 {
+
+// Class for a spacer
+class tspacer : public tcontrol
+{
+public:
+       tspacer() : 
+               tcontrol(0)
+               {
+               }
+
+       //! Inherited from tcontrol.
+       // We are always active, might not be visible but always active.
+       void set_active(const bool) {}
+       bool get_active() const { return true; }
+       unsigned get_state() const { return 0; }
+
+       void draw(surface&) {}
+       
+private:
+
+       //! Inherited from tcontrol.
+       const std::string& get_control_type() const 
+               { static const std::string type = "spacer"; return type; }
+};
+
+
+} // namespace gui2
+
+#endif
+
+

Propchange: trunk/src/gui/widgets/spacer.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/widgets/spacer.hpp
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: trunk/src/gui/widgets/window_builder.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder.cpp?rev=26173&r1=26172&r2=26173&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder.cpp (original)
+++ trunk/src/gui/widgets/window_builder.cpp Sun Apr 27 20:09:34 2008
@@ -19,6 +19,7 @@
 #include "gui/widgets/button.hpp"
 #include "gui/widgets/label.hpp"
 #include "gui/widgets/settings.hpp"
+#include "gui/widgets/spacer.hpp"
 #include "gui/widgets/text_box.hpp"
 #include "gui/widgets/widget.hpp"
 #include "gui/widgets/window.hpp"
@@ -88,6 +89,20 @@
        tbuilder_label();
 public:
        tbuilder_label(const config& cfg) :
+               tbuilder_control(cfg)
+       {}
+
+       twidget* build () const;
+
+};
+
+struct tbuilder_spacer : public tbuilder_control
+{
+
+private:
+       tbuilder_spacer();
+public:
+       tbuilder_spacer(const config& cfg) :
                tbuilder_control(cfg)
        {}
 
@@ -346,6 +361,8 @@
                                widgets.push_back(new 
tbuilder_button(*((**col_itor).child("button"))));
                        } else if((**col_itor).child("label")) {
                                widgets.push_back(new 
tbuilder_label(*((**col_itor).child("label"))));
+                       } else if((**col_itor).child("spacer")) {
+                               widgets.push_back(new 
tbuilder_spacer(*((**col_itor).child("spacer"))));
                        } else if((**col_itor).child("text_box")) {
                                widgets.push_back(new 
tbuilder_text_box(*((**col_itor).child("text_box"))));
                        } else if((**col_itor).child("grid")) {
@@ -436,6 +453,18 @@
        return tmp_label;
 }
 
+twidget* tbuilder_spacer::build() const
+{
+       tspacer *spacer = new tspacer();
+
+       init_control(spacer);
+
+       DBG_G << "Window builder: placed spacer '" << id << "' with defintion 
'" 
+               << definition << "'.\n";
+
+       return spacer;
+}
+
 twidget* tbuilder_text_box::build() const
 {
        ttext_box *text_box = new ttext_box();


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to