Class: Zgomot::UI::StrWindow

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(height, top) ⇒ StrWindow

Returns a new instance of StrWindow.



175
176
177
178
179
180
181
# File 'lib/zgomot/ui/windows.rb', line 175

def initialize(height, top)
  @select_mode, @selected, @top, @current, @height = false, [], top, 0, height
  @widths = Zgomot::UI::Output::STREAM_OUTPUT_FORMAT_WIDTHS
  TitleWindow.new('Streams', COLOR_BORDER, top, COLOR_BLUE)
  TableRowWindow.new(Zgomot::UI::Output::STREAM_HEADER, widths, COLOR_BORDER, top + 3, COLOR_BORDER)
  add_streams(top + 3)
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



174
175
176
# File 'lib/zgomot/ui/windows.rb', line 174

def current
  @current
end

#heightObject (readonly)

Returns the value of attribute height.



174
175
176
# File 'lib/zgomot/ui/windows.rb', line 174

def height
  @height
end

#rowsObject (readonly)

Returns the value of attribute rows.



174
175
176
# File 'lib/zgomot/ui/windows.rb', line 174

def rows
  @rows
end

#select_modeObject (readonly)

Returns the value of attribute select_mode.



174
175
176
# File 'lib/zgomot/ui/windows.rb', line 174

def select_mode
  @select_mode
end

#selectedObject (readonly)

Returns the value of attribute selected.



174
175
176
# File 'lib/zgomot/ui/windows.rb', line 174

def selected
  @selected
end

#topObject (readonly)

Returns the value of attribute top.



174
175
176
# File 'lib/zgomot/ui/windows.rb', line 174

def top
  @top
end

#widthsObject (readonly)

Returns the value of attribute widths.



174
175
176
# File 'lib/zgomot/ui/windows.rb', line 174

def widths
  @widths
end

#windowObject (readonly)

Returns the value of attribute window.



174
175
176
# File 'lib/zgomot/ui/windows.rb', line 174

def window
  @window
end

Instance Method Details

#dec_selectedObject



197
198
199
200
201
# File 'lib/zgomot/ui/windows.rb', line 197

def dec_selected
  if select_mode
    @current = (current - 1) % streams.length
  end
end

#deleteObject



224
225
226
227
228
229
# File 'lib/zgomot/ui/windows.rb', line 224

def delete
  selected.each do |s|
    stream = streams[s]
    Zgomot::Midi::Stream.delete(stream.name)
  end
end

#displayObject



182
183
184
185
186
187
188
189
190
191
# File 'lib/zgomot/ui/windows.rb', line 182

def display
  if streams.length == rows.length
    (0..streams.length-1).each do |i|
      stream = streams[i]
      rows[i].display(stream.info, stream_color(stream, i))
    end
  else
    add_streams(top + 3)
  end
end

#inc_selectedObject



192
193
194
195
196
# File 'lib/zgomot/ui/windows.rb', line 192

def inc_selected
  if select_mode
   @current = (current + 1) % streams.length
  end
end

#selectObject



202
203
204
205
206
207
208
# File 'lib/zgomot/ui/windows.rb', line 202

def select
  if selected.include?(current)
    @selected.delete(current)
  else
    @selected << current
  end
end

#set_select_modeObject



209
210
211
212
213
214
215
216
217
# File 'lib/zgomot/ui/windows.rb', line 209

def set_select_mode
  if select_mode
    @select_mode = false
    @selected = []
    @current = 0
  else
    @select_mode = true
  end
end

#togObject



218
219
220
221
222
223
# File 'lib/zgomot/ui/windows.rb', line 218

def tog
  selected.each do |s|
    stream = streams[s]
    Zgomot::Midi::Stream.tog(stream.name)
  end
end