1 EZControlSpecEditor : EZGui {
3 var <minView, <maxView, <warpView, <stepView, <controlSpec;
5 *new { arg parent, bounds, label = "Mn/Mx/Wp/Stp", controlSpec, labelWidth=100, labelHeight=20, layout=\horz, gap, margin;
7 ^super.new.init(parent, bounds, label, controlSpec, labelWidth, labelHeight, layout, gap, margin)
10 init { arg parentView, bounds, label, argControlSpec, labelWidth, labelHeight, argLayout, argGap, argMargin;
12 var labelBounds, minBounds, maxBounds, warpBounds, stepBounds;
15 this.prMakeMarginGap(parentView, argMargin, argGap);
18 bounds.isNil.if{bounds = 350@20};
21 // if no parent, then pop up window
22 #view,bounds = this.prMakeView(parentView, bounds);
25 labelSize=labelWidth@labelHeight;
27 // calculate bounds of all subviews
28 #labelBounds, minBounds, maxBounds, warpBounds, stepBounds = this.prSubViewBounds(innerBounds);
31 labelView = GUI.staticText.new(view, labelBounds);
32 labelView.string = label;
34 // (unitWidth>0).if{ //only add a unitLabel if desired
35 // unitView = GUI.staticText.new(view, unitBounds);
38 minView = GUI.numberBox.new(view, minBounds);
39 maxView = GUI.numberBox.new(view, maxBounds);
40 warpView = GUI.textField.new(view, warpBounds);
41 stepView = GUI.numberBox.new(view, stepBounds);
43 // set view parameters and actions
45 controlSpec = argControlSpec.asSpec;
47 minView.value = controlSpec.minval;
48 maxView.value = controlSpec.maxval;
49 warpView.value = controlSpec.warp.asSpecifier.asCompileString;
50 stepView.value = controlSpec.step;
52 minView.action = { controlSpec.minval = minView.value };
53 maxView.action = { controlSpec.maxval = maxView.value };
54 warpView.action = { try { controlSpec.warp = warpView.value.interpret.asWarp(controlSpec) } };
55 stepView.action = { controlSpec.step = stepView.value };
57 //this.prSetViewParams;
61 prSubViewBounds{arg rect; // calculate subview bounds
62 var labelBounds, minBounds, maxBounds, warpBounds, stepBounds;
63 var gap1, gap2, gap3, tmp, labelH, componentSize;
67 labelH=labelSize.y;// needed for \vert
71 componentSize = ((rect.width - (3 * gap.x) - labelSize.x) / 4)@labelH;
72 stepBounds = componentSize.asRect.left_(rect.width - componentSize.x);
73 warpBounds = componentSize.asRect.left_(stepBounds.left-componentSize.x-gap.x);
74 maxBounds = componentSize.asRect.left_(warpBounds.left-componentSize.x-gap.x);
75 minBounds = componentSize.asRect.left_(maxBounds.left-componentSize.x-gap.x);
76 labelBounds = (labelSize.x@labelSize.y).asRect.width_(minBounds.left-gap.x); //adjust width
80 componentSize = labelSize.x@((rect.height - (3 * gap.y) - labelH) / 4);
81 labelBounds = (rect.width@labelH).asRect; // to top
82 minBounds = (rect.width@componentSize.y)
83 .asRect.top_(labelBounds.bottom + gap.y);
84 maxBounds = (rect.width@componentSize.y)
85 .asRect.top_(minBounds.bottom + gap.y);
86 warpBounds = (rect.width@componentSize.y)
87 .asRect.top_(maxBounds.bottom + gap.y);
88 stepBounds = (rect.width@componentSize.y)
89 .asRect.top_(warpBounds.bottom + gap.y);
93 componentSize = ((rect.width - (3 * gap.x) - labelSize.x) / 4)@labelH;
94 stepBounds = componentSize.asRect.left_(rect.width - componentSize.x);
95 warpBounds = componentSize.asRect.left_(stepBounds.left-componentSize.x-gap.x);
96 maxBounds = componentSize.asRect.left_(warpBounds.left-componentSize.x-gap.x);
97 minBounds = componentSize.asRect.left_(maxBounds.left-componentSize.x-gap.x);
98 labelBounds = (labelSize.x@labelSize.y).asRect.width_(minBounds.left-gap.x); //adjust width
103 ^[labelBounds, minBounds, maxBounds, warpBounds, stepBounds].collect{arg v; v.moveBy(margin.x,margin.y)}