Author: AlbrechtS
Date: 2011-05-01 05:45:29 -0700 (Sun, 01 May 2011)
New Revision: 8630
Log:
Fixed drawing artifacts when scrolling round boxes (FL_ROUND_UP_BOX and
FL_ROUND_DOWN_BOX) on Linux (STR #2615). This was done by

 (a) setting the line width in the box drawing function (was undefined, maybe 0)
 (b) taking care of zero and negative line width in X11 clipping functions.

Both solutions would have solved the particular problem individually.

Additionally made local helper function fl_arc_i() in src/fl_round_box.cxx
static to avoid name clashes.


Modified:
   branches/branch-1.3/src/fl_rect.cxx
   branches/branch-1.3/src/fl_round_box.cxx

Modified: branches/branch-1.3/src/fl_rect.cxx
===================================================================
--- branches/branch-1.3/src/fl_rect.cxx 2011-05-01 12:24:22 UTC (rev 8629)
+++ branches/branch-1.3/src/fl_rect.cxx 2011-05-01 12:45:29 UTC (rev 8630)
@@ -82,6 +82,10 @@
   
   In this example case, no clipping would be done, because X can
   handle it and clip unneeded pixels.
+  
+  Note that we must also take care of the case where fl_line_width_
+  is zero (maybe unitialized). If this is the case, we assume a line
+  width of 1.
 
   Todo: Arbitrary line drawings (e.g. polygons) and clip regions
   are not yet done.
@@ -120,8 +124,9 @@
 
 static int clip_to_short(int &x, int &y, int &w, int &h) {
 
-  int kmin = -fl_line_width_;
-  int kmax = SHRT_MAX - fl_line_width_;
+  int lw = (fl_line_width_ > 0) ? fl_line_width_ : 1;
+  int kmin = -lw;
+  int kmax = SHRT_MAX - lw;
 
   if (w <= 0 || h <= 0) return 1;              // (a)
   if (x+w < kmin || y+h < kmin) return 1;      // (b)
@@ -145,8 +150,9 @@
 */
 static int clip_x (int x) {
 
-  int kmin = -fl_line_width_;
-  int kmax = SHRT_MAX - fl_line_width_;
+  int lw = (fl_line_width_ > 0) ? fl_line_width_ : 1;
+  int kmin = -lw;
+  int kmax = SHRT_MAX - lw;
 
   if (x < kmin)
     x = kmin;

Modified: branches/branch-1.3/src/fl_round_box.cxx
===================================================================
--- branches/branch-1.3/src/fl_round_box.cxx    2011-05-01 12:24:22 UTC (rev 
8629)
+++ branches/branch-1.3/src/fl_round_box.cxx    2011-05-01 12:45:29 UTC (rev 
8630)
@@ -35,7 +35,7 @@
 // A compiler from a certain very large software company will not compile
 // the function pointer assignment due to the name conflict with fl_arc.
 // This function is to fix that:
-void fl_arc_i(int x,int y,int w,int h,double a1,double a2) {
+static void fl_arc_i(int x,int y,int w,int h,double a1,double a2) {
   fl_arc(x,y,w,h,a1,a2);
 }
 
@@ -52,6 +52,7 @@
   int d = w <= h ? w : h;
   if (d <= 1) return;
   fl_color(color);
+  fl_line_style(0,1);
   void (*f)(int,int,int,int,double,double);
   f = (which==FILL) ? fl_pie : fl_arc_i;
   if (which >= CLOSED) {
@@ -78,6 +79,7 @@
       if (which != LOWER_RIGHT) fl_xyline(x+d/2-1, y, x+w-d/2+1);
     }
   }
+  fl_line_style(0);
 }
 
 extern uchar* fl_gray_ramp();

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to