Prima::Sliders - sliding bars, spin buttons, dial widgets, etc
The module contains a set of unrelated widget classes that provide input and/or output of an integer value. That is the only thing common in these classes, which are:
Prima::AbstractSpinButton Prima::SpinButton Prima::AltSpinButton Prima::SpinEdit Prima::Gauge Prima::PrigressBar Prima::AbstractSlider Prima::Slider Prima::CircularSlider
Provides a generic interface to the spin-button class functionality that includes events and range definition properties. Neither Prima::AbstractSpinButton nor its descendants store the integer value. These provide a mere possibility for the user to send the incrementing and decrementing commands.
Prima::AbstractSpinButton
The class is not usable directly.
The property manages a common internal state that doesn't have an exact meaning, as it is only defined in the descendant classes. For example, the state can be set to non-zero when the user performs a mouse drag action.
Called when the user presses a part of the widget that is responsible for incrementing or decrementing commands. DELTA is an integer value that indicates how the associated value must be modified.
Called when the user finished the mouse transaction.
A rectangular spin button that consists of three parts, divided horizontally. The upper and the lower parts are push buttons associated with singular increment and decrement commands. The middle part, when dragged by the mouse, fires the Increment events with delta value, based on the vertical position of the mouse pointer.
Increment
A rectangular spin button that consists of two push-buttons, associated with singular increment and decrement commands. Compared to Prima::SpinButton, the class is a bit less functional but has a more stylish look.
Prima::SpinButton
The widget contains a numerical input line and a spin button. The input line value can be changed in three ways - either as a direct traditional keyboard input, as a result of the spin button actions, or as the mouse wheel response. The class provides properties for value storage and range selection.
If set, allows an empty string as a valid value
Default value: false
Selects the value modification rule when the increment or decrement action hits a range limit. If 1, the value is changed to the opposite limit value ( for example, if the value is 100 in the range 2-100, and the user clicks on the 'increment' button, the value is changed to 2 ).
If 0, the value does not change.
Default value: 0
Assigns the input line class.
A create-only property.
Default value: Prima::InputLine
Prima::InputLine
Assigns the input line list of the notifications.
Assigns a hash of properties passed to the input line during the creation.
Sets the upper limit for value.
value
Default value: 100.
Sets the lower limit for value.
Determines the multiplication factor for incrementing and decrementing actions of the mouse wheel.
Default value: 10
Assigns the spin-button class.
Default value: Prima::AltSpinButton
Prima::AltSpinButton
Assigns the spin-button list of the delegated notifications.
Assigns a hash of properties passed to the spin-button during the creation.
Determines the multiplication factor for incrementing and decrementing actions of the spin-button.
Default value: 1
Selects the integer value in the range from min to max. The value is reflected in the input line.
min
max
Default value: 0.
Simultaneously sets both min and max values.
Called when value is changed.
An output-only widget class, displays a progress bar and an eventual percentage string. Useful as a progress indicator.
Selects the width of the border around the widget.
Selects the style of the border around the widget. Can be one of the following gr::XXX constants:
gr::XXX
gr::Sink - 3d sunken look gr::Border - uniform black border gr::Raise - 3d raised look
Default value: gr::Sink.
gr::Sink
Selects the threshold value used to determine if the changes to value are reflected immediately or are deferred until the value is changed more significantly. When 0, all calls to value result in an immediate repaint request.
Selects the integer value between min and max, reflected in the progress bar and eventual text.
If 1, the widget is drawn vertically and the progress bar moves from bottom to top. If 0, the widget is drawn horizontally and the progress bar moves from left to right.
Converts the integer VALUE into a string format and stores it in the REF scalar reference. Default stringifying conversion is identical to a call to sprintf("%2d%%").
sprintf("%2d%%")
Displays a progress bar
Selects the integer value between min and max, reflected in the progress bar and an eventual text.
The class provides the basic functionality of a sliding bar, equipped with tick marks. The tick marks are supposed to be drawn alongside the main sliding axis or the dialing circle, and provide visual feedback for the user.
A boolean flag, selects the way notifications are executed when the user mouse-drags the sliding bar. If 1, the Change notification is executed as soon as value is changed. If 0, Change is deferred until the user finishes the mouse drag; instead, the Track notification is executed when the bar is moved.
Change
Track
This property can be used when the Change notification handler performs very slowly, so the eventual fast mouse interactions would not thrash down the program.
A step range value used in scheme for marking the key ticks. See scheme for details.
scheme
If 1, the user cannot change the value by moving the bar or otherwise.
Selects the tick marks representation along the sliding axis or the dialing circle. ARRAY consists of hashes, each for one tick. The hash must contain at least a value key with an integer value. The two additional keys height and text, select the height of a tick mark in pixels, and the text is drawn near the mark, correspondingly.
height
text
If ARRAY is undef, no ticks are drawn.
undef
scheme is a property that creates a set of tick marks using one of the predefined scale designs selected by the ss::XXX constants. Each constant produces a different scale; some make use of the increment integer property that selects a step that is used to place additional text marks. As an example, the ss::Thermometer design with the default min, max, and increment values would look like this:
ss::XXX
increment
ss::Thermometer
0 10 20 100 | | | | |||||||||||||||....|||
The module defines the following constants:
ss::Axis - 5 minor ticks per increment ss::Gauge - 1 tick per increment ss::StdMinMax - 2 ticks at the ends of the bar ss::Thermometer - 10 minor ticks per increment, longer text ticks
When the tick property is explicitly set, scheme is reset to undef.
tick
If 1, value cannot accept values that are not on the tick scale. When such a value is attempted to be set, it is rounded to the closest tick mark. If 0, value can accept any integer value in the range from min to max.
An integer delta for singular increment and decrement commands, and also a threshold for value when the snap value is 0.
snap
Selects an integer value between min and max and the corresponding sliding bar position.
Called when the value value is changed, with one exception: if the user moves the sliding bar while autoTrack is 0, the Track notification is called instead.
autoTrack
Called when the user moves the sliding bar while the autoTrack value is 0; this notification is a substitute to Change.
Presents a linear sliding bar, movable along a linear shaft.
In horizontal mode, sets extra margin space between the slider line and the widget boundaries. Can be used for fine-tuning text labels from ticks(), where the default spacing (0) or spacing procedure (drop overlapping labels) does not produce decent results.
ticks()
If 1, the parts of the shaft are painted with different colors to increase visual feedback. If 0, the shaft is painted with the single default background color.
The breadth of the shaft in pixels.
Default value: 6
One of the tka::XXX constants that correspond to the position of the tick marks:
tka::XXX
tka::Normal - ticks are drawn on the left or the top of the shaft tka::Alternative - ticks are drawn on the right or at the bottom of the shaft tka::Dual - ticks are drawn both ways
The ticks' orientation ( left or top, right or bottom ) is dependent on the vertical property value.
vertical
Default value: tka::Normal
tka::Normal
If 1, the widget is drawn vertically, and the slider moves from bottom to top. If 0, the widget is drawn horizontally, and the slider moves from left to right.
Translates integer coordinates pair ( X, Y ) into the value corresponding to the scale, and returns three scalars:
If undef, the user-driven positioning is not possible ( min equals to max ).
If 1, the point is located on the slider.
If 0, the point is outside the slider.
If info is 0 or 1, contains the corresponding value.
info
Offset in pixels along the shaft axis.
Presents a slider widget with a dialing circle and two increment/decrement buttons. The tick marks are drawn around the perimeter of the dial; the current value is displayed in the center of the dial.
If 1, the increment / decrement buttons are shown at the bottom of the dial, and the user can change the value either by the dial or by the buttons. If 0, the buttons are not shown.
Default values: 0
Determines the style of a value indicator ( pointer ) on the dial. If 1, it is drawn as a black triangular mark. If 0, it is drawn as a small circular knob.
Converts integer value in the range from min to max into the corresponding angle, and returns two floating-point values: cosine and sine of the angle.
Converts integer value in the range from min to max into the point coordinates, with the RADIUS and dial center coordinates X and Y. Return the calculated point coordinates as two integers in the (X,Y) format.
Converts widget coordinates X and Y into value in the range from min to max and returns two scalars: the value and the boolean flag, which is set to 1 if the (X,Y) point is inside the dial circle, and to 0 otherwise.
Converts integer VALUE into a string format and stores it in the REF scalar reference. The resulting string is displayed in the center of the dial.
The default conversion routine simply copies VALUE to REF as is.
Dmitry Karasik, <dmitry@karasik.eu.org>, Anton Berezin <tobez@tobez.org>.
Prima, examples/fontdlg.pl
To install Prima, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Prima
CPAN shell
perl -MCPAN -e shell install Prima
For more information on module installation, please visit the detailed CPAN module installation guide.