Permalink
Browse files

CVWidgetMS: fix initial display or reference (zero crossing)

if a multislider widgets spec's range is crossing zero this should be
visible in the slider. That worked so far if the spec had been set after
the widget had been created but not during initialisation.

Signed-off-by: Stefan Nussbaumer <st9fan@gmail.com>
  • Loading branch information...
nuss committed Feb 1, 2017
1 parent 74874d9 commit b0b649e08eab5589113a41414eebf5e6983a77ae
Showing with 11 additions and 1 deletion.
  1. +0 −1 CVCenter/CVWidget.sc
  2. +11 −0 CVCenter/CVWidgetMS.sc
View
@@ -1736,7 +1736,6 @@ CVWidget {
if(tmp.minval.isNegative and:{ tmp.maxval.isNegative }, { reference = reference.add(1) });
if(tmp.minval.isPositive and:{ tmp.maxval.isPositive }, { reference = reference.add(0) });
});
- // "reference: %\n".postf(reference);
this.mSlider.reference_(reference);
});
View
@@ -27,6 +27,7 @@ CVWidgetMS : CVWidget {
var nextX, nextY, knobX, knobY;
var calibViewsWidth, calibViewsNextX;
var text, tActions;
+ var reference = [];
background ?? { background = Color.white };
stringColor ?? { stringColor = Color.black };
@@ -476,6 +477,16 @@ CVWidgetMS : CVWidget {
widgetBg, calibViews, nameField, activeSliderB, activeTextB
]);
+ this.getSpec.split.do{ |sp|
+ if(sp.excludingZeroCrossing, {
+ if(sp.minval < sp.maxval, { reference = reference.add(sp.minval.abs/(sp.maxval-sp.minval)) });
+ if(sp.minval > sp.maxval, { reference = reference.add(sp.maxval.abs/(sp.maxval-sp.minval).abs) });
+ });
+ if(sp.minval.isNegative and:{ sp.maxval.isNegative }, { reference = reference.add(1) });
+ if(sp.minval.isPositive and:{ sp.maxval.isPositive }, { reference = reference.add(0) });
+ };
+ mSlider.reference_(reference);
+
msSize.do({ |slot| this.initControllerActions(slot) });
connectS !? { this.connectGUI(connectS, nil) };

0 comments on commit b0b649e

Please sign in to comment.