TriggerView, ToggleView, FlatButtonView a gui button / toggle
*new(parent, bounds);
bounds: a Rect(
distance from left,
distance from bottom,
width,
height
)
value - a boolean that indicates the object's state
<>string
<>centerString - boolean
<>hasBorder - boolean
<>colorOn
<>colorOff
<>fontColorOn
<>fontColorOff
<>font
<>fontColor
<>action
TriggerView
-----------
mouse
dn up
---- ----
| |
---------
state
true false
---------
| |
---- ----
ToggleView
----------
mouse
dn up dn up
---- -------- ----
| | | |
--------- ---------
state
true false
------------------
| |
---- --------------
//example
(
w = SCWindow("TriggerView", Rect(200, 440, 344, 160)).front;
w.view.decorator = FlowLayout(w.view.bounds);
Array.fill(4, { arg i;
TriggerView.new(w, Rect(0,0,80,60))
.string_("Hit me" + (i+1))
.canFocus_(false)
.action_({|v| format("hit % %", (i+1), v.value).postln });
});
Array.fill(4, { arg i;
v = ToggleView.new(w, 80@60)
.string_("Toggle" + (i+1))
.canFocus_(true)
.action_({|v| format("Toggle % %", i+1, v.value).postln });
});
Array.fill(4, { arg i;
ToggleView.new(w, 10@10)
.canFocus_(false)
.colorOn_(Color.red(alpha:0.7))
.action_({|v| format("Toggle % %", i+5, v.value).postln });
});
)
v.value = true
v.value = false
v.valueAction = true
(
Sheet({ arg layout;
layout.flow({ arg layout;
layout.bounds = layout.bounds.width_(344);
Array.fill(4, { arg i;
TriggerView.new(layout, 80@60)
.canFocus_(false)
.string_("Hit me" + (i+1))
.action_({|v| format("hit % %", (i+1), v.value).postln });
});
Array.fill(4, { arg i;
v = ToggleView.new(layout, 80@60)
.string_("Toggle" + (i+1))
.action_({|v| format("Toggle % %", i+1, v.value).postln });
});
Array.fill(4, { arg i;
ToggleView.new(layout, 10@10)
.colorOn_(Color.red(alpha:0.7))
.canFocus_(false)
.action_({|v| format("Toggle % %", i+5, v.value).postln });
});
}).background_(Color.blue(0.1,0.1));
SCTextField(layout, 100@17);
}, "TriggerView");
)
// a flat button view
(
w = SCWindow.new("FlatButtonView", Rect(195,200,200,100)).front;
FlatButtonView.new(w, Rect(10,5,50,16))
.font_(Font.new("Helvetica", 9))
.colorOff_(Color.clear)
.canFocus_(false)
.string_("Button")
.action_({ arg btn;
"action".postln;
});
)