aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcarmen rocco <ix9@users.sourceforge.net>2005-04-05 18:41:36 +0000
committercarmen rocco <ix9@users.sourceforge.net>2005-04-05 18:41:36 +0000
commitcea5218739ff4114f3f65f29b8b64d04cc011986 (patch)
tree049cb940a8a76e6eaf055678808d9cd59a11aa96
parent5c492bdec6cd9302f0d92868ccfea8eadbd25896 (diff)
-tkzinc
svn path=/trunk/; revision=2681
-rwxr-xr-xextensions/gui/ix/dm.wid2
-rwxr-xr-xextensions/gui/ix/knob-demo.pd55
-rwxr-xr-xextensions/gui/ix/knob.wid102
3 files changed, 158 insertions, 1 deletions
diff --git a/extensions/gui/ix/dm.wid b/extensions/gui/ix/dm.wid
index d67bda99..389e31bb 100755
--- a/extensions/gui/ix/dm.wid
+++ b/extensions/gui/ix/dm.wid
@@ -2,7 +2,7 @@
namespace eval ::ix {
variable _
proc spin_resize {w} {
- update
+# update
$w config -height [winfo height $w] -width [winfo width $w]
}
proc spin {c w t bg fg font items arrows} {
diff --git a/extensions/gui/ix/knob-demo.pd b/extensions/gui/ix/knob-demo.pd
new file mode 100755
index 00000000..f9fa7600
--- /dev/null
+++ b/extensions/gui/ix/knob-demo.pd
@@ -0,0 +1,55 @@
+#N canvas 403 277 435 265 12;
+#X floatatom 234 44 5 16 1024 0 - - -;
+#X msg 234 62 #w \$1 \, #h \$1;
+#X msg 14 209 #trans \$1;
+#X floatatom 14 191 5 22 100 0 - - -;
+#X obj 356 150 widget knob n2 #w 34 #h 35 #ca "#ff4a9c" #cb "#83f735"
+#cc "#fff74a" #trans 100 #th 8 #bg "#446dfd" #cn "#83f735" #nx -30
+#ny -30 -bd 1;
+#X obj 103 198 nbx 8 14 -1e+37 1e+37 0 0 empty empty empty 0 -6 0 10
+-262144 -1 -1 -0.247674 256;
+#X obj 103 89 widget knob n1 #w 88 #h 88 #th 7 #cc purple #cb black
+#ca red #trans 81 #bg green #range 1 #cn navy #ny 79 #nx 43 #max 0
+#min 0 #an white -bd 1;
+#X msg 225 159 #range \$1;
+#X msg 247 194 1;
+#X msg 274 194 10000;
+#X obj 182 29 widget knob n3 #size #1 #w 30 #h 30 #ny 87 #nx 33 #th
+8 #bg orange #cc green #trans 134;
+#X floatatom 280 114 5 0 0 0 - - -;
+#X msg 280 129 #ny \$1;
+#X floatatom 181 11 5 0 0 0 - - -;
+#X floatatom 183 62 5 0 0 0 - - -;
+#X floatatom 280 81 5 0 0 0 - - -;
+#X msg 280 96 #nx \$1;
+#X msg 247 220 #max 1;
+#X msg 292 220 #max 32 \, #min 16;
+#X msg 247 240 #min 0 \, #max 0;
+#X msg 97 56 redefine;
+#X msg 193 157 1;
+#X msg 193 135 100;
+#X msg 194 113 1000;
+#X msg 194 91 0.1;
+#X connect 0 0 1 0;
+#X connect 1 0 6 0;
+#X connect 2 0 6 0;
+#X connect 3 0 2 0;
+#X connect 6 0 5 0;
+#X connect 7 0 6 0;
+#X connect 8 0 6 0;
+#X connect 9 0 6 0;
+#X connect 10 0 14 0;
+#X connect 11 0 12 0;
+#X connect 12 0 6 0;
+#X connect 13 0 10 0;
+#X connect 14 0 6 0;
+#X connect 15 0 16 0;
+#X connect 16 0 6 0;
+#X connect 17 0 6 0;
+#X connect 18 0 6 0;
+#X connect 19 0 6 0;
+#X connect 20 0 6 0;
+#X connect 21 0 7 0;
+#X connect 22 0 7 0;
+#X connect 23 0 7 0;
+#X connect 24 0 7 0;
diff --git a/extensions/gui/ix/knob.wid b/extensions/gui/ix/knob.wid
new file mode 100755
index 00000000..450f1baf
--- /dev/null
+++ b/extensions/gui/ix/knob.wid
@@ -0,0 +1,102 @@
+namespace eval ::ix {
+ variable _
+ proc nobfloat {path t num} {
+ variable _
+ $path itemconfigure $t:num -text $num
+ pd [concat $t.rp _cb $num \;]
+ set _($t:num) $num
+ }
+ proc nob_mover {w t f x y} {
+ variable _
+ if {$::ix::_($t:clickd) > 0} {
+ set move [expr (($x - $::ix::_($t:lx)) + (-1 * ($y - $::ix::_($t:ly)))) / ([winfo width $w].0 + [winfo height $w].0) * $f]
+ nob_move $w $t $move
+ }
+ set ::ix::_($t:clickd) 1
+ set ::ix::_($t:lx) $x
+ set ::ix::_($t:ly) $y
+ }
+ proc nob_move {w t move} {
+ variable _
+ set on [$w itemcget $t:num -text]
+ set no [expr $on + $_($t:range) * $move * 2]
+ if {$_($t:min) != $_($t:max)} {
+ if {$no > $_($t:max)} {set no $_($t:max);set move 0}
+ if {$no < $_($t:min)} {set no $_($t:min);set move 0}
+ }
+ nobfloat $w $t $no
+ foreach e {1 10 100} {
+ set a [expr [$w itemcget $t:nob$e -start] + int($move * $e * 90)]
+ $w itemconfigure $t:nob$e -start $a
+ set _($t:a$e) $a
+ }
+ }
+
+ proc nob {path t w h range bg c1 c2 c3 cn th nx ny max min} {
+ variable _
+ set _($t:lx) 32
+ set _($t:clickd) -1
+ set _($t:max) $max
+ set _($t:min) $min
+ if {$_($t:min) != $_($t:max)} {
+ set _($t:range) [expr abs($min - $max)]
+ } else {
+ set _($t:range) $range
+ }
+ if {[winfo exists $path.nob] != 1} {
+ canvas $path.nob -width $w -height $h -borderwidth 1 -bg $bg
+ $path configure -width $w -height $h
+ place $path.nob -anchor nw -relwidth 1 -relheight 1
+ $path.nob delete *
+ set i 0
+ set colors [list $c1 $c2 $c3]
+ set ratios {1 10 0.1}
+ set edge 10
+ $path.nob create rectangle {1 1 8 4} -fill "#555555"
+ $path.nob create rectangle "1 $h 8 [expr $h - 5]" -fill "#555555"
+ foreach e {1 10 100} {
+ $path.nob create arc \
+ "[expr $w / $edge / ($i + 1) + ($edge / 2)] [expr $h / $edge / ($i + 1) + ($edge / 2)] [expr $w - $w / $edge / ($i + 1) - ($edge / 2)] [expr $h - $h / $edge / ($i + 1) - ($edge / 2)]" \
+ -extent [expr int(300 / $e)] -start 90 \
+ -outline "[lindex $colors $i]" \
+ -style arc \
+ -width [expr int($h / $th)] \
+ -tags $t:nob$e
+ bind $path.nob <B[expr $i + 1]-Motion> \
+ "::ix::nob_mover $path.nob $t [lindex $ratios $i] %x %y"
+ incr i
+ bind $path.nob <ButtonRelease-$i> "set ::ix::_($t:clickd) -1"
+ }
+ bind $path <MouseWheel> {::ix::nob_move %W.nob [winfo name %W] [expr %D / 2400.]}
+ bind $path <Shift-MouseWheel> {::ix::nob_move %W.nob [winfo name %W] [expr %D / 24000.]}
+ bind $path <Control-MouseWheel> {::ix::nob_move %W.nob [winfo name %W] [expr %D / 240.]}
+ bind $path.nob <Shift-B1-Motion> "::ix::nob_mover $path.nob $t 10 %x %y"
+ bind $path.nob <Control-B1-Motion> "::ix::nob_mover $path.nob $t 0.1 %x %y"
+ if {$nx == 0} {
+ set nx [expr $w / 2]
+ set ny [expr $h - 20]
+ }
+ $path.nob create text $nx $ny -text "0.0" -tags $t:num -fill "$cn" -font {{Bitstream Vera Sans} 8}
+ }
+ if {[info exists _($t:num)]} {
+ $path.nob itemconfigure $t:num -text $_($t:num)
+ foreach e {1 10 100} {
+ $path.nob itemconfigure $t:nob$e -start $_($t:a$e)
+ }
+ } else {
+ foreach e {1 10 100} {set _($t:a$e) 90}
+ set _($t:num) 0.0}
+
+ }
+}
+#> knob frame
+#. -bd 1 -bg "#cccccc"
+#. -highlightbackground red
+#. #max 0 #min 0
+#. #w 128 #h 128 #th 5 #range 100 #nx 0 #ny 0
+#. #bg purple #ca blue #cb yellow #cc green #cn orange
+#. @float ::ix::nobfloat .-.nob .| .#1
+#. @cmd eval ".-.nob .#args"
+bind .- <Enter> {focus .-}
+bind .- <Leave> {focus .^.c}
+::ix::nob .- .| .#w .#h .#range .#bg .#ca .#cb .#cc .#cn .#th .#nx .#ny .#max .#min