From aa0e4bb823949946ad4153b8d7eecbff0662553d Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Sun, 25 Dec 2011 17:51:50 +0000 Subject: [PATCH] Small fix for vertical connectors between far away items, as noted by Christophe. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9217 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Tree_Item.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx index 521daee53..f37a20c55 100644 --- a/src/Fl_Tree_Item.cxx +++ b/src/Fl_Tree_Item.cxx @@ -547,6 +547,8 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, Fl_Tree_Item *itemfocus, const Fl_Tree_Prefs &prefs, int lastchild) { if ( ! _visible ) return; + int tree_top = tree->y(); + int tree_bot = tree_top + tree->h(); fl_font(_labelfont, _labelsize); int H = _labelsize; if(usericon() && H < usericon()->h()) H = usericon()->h(); @@ -586,7 +588,7 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, // 'clipped' is an optimization to prevent drawing anything offscreen. // char drawthis = ( is_root() && prefs.showroot() == 0 ) ? 0 : 1; - char clipped = ((Y+H) < tree->y()) || (Y>(tree->y()+tree->h())) ? 1 : 0; + char clipped = ((Y+H) < tree_top) || (Y>tree_bot) ? 1 : 0; if ( drawthis ) { // Draw connectors if ( prefs.connectorstyle() != FL_TREE_CONNECTOR_NONE ) { @@ -696,6 +698,9 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, Y += prefs.openchild_marginbottom(); // offset below open child tree } if ( ! lastchild ) { + // Special 'clipped' calculation. (intentional variable shadowing) + int clipped = ((child_y_start < tree_top) && (Y < tree_top)) || + ((child_y_start > tree_bot) && (Y > tree_bot)); if (!clipped) draw_vertical_connector(hstartx, child_y_start, Y, prefs); } }