X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=_UIFramework.pde;h=ca744646078e8780cf50cc6a50f10b9f4b3ab4a2;hb=22cb1606e32aac75561f2ad477bb2d9aa13531cf;hp=0e0be79c005c08fd3750c5b9795070270de008d7;hpb=4df91dafc9bd6e090a89cd4ce2dc913d92de435e;p=SugarCubes.git diff --git a/_UIFramework.pde b/_UIFramework.pde index 0e0be79..ca74464 100644 --- a/_UIFramework.pde +++ b/_UIFramework.pde @@ -21,6 +21,8 @@ final PFont defaultTitleFont = createFont("Myriad Pro", 10); public abstract class UIObject { + protected final static int DOUBLE_CLICK_THRESHOLD = 300; + protected final List children = new ArrayList(); protected boolean needsRedraw = true; @@ -602,6 +604,18 @@ public class UIParameterKnob extends UIParameterControl { pg.text(knobLabel, knobSize/2, knobSize + knobLabelHeight - 2); } + private long lastMousePress = 0; + public void onMousePressed(float mx, float my) { + super.onMousePressed(mx, my); + long now = millis(); + if (now - lastMousePress < DOUBLE_CLICK_THRESHOLD) { + parameter.reset(); + lastMousePress = 0; + } else { + lastMousePress = now; + } + } + public void onMouseDragged(float mx, float my, float dx, float dy) { if (parameter != null) { float value = constrain(parameter.getValuef() - dy / 100., 0, 1); @@ -639,7 +653,7 @@ public class UIParameterSlider extends UIParameterControl { if (mx >= handleLeft && mx < handleLeft + handleWidth) { editing = true; } else { - if ((now - lastClick) < 300 && abs(mx - doubleClickX) < 3) { + if ((now - lastClick) < DOUBLE_CLICK_THRESHOLD && abs(mx - doubleClickX) < 3) { parameter.setValue(doubleClickMode); } doubleClickX = mx; @@ -703,7 +717,7 @@ public class UIScrollList extends UIObject { itemColor = #707070; } float factor = even ? .92 : 1.08; - itemColor = color(hue(itemColor), saturation(itemColor), min(100, factor*brightness(itemColor))); + itemColor = lx.scaleBrightness(itemColor, factor); pg.noStroke(); pg.fill(itemColor); @@ -718,7 +732,7 @@ public class UIScrollList extends UIObject { } if (hasScroll) { pg.noStroke(); - pg.fill(color(0, 0, 100, 15)); + pg.fill(0x26ffffff); pg.rect(w-12, 0, 12, h); pg.fill(#333333); pg.rect(w-12, scrollYStart, 12, scrollYHeight);