FLTK logo

[Library] r4374 - in branches/branch-1.1: . src test

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[Library] r4374 - in branches/branch-1.1: . src test fltk-dev May 27, 2005  
 
Author: matt
Date: 2005-05-27 07:33:34 -0400 (Fri, 27 May 2005)
New Revision: 4374

Modified:
   branches/branch-1.1/CHANGES
   branches/branch-1.1/src/Fl_get_system_colors.cxx
   branches/branch-1.1/src/fl_plastic.cxx
   branches/branch-1.1/test/boxtype.cxx
Log:
Fixed the Round Plastic buttons to actually draw nice and riund, just
like the original scheme buttons. This is relatively slow, but worth
the effort, I beleive. Just use double buffered windows... .

Modified: branches/branch-1.1/CHANGES
===================================================================
--- branches/branch-1.1/CHANGES	2005-05-26 21:13:17 UTC (rev 4373)
+++ branches/branch-1.1/CHANGES	2005-05-27 11:33:34 UTC (rev 4374)
@@ -8,6 +8,7 @@
 	  startup (STR #886)
 	- Selected tabs are now drawn slightly larger than
 	  unselected tabs so they stand out more (STR #882)
+	- Round Plastic boxes now draw round (STR #841)
 	- FL_PLASTIC_DOWN_BOX drew with artifacts (STR #852)
 	- Changed initializations on WIN32 (STR #862)
 	- Fl_Preferences::getUserdataPath() didn't work for

Modified: branches/branch-1.1/src/Fl_get_system_colors.cxx
===================================================================
--- branches/branch-1.1/src/Fl_get_system_colors.cxx	2005-05-26 21:13:17 UTC (rev 4373)
+++ branches/branch-1.1/src/Fl_get_system_colors.cxx	2005-05-27 11:33:34 UTC (rev 4374)
@@ -302,7 +302,7 @@
     set_boxtype(FL_THIN_UP_BOX,     FL_PLASTIC_THIN_UP_BOX);
     set_boxtype(FL_THIN_DOWN_BOX,   FL_PLASTIC_THIN_DOWN_BOX);
     set_boxtype(_FL_ROUND_UP_BOX,   FL_PLASTIC_ROUND_UP_BOX);
-    set_boxtype(_FL_ROUND_DOWN_BOX, FL_PLASTIC_ROUND_UP_BOX);
+    set_boxtype(_FL_ROUND_DOWN_BOX, FL_PLASTIC_ROUND_DOWN_BOX);
   } else {
     // Use the standard FLTK look-n-feel...
     if (scheme_bg_) {

Modified: branches/branch-1.1/src/fl_plastic.cxx
===================================================================
--- branches/branch-1.1/src/fl_plastic.cxx	2005-05-26 21:13:17 UTC (rev 4373)
+++ branches/branch-1.1/src/fl_plastic.cxx	2005-05-27 11:33:34 UTC (rev 4374)
@@ -103,18 +103,52 @@
   uchar *g = fl_gray_ramp();
   int b = strlen(c) / 4 + 1;
 
-  for (; b > 1; b --, x ++, y ++, w -= 2, h -= 2)
-  {
-    // Draw arcs around the perimeter of the button, 4 colors per
-    // circuit.
-    fl_color(shade_color(g[*c++], bc));
-    fl_arc(x, y, w, h, 45.0, 135.0);
-    fl_color(shade_color(g[*c++], bc));
-    fl_arc(x, y, w, h, 315.0, 405.0);
-    fl_color(shade_color(g[*c++], bc));
-    fl_arc(x, y, w, h, 225.0, 315.0);
-    fl_color(shade_color(g[*c++], bc));
-    fl_arc(x, y, w, h, 135.0, 225.0);
+  if (w==h) {
+    for (; b > 1; b --, x ++, y ++, w -= 2, h -= 2)
+    {
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x, y, w, h, 45.0, 135.0);
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x, y, w, h, 315.0, 405.0);
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x, y, w, h, 225.0, 315.0);
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x, y, w, h, 135.0, 225.0);
+    }
+  } else if (w>h) {
+    int d = h/2;
+    for (; b > 1; d--, b --, x ++, y ++, w -= 2, h -= 2)
+    {
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x, y, h, h, 90.0, 135.0);
+      fl_xyline(x+d, y, x+w-d);
+      fl_arc(x+w-h, y, h, h, 45.0, 90.0);
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x+w-h, y, h, h, 315.0, 405.0);
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x+w-h, y, h, h, 270.0, 315.0);
+      fl_xyline(x+d, y+h, x+w-d);
+      fl_arc(x, y, h, h, 225.0, 270.0);
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x, y, h, h, 135.0, 225.0);
+    }
+  } else if (w<h) {
+    int d = w/2;
+    for (; b > 1; d--, b --, x ++, y ++, w -= 2, h -= 2)
+    {
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x, y, w, w, 45.0, 135.0);
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x, y, w, w, 0.0, 45.0);
+      fl_yxline(x+w, y+d, y+h-d);
+      fl_arc(x, y+h-w, w, w, 315.0, 360.0);
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x, y+h-w, w, w, 225.0, 315.0);
+      fl_color(shade_color(g[*c++], bc));
+      fl_arc(x, y+h-w, w, w, 180.0, 225.0);
+      fl_yxline(x, y+d, y+h-d);
+      fl_arc(x, y, w, w, 135.0, 180.0);
+    }
   }
 }
 
@@ -193,48 +227,56 @@
 
 static void shade_round(int x, int y, int w, int h, const char *c, Fl_Color bc) {
   uchar		*g = fl_gray_ramp();
-  int		i, j, k;
+  int		i, j;
   int		clen = strlen(c) - 1;
   int		chalf = clen / 2;
   int		cstep = 1;
-  static const int kvals_table[] = { 21, 16, 11, 8, 5, 3, 2, 1 };
-  const int *kvals = kvals_table + 8 - chalf;
-  if (clen >= h) cstep = 2;
 
-  for (i = 0, j = 0; j < chalf; i ++, j += cstep) {
-    // Indent k inside a circle...
-    k = kvals[i];
-
-    // Draw the top line and points...
-    fl_color(shade_color(g[c[i]], bc));
-    fl_xyline(x + k, y + i, x + w - k);
-
-    fl_color(shade_color(g[c[i] - 2], bc));
-    fl_point(x + k - 1, y + i + 1);
-    fl_point(x + k - 2, y + i + 2);
-    fl_point(x + w - k, y + i + 1);
-    fl_point(x + w - k - 1, y + i + 2);
-
-    // Draw the bottom line and points...
-    fl_color(shade_color(g[c[clen - i]], bc));
-    fl_xyline(x + k, y + h - i, x + w - k);
-
-    fl_color(shade_color(g[c[clen - i] - 2], bc));
-    fl_point(x + k - 1, y + h - i);
-    fl_point(x + k - 2, y + h - i - 1);
-    fl_point(x + w - k, y + h - i);
-    fl_point(x + w - k - 1, y + h - i - 1);
+  if (w>h) {
+    int d = h/2;
+    const int na = 8;
+    for (i=0; i<chalf; i++, d--, x++, y++, w-=2, h-=2)
+    {
+      fl_color(shade_color(g[c[i]], bc));
+      fl_pie(x, y, h, h, 90.0, 135.0+i*na);
+      fl_xyline(x+d, y, x+w-d);
+      fl_pie(x+w-h, y, h, h, 45.0+i*na, 90.0);
+      fl_color(shade_color(g[c[i] - 2], bc));
+      fl_pie(x+w-h, y, h, h, 315.0+i*na, 405.0+i*na);
+      fl_color(shade_color(g[c[clen - i]], bc));
+      fl_pie(x+w-h, y, h, h, 270.0, 315.0+i*na);
+      fl_xyline(x+d, y+h, x+w-d);
+      fl_pie(x, y, h, h, 225.0+i*na, 270.0);
+      fl_color(shade_color(g[c[clen - i] - 2], bc));
+      fl_pie(x, y, h, h, 135.0+i*na, 225.0+i*na);
+    }
+    fl_color(shade_color(g[c[chalf]], bc));
+    fl_rectf(x+d, y, w-h+1, h+1);
+    fl_pie(x, y, h, h, 90.0, 270.0);
+    fl_pie(x+w-h, y, h, h, 270.0, 90.0);
+  } else {
+    int d = w/2;
+    const int na = 8;
+    for (i=0; i<chalf; i++, d--, x++, y++, w-=2, h-=2)
+    {
+      fl_color(shade_color(g[c[i]], bc));
+      fl_pie(x, y, w, w, 45.0+i*na, 135.0+i*na);
+      fl_color(shade_color(g[c[i] - 2], bc));
+      fl_pie(x, y, w, w, 0.0, 45.0+i*na);
+      fl_yxline(x+w, y+d, y+h-d);
+      fl_pie(x, y+h-w, w, w, 315.0+i*na, 360.0);
+      fl_color(shade_color(g[c[clen - i]], bc));
+      fl_pie(x, y+h-w, w, w, 225.0+i*na, 315.0+i*na);
+      fl_color(shade_color(g[c[clen - i] - 2], bc));
+      fl_pie(x, y+h-w, w, w, 180.0, 225.0+i*na);
+      fl_yxline(x, y+d, y+h-d);
+      fl_pie(x, y, w, w, 135.0+i*na, 180.0);
+    }
+    fl_color(shade_color(g[c[chalf]], bc));
+    fl_rectf(x, y+d, w+1, h-w+1);
+    fl_pie(x, y, w, w, 0.0, 180.0);
+    fl_pie(x, y+h-w, w, w, 180.0, 360.0);
   }
-
-  // Draw the interior and sides...
-  i = chalf / cstep;
-
-  fl_color(shade_color(g[c[chalf]], bc));
-  fl_rectf(x + 1, y + i, w - 2, h - 2 * i + 1);
-
-  fl_color(shade_color(g[c[chalf] - 2], bc));
-  fl_yxline(x, y + i, y + h - i);
-  fl_yxline(x + w - 1, y + i, y + h - i);
 }
 
 
@@ -266,11 +308,8 @@
 
 
 static void up_round(int x, int y, int w, int h, Fl_Color c) {
-  if (w != h) up_box(x, y, w, h, c);
-  else {
-    shade_round(x + 1, y + 1, w - 2, h - 2, "RVQNOPQRSTUVWVQ", c);
-    frame_round(x, y, w, h, "IJLM", c);
-  }
+  shade_round(x, y, w, h-1, "RVQNOPQRSTUVWVQ", c);
+  frame_round(x, y, w, h-1, "IJLM", c);
 }
 
 
@@ -286,11 +325,8 @@
 
 
 static void down_round(int x, int y, int w, int h, Fl_Color c) {
-  if (w != h) down_box(x, y, w, h, c);
-  else {
-    shade_round(x + 2, y + 2, w - 4, h - 4, "STUVWWWVT", c);
-    frame_round(x, y, w, h, "MLJI", c);
-  }
+  shade_round(x, y, w, h-1, "STUVWWWVT", c);
+  frame_round(x, y, w, h-1, "IJLM", c);
 }
 
 

Modified: branches/branch-1.1/test/boxtype.cxx
===================================================================
--- branches/branch-1.1/test/boxtype.cxx	2005-05-26 21:13:17 UTC (rev 4373)
+++ branches/branch-1.1/test/boxtype.cxx	2005-05-27 11:33:34 UTC (rev 4374)
@@ -92,7 +92,7 @@
   bt("FL_PLASTIC_THIN_DOWN_BOX",FL_PLASTIC_THIN_DOWN_BOX);
   window->resizable(window);
   window->end();
-//  window->show(argc,argv);
+  //window->show(argc,argv);
   window->show();
   return Fl::run();
 }

Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.