From 9f8b6228d141bbfce93c24c359ae4f2824ddcda0 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 20 Feb 2004 15:46:38 +0000 Subject: Change most keyborad bindings to make it more intuitive. Added a delete item command. Swap axis works also in the X direction. Fixed a bug preventing update of the compose* toggles buttons when changing items. --- demos/transforms.tcl | 73 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/demos/transforms.tcl b/demos/transforms.tcl index be0273e..3c6f5b6 100644 --- a/demos/transforms.tcl +++ b/demos/transforms.tcl @@ -35,16 +35,18 @@ pack $w.text -expand yes -fill x $w.text insert 0.0 {Items are always added to the current group. The available commands are: - Button 1 on the background, add an item with initial translation - Button 2 on the background, add a group with initial translation - Button 1 on item/group axes, select/deselect that item space - Drag Button 1 on item/group axes, translate that item space - Del reset the transformation - Shift-Del reset a group direct children transformations - PageUp/Down scale up/down - End/Home rotate right/left - Ins swap the Y axis - 4 arrows translate in the 4 directions} + Button 1 on the background, add an item with initial translation + Button 2 on the background, add a group with initial translation + Button 1 on item/group axes, select/deselect that item coordinates + Drag Button 1 on item/group axes, translate that item coordinates + Home reset the transformation + Shift-Home reset a group direct children transformations + +/- scale the selected item up/down + Ctrl-Left/Right rotate the selected item right/left + Shift-Up/Down swap the selected item Y axis + Shift-Left/Right swap the selected item X axis + 4 arrows translate in the 4 directions + Delete destroy the selected item} $w.text configure -state disabled ########################################### @@ -59,7 +61,7 @@ pack $w.zinc -expand y -fill both set top 1 -set inactiveAxisColor black +set inactiveAxisColor blue set activeAxisColor red set worldAxisColor \#a5a5a5 @@ -116,13 +118,19 @@ bind $w.zinc moveUp bind $w.zinc moveLeft bind $w.zinc moveRight bind $w.zinc moveDown -bind $w.zinc scaleDown -bind $w.zinc scaleUp -bind $w.zinc reset -bind $w.zinc resetChildren -bind $w.zinc rotateLeft -bind $w.zinc rotateRight -bind $w.zinc swapAxis +bind $w.zinc scaleDown +bind $w.zinc scaleDown +bind $w.zinc scaleUp +bind $w.zinc scaleUp +bind $w.zinc reset +bind $w.zinc resetChildren +bind $w.zinc rotateLeft +bind $w.zinc rotateRight +bind $w.zinc {swapAxis y} +bind $w.zinc {swapAxis y} +bind $w.zinc {swapAxis x} +bind $w.zinc {swapAxis x} +bind $w.zinc deleteItem bind $w.zinc "resize %w %h" @@ -142,12 +150,19 @@ proc resize {width height} { $w.zinc translate "axis:$world" $x $y } -proc swapAxis {} { +proc swapAxis {axis} { global w currentItem + set sx 1 + set sy 1 + if { $axis eq "x" } { + set sx -1 + } elseif { $axis eq "y" } { + set sy -1 + } if {$currentItem != 0} { - $w.zinc scale $currentitem 1 -1 - $w.zinc scale "axisgrp:$currentItem" 1 -1 + $w.zinc scale $currentItem $sx $sy + $w.zinc scale "axisgrp:$currentItem" $sx $sy } } @@ -169,6 +184,19 @@ proc toggleComposeScale {} { } } +proc deleteItem {} { + global w currentItem currentGroup world + + if {$currentItem != 0} { + $w.zinc remove $currentItem + $w.zinc remove axisgrp:$currentItem + if { $currentGroup == $currentItem } { + set currentGroup $world + } + set currentItem 0 + } +} + proc dragItem {x y} { global w drag currentItem @@ -198,6 +226,7 @@ proc select {} { proc changeItem {item} { global w currentItem currentGroup + global composeRot composeScale global drag activeAxisColor inactiveAxisColor if {($currentItem != 0) && !$drag} { @@ -260,7 +289,7 @@ proc resetChildren {} { global w currentItem if {($currentItem != 0) && ([$w.zinc type $currentItem] == "group")} { - $w.zinc addtag rt withtag all $currentItem 0 + $w.zinc addtag rt withtag .$currentItem. $w.zinc treset rt $w.zinc dtag rt rt } -- cgit v1.1