Class: RETerm::Components::Dial

Inherits:
RETerm::Component show all
Includes:
RETerm::ComponentInput
Defined in:
lib/reterm/components/dial.rb

Constant Summary

Constants included from RETerm::CommonKeys

RETerm::CommonKeys::DEC_CONTROLS, RETerm::CommonKeys::ENTER_CONTROLS, RETerm::CommonKeys::INC_CONTROLS, RETerm::CommonKeys::QUIT_CONTROLS

Constants included from LogHelpers

LogHelpers::LOG_FILE

Instance Attribute Summary collapse

Attributes included from RETerm::CommonControls

#quit_on_enter

Attributes inherited from RETerm::Component

#activatable, #activate_focus, #highlight_focus, #window

Instance Method Summary collapse

Methods included from RETerm::ComponentInput

#bind_key, #handle_input, #key_bound?, #on_enter, #on_key

Methods included from RETerm::CommonControls

#quit_on_enter?

Methods inherited from RETerm::Component

#activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #reactivate!, #resize, #sync!, #sync_getch

Methods included from KeyBindings

#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?

Methods included from LogHelpers

#logger

Methods included from EventDispatcher

#dispatch, #handle

Constructor Details

#initialize(args = {}) ⇒ Dial

Enapsulating window should be at least 4x4 for decent effect, at least 7x7 provides best resolution

Examples:

activating a dial

win  = Window.new
dial = Dial.new
win.component = dial

val = dial.activate!

Parameters:

  • args (Hash) (defaults to: {})

    dial params

[View source]

22
23
24
25
26
27
28
29
# File 'lib/reterm/components/dial.rb', line 22

def initialize(args={})
  super
  @initial_value = 0
  @increment     = 0.01
  @range         = [0, 1]
  @labels        = true
  @value = initial_value
end

Instance Attribute Details

#incrementObject

Returns the value of attribute increment.


6
7
8
# File 'lib/reterm/components/dial.rb', line 6

def increment
  @increment
end

#initial_valueObject

Returns the value of attribute initial_value.


6
7
8
# File 'lib/reterm/components/dial.rb', line 6

def initial_value
  @initial_value
end

#labelsObject

Returns the value of attribute labels.


6
7
8
# File 'lib/reterm/components/dial.rb', line 6

def labels
  @labels
end

#rangeObject

Returns the value of attribute range.


6
7
8
# File 'lib/reterm/components/dial.rb', line 6

def range
  @range
end

#valueObject

Returns the value of attribute value.


8
9
10
# File 'lib/reterm/components/dial.rb', line 8

def value
  @value
end

Instance Method Details

#activatable?Boolean

Returns:

  • (Boolean)
[View source]

43
44
45
# File 'lib/reterm/components/dial.rb', line 43

def activatable?
  true
end

#activate!(*input) ⇒ Object

[View source]

47
48
49
50
51
# File 'lib/reterm/components/dial.rb', line 47

def activate!(*input)
  refresh_win
  handle_input(*input)
  @value
end

#draw!Object

[View source]

39
40
41
# File 'lib/reterm/components/dial.rb', line 39

def draw!
  refresh_win
end

#requested_colsObject

[View source]

35
36
37
# File 'lib/reterm/components/dial.rb', line 35

def requested_cols
  7
end

#requested_rowsObject

[View source]

31
32
33
# File 'lib/reterm/components/dial.rb', line 31

def requested_rows
  7
end