1 // blackrain at realizedsound dot net - 05/2006
2 // fix key modidiers bug by Stephan Wittwer 08/2006 - thanks!
3 // Knob updates only on value changes - 10/2006
4 // GUI.cocoa changes - 04/2007
6 // 03.10.2008 - new implementation:
7 // - Knob now is a subclass of SCViewHolder
10 // 01.20.2009 - SCKnob
11 // - a subclass of SCUserView again.
14 // 08.03.2010 - QKnob = SCKnob adjusted for GUI.qt scheme (by Jakob Leben)
16 QKnob : QAbstractStepValue {
17 classvar <>defaultMode = \round;
23 *new { arg parent, bounds;
24 var me = super.new(parent,bounds);
25 me.mode = defaultMode;
29 value { ^this.getProperty(\value) }
30 value_ { arg val; this.setProperty(\value, val) }
31 valueAction_ { arg val; this.value = val; this.doAction }
34 var m = this.getProperty(\mode);
35 ^ #[\round, \horiz, \vert].at(m);
38 mode_ { arg inputMode;
46 this.setProperty( \mode, iMode );
49 centered_ { arg bool; this.setProperty( \centered, bool ); }
50 centered { ^this.getProperty( \centered ); }
52 // FIXME: find better alternatives to set colors separately.
57 p.windowText = colors[1];
59 p.buttonText = colors[3];
66 ^[p.button, p.windowText, p.window, p.buttonText];
69 getScale { |modifiers|
71 { modifiers.isShift } { this.shift_scale }
72 { modifiers.isCtrl } { this.ctrl_scale }
73 { modifiers.isAlt } { this.alt_scale }
77 defaultKeyDownAction { arg char, modifiers, unicode, keycode, key;
78 var zoom = this.getScale(modifiers);
82 $r, { this.valueAction = 1.0.rand },
83 $n, { this.valueAction = 0.0 },
84 $x, { this.valueAction = 1.0 },
85 $c, { this.valueAction = 0.5 },
89 16r5b, { this.decrement(zoom) },
90 16r5d, { this.increment(zoom) },
91 16r1000013, { this.increment(zoom) },
92 16r1000014, { this.increment(zoom) },
93 16r1000015, { this.decrement(zoom) },
94 16r1000012, { this.decrement(zoom) },
95 {^this} // propagate on if the key is a no-op
102 increment { |zoom=1| ^this.valueAction = (this.value + (keystep * zoom)) }
104 decrement { |zoom=1| ^this.valueAction = (this.value - (keystep * zoom)) }
106 defaultGetDrag { ^this.value }
107 defaultCanReceiveDrag { ^QView.currentDrag.isNumber }
108 defaultReceiveDrag { this.valueAction = QView.currentDrag }