Browse Source

Have menu items drawn with same colors in all platforms (#969)

Also, remove this text from the doc of Fl_Menu_::down_box()
    "If this is FL_NO_BOX then it acts like
    FL_THIN_UP_BOX and selection_color() acts like
    FL_WHITE, for back compatibility."
that was true only for the Windows platform and that required
selection_color to be replaced by white for menu items which is
not what FLTK 1.4 expects.

The new state of menu item drawings is as follows :
- all platforms draw menu items with the same symbolic colors
- selected items and menu titles are drawn with the selection color
as background color
- menu items are drawn by default with no box but can be given one
by Fl_Menu_::down_box(Fl_Boxtype)
- the text of selected items is drawn with the menu's color
unless fl_contrast() finds it does not make enough contrast with
the background (selection color) and substitutes it with a more
adapted color
- the Windows platform uses a visibly different hue for its default
selection color from what other platforms use
pull/974/head
ManoloFLTK 1 year ago
parent
commit
d428a00443
  1. 4
      FL/Fl_Menu_.H
  2. 10
      src/Fl_Menu.cxx

4
FL/Fl_Menu_.H

@ -228,9 +228,7 @@ public:
/** /**
This box type is used to surround the currently-selected items in the This box type is used to surround the currently-selected items in the
menus. If this is FL_NO_BOX then it acts like menus.
FL_THIN_UP_BOX and selection_color() acts like
FL_WHITE, for back compatibility.
*/ */
Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;} Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
/** Sets the box type used to surround the currently-selected items in the menus. */ /** Sets the box type used to surround the currently-selected items in the menus. */

10
src/Fl_Menu.cxx

@ -285,17 +285,7 @@ void Fl_Menu_Item::draw(int x, int y, int w, int h, const Fl_Menu_* m,
if (selected) { if (selected) {
Fl_Color r = m ? m->selection_color() : FL_SELECTION_COLOR; Fl_Color r = m ? m->selection_color() : FL_SELECTION_COLOR;
Fl_Boxtype b = m && m->down_box() ? m->down_box() : FL_FLAT_BOX; Fl_Boxtype b = m && m->down_box() ? m->down_box() : FL_FLAT_BOX;
if (fl_contrast(r, color) != r) { // back compatibility boxtypes
if (selected == 2) { // menu title
r = color;
b = m ? m->box() : FL_UP_BOX;
} else {
r = (Fl_Color)(FL_COLOR_CUBE-1); // white
l.color = fl_contrast((Fl_Color)labelcolor_, r);
}
} else {
l.color = fl_contrast((Fl_Color)labelcolor_, r); l.color = fl_contrast((Fl_Color)labelcolor_, r);
}
if (selected == 2) { // menu title if (selected == 2) { // menu title
fl_draw_box(b, x, y, w, h, r); fl_draw_box(b, x, y, w, h, r);
x += 3; x += 3;

Loading…
Cancel
Save