summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2019-05-26 19:10:42 (GMT)
committerfvogel <fvogelnew1@free.fr>2019-05-26 19:10:42 (GMT)
commit9e395306396549a5ef50de28a5bafad4ee00faed (patch)
treeec845a4505a6aecd3a91b66fedbf5d22152ff71c /tests
parent984945146cd760e799a6684917573e4f1175ef08 (diff)
parent3092b520d216d7e37baa5f60db86e7de2ede6b90 (diff)
downloadtk-9e395306396549a5ef50de28a5bafad4ee00faed.zip
tk-9e395306396549a5ef50de28a5bafad4ee00faed.tar.gz
tk-9e395306396549a5ef50de28a5bafad4ee00faed.tar.bz2
Fix [ce470f20fd]: ttk::treeview has column dragging issues
Diffstat (limited to 'tests')
-rw-r--r--tests/ttk/treeview.test88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test
index d2e09b6..e20f28a 100644
--- a/tests/ttk/treeview.test
+++ b/tests/ttk/treeview.test
@@ -690,4 +690,92 @@ test treeview-368fa4561e "indicators cannot be clicked on leafs" -setup {
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