[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Sc-devel] SCEnvelopeView valueAction and help file



Hello All

it would be great if we could have the valueAction method for SCEnvelopeView, which would make that class more in line with how other SC GUIs worked IMHO.

The current SCEnvelopeView help file is a bit of a tease in this regard
and could perhaps be made more clear and generally friendly for 3.2.

The first example has an .action, which works as expected:

use as envelope view
(
//use shift-click to keep a node selected
a = SCWindow("envelope", Rect(200 , 450, 250, 100));
a.view.decorator =  FlowLayout(a.view.bounds);

b = SCEnvelopeView(a, Rect(0, 0, 230, 80))
	.drawLines_(true)
	.selectionColor_(Color.red)
	.drawRects_(true)
	.resize_(5)
	.action_({arg b; [b.index,b.value].postln})
	.thumbSize_(5)
	.value_([[0.0, 0.1, 0.5, 1.0],[0.1,1.0,0.8,0.0]]);

a.front;
)


Then the 2nd example has an all-singing,
all-dancing routine to move the nodes,
but which is pretty much non-functional "eye-candy"
since there is no valueAction implemented.
All this is kind of a subtle thing,
and rather confusing for a beginner I would imagine?

(
//use shift click to select/unselect the points
a = SCWindow("test", Rect(200 , 450, 450, 150));
a.view.decorator =  FlowLayout(a.view.bounds);

b = SCEnvelopeView(a, Rect(0, 0, 350, 100))
	.thumbSize_(5)
	.drawLines_(true)
	.fillColor_(Color.green)
	.selectionColor_(Color.red)
	.drawRects_(true)
	.value_([(0.0, 0.1 .. 1.0), (0.0, 0.1 .. 1.0)])
	.setEditable(0,false);

a.front;
)
(
r = Routine({
	var j = 0;
	20.do({ arg i;
	b.select((b.size -1).rand.abs);

	0.1.wait;
	b.x_(1.0.rand.abs);
	b.y_(1.0.rand.abs);
	});
	b.select(-1);

	});
	AppClock.play(r);
)	


IMHO the valueAction method should either be implemented
- which would be great -
or the 2nd example be taken out
(since it can't be used for anything much functional)
or at lease given a health warning,
such as somehting like:
"Note that in this example the action method cannot be used
as the nodes(?) are not being moved via the mouse.
Other Classes use the valueAction method to achieve this
but this method is not currently implemented for SCEnvelopeView".

BTW, due to where SCEnvelopeView sits in the class tree structure,
I don't think it's as simple an implementation
as Tom Tlalim's extentension for SCMultiSliderView,
posted recently in sc-users?

+SCMultiSliderView {
	valueAction_ {|val|
			this.value = val;
			this.doAction
	}
}
)
)

In any case, most of the action seems to happen in the primitive,
so I have no idea how much work this may be.

Finally, since many people use SCEnvelopeView in ways _other_
than simply for envelopes - as the 2nd example suggests -
it might be helpful to have a few sentences in the help file
to introduce the class, which is a little cryptic
for those not in the know. It begins:

SCEnvelopeView

value_([times,values])
	where times and values are all 0..1

value
	[times,values]
	where times and values are all 0..1

action
	function is passed the view

...

Regards

Tom