diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2010-07-10 09:44:45 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2010-07-10 09:44:45 +0000 |
| commit | 32716d6b1e8a90cbe61b60994323029ec6abe85c (patch) | |
| tree | 9c047f9cbf6a6581ef408dfabdab0aebde240a1b /src/Fl_Tree_Item.cxx | |
| parent | 8306c3d0b31d4e60a9ba9c4d0ca4ed6a32226de1 (diff) | |
Updated the Fluid IDE support for the current source file structure. Changed the Fl_Tree rendering code around a bit to make the tree more like MSWindows on Windows and more like Apple on Apple machines. I hope you guys like it. I also moved the function to load Fl_Preferences into an Fl_Tree into the Fl_Tree class where it belongs.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7672 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Tree_Item.cxx')
| -rw-r--r-- | src/Fl_Tree_Item.cxx | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx index 18a1cfac4..24f33cd2c 100644 --- a/src/Fl_Tree_Item.cxx +++ b/src/Fl_Tree_Item.cxx @@ -481,6 +481,11 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, int H = _labelsize; if(usericon() && H < usericon()->h()) H = usericon()->h(); H += prefs.linespacing() + fl_descent(); + // adjust horizontally if we draw no connecting lines + if ( is_root() && prefs.connectorstyle() == FL_TREE_CONNECTOR_NONE ) { + X -= prefs.openicon()->w(); + W += prefs.openicon()->w(); + } // Colors, fonts Fl_Color fg = _selected ? prefs.bgcolor() : _labelfgcolor; Fl_Color bg = _selected ? prefs.selectcolor() : _labelbgcolor; @@ -497,9 +502,9 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, int textw=0, texth=0; fl_measure(_label, textw, texth, 0); int textycenter = Y+(H/2); - int &icon_x = _collapse_xywh[0] = X-1; - int &icon_y = _collapse_xywh[1] = textycenter - (prefs.openicon()->h()/2); int &icon_w = _collapse_xywh[2] = prefs.openicon()->w(); + int &icon_x = _collapse_xywh[0] = X + (icon_w + prefs.connectorwidth())/2 - 3; + int &icon_y = _collapse_xywh[1] = textycenter - (prefs.openicon()->h()/2); _collapse_xywh[3] = prefs.openicon()->h(); // Horizontal connector values int hstartx = X+icon_w/2-1; @@ -514,7 +519,11 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, // Draw connectors if ( prefs.connectorstyle() != FL_TREE_CONNECTOR_NONE ) { // Horiz connector between center of icon and text - draw_horizontal_connector(hstartx, hendx, textycenter, prefs); + // if this is root, the connector should not dangle in thin air on the left + if (is_root()) + draw_horizontal_connector(hcenterx, hendx, textycenter, prefs); + else + draw_horizontal_connector(hstartx, hendx, textycenter, prefs); if ( has_children() && is_open() ) { // Small vertical line down to children draw_vertical_connector(hcenterx, textycenter, Y+H, prefs); @@ -538,9 +547,11 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, } } // Background for this item - int &bx = _label_xywh[0] = X+(icon_w/2-1+prefs.connectorwidth()); + int cw1 = icon_w+prefs.connectorwidth()/2, cw2 = prefs.connectorwidth(); + int cwidth = cw1>cw2 ? cw1 : cw2; + int &bx = _label_xywh[0] = X+(icon_w/2-1+cwidth); int &by = _label_xywh[1] = Y; - int &bw = _label_xywh[2] = W-(icon_w/2-1+prefs.connectorwidth()); + int &bw = _label_xywh[2] = W-(icon_w/2-1+cwidth); int &bh = _label_xywh[3] = H; // Draw bg only if different from tree's bg if ( bg != tree->color() || is_selected() ) { @@ -554,7 +565,7 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, } } // Draw user icon (if any) - int useroff = (icon_w/2-1+prefs.connectorwidth()); + int useroff = (icon_w/2-1+cwidth); if ( usericon() ) { // Item has user icon? Use it useroff += prefs.usericonmarginleft(); |
