Class: MittensUi::Slider

Inherits:
Core
  • Object
show all
Defined in:
lib/mittens_ui/slider.rb

Instance Attribute Summary

Attributes inherited from Core

#core_widget

Instance Method Summary collapse

Methods inherited from Core

#hidden?, #hide, #remove, #show

Methods included from Helpers

#icon_map, #list_system_icons, #set_margin_from_opts_for

Constructor Details

#initialize(options = {}) ⇒ Slider

Returns a new instance of Slider.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mittens_ui/slider.rb', line 5

def initialize(options={})
  start_value = options[:start_value].nil?    ? 1.0  : options[:start_value]
  stop_value  = options[:stop_value].nil?     ? 10.0 : options[:stop_value]
  step_value  = options[:step_value].nil?     ? 1.0  : options[:step_value]
  init_value  = options[:initial_value].nil?  ? 1.0  : options[:initial_value]

  @scale = Gtk::Scale.new(:horizontal, start_value, stop_value, step_value)
  @scale.digits = 0
  @scale.draw_value = true
  @scale.value = init_value

  super(@scale)
end

Instance Method Details

#moveObject Also known as: slide



19
20
21
22
23
# File 'lib/mittens_ui/slider.rb', line 19

def move
  @scale.signal_connect "value_changed" do |scale_widget|
    yield(scale_widget)
  end
end

#renderObject



26
27
28
29
# File 'lib/mittens_ui/slider.rb', line 26

def render
  $vertical_box.pack_start(@scale)
  return self
end