summaryrefslogtreecommitdiff
path: root/src/Fl_Menu_Button.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2022-11-24 19:00:00 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2022-11-25 00:00:48 +0100
commitb1ba37c5ba1df543baa87d328805af34da4bd2b1 (patch)
tree01d6ff63843cd9ed1f58fd2ab201f462bf11a385 /src/Fl_Menu_Button.cxx
parent40f376a6f707e6c5ae69c0f73300575bd79e28e3 (diff)
Add "Oxy" scheme (STR 2675, STR 3477)
This commit is similar to the patch given in STR 3477, oxy_v5.diff: https://www.fltk.org/strfiles/3477/oxy_v5.diff ... with modifications, and updated to current FLTK code.
Diffstat (limited to 'src/Fl_Menu_Button.cxx')
-rw-r--r--src/Fl_Menu_Button.cxx28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/Fl_Menu_Button.cxx b/src/Fl_Menu_Button.cxx
index f57b52b4e..b9dfb666e 100644
--- a/src/Fl_Menu_Button.cxx
+++ b/src/Fl_Menu_Button.cxx
@@ -26,31 +26,23 @@ 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
+ // calculate position and size of virtual "arrow box" (choice button)
- 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;
+ int ah = h() - Fl::box_dh(box());
+ int aw = ah > 20 ? 20 : ah; // limit width: don't waste space for button
+ int ax = x() + w() - Fl::box_dx(box()) - aw;
+ int ay = y() + (h() - ah) / 2;
+
+ // the remaining space is used to draw the label
draw_box(pressed_menu_button_ == this ? fl_down(box()) : box(), color());
- draw_label(x()+Fl::box_dx(box()), y(), X-x()+2, h());
+ draw_label(x() + Fl::box_dx(box()), y(), w() - Fl::box_dw(box()) - aw, h());
if (Fl::focus() == this) draw_focus();
-#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
+ // draw the arrow (choice button)
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
+ fl_draw_arrow(Fl_Rect(ax, ay, aw, ah), FL_ARROW_SINGLE, FL_ORIENT_DOWN, arrow_color);
}