diff options
Diffstat (limited to 'src/Fl_Tree_Item.cxx')
| -rw-r--r-- | src/Fl_Tree_Item.cxx | 25 |
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 { |
