Class: Zgomot::UI::MainWindow

Inherits:
Object
  • Object
show all
Defined in:
lib/zgomot/ui/windows.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cc_windowObject (readonly)

Returns the value of attribute cc_window.



40
41
42
# File 'lib/zgomot/ui/windows.rb', line 40

def cc_window
  @cc_window
end

.globals_windowObject (readonly)

Returns the value of attribute globals_window.



40
41
42
# File 'lib/zgomot/ui/windows.rb', line 40

def globals_window
  @globals_window
end

.main_windowObject (readonly)

Returns the value of attribute main_window.



40
41
42
# File 'lib/zgomot/ui/windows.rb', line 40

def main_window
  @main_window
end

.str_windowObject (readonly)

Returns the value of attribute str_window.



40
41
42
# File 'lib/zgomot/ui/windows.rb', line 40

def str_window
  @str_window
end

Class Method Details

.dashObject



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/zgomot/ui/windows.rb', line 85

def dash
  init_curses
  @globals_window = GlobalsWindow.new(0)
  @cc_window = CCWindow.new(Curses.lines - CCS_TOP, CCS_TOP)
  @str_window = StrWindow.new(GLOBALS_HEIGHT)
  Curses.refresh
  poll
  loop do
    case Curses.getch
    when ?t
      str_window.set_tog_mode
      update
    when Curses::Key::UP
      str_window.dec_selected
      update
    when Curses::Key::DOWN
      str_window.inc_selected
      update
    when 10
      str_window.tog
      update
    when ?p
      Zgomot::Midi::Stream.play
      update
    when ?s
      Zgomot::Midi::Stream.stop
      update
    when ?q
      @thread.kill
      Curses.close_screen
      break
    end
  end
end

.init_cursesObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/zgomot/ui/windows.rb', line 41

def init_curses
  Curses.init_screen
  Curses.noecho
  Curses.stdscr.keypad(true)
  Curses.start_color
  Curses.curs_set(0)
  Curses.init_color(COLOR_GREY, 700, 700, 700)
  Curses.init_color(COLOR_GOLD, 1000, 840, 0)
  Curses.init_color(COLOR_GREEN, 484, 980, 0)
  Curses.init_color(COLOR_PINK, 1000, 100, 575)
  Curses.init_color(COLOR_BLUE, 117, 575, 1000)
  Curses.init_color(COLOR_VIOLET, 810, 410, 980)
  Curses.init_color(COLOR_MAGENTA, 1000, 200, 1000)
  Curses.init_color(COLOR_YELLOW_GREEN, 750, 980, 410)
  Curses.init_color(COLOR_LIGHT_BLUE,600, 1000, 1000)
  Curses.init_color(COLOR_ORANGE,1000 , 600, 0)
  Curses.init_pair(COLOR_GOLD,COLOR_GOLD,COLOR_BLACK)
  Curses.init_pair(COLOR_GREEN,COLOR_GREEN,COLOR_BLACK)
  Curses.init_pair(COLOR_PINK,COLOR_PINK,COLOR_BLACK)
  Curses.init_pair(COLOR_BLUE,COLOR_BLUE,COLOR_BLACK)
  Curses.init_pair(COLOR_BORDER,COLOR_GREY,COLOR_BLACK)
  Curses.init_pair(COLOR_IDLE,COLOR_GOLD,COLOR_BLACK)
  Curses.init_pair(COLOR_ACTIVE,COLOR_GREEN,COLOR_BLACK)
  Curses.init_pair(COLOR_STREAM_PLAYING_SELECTED,COLOR_BLACK,COLOR_GREEN)
  Curses.init_pair(COLOR_STREAM_PAUSED_SELECTED,COLOR_BLACK,COLOR_GOLD)
  Curses.init_pair(COLOR_CC_SWITCH_TRUE,COLOR_ORANGE,COLOR_BLACK)
  Curses.init_pair(COLOR_CC_SWITCH_FALSE,COLOR_LIGHT_BLUE,COLOR_BLACK)
  Curses.init_pair(COLOR_CC_IDLE,COLOR_VIOLET,COLOR_BLACK)
  Curses.init_pair(COLOR_CC_ACTIVE,COLOR_BLACK,COLOR_VIOLET)
end

.pollObject



77
78
79
80
81
82
83
84
# File 'lib/zgomot/ui/windows.rb', line 77

def poll
  @thread = Thread.new do
              loop do
                update
                sleep(Zgomot::Midi::Clock.beat_sec)
              end
            end
end

.updateObject



71
72
73
74
75
76
# File 'lib/zgomot/ui/windows.rb', line 71

def update
  globals_window.display
  cc_window.display
  str_window.display
  Curses.refresh
end