Skip to content

Commit

Permalink
Fix [a9e637f1c8]: ttk::treeview does not show partial bottom row
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Jan 5, 2024
2 parents ea8d732 + 89d9617 commit d125895
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions generic/ttk/ttkTreeview.c
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ static Ttk_Layout TreeviewGetLayout(
static void TreeviewDoLayout(void *clientData)
{
Treeview *tv = clientData;
int visibleRows;
int totalRows, visibleRows;

Ttk_PlaceLayout(tv->core.layout,tv->core.state,Ttk_WinBox(tv->core.tkwin));
tv->tree.treeArea = Ttk_ClientRegion(tv->core.layout, "treearea");
Expand All @@ -1636,12 +1636,22 @@ static void TreeviewDoLayout(void *clientData)
tv->tree.headingArea = Ttk_MakeBox(0,0,0,0);
}

visibleRows = tv->tree.treeArea.height / tv->tree.rowHeight;
tv->tree.root->state |= TTK_STATE_OPEN;
totalRows = CountRows(tv->tree.root) - 1;
visibleRows = tv->tree.treeArea.height / tv->tree.rowHeight;
if (tv->tree.treeArea.height % tv->tree.rowHeight) {
/* When the treeview height doesn't correspond to an exact number
* of rows, the visible row count must be incremented to draw a
* partial row at the bottom. The total row count must also be
* incremented to be able to scroll all the way to the bottom.
*/
visibleRows++;
totalRows++;
}
TtkScrolled(tv->tree.yscrollHandle,
tv->tree.yscroll.first,
tv->tree.yscroll.first + visibleRows,
CountRows(tv->tree.root) - 1);
totalRows);
}

/* + TreeviewSize --
Expand Down

0 comments on commit d125895

Please sign in to comment.