From a69c5c5c925bb1521d894ef72ca7d99fb2f8f3aa Mon Sep 17 00:00:00 2001 From: Cyprinus Carpio Date: Sun, 30 Jun 2024 18:08:00 +0200 Subject: Fl_Tree +/- buttons are no longer drawn using bitmaps, different default line color (#995) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fl_Tree changed to support system color themes (PR #995) merging CyprinusCarpio's mods carried over from from issue #972. * Fl_Tree: use named (colormap) colors to support system color themes (see issue #972). changed connectorcolor() default from gray ramp color to FL_INACTIVE_COLOR (Fl_Color(8)), and similar named colormap colors for icon drawing. * Fl_Tree ⊞ / ⊟ icons (and on macs, ▶ / ▼icons) are now drawn w/fl_draw() functions instead of with xpm bitmaps for colormap control --------- Co-authored-by: Greg Ercolano --- src/Fl_Tree_Item.cxx | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src/Fl_Tree_Item.cxx') diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx index 544170a32..a9e192692 100644 --- a/src/Fl_Tree_Item.cxx +++ b/src/Fl_Tree_Item.cxx @@ -9,6 +9,7 @@ #include #include #include +#include "Fl_System_Driver.H" ////////////////////// // Fl_Tree_Item.cxx @@ -804,7 +805,7 @@ Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs, int yonly) /// - visibility (if !is_visible(), returns 0) /// - labelfont() height: if label() != NULL /// - widget() height: if widget() != NULL -/// - openicon() height (if not NULL) +/// - openicon() height (if has children) /// - usericon() height (if not NULL) /// Does NOT include Fl_Tree::linespacing(); /// \returns maximum pixel height @@ -821,8 +822,8 @@ int Fl_Tree_Item::calc_item_height(const Fl_Tree_Prefs &prefs) const { H < widget()->h()) { H = widget()->h(); } - if ( has_children() && prefs.openicon() && Hh() ) - H = prefs.openicon()->h(); + if ( has_children() && H < prefs.openicon_h() ) + H = prefs.openicon_h(); if ( usericon() && Hh() ) H = usericon()->h(); return(H); @@ -990,13 +991,13 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus, // We don't care about items clipped off the viewport; they won't get mouse events. // int item_y_center = Y+(H/2); - _collapse_xywh[2] = prefs.openicon()->w(); + _collapse_xywh[2] = prefs.openicon_w(); int &icon_w = _collapse_xywh[2]; _collapse_xywh[0] = X + (icon_w + prefs.connectorwidth())/2 - 3; int &icon_x = _collapse_xywh[0]; - _collapse_xywh[1] = item_y_center - (prefs.openicon()->h()/2); + _collapse_xywh[1] = item_y_center - prefs.openicon_h()/2; int &icon_y = _collapse_xywh[1]; - _collapse_xywh[3] = prefs.openicon()->h(); + _collapse_xywh[3] = prefs.openicon_h(); // Horizontal connector values // Must calculate these even if(clipped) because 'draw children' code (below) @@ -1080,11 +1081,19 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus, if ( render && has_children() && prefs.showcollapse() ) { // Draw icon image if ( is_open() ) { - if ( active ) prefs.closeicon()->draw(icon_x,icon_y); - else prefs.closedeicon()->draw(icon_x,icon_y); + if ( prefs.closeicon() ) { + if ( active ) prefs.closeicon()->draw(icon_x, icon_y); + else prefs.closedeicon()->draw(icon_x, icon_y); + } else { + Fl::system_driver()->tree_draw_expando_button(icon_x, icon_y, false, active); + } } else { - if ( active ) prefs.openicon()->draw(icon_x,icon_y); - else prefs.opendeicon()->draw(icon_x,icon_y); + if ( prefs.openicon() ) { + if ( active ) prefs.openicon()->draw(icon_x, icon_y); + else prefs.opendeicon()->draw(icon_x, icon_y); + } else { + Fl::system_driver()->tree_draw_expando_button(icon_x, icon_y, true, active); + } } } // Draw user icon (if any) -- cgit v1.2.3