Author: spitzak
Date: 2007-06-26 14:49:21 -0400 (Tue, 26 Jun 2007)
New Revision: 5918
Log:
Made inactive text be visible in dark color schemes where the background
color might be the same as the old inactive color was. Also some fixes
to some test programs.


Modified:
   trunk/fltk/Color.h
   trunk/src/FileIcon.cxx
   trunk/src/FileInput.cxx
   trunk/src/Input.cxx
   trunk/src/RadioButton.cxx
   trunk/src/Slider.cxx
   trunk/src/Style.cxx
   trunk/src/setcolor.cxx
   trunk/test/checkers.cxx
   trunk/test/help.cxx
   trunk/test/resize.cxx
   trunk/test/resize.fl
   trunk/test/resize.h

Modified: trunk/fltk/Color.h
===================================================================
--- trunk/fltk/Color.h  2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/fltk/Color.h  2007-06-26 18:49:21 UTC (rev 5918)
@@ -109,8 +109,8 @@
 FL_API Color color(const char*);
 FL_API Color parsecolor(const char*, unsigned length);
 FL_API Color lerp(Color c0, Color c1, float f);
-FL_API Color inactive(Color);
-FL_API Color inactive(Color, Flags f);
+FL_API Color inactive(Color fg);
+FL_API Color inactive(Color fg, Color bg);
 FL_API Color contrast(Color fg, Color bg);
 FL_API void split_color(Color c, unsigned char& r, unsigned char& g, unsigned 
char& b);
 FL_API void set_color_index(Color index, Color);

Modified: trunk/src/FileIcon.cxx
===================================================================
--- trunk/src/FileIcon.cxx      2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/src/FileIcon.cxx      2007-06-26 18:49:21 UTC (rev 5918)
@@ -272,7 +272,6 @@
   // fabien: must save currentcolor because otherwise the browser would write 
the text
   // with icon color, thanks bill for having removed the back pointer !
   Color saved_color = getcolor(); 
-                                           
 
   // Setup the transform matrix as needed...
   scale = float(r.w() < r.h() ? r.w() : r.h());

Modified: trunk/src/FileInput.cxx
===================================================================
--- trunk/src/FileInput.cxx     2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/src/FileInput.cxx     2007-06-26 18:49:21 UTC (rev 5918)
@@ -212,12 +212,12 @@
          fltk::setfont(labelfont(), labelsize());
          float width = getwidth(label());
          label_width = int(width+getwidth(":")+2.5);
-         setcolor(color());
+          Color color = this->color();
+         setcolor(color);
          Rectangle lr(r); lr.w(label_width);
          fillrect(lr);
-         Color color = labelcolor();
-         if (flag(INACTIVE_R)) color = inactive(color);
-         setcolor(color);
+         if (flag(INACTIVE_R)) setcolor(inactive(labelcolor(), color));
+          else setcolor(labelcolor());
          float y = r.y()+((r.h()-height)>>1)+desc;
          drawtext(label(), float(r.x()+2), y);
          drawtext(":", r.x()+2+width, y);

Modified: trunk/src/Input.cxx
===================================================================
--- trunk/src/Input.cxx 2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/src/Input.cxx 2007-06-26 18:49:21 UTC (rev 5918)
@@ -239,12 +239,12 @@
       fltk::setfont(labelfont(), labelsize());
       float width = getwidth(label());
       label_width = int(width+getwidth(":")+2.5);
-      setcolor(color());
+      Color color = this->color();
+      setcolor(color);
       Rectangle lr(r); lr.w(label_width);
       fillrect(lr);
-      Color color = labelcolor();
-      if (flag(INACTIVE_R)) color = inactive(color);
-      setcolor(color);
+      if (flag(INACTIVE_R)) setcolor(inactive(labelcolor(), color));
+      else setcolor(labelcolor());
       float y = r.y()+((r.h()-height)>>1)+desc;
       drawtext(label(), float(r.x()+2), y);
       drawtext(":", r.x()+2+width, y);
@@ -269,8 +269,7 @@
 {
 
   // ignore HIGHLIGHT so it does not change color when mouse points at it:
-  Flags flags = this->flags()&~HIGHLIGHT;
-  drawstyle(style(), flags);
+  drawstyle(style(), this->flags()&~HIGHLIGHT);
 
   const Color background = getbgcolor();
   const Color textcolor = getcolor();

Modified: trunk/src/RadioButton.cxx
===================================================================
--- trunk/src/RadioButton.cxx   2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/src/RadioButton.cxx   2007-06-26 18:49:21 UTC (rev 5918)
@@ -58,8 +58,11 @@
       Rectangle r(R);
       box->inset(r);
       // use the selection color only if they directly set it:
-      if (drawstyle()->selection_color_)
-       setcolor(inactive(drawstyle()->selection_color_, drawflags()));
+      Color c = drawstyle()->selection_color_;
+      if (c) {
+        if (drawflags()&INACTIVE_R) c = inactive(c);
+        setcolor(c);
+      }
       r.inset((r.h()+1)/6);
       addchord(r, 0, 360);
       fillpath();

Modified: trunk/src/Slider.cxx
===================================================================
--- trunk/src/Slider.cxx        2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/src/Slider.cxx        2007-06-26 18:49:21 UTC (rev 5918)
@@ -424,7 +424,9 @@
         break;
       }
     }
-    setcolor(inactive(contrast(textcolor(),color()),flags));
+    Color b = color();
+    Color c = contrast(textcolor(), b);
+    if (flags&INACTIVE_R) c = inactive(c, b);
     draw_ticks(tr, (slider_size()+1)/2);
   }
 

Modified: trunk/src/Style.cxx
===================================================================
--- trunk/src/Style.cxx 2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/src/Style.cxx 2007-06-26 18:49:21 UTC (rev 5918)
@@ -396,7 +396,7 @@
     else {bg = style->color(); fg = style->textcolor();}
     // fg = contrast(fg, bg);this messes up things
   }
-  if (flags & INACTIVE_R) fg = inactive(fg);
+  if (flags & INACTIVE_R) fg = inactive(fg,bg);
   setcolor(fg);
   setbgcolor(bg);
   if (flags & OUTPUT) setfont(style->labelfont(), style->labelsize());

Modified: trunk/src/setcolor.cxx
===================================================================
--- trunk/src/setcolor.cxx      2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/src/setcolor.cxx      2007-06-26 18:49:21 UTC (rev 5918)
@@ -99,15 +99,14 @@
        (uchar)(((uchar)(rgb1>>8))*weight + ((uchar)(rgb0>>8))*(1-weight)));
 }
 
-/*! Same as lerp(c, GRAY75, .7), it grays out the color. */
-Color fltk::inactive(Color c) {
-  return lerp(c, GRAY75, 0.70f);
+/*! Same as lerp(fg, bg, .5), it grays out the color. */
+Color fltk::inactive(Color fg, Color bg) {
+  return lerp(fg, bg, .5);
 }
 
-/*! Same as (f&INACTIVE_R) ? inactive(c) : c */
-Color fltk::inactive(Color c, Flags f) {
-  if (f&INACTIVE_R) return lerp(c, GRAY75, 0.70f);
-  return c;
+/*! Same as lerp(fg, getbgcolor(), .5). This is for back-compatability only? */
+Color fltk::inactive(Color fg) {
+  return lerp(fg, current_bgcolor_, .5);
 }
 
 /*! Returns \a fg if fltk decides it can be seen well when drawn against

Modified: trunk/test/checkers.cxx
===================================================================
--- trunk/test/checkers.cxx     2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/test/checkers.cxx     2007-06-26 18:49:21 UTC (rev 5918)
@@ -330,7 +330,7 @@
           spiece*(friendpieces-enemypieces));
     printf("kings\t%d\t%d\t%d\n",enemykings,friendkings,
           (sking-spiece)*(friendkings-enemykings));
-    printf("mobil\t%d\t%d\n",f->mobil,n->mobil);
+    printf("mobil\t%d\t%d\t%d\n",f->mobil,n->mobil,n->mobil?0:sallpin);
     printf("deny\t%d\t%d\t%d\n",f->deny,n->deny,sdeny*(n->deny-f->deny));
     printf("pin\t%d\t%d\t%d\n",f->pin,n->pin,spin*(n->pin-f->pin));
     
printf("threat\t%d\t%d\t%d\n",f->threat,n->threat,sthreat*(n->threat-f->threat));
@@ -342,7 +342,7 @@
     printf("mode2\t%d\t%d\t%d\n",f->mode2,n->mode2,smode2*(n->mode2-f->mode2));
     printf("mode3\t%d\t%d\t%d\n",f->mode3,n->mode3,smode3*(n->mode3-f->mode3));
     printf("demmo\t%d\t%d\t%d\n",f->demmo,n->demmo,sdemmo*(n->demmo-f->demmo));
-    
printf("cent\t%d\t%d\t%dn",enemycent,friendcent,scent*(friendcent-enemycent));
+    
printf("cent\t%d\t%d\t%d\n",enemycent,friendcent,scent*(friendcent-enemycent));
     
printf("kcent\t%d\t%d\t%d\n",enemykcent,friendkcent,skcent*(friendkcent-enemykcent));
     printf("total:\t\t\t%d\n",total);
   }

Modified: trunk/test/help.cxx
===================================================================
--- trunk/test/help.cxx 2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/test/help.cxx 2007-06-26 18:49:21 UTC (rev 5918)
@@ -52,7 +52,7 @@
   else
     help->load(argv[1]);
 
-  help->show(argc, argv);
+  help->show();
 
   fltk::run();
 

Modified: trunk/test/resize.cxx
===================================================================
--- trunk/test/resize.cxx       2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/test/resize.cxx       2007-06-26 18:49:21 UTC (rev 5918)
@@ -1,4 +1,4 @@
-// generated by Fast Light User Interface Designer (fluid) version 2.0002
+// generated by Fast Light User Interface Designer (fluid) version 2.1000
 
 #include "resize.h"
 
@@ -39,6 +39,7 @@
   fltk::Window* w;
    {fltk::Window* o = new fltk::Window(320, 240);
     w = o;
+    o->shortcut(0xff1b);
     o->begin();
      {fltk::Button* o = new fltk::Button(60, 0, 39, 40, "@8->");
       o->set_vertical();
@@ -49,7 +50,7 @@
 er should not go into fits echoing resizes back and forth!");
       o->set_vertical();
       o->box(fltk::BORDER_BOX);
-      o->align(fltk::ALIGN_LEFT|fltk::ALIGN_INSIDE|fltk::ALIGN_WRAP);
+      
o->align(fltk::ALIGN_LEFT|fltk::ALIGN_CENTER|fltk::ALIGN_INSIDE|fltk::ALIGN_WRAP);
       fltk::Group::current()->resizable(o);
     }
      {fltk::Button* o = new fltk::Button(20, 40, 40, 40, "@<-");
@@ -76,7 +77,6 @@
     }
     o->end();
   }
-  //w->resize(600, 600);
   w->show(argc, argv);
   return  fltk::run();
 }

Modified: trunk/test/resize.fl
===================================================================
--- trunk/test/resize.fl        2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/test/resize.fl        2007-06-26 18:49:21 UTC (rev 5918)
@@ -1,5 +1,5 @@
 # data file for the FLTK User Interface Designer (FLUID)
-version 2.0002 
+version 2.1000 
 images_dir ./ 
 header_name {.h} 
 code_name {.cxx} 
@@ -18,8 +18,8 @@
       xywh {60 0 39 40}
     }
     {fltk::InvisibleBox} {} {
-      label {This is a test of program-generated resize() of a window.  The 
window should move or resize once when each button is clicked.  The program and 
window manager should not go into fits echoing resizes back and forth!}
-      xywh {148 10 157 218} align 148 resizable box BORDER_BOX
+      label {This is a test of program-generated resize() of a window.  The 
window should move or resize once when each button is clicked.  The program and 
window manager should not go into fits echoing resizes back and forth!} selected
+      xywh {148 10 157 218} align 180 resizable box BORDER_BOX
     }
     {fltk::Button} {} {
       label {@<-}
@@ -42,13 +42,13 @@
     {fltk::Button} {} {
       label grow
       callback {fltk::Window* w = o->window();
-w->size(w->w()+20, w->h()+20);}
+w->resize(w->w()+20, w->h()+20);}
       xywh {30 129 108 40} labelfont 1 labelsize 18
     }
     {fltk::Button} {} {
       label shrink
       callback {fltk::Window* w = o->window();
-w->size(w->w()-20, w->h()-20);} selected
+w->resize(w->w()-20, w->h()-20);}
       xywh {30 188 108 40} labelfont 1 labelsize 18
     }
   }

Modified: trunk/test/resize.h
===================================================================
--- trunk/test/resize.h 2007-06-20 13:07:23 UTC (rev 5917)
+++ trunk/test/resize.h 2007-06-26 18:49:21 UTC (rev 5918)
@@ -1,4 +1,4 @@
-// generated by Fast Light User Interface Designer (fluid) version 2.0002
+// generated by Fast Light User Interface Designer (fluid) version 2.1000
 
 #ifndef resize_h
 #define resize_h

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

Reply via email to