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_Prefs.cxx | 88 +++++++++++---------------------------------------- 1 file changed, 19 insertions(+), 69 deletions(-) (limited to 'src/Fl_Tree_Prefs.cxx') diff --git a/src/Fl_Tree_Prefs.cxx b/src/Fl_Tree_Prefs.cxx index aa0d17c3b..f34675c9c 100644 --- a/src/Fl_Tree_Prefs.cxx +++ b/src/Fl_Tree_Prefs.cxx @@ -22,12 +22,9 @@ #include "Fl_System_Driver.H" #include -#include +#include #include - -// INTERNAL: BUILT IN OPEN/STOW XPMS -// These can be replaced via prefs.openicon()/closeicon() -// +#include /** \cond DriverDev @@ -35,61 +32,16 @@ \{ */ -const char * const Fl_System_Driver::tree_open_xpm[] = { - "11 11 3 1", - ". c #fefefe", - "# c #444444", - "@ c #000000", - "###########", - "#.........#", - "#.........#", - "#....@....#", - "#....@....#", - "#..@@@@@..#", - "#....@....#", - "#....@....#", - "#.........#", - "#.........#", - "###########" -}; - -const char * const Fl_System_Driver::tree_close_xpm[] = { -"11 11 3 1", -". c #fefefe", -"# c #444444", -"@ c #000000", -"###########", -"#.........#", -"#.........#", -"#.........#", -"#.........#", -"#..@@@@@..#", -"#.........#", -"#.........#", -"#.........#", -"#.........#", -"###########" -}; - - -/** - Return the address of a pixmap that show a plus in a box. - - This pixmap is used to indicate a brach of a tree that is closed and - can be opened by clicking it. - - Other platforms may use other symbols which can be reimplemented in the - driver. Notably, Apple Mac systems mark a closed branch with a triangle - pointing to the right, and an open branch with a triangle pointing down. - */ -Fl_Pixmap *Fl_System_Driver::tree_openpixmap() { - static Fl_Pixmap *pixmap = new Fl_Pixmap(tree_open_xpm); - return pixmap; -} - -Fl_Pixmap *Fl_System_Driver::tree_closepixmap() { - static Fl_Pixmap *pixmap = new Fl_Pixmap(tree_close_xpm); - return pixmap; +// Draw non-OS specific Fl_Tree open/close icons +// ┌───┐ ┌───┐ +// │ + │ │ - │ +// └───┘ └───┘ +void Fl_System_Driver::tree_draw_expando_button(int x, int y, bool state, bool active) { + fl_rectf(x, y, 11, 11, active ? FL_BACKGROUND2_COLOR : fl_inactive(FL_BACKGROUND2_COLOR)); // fill + fl_rect(x, y, 11, 11, FL_INACTIVE_COLOR); // outline + fl_color(active ? FL_FOREGROUND_COLOR : FL_INACTIVE_COLOR); + fl_line(x + 3, y + 5, x + 7, y + 5); // horiz line + if (state) fl_line(x + 5, y + 3, x + 5, y + 7); // vert line } int Fl_System_Driver::tree_connector_style() { @@ -109,7 +61,7 @@ int Fl_System_Driver::tree_connector_style() { /// \param[in] val -- The new image, or zero to use the default [+] icon. /// void Fl_Tree_Prefs::openicon(Fl_Image *val) { - _openimage = val ? val : Fl::system_driver()->tree_openpixmap(); + _openimage = val ? val : 0; // Update deactivated version of icon.. if ( _opendeimage ) delete _opendeimage; if ( _openimage ) { @@ -126,7 +78,7 @@ void Fl_Tree_Prefs::openicon(Fl_Image *val) { /// \param[in] val -- The new image, or zero to use the default [-] icon. /// void Fl_Tree_Prefs::closeicon(Fl_Image *val) { - _closeimage = val ? val : Fl::system_driver()->tree_closepixmap(); + _closeimage = val ? val : 0; // Update deactivated version of icon.. if ( _closedeimage ) delete _closedeimage; if ( _closeimage ) { @@ -151,15 +103,13 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() { _linespacing = 0; _labelfgcolor = FL_FOREGROUND_COLOR; _labelbgcolor = 0xffffffff; // we use this as 'transparent' - _connectorcolor = Fl_Color(43); + _connectorcolor = FL_INACTIVE_COLOR; _connectorstyle = (Fl_Tree_Connector)Fl::system_driver()->tree_connector_style(); - _openimage = Fl::system_driver()->tree_openpixmap(); - _closeimage = Fl::system_driver()->tree_closepixmap(); + _openimage = 0; + _closeimage = 0; _userimage = 0; - _opendeimage = _openimage->copy(); - _opendeimage->inactive(); - _closedeimage = _closeimage->copy(); - _closedeimage->inactive(); + _opendeimage = 0; + _closedeimage = 0; _userdeimage = 0; _showcollapse = 1; _showroot = 1; -- cgit v1.2.3