summaryrefslogtreecommitdiff
path: root/src/Fl_Tree_Item.cxx
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2019-08-25 01:13:35 -0700
committerGreg Ercolano <erco@seriss.com>2019-08-25 01:13:35 -0700
commit4870cde0a68ccdc5512fc5aef1ac4502dc64476d (patch)
tree60e823eb9e540a586f0607e78fa30be9e1b04453 /src/Fl_Tree_Item.cxx
parenteed1d364d953850e53fc9570bb94ff61ea01086c (diff)
More fixes for STR #3527; handle usericons, etc
Diffstat (limited to 'src/Fl_Tree_Item.cxx')
-rw-r--r--src/Fl_Tree_Item.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx
index d78c3427c..e6819a8ef 100644
--- a/src/Fl_Tree_Item.cxx
+++ b/src/Fl_Tree_Item.cxx
@@ -1190,6 +1190,31 @@ int Fl_Tree_Item::event_on_collapse_icon(const Fl_Tree_Prefs &prefs) const {
}
}
+/// Was the event on the 'user icon' of this item, if any?
+///
+int Fl_Tree_Item::event_on_user_icon(const Fl_Tree_Prefs &prefs) const {
+ // NOTE: Fl_Tree_Item doesn't keep an _xywh[] for usericon, but we can derive it as
+ // by elimitation of all other possibilities.
+ if ( !is_visible() ) return 0; // item not visible? not us
+ if ( !event_inside(_xywh) ) return 0; // not inside item? not us
+ if ( event_on_collapse_icon(prefs) ) return 0; // inside collapse icon? not us
+ if ( Fl::event_x() >= _label_xywh[0] ) return 0; // inside label or beyond (e.g. widget())? not us
+ // Is a user icon being shown?
+ // TBD: Determining usericon xywh and 'if displayed' should be class methods used here and by draw_*()
+ Fl_Image *ui = 0;
+ if ( is_active() ) {
+ if ( usericon() ) ui = usericon(); // user icon for item?
+ else if ( prefs.usericon() ) ui = prefs.usericon(); // user icon for tree?
+ } else {
+ if ( userdeicon() ) ui = userdeicon(); // user deicon for this item?
+ else if ( prefs.userdeicon() ) ui = prefs.userdeicon(); // user deicon for tree?
+ }
+ if ( !ui ) return 0; // no user icon? not us
+ int uix = _label_xywh[0]-ui->w(); // find x position of usericon
+ if ( Fl::event_x() < uix ) return 0; // event left of usericon? not us
+ return 1; // must be inside usericon by elimination
+}
+
/// Was event on the label() of this item?
///
int Fl_Tree_Item::event_on_label(const Fl_Tree_Prefs &prefs) const {