Skip to content

Commit

Permalink
Merge fix for [d82fa2953a]: Cosmetic issues when ttk::treeview height…
Browse files Browse the repository at this point in the history
… is not

a full number of lines.
  • Loading branch information
sbron committed Aug 16, 2024
2 parents 972e0f0 + 76bd762 commit d7e3de1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
2 changes: 2 additions & 0 deletions doc/ttk_treeview.n
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ The rectangle defined is removed from the cell selection.
\fIpathname \fBcellselection toggle \fIcellList\fR
.
Toggle the cell selection state of each cell in \fIcellList\fR.
If the element is partially visible, the result gives the full area of the
element, including any parts that are not visible.
.TP
\fIpathname \fBcellselection toggle \fIfirstCell lastCell\fR
.
Expand Down
4 changes: 2 additions & 2 deletions generic/ttk/ttkLabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
b = Ttk_AnchorBox(b, text->width, text->height, anchor);

/*
* Clip text if it's too wide:
* Clip text if it's too wide or too high:
*/
if (b.width < text->width) {
if (b.width < text->width || b.height < text->height) {
XRectangle rect;

clipRegion = TkCreateRegion();
Expand Down
32 changes: 22 additions & 10 deletions generic/ttk/ttkTreeview.c
Original file line number Diff line number Diff line change
Expand Up @@ -1973,15 +1973,6 @@ static void TreeviewDoLayout(void *clientData)
first = tv->tree.yscroll.first;
last = tv->tree.yscroll.first + visibleRows - tv->tree.titleRows;
total = tv->tree.totalRows - tv->tree.titleRows;
if (tv->tree.treeArea.height % tv->tree.rowHeight) {
/* When the treeview height doesn't correspond to an exact number
* of rows, the last 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.
*/
last++;
total++;
}
TtkScrolled(tv->tree.yscrollHandle, first, last, total);
}

Expand Down Expand Up @@ -2186,6 +2177,11 @@ static void DrawCells(
xPad = tv->tree.colSeparatorWidth/2;
}

/* Make sure that the cells won't overlap the border's bottom edge */
if (y + rowHeight > tv->tree.treeArea.y + tv->tree.treeArea.height) {
rowHeight = tv->tree.treeArea.y + tv->tree.treeArea.height - y;
}

/* An Item's image should not propagate to a Cell.
A Cell's image can only be set by cell tags. */
displayItemCell = *displayItem;
Expand Down Expand Up @@ -2273,13 +2269,25 @@ static void DrawItem(
int dispRow = DisplayRow(item->rowPos, tv);
int y = tv->tree.treeArea.y + tv->tree.rowHeight * dispRow;

/* Make sure that the item won't overlap the border's bottom edge:
*/
if (y + rowHeight > tv->tree.treeArea.y + tv->tree.treeArea.height) {
rowHeight = tv->tree.treeArea.y + tv->tree.treeArea.height - y;
}

PrepareItem(tv, item, &displayItem, state);
PrepareItem(tv, item, &displayItemSel, state | TTK_STATE_SELECTED);

/* Draw row background:
*/
{
Ttk_Box rowBox = Ttk_MakeBox(x, y, TreeWidth(tv), rowHeight);
int itemWidth = TreeWidth(tv);
/* Make sure that the background won't overlap the border's right edge:
*/
if (itemWidth > tv->tree.treeArea.width) {
itemWidth = tv->tree.treeArea.width;
}
Ttk_Box rowBox = Ttk_MakeBox(x, y, itemWidth, rowHeight);
DisplayLayout(tv->tree.rowLayout, &displayItem, state, rowBox, d);
}

Expand Down Expand Up @@ -3488,6 +3496,9 @@ static int TreeviewSeeCommand(
UpdatePositionTree(tv);
}

/* Update the scroll information, if necessary */
TtkUpdateScrollInfo(tv->tree.yscrollHandle);

/* Make sure item is visible:
*/
if (item->rowPos < tv->tree.titleRows) {
Expand Down Expand Up @@ -4523,6 +4534,7 @@ static void TreeitemIndicatorSize(

Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginsObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
if (size % 2 == 0) --size; /* An odd size is better for the arrow. */

*widthPtr = size + Ttk_PaddingWidth(margins);
*heightPtr = size + Ttk_PaddingHeight(margins);
Expand Down

0 comments on commit d7e3de1

Please sign in to comment.