Class: Zgomot::UI::GlobalsWindow

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

Constant Summary collapse

ITEM_WIDTH =
32
TIME_WIDTH =
15

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(top) ⇒ GlobalsWindow

Returns a new instance of GlobalsWindow.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/zgomot/ui/windows.rb', line 143

def initialize(top)
  output = Zgomot::Drivers::Mgr.output
  input = Zgomot::Drivers::Mgr.input || 'None'
  beats_per_minute = Zgomot::Midi::Clock.beats_per_minute.to_i.to_s
  time_signature = Zgomot::Midi::Clock.time_signature
  resolution = "1/#{Zgomot::Midi::Clock.resolution.to_i}"
  seconds_per_beat = Zgomot::Midi::Clock.beat_sec.to_s
  TitleWindow.new('zgomot', COLOR_BORDER, 0, COLOR_PINK)
  @input_window = TextWithValueWindow.new('Input', input, COLOR_BORDER, 3, 0, COLOR_IDLE)
  @output_window = TextWithValueWindow.new('Output', output, COLOR_BORDER, 4, 0, COLOR_IDLE)
  @time_signature_window = TextWithValueWindow.new('Time Signature', time_signature, COLOR_BORDER, 5, 0, COLOR_IDLE)
  @beats_per_minute_window = TextWithValueWindow.new('Beats/Minute', beats_per_minute, COLOR_BORDER, 3, ITEM_WIDTH, COLOR_IDLE)
  @seconds_per_beat_window = TextWithValueWindow.new('Seconds/Beat', seconds_per_beat, COLOR_BORDER, 4, ITEM_WIDTH, COLOR_IDLE)
  @resolution_window = TextWithValueWindow.new('Resolution', resolution, COLOR_BORDER, 5, ITEM_WIDTH, COLOR_IDLE)
  @time_window = TextWindow.new(time_to_s, COLOR_ACTIVE, 3, WIDTH - TIME_WIDTH)
end

Instance Attribute Details

#beats_per_minute_windowObject (readonly)

Returns the value of attribute beats_per_minute_window.



141
142
143
# File 'lib/zgomot/ui/windows.rb', line 141

def beats_per_minute_window
  @beats_per_minute_window
end

#input_windowObject (readonly)

Returns the value of attribute input_window.



141
142
143
# File 'lib/zgomot/ui/windows.rb', line 141

def input_window
  @input_window
end

#output_windowObject (readonly)

Returns the value of attribute output_window.



141
142
143
# File 'lib/zgomot/ui/windows.rb', line 141

def output_window
  @output_window
end

#resolution_windowObject (readonly)

Returns the value of attribute resolution_window.



141
142
143
# File 'lib/zgomot/ui/windows.rb', line 141

def resolution_window
  @resolution_window
end

#seconds_per_beat_windowObject (readonly)

Returns the value of attribute seconds_per_beat_window.



141
142
143
# File 'lib/zgomot/ui/windows.rb', line 141

def seconds_per_beat_window
  @seconds_per_beat_window
end

#time_signature_windowObject (readonly)

Returns the value of attribute time_signature_window.



141
142
143
# File 'lib/zgomot/ui/windows.rb', line 141

def time_signature_window
  @time_signature_window
end

#time_windowObject (readonly)

Returns the value of attribute time_window.



141
142
143
# File 'lib/zgomot/ui/windows.rb', line 141

def time_window
  @time_window
end

Instance Method Details

#displayObject



162
163
164
165
166
167
168
169
170
# File 'lib/zgomot/ui/windows.rb', line 162

def display
  time_window.display(time_to_s)
  input_window.display(Zgomot::Drivers::Mgr.input || 'None')
  output_window.display(Zgomot::Drivers::Mgr.output)
  time_signature_window.display(Zgomot::Midi::Clock.time_signature)
  beats_per_minute_window.display(Zgomot::Midi::Clock.beats_per_minute.to_i.to_s)
  seconds_per_beat_window.display(Zgomot::Midi::Clock.beat_sec.to_s)
  resolution_window.display("1/#{Zgomot::Midi::Clock.resolution.to_i}")
end

#time_to_sObject



159
160
161
# File 'lib/zgomot/ui/windows.rb', line 159

def time_to_s
  "%#{TIME_WIDTH}s" % /(\d*:\d*)/.match(Zgomot::Midi::Dispatcher.clk).captures.first
end