GMZZSlider:
Filter:
GraphicalModule/Classes (extension) | GUI > Graphical Module

GMZZSlider
ExtensionExtension

An abstract class for single value sliders (Graphical Module)

Description

A note on this class hierarchy

GMZZSlider is an abstract class that defines single value sliders behavior within the scope of the Graphical Module. The class name begins with "GMZZ" so it is displayed last in the autocompletion API.

This abstract class only defines the interaction methods, that other slider classes inherits. Those other classes are responsible for the drawFunc definition of the slider. As such, GMZZSlider shouldn't be instanciated, as it doesn't display anything by itself.

Basic setup

GMZZSlider requires you to provide a min, a max, a scale, a default value and a function to be usable :

The Function associated to the action will be evaluated every time the value changes, with the value as argument.

The min and max values can only be positive, and max should be greater than min. The displayFunction method of this class child classes provide a workaround to this limitation.

Scale argument

The provided scale must be either \lin, \exp, \log or a number :

If \lin is specified, the mapping will be performed using the linlin function.

If \exp or \log is specified, the mapping will be performed using the linexp function. It is still possible to set min equals to 0 when using those scales. In this special case, you should also specify an expMin value to allow the correct mapping (slider will return 0 at minimum position, a mapping between expMin and max otherwise) :

If a number is specified, the mapping will be performed using the lincurve function.

Orientation

The slider can be turned horizontally if needed :

Polarity

By default, the slider ranges from min to max. It can be toggled to range from max.neg to max, excluding the min.neg to min region :

Key modifier ALT

When clicking the slider down while pressing ALT, the current slider value will be stored, then the slider will be set to the new value. When releasing the mouse button, if ALT is pressed, the slider will jump back to the stored value. The intention is to provide a 'live instrument' feel to the slider.

Helpers and key modifier SHIFT

This is easier to explain starting from a visual example :

Wether they are displayed or not, the slider comes with 'helpers' that subdivide its range equally. The helpersNumber property will set the number of 'big helpers', the helperSubdivisions property will set how much 'small helpers' there are between 'big ones' :

If the slider range is bipolar, the specified number of helpers still only applies to only one pole of the scale :

When interacting with the slider while pressing the SHIFT key (but not the CTRL key, see below), the selected value will automatically stick to the closest helper :

As you can see in this example, this can allow to automatically select some discrete key values, as one would in a multi state button, without losing the slider continuous ability.

Pressing ALT + SHIFT mixes both associated behavior, and can allow you, for example, to jump back and forth in octaves.

Mod Steps and key modifier CTRL

Pressing and holding CTRL or CTRL + SHIFT will modify the way the mouse cursor interacts with the widget. When CTRL is held and the slider is clicked down, or the slider is allready clicked and CTRL is pressed, the cursor position will be stored, and further mouse movement will modify the value using three parameters :

The operator can be either \add or mul.

Let's take an example :

Here, when CTRL is held, everytime the cursor moves up by 10 pixels, the current value will be incremented by 0.2. Everytime the cursor moves down by 10 pixels, the current value will be decremented by 0.2.

The main usage of the \add operator is to fine tune the sliders value.

Here, when CTRL is held, everytime the cursor moves up by 25 pixels, the current value will be multiplied by 2. Everytime the cursor moves down by 25 pixels, the current value will be divided by 2.

In this example, this allows to jump by octave. This could also be used to double a tempo. A smaller step value, like 1.1, could also be used to increase or decrease the tempo smoothly as the cursor moves.

On bipolar scales, by nature, the \mul operator doesn't allow to cross the min value.

You can specify up to two 'mod steps' : one when CTRl only is pressed, an other when CTRL + SHIFT is pressed :

Due to the implementation of this algorithm, switching directly between CTRL and CTRL + SHIFT without releasing the mouse button is likely to introduce unwanted behavior.

When pressing ALT and a 'mod step' at the same time, the anchor point will be the value at the cursor position.

Class Methods

.new

Creates a new instance of GMZZSlider.

Returns:

a GMZZSlider instance. This method is implicitely internal.

Instance Methods

Interaction

.action

Sets or gets the Function to be triggered when interacting with the slider changes its value. This Function takes the current slider value as argument.

Arguments:

aFunction

A Function with an argument, a Float which correspond to the sliders current value.

.mouseDownAction

Sets or gets the Function to be triggered when interacting with the slider changes its value. This Function takes the current slider value as argument. Equivalent to .action.

Arguments:

aFunction

A Function with an argument, a Float which correspond to the sliders current value.

.value

Sets or gets the current slider value. It will be clipped between min and max values.

.min

Sets or gets the slider minimum value.

.max

Sets or gets the slider maximum value.

.scale

Sets or gets the slider scale. Can be either \lin, \exp or \log, or a number.

Arguments:

aScale

A Symbol or a SimpleNumber.

.expMin

Sets or gets safety value the slider will use to perform mapping in the special case where scale is either \exp or \log, and min equals 0.

.orientation

Sets the View direction.

Arguments:

aSymbol

The View will be distributed horizontally if set as \horizontal, vertically otherwise.

.polarity

Sets the polarity of the scale. Slider will range from min to max if set as \uni, or from max.neg to max, excluding min.neg to min, if set as \bi.

Arguments:

aSymbol

Either \uni or \bi.

.helpersNumber

Sets or gets the slider 'big helpers' number.

.helperSubdivisions

Sets or gets the number of 'small helpers' between each 'big helpers' pair.

.modStep

Sets or gets the step value to use when CTRL is pressed.

.modStepOperator

Sets or gets the operator to use when CTRL is pressed.

Arguments:

aSymbol

Either \add or \mul.

.modStepPixelRange

Sets or gets the pixel range to use when CTRL is pressed.

.modStep2

Sets or gets the step value to use when CTRL + SHIFT is pressed.

.modStep2Operator

Sets or gets the operator to use when CTRL + SHIFT is pressed.

Arguments:

aSymbol

Either \add or \mul.

.modStep2PixelRange

Sets or gets the pixel range to use when CTRL + SHIFT is pressed.

.modSteps

Sets or gets both mod steps values.

.modStepsOperators

Sets or gets both mod steps operators.

.modStepsPixelRanges

Sets or gets both mod steps pixel ranges.

Internal Methods

.prCheckMod

.prGetClosestHelper

.prGetModStepValue

.prUpdateValue

Examples

See the GMFaderSlider documentation for examples and templates.