TK.LevelMeter

new LevelMeter(optionsopt)

TK.LevelMeter is a fully functional meter bar displaying numerical values. TK.LevelMeter is an enhanced TK.MeterBase's containing a clip LED, a peak pin with value label and hold markers. In addition, LevelMeter has an optional falling animation, top and bottom peak values and more.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{ }

An object containing initial options.

Properties:
Name Type Attributes Default Description
options.show_clip Boolean <optional>
false

If set to true, show the clipping LED.

options.clipping Number <optional>
0

If clipping is enabled, this is the threshold for the clipping effect.

options.auto_clip Integer | Boolean <optional>
false

This is the clipping timeout. If set to false automatic clipping is disabled. If set to n the clipping effect times out after n ms, if set to -1 it remains forever.

options.clip Boolean <optional>
false

If clipping is enabled, this option is set to true when clipping happens. When automatic clipping is disabled, it can be set to true to set the clipping state.

options.clip_options Object <optional>
{}

Additional options for the TK.State clip LED.

options.show_hold Boolean <optional>
false

If set to true, show the hold value LED.

options.hold_size Integer <optional>
1

Size of the hold value LED in the number of segments.

options.auto_hold Number | boolean <optional>
false

If set to false the automatic hold LED is disabled, if set to n the hold value is reset after n ms and if set to -1 the hold value is not reset automatically.

options.top Number <optional>
false

The top hold value. If set to false it will equal the meter level.

options.bottom Number <optional>
false

The bottom hold value. This only exists if a base value is set and the value falls below the base.

options.show_peak Boolean <optional>
false

If set to true, show the peak label.

options.peak_label Integer | Boolean <optional>
false

If set to false the automatic peak label is disabled, if set to n the peak label is reset after n ms and if set to -1 it remains forever.

options.format_peak function <optional>
TK.FORMAT("%.2f")

Formatting function for the peak label.

options.falling Number <optional>
0

If set to a positive number, activates the automatic falling animation. The meter level will fall by this amount per frame.

options.falling_fps Number <optional>
24

This is the number of frames of the falling animation. It is not an actual frame rate, but instead is used to determine the actual speed of the falling animation together with the option falling.

options.falling_init Number <optional>
2

Initial falling delay in number of frames. This option can be used to delay the start of the falling animation in order to avoid flickering if internal and external falling are combined.

Source:

Extends

Members

_peak :HTMLDivElement

The DIV element for the peak marker. Has class toolkit-peak.

Source:

element :HTMLDivElement

The main DIV container. Has class toolkit-level-meter.

Overrides:
Source:

Members inherited from TK.MeterBase

_bar :HTMLDivElement

The DIV element containing the masks and drawing the background. Has class toolkit-bar.

_canvas :HTMLCanvas

The canvas element drawing the mask. Has class toolkit-mask.

label :TK.Label

The TK.Label displaying the label.

scale :TK.Scale

The TK.Scale of the meter.

title :TK.Label

The TK.Label displaying the title. Has class toolkit-title.

Methods

reset_all()

Resets all hold features.

Source:
Fires:

reset_bottom()

Resets the bottom hold.

Source:
Fires:

reset_clip()

Resets the clipping LED.

Source:
Fires:

reset_label()

Resets the label.

Source:
Fires:

reset_peak()

Resets the peak label.

Source:
Fires:

reset_top()

Resets the top hold.

Source:
Fires:

Methods inherited from TK.Widget

add_child(child)

Registers a widget as a child widget. This method is used to build up the widget tree. It does not modify the DOM tree.

add_children(a)

Registers an array of widgets as children.

all_children()

Returns an array of all children.

enable_draw()

Schedules this widget for drawing.

force_hide()

This is an alias for hide, which may be overloaded. See TK.Container for an example.

force_show()

This is an alias for hide, which may be overloaded. See TK.Container for an example.

get_style()

Returns the computed style of this widgets DOM element.

hidden()

Returns the current hidden status.

hide()

Make the widget hidden. This does not modify the DOM, instead it will stop rendering this widget. Options changed after calling hide will only be rendered (i.e. applied to the DOM) when the widget is made visible again using TK.Widget#show.

remove_child(child)

Removes a child widget. Note that this method only modifies the widget tree and does not change the DOM.

remove_children(a)

Removes an array of children.

set(key, value)

Sets an option.

set_style()

Sets a CSS style property in this widgets DOM element.

show()

Make the widget visible. This does not modify the DOM, instead it will only schedule the widget for rendering.

toggle_hidden()

TK.Toggle the hidden status. This is equivalent to calling hide() or show(), depending on the current hidden status of this widget.

visible_children()

Returns an array of all visible children.

widgetize()

Set the DOM elements of this widgets. This method is usually only used internally. Basically it means to add the id from options and set a basic CSS class. If delegate is true, basic events will be delegated from the element to the widget instance if classify is true, CSS functions will be bound to the widget instance.

Methods inherited from TK.Base

add_event(event, func, prevent, stop)

Register an event handler.

add_events(events, func)

Add multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

delegate_events(element) → {HTMLElement}

Delegates all occuring DOM events of a specific DOM node to the widget. This way the widget fires e.g. a click event if someone clicks on the given DOM node.

destroy()

Destroys all event handlers and the options object.

fire_event(event, …args)

Fires an event.

fire_events(events)

Fires several events.

get(key)

Get the value of an option.

has_event_listeners(event) → {boolean}

Test if the event descriptor has some handler functions in the queue.

remove_event(event, fun)

Removes the given function from the event queue. If it is a native DOM event, it removes the DOM event listener as well.

remove_events(events, func)

Remove multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

set_options(optionsopt)

Merges a new options object into the existing one, including deep copies of objects. If an option key begins with the string "on" it is considered as event handler. In this case the value should be the handler function for the event with the corresponding name without the first "on" characters.

userset(key, value)

Sets an option by user interaction. Emits the userset event. The userset event can be cancelled (if an event handler returns false), in which case the option is not set. Returns true if the option was set, false otherwise. If the option was set, it will emit a useraction event.

Events

drawpeak

Is fired when the peak was drawn.

Source:

resetbottom

Is fired when the bottom hold was reset.

Source:

resetclip

Is fired when the clipping LED was reset.

Source:

resetlabel

Is fired when the label was reset.

Source:

resetpeak

Is fired when the peak was reset.

Source:

resettop

Is fired when the top hold was reset.

Source:

Events inherited from TK.MeterBase

basechanged

Is fired when the base value changed. The argument is the actual base value.

labelchanged

Is fired when the label changed. The argument is the actual label value.

titlechanged

Is fired when the title changed. The argument is the actual title.

valuechanged

Is fired when the value changed. The argument is the actual value.

Events inherited from TK.Widget

GenericDOMEvents

Generic DOM events. Please refer to W3Schools for further details.

classified

Is fired when a widget is classified.

destroy

Is fired when a widget is destroyed.

doubleclick

Is fired after a double click appeared. Set dblclick to 0 to disable click event handling.

hide

The hide event is emitted when a widget is hidden and is not rendered anymore. This happens both with browser visibility changes and also internally when using layout widgets such as TK.Pager.

initialized

Is fired when a widget is initialized.

redraw

Is fired when a redraw is executed.

resize

The resize event is emitted whenever a widget is being resized. This event can be used to e.g. measure its new size. Note that some widgets do internal adjustments after the resize event. If that is relevant, the TK.Widget#resized event can be used, instead.

resized

The resized event is emitted after each rendering frame, which was triggered by a resize event.

set

The set event is emitted when an option was set using the TK.Widget#set method. The arguments are the option name and its new value.

Note that this happens both for user interaction and programmatical option changes.

show

The show event is emitted when a widget is shown and is being rendered. This is the counterpart to TK.Widget#hide.

stylized

Is fired when a widget is stylized.

visibility

Is fired when the visibility state changes. The first argument is the visibility state, which is either true or false.

widgetize

Is fired when a widget is widgetized.

Events inherited from TK.Base

delegated

Is fired when an element is delegated.

set_[option]

Is fired when an option is set.