svgKnob snap question


(Phil Golden) #1

Just wondering if this is possible:

What I want to do is have a button with a lock icon that upon enable will store the value on the knob and pass snap = true; to SVGKnob. With snap and the value stored I want to change that value by a specific increment/decrement.

If that is not possible the way around it might be to have another knob on snap = true; and get that value to snap to the first knobs value, program the button to clamp(1stknob, .value, .value) or vice versa. Iv’e not tried either yet.


(Skrylar) #2

Since the source code is available for snapping and non-snapping knobs, you should be able to spork it out of the Rack source and frankenstein them together as-needed. I had to do something like this in SkJACK since some of the drawing behavior for LED text fields wasn’t exposed.


(Andrew Belt) #3

It’s possible (since I’ve designed the Widget framework to be extremely general), but things like this are horrible UX.


(Phil Golden) #4

Hmm did not get a notification that there was replies to this, anyway…

I hear what you’re saying Andrew but IMO I think it depends on what it is being used for, some values depend on snapping UX wise. IMO it is horrid when a knob doesn’t snap when its values are non float.

Is there any known example of passing a value from another component to a knob? I’m using my own components anyway so I was thinking of just putting an if/else in the component struct.

struct Knob : SVGKnob {
		Knob() {
			 if(btn == 1.0){snap = true;} else snap = false;
		}
	};

I may just use a pointer to a #define or an int declared in scope and set the define/int to 1 or 0 in the button.

int btn;

struct Snap : SVGSwitch, ToggleSwitch {

		//some code to detect frame state!??
if(state == 0){int btn = 1;}else btn = 0;//can't tab in this text box btw
		}
	};

struct Knob : SVGKnob {
		Knob() {
			 if(btn == 1){snap = true;} else snap = false;
		}
	};

(Andrew Belt) #5

Maybe something like this (untested)

struct CoirtKnob : SVGKnob {
	ParamWidget *modeSwitch;
	void step() override {
		snap = (modeSwitch->value > 0.f);
		SVGKnob::snap();
	}
};

Of course set coirtKnob->modeSwitch = modeSwitch in your ModuleWidget constructor.


(Phil Golden) #6

Will give it a try tomorrow.


(Phil Golden) #7

Not too sure how to implement that. I might just add a knob with snap enabled and with some manual routing or super hidden feature :shushing_face: finetune, turns out snap is the perfect multiplier for halving/double. Something like this:


(Skrylar) #8

I ran in to this with the ALAN. Scaler knobs are another case where you probably wanted one of a small number of presets, but the option to have an arbitrary scale is still there.


(Phil Golden) #9

No room for another knob :wink::wink: