Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix [ce470f20fd]: ttk::treeview has column dragging issues |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8a782f3b2d3f1887d713743c037550ed |
User & Date: | fvogel 2019-05-26 19:11:02.895 |
Context
2019-05-26
| ||
21:08 | Cleanup to avoid bad interaction between recently added treeview tests. Also, fix error in the spelling of the Windows windowingsystem check-in: 36a8dbb3 user: fvogel tags: trunk | |
19:11 | Fix [ce470f20fd]: ttk::treeview has column dragging issues check-in: 8a782f3b user: fvogel tags: trunk | |
19:10 | Fix [ce470f20fd]: ttk::treeview has column dragging issues check-in: 0e9cbdba user: fvogel tags: core-8-6-branch | |
19:06 | Fix [2a6c62afd9] - <<TreeviewSelect>> does not fire on item delete check-in: 27092202 user: fvogel tags: trunk | |
Changes
Changes to doc/ttk_treeview.n.
︙ | ︙ | |||
129 130 131 132 133 134 135 | .RS .TP \fB\-id \fIname\fR The column name. This is a read-only option. For example, [\fI$pathname \fBcolumn #\fIn \fB\-id\fR] returns the data column associated with display column #\fIn\fR. .TP | | | | | | | | > > | | > > | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | .RS .TP \fB\-id \fIname\fR The column name. This is a read-only option. For example, [\fI$pathname \fBcolumn #\fIn \fB\-id\fR] returns the data column associated with display column #\fIn\fR. .TP \fB\-anchor \fIanchor\fR Specifies how the text in this column should be aligned with respect to the cell. \fIAnchor\fR is one of \fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR, \fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, or \fBcenter\fR. .TP \fB\-minwidth \fIminwidth\fR The minimum width of the column in pixels. The treeview widget will not make the column any smaller than \fB\-minwidth\fR when the widget is resized or the user drags a column separator. Default is 20 pixels. .TP \fB\-stretch \fIboolean\fR Specifies whether or not the column width should be adjusted when the widget is resized or the user drags a column separator. \fIBoolean\fR may have any of the forms accepted by \fBTcl_GetBoolean\fR. By default columns are stretchable. .TP \fB\-width \fIwidth\fR The width of the column in pixels. Default is 200 pixels. The specified column width may be changed by Tk in order to honor \fB\-stretch\fR and/or \fB\-minwidth\fR, or when the widget is resized or the user drags a column separator. .PP Use \fIpathname column #0\fR to configure the tree column. .RE .TP \fIpathname \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? Modify or query widget options; see \fIttk::widget(n)\fR. .TP |
︙ | ︙ |
Changes to generic/ttk/ttkTreeview.c.
︙ | ︙ | |||
276 277 278 279 280 281 282 | DEF_COLWIDTH, -1, Tk_Offset(TreeColumn,width), 0,0,GEOMETRY_CHANGED }, {TK_OPTION_INT, "-minwidth", "minWidth", "MinWidth", DEF_MINWIDTH, -1, Tk_Offset(TreeColumn,minWidth), 0,0,0 }, {TK_OPTION_BOOLEAN, "-stretch", "stretch", "Stretch", "1", -1, Tk_Offset(TreeColumn,stretch), | | | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | DEF_COLWIDTH, -1, Tk_Offset(TreeColumn,width), 0,0,GEOMETRY_CHANGED }, {TK_OPTION_INT, "-minwidth", "minWidth", "MinWidth", DEF_MINWIDTH, -1, Tk_Offset(TreeColumn,minWidth), 0,0,0 }, {TK_OPTION_BOOLEAN, "-stretch", "stretch", "Stretch", "1", -1, Tk_Offset(TreeColumn,stretch), 0,0,GEOMETRY_CHANGED }, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "w", Tk_Offset(TreeColumn,anchorObj), -1, /* <<NOTE-ANCHOR>> */ 0,0,0 }, {TK_OPTION_STRING, "-id", "id", "ID", NULL, Tk_Offset(TreeColumn,idObj), -1, TK_OPTION_NULL_OK,0,READONLY_OPTION }, {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0} |
︙ | ︙ | |||
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 | * geometry jumping during interactive column resize. */ if (mask & GEOMETRY_CHANGED) { if (!Tk_IsMapped(tv->core.tkwin)) { TtkResizeWidget(&tv->core); } RecomputeSlack(tv); } TtkRedisplayWidget(&tv->core); | > < < | 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 | * geometry jumping during interactive column resize. */ if (mask & GEOMETRY_CHANGED) { if (!Tk_IsMapped(tv->core.tkwin)) { TtkResizeWidget(&tv->core); } RecomputeSlack(tv); ResizeColumns(tv, TreeWidth(tv)); } TtkRedisplayWidget(&tv->core); Tk_FreeSavedOptions(&savedOptions); return TCL_OK; error: Tk_RestoreSavedOptions(&savedOptions); return TCL_ERROR; } |
︙ | ︙ | |||
1609 1610 1611 1612 1613 1614 1615 | * Invokes scroll callbacks. */ static void TreeviewDoLayout(void *clientData) { Treeview *tv = clientData; int visibleRows; | < < < | 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 | * Invokes scroll callbacks. */ static void TreeviewDoLayout(void *clientData) { Treeview *tv = clientData; int visibleRows; Ttk_PlaceLayout(tv->core.layout,tv->core.state,Ttk_WinBox(tv->core.tkwin)); tv->tree.treeArea = Ttk_ClientRegion(tv->core.layout, "treearea"); ResizeColumns(tv, tv->tree.treeArea.width); TtkScrolled(tv->tree.xscrollHandle, tv->tree.xscroll.first, tv->tree.xscroll.first + tv->tree.treeArea.width, TreeWidth(tv)); if (tv->tree.showFlags & SHOW_HEADINGS) { |
︙ | ︙ | |||
2885 2886 2887 2888 2889 2890 2891 | return TCL_ERROR; } for (;i < tv->tree.nDisplayColumns; ++i) { TreeColumn *c = tv->tree.displayColumns[i]; int right = left + c->width; if (c == column) { | > > > > > > > > > > > > > > > > > > > | < | > > > > > > > > > > > > > > > | 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 | return TCL_ERROR; } for (;i < tv->tree.nDisplayColumns; ++i) { TreeColumn *c = tv->tree.displayColumns[i]; int right = left + c->width; if (c == column) { /* The limit not to exceed at the right is given by the tree width minus the sum of the min widths of the columns at the right of the one being resized (and don't forget possible x scrolling!). For stretchable columns, this min width really is the minWidth, for non-stretchable columns, this is the column width. */ int newxRightLimit = tv->tree.treeArea.x - tv->tree.xscroll.first + tv->tree.treeArea.width; int j = i + 1; while (j < tv->tree.nDisplayColumns) { TreeColumn *cr = tv->tree.displayColumns[j]; if (cr->stretch) { newxRightLimit -= cr->minWidth; } else { newxRightLimit -= cr->width; } ++j; } if (newx <= newxRightLimit) { DragColumn(tv, i, newx - right); TtkRedisplayWidget(&tv->core); } return TCL_OK; } left = right; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "column %s is not displayed", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN_INVISIBLE", NULL); return TCL_ERROR; } static int TreeviewDropCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = recordPtr; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "drop"); return TCL_ERROR; } ResizeColumns(tv, TreeWidth(tv)); TtkRedisplayWidget(&tv->core); return TCL_OK; } /*------------------------------------------------------------------------ * +++ Widget commands -- focus and selection */ /* + $tree focus ?item? */ |
︙ | ︙ | |||
3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 | { "children", TreeviewChildrenCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, { "column", TreeviewColumnCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "delete", TreeviewDeleteCommand,0 }, { "detach", TreeviewDetachCommand,0 }, { "drag", TreeviewDragCommand,0 }, { "exists", TreeviewExistsCommand,0 }, { "focus", TreeviewFocusCommand,0 }, { "heading", TreeviewHeadingCommand,0 }, { "identify", TreeviewIdentifyCommand,0 }, { "index", TreeviewIndexCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "insert", TreeviewInsertCommand,0 }, | > | 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 | { "children", TreeviewChildrenCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, { "column", TreeviewColumnCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "delete", TreeviewDeleteCommand,0 }, { "detach", TreeviewDetachCommand,0 }, { "drag", TreeviewDragCommand,0 }, { "drop", TreeviewDropCommand,0 }, { "exists", TreeviewExistsCommand,0 }, { "focus", TreeviewFocusCommand,0 }, { "heading", TreeviewHeadingCommand,0 }, { "identify", TreeviewIdentifyCommand,0 }, { "index", TreeviewIndexCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "insert", TreeviewInsertCommand,0 }, |
︙ | ︙ |
Changes to library/ttk/treeview.tcl.
︙ | ︙ | |||
201 202 203 204 205 206 207 | proc ttk::treeview::resize.drag {w x} { variable State $w drag $State(resizeColumn) $x } proc ttk::treeview::resize.release {w x} { | | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | proc ttk::treeview::resize.drag {w x} { variable State $w drag $State(resizeColumn) $x } proc ttk::treeview::resize.release {w x} { $w drop } ### Heading activation. # proc ttk::treeview::heading.press {w x y} { variable State |
︙ | ︙ |
Changes to tests/ttk/treeview.test.
︙ | ︙ | |||
685 686 687 688 689 690 691 692 693 | event generate .tv <ButtonPress-1> \ -x [expr ($x + $h / 2)] \ -y [expr ($y + $h / 2)] lappend res [.tv item foo -open] .tv insert foo end -text "sub" lappend res [.tv item foo -open] } -result {0 0 0} tcltest::cleanupTests | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 | event generate .tv <ButtonPress-1> \ -x [expr ($x + $h / 2)] \ -y [expr ($y + $h / 2)] lappend res [.tv item foo -open] .tv insert foo end -text "sub" lappend res [.tv item foo -open] } -result {0 0 0} test treeview-ce470f20fd-1 "dragging further than the right edge of the treeview is forbidden" -setup { pack [ttk::treeview .tv] .tv heading #0 -text "Drag my right edge -->" update } -body { set res [.tv column #0 -width] .tv drag #0 400 lappend res [expr {[.tv column #0 -width] > $res}] } -cleanup { destroy .tv } -result {200 0} proc nostretch {tv} { foreach col [$tv cget -columns] { $tv column $col -stretch 0 } $tv column #0 -stretch 0 update idletasks ; # redisplay $tv } test treeview-ce470f20fd-2 "changing -stretch resizes columns" -setup { pack [ttk::treeview .tv -columns {bar colA colB colC foo}] foreach col [.tv cget -columns] { .tv heading $col -text $col } nostretch .tv .tv column colA -width 50 ; .tv column colB -width 50 ; # slack created update idletasks ; # redisplay treeview } -body { # when no column is stretchable and one of them becomes stretchable # the stretchable column takes the slack and the widget is redisplayed # automatically at idle time set res [.tv column colA -width] .tv column colA -stretch 1 update idletasks ; # no slack anymore, widget redisplayed lappend res [expr {[.tv column colA -width] > $res}] } -cleanup { destroy .tv } -result {50 1} test treeview-ce470f20fd-3 "changing -stretch resizes columns" -setup { pack [ttk::treeview .tv -columns {bar colA colB colC foo}] foreach col [.tv cget -columns] { .tv heading $col -text $col } .tv configure -displaycolumns {colB colA colC} nostretch .tv .tv column colA -width 50 ; .tv column colB -width 50 ; # slack created update idletasks ; # redisplay treeview } -body { # only some columns are displayed (and in a different order than declared # in -columns), a displayed column becomes stretchable --> the stretchable # column expands set res [.tv column colA -width] .tv column colA -stretch 1 update idletasks ; # no slack anymore, widget redisplayed lappend res [expr {[.tv column colA -width] > $res}] } -cleanup { destroy .tv } -result {50 1} test treeview-ce470f20fd-4 "changing -stretch resizes columns" -setup { pack [ttk::treeview .tv -columns {bar colA colB colC foo}] foreach col [.tv cget -columns] { .tv heading $col -text $col } .tv configure -displaycolumns {colB colA colC} nostretch .tv .tv column colA -width 50 ; .tv column bar -width 60 ; # slack created update idletasks ; # redisplay treeview } -body { # only some columns are displayed (and in a different order than declared # in -columns), a non-displayed column becomes stretchable --> nothing # happens set origTreeWidth [winfo width .tv] set res [list [.tv column bar -width] [.tv column colA -width]] .tv column bar -stretch 1 update idletasks ; # no change, widget redisplayed lappend res [.tv column bar -width] [.tv column colA -width] # this column becomes visible --> widget resizes .tv configure -displaycolumns {bar colC colA colB} update idletasks ; # no slack anymore because the widget resizes (shrinks) lappend res [.tv column bar -width] [.tv column colA -width] \ [expr {[winfo width .tv] < $origTreeWidth}] } -cleanup { destroy .tv } -result {60 50 60 50 60 50 1} tcltest::cleanupTests |