Class: Ampv::ProgressBarWidget

Inherits:
Gtk::DrawingArea
  • Object
show all
Defined in:
lib/ampv/progressbarwidget.rb

Instance Method Summary collapse

Constructor Details

#initializeProgressBarWidget

Returns a new instance of ProgressBarWidget.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ampv/progressbarwidget.rb', line 4

def initialize
  super
  modify_bg(Gtk::STATE_NORMAL, Gdk::Color.parse("#000"))
  set_size_request(-1, Config["progress_bar_height"])

  @value      = 0
  @bar_color  = Config["bar_color"]
  @head_color = Config["head_color"]

  signal_connect("expose_event") {
    @cx = window.create_cairo_context
    @cx.set_source_color(@bar_color)
    @cx.rectangle(0, 0, (allocation.width * @value.to_f).round, allocation.height)
    @cx.fill

    if @value > 0
      @cx.set_source_color(@head_color)
      @cx.rectangle((allocation.width * @value.to_f).round, 0, 2, allocation.height)
      @cx.fill
    end
  }
end

Instance Method Details

#value=(v) ⇒ Object



27
28
29
30
# File 'lib/ampv/progressbarwidget.rb', line 27

def value=(v)
  @value = v
  queue_draw
end