FLTK logo

[master] b684f70 - Update remaining "arrow drawing" in menus

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 ]

[master] b684f70 - Update remaining "arrow drawing" in menus "Albrecht Schlosser" Nov 23, 2022  
 
commit b684f70ad75701f3d3436157b75c6f2650d6a97b
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Wed Nov 23 15:18:19 2022 +0100
Commit:     Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Wed Nov 23 15:21:34 2022 +0100

    Update remaining "arrow drawing" in menus
    
    Use the new standard arrow drawing methods (whose style depends on
    the active scheme) for "arrows" used in Fl_Menu and Fl_Menu_Button.
    
    To do: maybe we need some "fine tuning" of arrow sizes in some of
    the modified widgets using the new "arrow drawing" methods.

 src/Fl_Menu.cxx        | 15 ++++++++++++++-
 src/Fl_Menu_Button.cxx | 19 +++++++++++++++++--
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git src/Fl_Menu.cxx src/Fl_Menu.cxx
index f2d19a7..6e6d26d 100644
--- src/Fl_Menu.cxx
+++ src/Fl_Menu.cxx
@@ -476,6 +476,10 @@ void menuwindow::autoscroll(int n) {
 void menuwindow::drawentry(const Fl_Menu_Item* m, int n, int eraseit) {
   if (!m) return; // this happens if -1 is selected item and redrawn
 
+  // FIXME: size and coordinate calculation (sz, x1, y1) should be simplified when
+  //        the "old code" below is entirely removed (left as is for comparison).
+  //        AlbrechtS Nov. 23, 2022
+
   int BW = Fl::box_dx(box());
   int xx = BW;
   int W = w();
@@ -496,8 +500,17 @@ void menuwindow::drawentry(const Fl_Menu_Item* m, int n, int eraseit) {
     int sz = (hh-7)&-2;
     int y1 = yy+(hh-sz)/2;
     int x1 = xx+ww-sz-3;
-    // FIXME_ARROW: use fl_draw_arrow()
+
+#if (0) // old code, independent of active scheme (left for comparison)
+
     fl_polygon(x1+2, y1, x1+2, y1+sz, x1+sz/2+2, y1+sz/2);
+
+#else // right arrow whose style dependends on the active scheme
+
+    fl_draw_arrow(Fl_Rect(x1-1, y1-1, sz+2, sz+2), FL_ARROW_SINGLE, FL_ORIENT_RIGHT, fl_color());
+
+#endif
+
   } else if (m->shortcut_) {
     Fl_Font f = m->labelsize_ || m->labelfont_ ? (Fl_Font)m->labelfont_ :
                     button ? button->textfont() : FL_HELVETICA;
diff --git src/Fl_Menu_Button.cxx src/Fl_Menu_Button.cxx
index dadbaf5..f57b52b 100644
--- src/Fl_Menu_Button.cxx
+++ src/Fl_Menu_Button.cxx
@@ -16,6 +16,7 @@
 
 #include <FL/Fl.H>
 #include <FL/Fl_Menu_Button.H>
+#include <FL/Fl_Rect.H>
 #include <FL/fl_draw.H>
 
 
@@ -24,18 +25,32 @@ static Fl_Menu_Button   *pressed_menu_button_ = 0;
 
 void Fl_Menu_Button::draw() {
   if (!box() || type()) return;
+
+  // FIXME: size and coordinate calculation (H, X, Y) should be simplified when
+  //        the "old code" below is entirely removed (left as is for comparison).
+  //        AlbrechtS Nov. 23, 2022
+
   int H = (labelsize()-3)&-2;
   int X = x()+w()-H-Fl::box_dx(box())-Fl::box_dw(box())-1;
   int Y = y()+(h()-H)/2;
+
   draw_box(pressed_menu_button_ == this ? fl_down(box()) : box(), color());
   draw_label(x()+Fl::box_dx(box()), y(), X-x()+2, h());
   if (Fl::focus() == this) draw_focus();
-  // ** if (box() == FL_FLAT_BOX) return; // for XForms compatibility
-  // FIXME_ARROW: use fl_draw_arrow()
+
+#if (0) // old code: outline of an engraved down-arrow for all schemes
+
   fl_color(active_r() ? FL_DARK3 : fl_inactive(FL_DARK3));
   fl_line(X+H/2, Y+H, X, Y, X+H, Y);
   fl_color(active_r() ? FL_LIGHT3 : fl_inactive(FL_LIGHT3));
   fl_line(X+H, Y, X+H/2, Y+H);
+
+#else // new code: filled down-arrow whose style dependends on the current scheme
+
+  Fl_Color arrow_color = active_r() ? FL_DARK3 : fl_inactive(FL_DARK3);
+  fl_draw_arrow(Fl_Rect(X-1, Y-1, H+4, H+4), FL_ARROW_SINGLE, FL_ORIENT_DOWN, arrow_color);
+
+#endif
 }
 
 
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'.