File: QUserView.sc

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (52 lines) | stat: -rw-r--r-- 1,364 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
UserView : View {
	var <drawFunc, <drawingEnabled=true, <animate=false;

	*qtClass { ^'QcCustomPainted' }

	*new { arg parent, bounds;
		var me = super.new(parent, bounds ?? {this.sizeHint} );
		me.canFocus = true;
		^me;
	}

	*sizeHint {
		^Point(150,150);
	}

	drawingEnabled_ { arg boolean;
		// Allow setting the property apart from the instance variable
		// to optimize when drawFunc is nil. See drawFunc_ implementation.
		drawingEnabled = boolean;
		this.setProperty( \drawingEnabled, boolean );
	}

	clearOnRefresh { ^this.getProperty( \clearOnRefresh ); }
	clearOnRefresh_ { arg boolean; this.setProperty( \clearOnRefresh, boolean ); }

	clearDrawing { this.invokeMethod( \clear ); }

	drawFunc_ { arg aFunction;
		this.setProperty( \drawingEnabled, aFunction.notNil );
		drawFunc = aFunction;
	}

	draw {
		// NOTE: it is only allowed to call this while a QPaintEvent is being
		// processed by this QWidget, or an error will be thrown.
		drawFunc.value(this);
	}

	animate_ { arg bool; this.invokeMethod( \animate, bool ); animate = bool; }

	frameRate_ { arg fps; this.setProperty( \frameRate, fps.asFloat ); }
	frameRate { ^this.getProperty( \frameRate ); }

	frame { ^this.getProperty( \frameCount ); }

	// override View's action_ to not connect to 'action()' signal
	action_ { arg func;
		action = func;
	}

	doDrawFunc { drawFunc.value(this) }
}