Author: mordante
Date: Wed Apr 30 12:16:55 2008
New Revision: 26251
URL: http://svn.gna.org/viewcvs/wesnoth?rev=26251&view=rev
Log:
More refactoring, the window definition now inherits from the panel definition.
The window now uses the canvasses as defined in the control.
Modified:
trunk/src/gui/widgets/settings.cpp
trunk/src/gui/widgets/settings.hpp
trunk/src/gui/widgets/window.cpp
trunk/src/gui/widgets/window.hpp
Modified: trunk/src/gui/widgets/settings.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=26251&r1=26250&r2=26251&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Wed Apr 30 12:16:55 2008
@@ -599,67 +599,20 @@
}
twindow_definition::twindow_definition(const config& cfg) :
- tcontrol_definition(cfg)
-{
-/*WIKI (FIXME cleanup)
- * [window_definition]
- * The definition of a normal push window.
- *
- * id = (string = "") Unique id for this gui (theme).
- * description = (t_string = "") Unique translatable name for this gui.
- *
- * [resolution] The definitions of the window in various
- * resolutions.
- * [/window_definition]
+ tpanel_definition(cfg)
+{
+/*WIKI
+ * @page = GUIToolkitWML
+ * @order = 1_widget_window
+ *
+ * == Window ==
+ *
+ * The definition of a window. A window is a kind of panel see the panel for
+ * which fields exist
+ *
*/
DBG_G_P << "Parsing window " << id << '\n';
-
- load_resolutions<tresolution>(cfg.get_children("resolution"));
-}
-
-twindow_definition::tresolution::tresolution(const config& cfg) :
- tresolution_definition_(cfg),
- top_border(lexical_cast_default<unsigned>(cfg["top_border"])),
- bottom_border(lexical_cast_default<unsigned>(cfg["bottom_border"])),
- left_border(lexical_cast_default<unsigned>(cfg["left_border"])),
- right_border(lexical_cast_default<unsigned>(cfg["right_border"])),
- background(cfg.child("background")),
- foreground(cfg.child("foreground"))
-{
-/*WIKI (FIXME cleanup)
- * [resolution]
- * window_width = (unsigned = 0) Width of the application window.
- * window_height = (unsigned = 0)
- * Height of the application window.
- * min_width = (unsigned = 0) The minimum width of the windows.
- * min_height = (unsigned = 0) The minimum height of the windows.
- *
- * top_border = (unsigned = 0) The size which isn't used for the client
area.
- * bottom_border = (unsigned = 0)The size which isn't used for the client
area.
- * left_border = (unsigned = 0) The size which isn't used for the client
area.
- * right_border = (unsigned = 0) The size which isn't used for the client
area.
- *
- * [background] The things drawn on the window before
- * the widgets are drawn.
- * [foreground] The things drawn on the window on top
- * of the widgets.
- *
- * [/resolution]
- */
-
- DBG_G_P << "Parsing resolution "
- << window_width << ", " << window_height << '\n';
-}
-
-twindow_definition::tresolution::tlayer::tlayer(const config* cfg) :
- canvas()
-{
- const config* draw = cfg ? cfg->child("draw") : 0;
-
- VALIDATE(draw, _("No layer or draw section defined."));
-
- canvas.set_cfg(*draw);
}
tresolution_definition_* get_control(const std::string& control_type, const
std::string& definition)
Modified: trunk/src/gui/widgets/settings.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.hpp?rev=26251&r1=26250&r2=26251&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Wed Apr 30 12:16:55 2008
@@ -176,35 +176,9 @@
};
};
-struct twindow_definition : public tcontrol_definition
-{
-
+struct twindow_definition : public tpanel_definition
+{
twindow_definition(const config& cfg);
-
- struct tresolution : public tresolution_definition_
- {
- tresolution(const config& cfg);
-
- unsigned top_border;
- unsigned bottom_border;
-
- unsigned left_border;
- unsigned right_border;
-
- struct tlayer
- {
- private:
- tlayer();
-
- public:
- tlayer(const config* cfg);
-
- tcanvas canvas;
- };
-
- tlayer background;
- tlayer foreground;
- };
};
struct tgui_definition
Modified: trunk/src/gui/widgets/window.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.cpp?rev=26251&r1=26250&r2=26251&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Wed Apr 30 12:16:55 2008
@@ -53,18 +53,20 @@
twindow::twindow(CVideo& video,
const int x, const int y, const int w, const int h) :
- tpanel(false, 0),
+ tpanel(false),
tevent_handler(),
video_(video),
status_(NEW),
retval_(0),
need_layout_(true),
restorer_(),
- canvas_background_(),
- canvas_foreground_(),
+// canvas_background_(),
+// canvas_foreground_(),
tooltip_(),
help_popup_()
{
+ load_config();
+
set_x(x);
set_y(y);
set_width(w);
@@ -75,21 +77,6 @@
help_popup_.set_definition("default");
help_popup_.set_visible(false);
-
- load_config();
-
- // FIXME hack to load config stuff here
- const twindow_definition::tresolution* conf = dynamic_cast<const
twindow_definition::tresolution*>(config());
- assert(conf);
- canvas_background_ = conf->background.canvas;
- canvas_background_.set_width(get_width());
- canvas_background_.set_height(get_height());
-
- canvas_foreground_ = conf->foreground.canvas;
- canvas_foreground_.set_width(get_width());
- canvas_foreground_.set_height(get_height());
- // End of hack
-
}
int twindow::show(const bool restore, void* /*flip_function*/)
@@ -126,8 +113,8 @@
screen = make_neutral_surface(restorer_);
- canvas_background_.draw();
- blit_surface(canvas_background_.surf(), 0,
screen, 0);
+ canvas(0).draw();
+ blit_surface(canvas(0).surf(), 0, screen, 0);
}
#if 0
// Darkening for debugging redraw.
@@ -145,8 +132,8 @@
itor->draw(screen);
}
if(draw_foreground) {
- canvas_foreground_.draw();
- blit_surface(canvas_foreground_.surf(), 0,
screen, 0);
+ canvas(1).draw();
+ blit_surface(canvas(1).surf(), 0, screen, 0);
}
if(tooltip_.dirty()) {
tooltip_.draw(screen);
@@ -188,26 +175,6 @@
set_client_size(position);
}
-void twindow::set_width(const unsigned width)
-{
- canvas_background_.set_width(width);
- canvas_foreground_.set_width(width);
- need_layout_ = true;
-
- // inherited
- tcontrol::set_width(width);
-}
-
-void twindow::set_height(const unsigned height)
-{
- canvas_background_.set_height(height);
- canvas_foreground_.set_height(height);
- need_layout_ = true;
-
- // inherited
- tcontrol::set_height(height);
-}
-
void twindow::flip()
{
// fixme we need to add the option to either call
Modified: trunk/src/gui/widgets/window.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.hpp?rev=26251&r1=26250&r2=26251&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.hpp (original)
+++ trunk/src/gui/widgets/window.hpp Wed Apr 30 12:16:55 2008
@@ -68,10 +68,6 @@
void set_retval(const int retval, const bool close_window = true)
{ retval_ = retval; if(close_window) close(); }
- void set_width(const unsigned width);
-
- void set_height(const unsigned height);
-
//! Inherited from tevent_handler.
twindow& get_window() { return *this; }
const twindow& get_window() const { return *this; }
@@ -122,10 +118,6 @@
bool need_layout_;
surface restorer_;
-
- tcanvas
- canvas_background_,
- canvas_foreground_;
//! Inherited from tevent_handler.
void do_show_tooltip(const tpoint& location, const t_string& tooltip);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits