mail[Wesnoth-commits] r24670 - /trunk/src/gui/widgets/canvas.cpp


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

Header


Content

Posted by koraq on March 15, 2008 - 21:16:
Author: mordante
Date: Sat Mar 15 20:31:22 2008
New Revision: 24670

URL: http://svn.gna.org/viewcvs/wesnoth?rev=24670&view=rev
Log:
Fixed the rectangle code and did some testing with it.

Modified:
    trunk/src/gui/widgets/canvas.cpp

Modified: trunk/src/gui/widgets/canvas.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/canvas.cpp?rev=24670&r1=24669&r2=24670&view=diff
==============================================================================
--- trunk/src/gui/widgets/canvas.cpp (original)
+++ trunk/src/gui/widgets/canvas.cpp Sat Mar 15 20:31:22 2008
@@ -268,8 +268,8 @@
 
 void tcanvas::tline::draw(surface& canvas)
 {
-       DBG_GUI << "Draw line from :" 
-               << x1_ << ',' << y1_ << " to : " << x2_ << ',' << y2_ << '\n';
+       DBG_GUI << "Draw line from: " 
+               << x1_ << ',' << y1_ << " to: " << x2_ << ',' << y2_ << '\n';
 
        // we wrap around the coordinates, this might be moved to be more
        // generic place, but leave it here for now. Note the numbers are
@@ -326,6 +326,10 @@
        rect_.w = lexical_cast_default<int>(cfg["w"]);
        rect_.h = lexical_cast_default<int>(cfg["h"]);
 
+       if(border_colour_ == 0) {
+               border_thickness_ = 0;
+       }
+
        const std::string& debug = (cfg["debug"]);
        if(!debug.empty()) {
                DBG_GUI << debug << '\n';
@@ -336,17 +340,20 @@
 void tcanvas::trectangle::draw(surface& canvas)
 {
 
+       DBG_GUI << "Draw rectangle from: " << rect_.x << ',' << rect_.y 
+               << " width: " << rect_.w << " height: " << rect_.h << '\n';
+
+       surface_lock locker(canvas);
+
        //FIXME wrap the points and validate the input
-
-       surface_lock locker(canvas);
 
        // draw the border
        for(unsigned i = 0; i < border_thickness_; ++i) {
 
                const unsigned left = rect_.x + i;
-               const unsigned right = rect_.x + rect_.w - 2 * i;
+               const unsigned right = left + rect_.w - (i * 2) - 1;
                const unsigned top = rect_.y + i;
-               const unsigned bottom = rect_.y + rect_.h - 2 * i;
+               const unsigned bottom = top + rect_.h - (i * 2) - 1;
 
                // top horizontal (left -> right)
                draw_line(canvas, border_colour_, left, top, right, top);
@@ -362,6 +369,21 @@
 
        }
 
+       // The fill_rect_alpha code below fails, can't remember the exact 
cause
+       // so use the slow line drawing method to fill the rect.
+       if(fill_colour_) {
+               
+               const unsigned left = rect_.x + border_thickness_;
+               const unsigned right = left + rect_.w - (2 * 
border_thickness_) - 1;
+               const unsigned top = rect_.y + border_thickness_;
+               const unsigned bottom = top + rect_.h - (2 * 
border_thickness_);
+
+               for(unsigned i = top; i < bottom; ++i) {
+                       
+                       draw_line(canvas, fill_colour_, left, i, right, i);
+               }
+       }
+/*
        const unsigned left = rect_.x + border_thickness_ + 1;
        const unsigned top = rect_.y + border_thickness_ + 1;
        const unsigned width = rect_.w - (2 * border_thickness_) - 2;
@@ -372,8 +394,9 @@
        const Uint8 alpha = fill_colour_ & 0xFF;
 
        // fill
-       fill_rect_alpha(rect_, colour, alpha, canvas);
-
+       fill_rect_alpha(rect, colour, alpha, canvas);
+       canvas = blend_surface(canvas, 255, 0xAAAA00);  
+*/     
 }
 
 tcanvas::timage::timage(const vconfig& cfg) :




Related Messages


Powered by MHonArc, Updated Sat Mar 15 21:41:24 2008