Author: mordante
Date: Wed Apr 30 15:38:03 2008
New Revision: 26254
URL: http://svn.gna.org/viewcvs/wesnoth?rev=26254&view=rev
Log:
Move the drawing in it's own function, since get_rect() returns the screen
coordinates we can't inherit the panel function.
Modified:
trunk/src/gui/widgets/window.cpp
trunk/src/gui/widgets/window.hpp
Modified: trunk/src/gui/widgets/window.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.cpp?rev=26254&r1=26253&r2=26254&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Wed Apr 30 15:38:03 2008
@@ -59,7 +59,6 @@
status_(NEW),
retval_(0),
need_layout_(true),
- restorer_(),
tooltip_(),
help_popup_()
{
@@ -87,7 +86,7 @@
// We cut a piece of the screen and use that, that way all coordinates
// are relative to the window.
SDL_Rect rect = get_rect();
- restorer_ = get_surface_portion(video_.getSurface(), rect);
+ surface restorer = get_surface_portion(video_.getSurface(), rect);
surface screen;
// Start our loop drawing will happen here as well.
@@ -100,47 +99,10 @@
}
if(dirty() || need_layout_) {
- const bool draw_foreground = need_layout_;
if(need_layout_) {
- DBG_G << "Window: layout client area.\n";
- layout(get_client_rect());
- need_layout_ = false;
-
- screen = make_neutral_surface(restorer_);
-
- canvas(0).draw();
- blit_surface(canvas(0).surf(), 0, screen, 0);
+ screen = make_neutral_surface(restorer);
}
-#if 0
- // Darkening for debugging redraw.
- SDL_Rect temp_rect = {0, 0, screen->w, screen->h};
- fill_rect_alpha(temp_rect, 0, 1, screen);
-#endif
- // FIXME call grid().draw() and it do it's drawing.
- for(tgrid::iterator itor = begin(); itor != end();
++itor) {
- if(! *itor || !itor->dirty()) {
- continue;
- }
-
- log_scope2(gui_draw, "Window: draw child.");
-
- itor->draw(screen);
- }
- if(draw_foreground) {
- canvas(1).draw();
- blit_surface(canvas(1).surf(), 0, screen, 0);
- }
- if(tooltip_.dirty()) {
- tooltip_.draw(screen);
- }
- if(help_popup_.dirty()) {
- help_popup_.draw(screen);
- }
-
- rect = get_rect();
- SDL_BlitSurface(screen, 0, video_.getSurface(), &rect);
- update_rect(get_rect());
- set_dirty(false);
+ draw(screen);
}
// delay until it's our frame see display.ccp code for how to
do that
@@ -151,7 +113,7 @@
// restore area
if(restore) {
rect = get_rect();
- SDL_BlitSurface(restorer_, 0, video_.getSurface(), &rect);
+ SDL_BlitSurface(restorer, 0, video_.getSurface(), &rect);
update_rect(get_rect());
flip();
}
@@ -168,6 +130,45 @@
<< ',' << position.h << ".\n";
set_client_size(position);
+ need_layout_ = false;
+}
+
+//! Inherited from tpanel.
+void twindow::draw(surface& surface)
+{
+ const bool draw_foreground = need_layout_;
+ if(need_layout_) {
+ DBG_G << "Window: layout client area.\n";
+ layout(get_client_rect());
+
+ canvas(0).draw();
+ blit_surface(canvas(0).surf(), 0, surface, 0);
+ }
+
+ for(tgrid::iterator itor = begin(); itor != end(); ++itor) {
+ if(! *itor || !itor->dirty()) {
+ continue;
+ }
+
+ log_scope2(gui_draw, "Window: draw child.");
+
+ itor->draw(surface);
+ }
+ if(draw_foreground) {
+ canvas(1).draw();
+ blit_surface(canvas(1).surf(), 0, surface, 0);
+ }
+ if(tooltip_.dirty()) {
+ tooltip_.draw(surface);
+ }
+ if(help_popup_.dirty()) {
+ help_popup_.draw(surface);
+ }
+
+ SDL_Rect rect = get_rect();
+ SDL_BlitSurface(surface, 0, video_.getSurface(), &rect);
+ update_rect(get_rect());
+ set_dirty(false);
}
void twindow::flip()
Modified: trunk/src/gui/widgets/window.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.hpp?rev=26254&r1=26253&r2=26254&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.hpp (original)
+++ trunk/src/gui/widgets/window.hpp Wed Apr 30 15:38:03 2008
@@ -91,6 +91,9 @@
unsigned get_state() const { return 0; }
bool full_redraw() const { return false; /* FIXME IMPLEMENT */ }
+ //! Inherited from tpanel.
+ void draw(surface& surface);
+
//! Inherited from twidget.
tpoint get_minimum_size() const { /*FIXME IMPLEMENT*/ return
tpoint(0,0); }
tpoint get_best_size() const { /*FIXME IMPLEMENT*/ return tpoint(0,0);
}
@@ -117,7 +120,6 @@
//! When set the form needs a full layout redraw cycle.
bool need_layout_;
- surface restorer_;
//! 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