Fix horiz connection lines (#1008)

This commit is contained in:
Greg Ercolano 2024-07-08 12:13:44 -07:00
parent 317e06e5a3
commit 6776f89872
2 changed files with 18 additions and 22 deletions

View File

@ -714,13 +714,11 @@ void Fl_Tree_Item::draw_horizontal_connector(int x1, int x2, int y, const Fl_Tre
fl_color(prefs.connectorcolor()); fl_color(prefs.connectorcolor());
switch ( prefs.connectorstyle() ) { switch ( prefs.connectorstyle() ) {
case FL_TREE_CONNECTOR_SOLID: case FL_TREE_CONNECTOR_SOLID:
y |= 1; // force alignment w/dot pattern
fl_line(x1,y,x2,y); fl_line(x1,y,x2,y);
return; return;
case FL_TREE_CONNECTOR_DOTTED: case FL_TREE_CONNECTOR_DOTTED:
{ {
y |= 1; // force alignment w/dot pattern x1 |= 1; // force alignment w/dot pattern
x1 |= 1;
for ( int xx=x1; xx<=x2; xx+=2 ) { for ( int xx=x1; xx<=x2; xx+=2 ) {
fl_point(xx, y); fl_point(xx, y);
} }
@ -990,7 +988,7 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus,
// Note: calculate collapse icon's xywh for possible mouse click detection. // Note: calculate collapse icon's xywh for possible mouse click detection.
// We don't care about items clipped off the viewport; they won't get mouse events. // We don't care about items clipped off the viewport; they won't get mouse events.
// //
int item_y_center = Y+(H/2); int item_y_center = Y+(H/2)|1; // |1: force alignment w/dot pattern
_collapse_xywh[2] = prefs.openicon_w(); _collapse_xywh[2] = prefs.openicon_w();
int &icon_w = _collapse_xywh[2]; int &icon_w = _collapse_xywh[2];
_collapse_xywh[0] = X + (icon_w + prefs.connectorwidth())/2 - 3; _collapse_xywh[0] = X + (icon_w + prefs.connectorwidth())/2 - 3;
@ -1064,10 +1062,8 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus,
if ( (tree()->damage() & ~FL_DAMAGE_CHILD) || !render ) { // non-child damage? if ( (tree()->damage() & ~FL_DAMAGE_CHILD) || !render ) { // non-child damage?
// Draw connectors // Draw connectors
if ( render && prefs.connectorstyle() != FL_TREE_CONNECTOR_NONE ) { if ( render && prefs.connectorstyle() != FL_TREE_CONNECTOR_NONE ) {
// Horiz connector between center of icon and text // Horiz connector to center of icon
// if this is root, the connector should not dangle in thin air on the left draw_horizontal_connector(hconn_x, hconn_x_center, item_y_center, prefs);
if (is_root()) draw_horizontal_connector(hconn_x_center, hconn_x2, item_y_center, prefs);
else draw_horizontal_connector(hconn_x, hconn_x2, item_y_center, prefs);
// Small vertical line down to children // Small vertical line down to children
if ( has_children() && is_open() ) if ( has_children() && is_open() )
draw_vertical_connector(hconn_x_center, item_y_center, Y+H2, prefs); draw_vertical_connector(hconn_x_center, item_y_center, Y+H2, prefs);

View File

@ -523,17 +523,17 @@ tree->redraw();}
"11 11 2 1", "11 11 2 1",
". c None", ". c None",
"@ c \#000000", "@ c \#000000",
"...@.......", "...........",
"...@@......", "....@......",
"...@@@.....", "....@@.....",
"...@@@@....", "....@@@....",
"...@@@@@...", "....@@@@...",
"...@@@@@@..", "....@@@@@..",
"...@@@@@...", "....@@@@...",
"...@@@@....", "....@@@....",
"...@@@.....", "....@@.....",
"...@@......", "....@......",
"...@......." "..........."
\#endif \#endif
}; };
static Fl_Pixmap L_openpixmap(L_open_xpm); static Fl_Pixmap L_openpixmap(L_open_xpm);
@ -563,13 +563,13 @@ static const char *L_close_xpm[] = {
"...........", "...........",
"...........", "...........",
"...........", "...........",
"...........",
"@@@@@@@@@@@",
".@@@@@@@@@.", ".@@@@@@@@@.",
"..@@@@@@@..", "..@@@@@@@..",
"...@@@@@...", "...@@@@@...",
"....@@@....", "....@@@....",
".....@....." ".....@.....",
"...........",
"..........."
\#endif \#endif
}; };
static Fl_Pixmap L_closepixmap(L_close_xpm); static Fl_Pixmap L_closepixmap(L_close_xpm);