summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2019-05-26 19:11:02 (GMT)
committerfvogel <fvogelnew1@free.fr>2019-05-26 19:11:02 (GMT)
commitb450dcba5a91d6d3f4514306af14a2df22505ee7 (patch)
tree1ebfe9657383599acd58f593ea33450eeb569226 /generic
parent075c8c77b5d81bbd425891f8b107b647a6f85254 (diff)
parent9e395306396549a5ef50de28a5bafad4ee00faed (diff)
downloadtk-b450dcba5a91d6d3f4514306af14a2df22505ee7.zip
tk-b450dcba5a91d6d3f4514306af14a2df22505ee7.tar.gz
tk-b450dcba5a91d6d3f4514306af14a2df22505ee7.tar.bz2
Fix [ce470f20fd]: ttk::treeview has column dragging issues
Diffstat (limited to 'generic')
-rw-r--r--generic/ttk/ttkTreeview.c48
1 files changed, 39 insertions, 9 deletions
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index daee5db..7ca7f0c 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -280,7 +280,7 @@ static Tk_OptionSpec ColumnOptionSpecs[] = {
0,0,0 },
{TK_OPTION_BOOLEAN, "-stretch", "stretch", "Stretch",
"1", -1, Tk_Offset(TreeColumn,stretch),
- 0,0,0 },
+ 0,0,GEOMETRY_CHANGED },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
"w", Tk_Offset(TreeColumn,anchorObj), -1, /* <<NOTE-ANCHOR>> */
0,0,0 },
@@ -1232,11 +1232,10 @@ static int ConfigureColumn(
TtkResizeWidget(&tv->core);
}
RecomputeSlack(tv);
+ ResizeColumns(tv, TreeWidth(tv));
}
TtkRedisplayWidget(&tv->core);
- /* ASSERT: SLACKINVARIANT */
-
Tk_FreeSavedOptions(&savedOptions);
return TCL_OK;
@@ -1613,13 +1612,10 @@ static void TreeviewDoLayout(void *clientData)
Treeview *tv = clientData;
int visibleRows;
- /* ASSERT: SLACKINVARIANT */
-
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);
- /* ASSERT: SLACKINVARIANT */
TtkScrolled(tv->tree.xscrollHandle,
tv->tree.xscroll.first,
@@ -2889,9 +2885,28 @@ static int TreeviewDragCommand(
TreeColumn *c = tv->tree.displayColumns[i];
int right = left + c->width;
if (c == column) {
- DragColumn(tv, i, newx - right);
- /* ASSERT: SLACKINVARIANT */
- TtkRedisplayWidget(&tv->core);
+ /* 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;
@@ -2903,6 +2918,20 @@ static int TreeviewDragCommand(
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
*/
@@ -3252,6 +3281,7 @@ static const Ttk_Ensemble TreeviewCommands[] = {
{ "delete", TreeviewDeleteCommand,0 },
{ "detach", TreeviewDetachCommand,0 },
{ "drag", TreeviewDragCommand,0 },
+ { "drop", TreeviewDropCommand,0 },
{ "exists", TreeviewExistsCommand,0 },
{ "focus", TreeviewFocusCommand,0 },
{ "heading", TreeviewHeadingCommand,0 },