Module: MSPhysics::ControlPanel

Defined in:
RubyExtension/MSPhysics/control_panel.rb

Overview

Since:

  • 1.0.0

Constant Summary

TITLE =

Since:

  • 1.0.0

'MSPhysics Control Panel'
FADE_DURATION =

Since:

  • 1.0.0

2.0
FADE_DELAY =

Since:

  • 1.0.0

2.0
MIN_OPACITY =

Since:

  • 1.0.0

10
MAX_OPACITY =

Since:

  • 1.0.0

250

Class Method Summary collapse

Class Method Details

.add_slider(name, default_value = 0, min = 0, max = 1, step = 0.01) ⇒ Boolean

Create a range slider.

Parameters:

  • name (String)

    Slider name.

  • default_value (Numeric) (defaults to: 0)

    Starting value.

  • min (Numeric) (defaults to: 0)

    Minimum value.

  • max (Numeric) (defaults to: 1)

    Maximum value.

  • step (Numeric) (defaults to: 0.01)

    Snap step.

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0

.bring_to_frontBoolean

Make the control panel active.

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0

.compute_text_size(text, opts = {}) ⇒ Array?

Note:

The control panel must be open for the values to be generated properly.

Compute size of a text in pixels.

Parameters:

  • text (String)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :font (String) — default: "Ariel"

    Text font.

  • :size (Fixnum) — default: 11

    Font size in pixels.

  • :bold (Boolean) — default: false

    Whether to have the text bold.

  • :italic (Boolean) — default: false

    Whether to have the text italicized.

Returns:

  • (Array, nil)

    An array of two values if successful

Since:

  • 1.0.0

.execute_js(code) ⇒ nil

Execute JavaScript in the control panel.

Parameters:

  • code (String)

Returns:

  • (nil)

Since:

  • 1.0.0

.get_slider_value(name) ⇒ Numeric?

Get slider value.

Parameters:

  • name (String)

    Slider name.

Returns:

  • (Numeric, nil)

    Slider value or nil if slider with the given name doesn't exist.

Since:

  • 1.0.0

.handleFixnum?

Acquire handle to the control panel.

Returns:

  • (Fixnum, nil)

Since:

  • 1.0.0

.open(state) ⇒ Boolean

Open/close MSPhysics control panel.

Parameters:

  • state (Boolean)

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0

.open?Boolean

Determine whether control panel is open.

Returns:

  • (Boolean)

Since:

  • 1.0.0

.remove_slider(name) ⇒ Boolean

Destroy a range slider.

Parameters:

  • name (String)

    Slider name.

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0

.remove_slidersFixnum

Destroy all range sliders.

Returns:

  • (Fixnum)

    Number of sliders removed.

Since:

  • 1.0.0

.set_slider_value(name, value) ⇒ Boolean

Set slider value.

Parameters:

  • name (String)

    Slider name.

  • value (Numeric)

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0

.show(state) ⇒ Boolean

Note:

Windows only!

Show/hide the control panel window.

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0

.slider_exists?(name) ⇒ Boolean

Determine whether a range slider with a particular name already exists.

Parameters:

  • name (String)

Returns:

  • (Boolean)

Since:

  • 1.0.0

.sliders_countFixnum

Get the number of sliders in the control panel.

Returns:

  • (Fixnum)

Since:

  • 1.0.0

.visible?Boolean

Determine whether the control panel window is visible.

Returns:

  • (Boolean)

Since:

  • 1.0.0