Class: Ektoplayer::Views::ProgressBar

Inherits:
UI::Pad show all
Defined in:
lib/ektoplayer/views/progressbar.rb

Instance Attribute Summary

Attributes inherited from UI::Pad

#win

Attributes inherited from UI::Widget

#pos, #size

Instance Method Summary collapse

Methods inherited from UI::Pad

#bottom, #down, #initialize, #mouse_click, #noutrefresh, #pad_mincol=, #pad_minrow=, #pad_size=, #page_down, #page_up, #refresh, #top, #up, #with_mouse_section_event

Methods inherited from UI::Widget

#display, #events, #initialize, #invisible!, #invisible?, #key_press, #keys, #lock, #mouse, #mouse_click, #mouse_event_transform, #mouse_section, #on_key_press, #on_widget_raise, #raise_widget, #refresh, #sub, #unlock, #visible!, #visible=, #visible?, #want_layout, #want_redraw, #want_refresh, #with_lock

Constructor Details

This class inherits a constructor from UI::Pad

Instance Method Details

#attach(player) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ektoplayer/views/progressbar.rb', line 35

def attach(player)
   player.events.on(:position_change) do
      old = @progress_width
      @progress_width = @size.width - (player.position_percent * @size.width).to_i rescue 0

      if (old != @progress_width) and visible?
         @pad_mincol = (@progress_width)
         refresh
      end
   end

   view=self # TODO
   [ICurses::BUTTON1_CLICKED, ICurses::BUTTON2_CLICKED, ICurses::BUTTON3_CLICKED].
      each do |button|
      view.mouse.on(button) do |mevent|
         x = mevent.x - @pad_mincol
         pos = Float(x) / (self.size.width - 1) * player.length rescue player.position
         player.seek(pos.to_i)
         @progress_width = x
         self.pad_mincol=(@size.width - @progress_width)
      end
   end
end

#drawObject



59
60
# File 'lib/ektoplayer/views/progressbar.rb', line 59

def draw
end

#layoutObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ektoplayer/views/progressbar.rb', line 8

def layout
   super
   self.pad_size=(UI::Size.new(
      height: 1, width:  @size.width * 2
   ))

   if Theme.current == 256
      fader = UI::ColorFader.new([25,26,27,32,39,38,44,44,45,51,87,159,195])
   elsif Theme.current == 8
      fader = UI::ColorFader.new([:blue])
   else
      fader = UI::ColorFader.new([-1])
   end

   progress_char = Config[:'progressbar.progress_char']

   @win.move(0,0)

   fader.fade(@size.width).each do |c|
      @win.attron(c)
      @win.addstr(progress_char)
   end

   @win.attron(Theme[:'progressbar.rest'])
   @win << Config[:'progressbar.rest_char'] * @size.width
end