Class: Ektoplayer::Views::Playlist

Inherits:
UI::ListWidget show all
Defined in:
lib/ektoplayer/views/playlist.rb

Instance Attribute Summary

Attributes inherited from UI::ListWidget

#cursor, #item_renderer, #list, #selected, #selection

Attributes inherited from UI::Window

#win

Attributes inherited from UI::Widget

#pos, #size

Instance Method Summary collapse

Methods inherited from UI::ListWidget

#bottom, #center, #down, #draw, #force_cursorpos, #get_selection, #layout, #on_mouse_click, #page_down, #page_up, #scroll_cursor_down, #scroll_cursor_up, #scroll_list_down, #scroll_list_up, #search_down, #search_next, #search_prev, #search_start, #search_up, #select_from_cursorpos, #toggle_selection, #top, #up

Methods inherited from UI::Window

#layout, #noutrefresh, #refresh

Methods inherited from UI::Widget

#display, #draw, #events, #invisible!, #invisible?, #key_press, #keys, #layout, #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

#initialize(**opts) ⇒ Playlist

Returns a new instance of Playlist.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ektoplayer/views/playlist.rb', line 9

def initialize(**opts)
   super(**opts)

   if ICurses.colors == 256
      f = Config[:'playlist.format_256']
   else
      f = Config[:'playlist.format']
   end

   self.item_renderer=(TrackRenderer.new(width: @size.width, format: f))
end

Instance Method Details

#attach(playlist) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ektoplayer/views/playlist.rb', line 21

def attach(playlist)
   self.list=(playlist.to_a)

   playlist.events.on(:changed) do
      with_lock { self.list=(playlist.to_a); want_redraw }
   end

   playlist.events.on(:current_changed) do
      self.current_playing=(playlist.current_playing)
   end
end

#current_playing=(p) ⇒ Object



38
39
40
41
# File 'lib/ektoplayer/views/playlist.rb', line 38

def current_playing=(p)
   return if @current_playing == p
   with_lock { @current_playing = p; want_redraw }
end

#render(index, **opts) ⇒ Object



33
34
35
36
# File 'lib/ektoplayer/views/playlist.rb', line 33

def render(index, **opts)
   opts[:marked] = true if index == @current_playing
   super(index, **opts)
end