Class: RETerm::Components::VSlider

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

Overview

Vertical Slider Component

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 = {}) ⇒ VSlider

Initialize the slider component

Parameters:

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

    slider params

[View source]

12
13
14
15
16
17
18
19
# File 'lib/reterm/components/vslider.rb', line 12

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.


7
8
9
# File 'lib/reterm/components/vslider.rb', line 7

def increment
  @increment
end

#initial_valueObject

Returns the value of attribute initial_value.


7
8
9
# File 'lib/reterm/components/vslider.rb', line 7

def initial_value
  @initial_value
end

#labelsObject

Returns the value of attribute labels.


7
8
9
# File 'lib/reterm/components/vslider.rb', line 7

def labels
  @labels
end

#rangeObject

Returns the value of attribute range.


7
8
9
# File 'lib/reterm/components/vslider.rb', line 7

def range
  @range
end

Instance Method Details

#activatable?Boolean

Returns:

  • (Boolean)
[View source]

33
34
35
# File 'lib/reterm/components/vslider.rb', line 33

def activatable?
  true
end

#activate!(*input) ⇒ Object

[View source]

37
38
39
40
41
# File 'lib/reterm/components/vslider.rb', line 37

def activate!(*input)
  refresh_win
  handle_input(*input)
  (range[1] - range[0]) * @value
end

#draw!Object

[View source]

29
30
31
# File 'lib/reterm/components/vslider.rb', line 29

def draw!
  refresh_win
end

#requested_colsObject

[View source]

25
26
27
# File 'lib/reterm/components/vslider.rb', line 25

def requested_cols
  3
end

#requested_rowsObject

[View source]

21
22
23
# File 'lib/reterm/components/vslider.rb', line 21

def requested_rows
  10
end