aboutsummaryrefslogtreecommitdiff
path: root/demos/transforms.tcl
diff options
context:
space:
mode:
authorlecoanet2004-02-20 15:46:38 +0000
committerlecoanet2004-02-20 15:46:38 +0000
commit9f8b6228d141bbfce93c24c359ae4f2824ddcda0 (patch)
tree7d38e2c3712d3c914e945d790e2655573f776a5e /demos/transforms.tcl
parent6ac3415550b7c47dd7bcc24ecdd0e626ad9eb31c (diff)
downloadtkzinc-9f8b6228d141bbfce93c24c359ae4f2824ddcda0.zip
tkzinc-9f8b6228d141bbfce93c24c359ae4f2824ddcda0.tar.gz
tkzinc-9f8b6228d141bbfce93c24c359ae4f2824ddcda0.tar.bz2
tkzinc-9f8b6228d141bbfce93c24c359ae4f2824ddcda0.tar.xz
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.
Diffstat (limited to 'demos/transforms.tcl')
-rw-r--r--demos/transforms.tcl73
1 files 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 <Up> moveUp
bind $w.zinc <Left> moveLeft
bind $w.zinc <Right> moveRight
bind $w.zinc <Down> moveDown
-bind $w.zinc <Next> scaleDown
-bind $w.zinc <Prior> scaleUp
-bind $w.zinc <Delete> reset
-bind $w.zinc <Shift-Delete> resetChildren
-bind $w.zinc <End> rotateLeft
-bind $w.zinc <Home> rotateRight
-bind $w.zinc <Insert> swapAxis
+bind $w.zinc <minus> scaleDown
+bind $w.zinc <KP_Subtract> scaleDown
+bind $w.zinc <plus> scaleUp
+bind $w.zinc <KP_Add> scaleUp
+bind $w.zinc <Home> reset
+bind $w.zinc <Shift-Home> resetChildren
+bind $w.zinc <Control-Left> rotateLeft
+bind $w.zinc <Control-Right> rotateRight
+bind $w.zinc <Shift-Up> {swapAxis y}
+bind $w.zinc <Shift-Down> {swapAxis y}
+bind $w.zinc <Shift-Left> {swapAxis x}
+bind $w.zinc <Shift-Right> {swapAxis x}
+bind $w.zinc <Delete> deleteItem
bind $w.zinc <Configure> "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
}