samples/07_advanced_audio/01_audio_mixer/app/main.rb
def input_panel args
  return unless args.state.panel
  return if args.state.dragging

  audio_entry = args.audio[args.state.selected]
  results = args.state.panel

  if args.state.mouse_state == :held && args.inputs.mouse.position.inside_rect?(results.pitch_slider_rect.rect)
    audio_entry.pitch = 2.0 * ((args.inputs.mouse.x - results.pitch_slider_rect.x).to_f / (results.pitch_slider_rect.w - 1.0))
  elsif args.state.mouse_state == :held && args.inputs.mouse.position.inside_rect?(results.playtime_slider_rect.rect)
    audio_entry.playtime = audio_entry.length_ * ((args.inputs.mouse.x - results.playtime_slider_rect.x).to_f / (results.playtime_slider_rect.w - 1.0))
  elsif args.state.mouse_state == :held && args.inputs.mouse.position.inside_rect?(results.gain_slider_rect.rect)
    audio_entry.gain = (args.inputs.mouse.x - results.gain_slider_rect.x).to_f / (results.gain_slider_rect.w - 1.0)
  elsif args.inputs.mouse.click && args.inputs.mouse.position.inside_rect?(results.looping_checkbox_rect.rect)
    audio_entry.looping = !audio_entry.looping
  elsif args.inputs.mouse.click && args.inputs.mouse.position.inside_rect?(results.paused_checkbox_rect.rect)
    audio_entry.paused = !audio_entry.paused
  elsif args.inputs.mouse.click && args.inputs.mouse.position.inside_rect?(results.delete_button_rect.rect)
    args.audio.delete args.state.selected
  end
end
# these are values you can change on the ~args.audio~ data structure
these are values you can change on the ~args.audio~ data structure
these are values you can change on the ~args . audio~ data structure
def input_panel args
  return unless args.state.panel
  return if args.state.dragging
  audio_entry = args.audio[args.state.selected]
  results = args.state.panel
  if args.state.mouse_state == :held && args.inputs.mouse.position.inside_rect?(results.pitch_slider_rect.rect)
    audio_entry.pitch = 2.0 * ((args.inputs.mouse.x - results.pitch_slider_rect.x).to_f / (results.pitch_slider_rect.w - 1.0))
  elsif args.state.mouse_state == :held && args.inputs.mouse.position.inside_rect?(results.playtime_slider_rect.rect)
    audio_entry.playtime = audio_entry.length_ * ((args.inputs.mouse.x - results.playtime_slider_rect.x).to_f / (results.playtime_slider_rect.w - 1.0))
  elsif args.state.mouse_state == :held && args.inputs.mouse.position.inside_rect?(results.gain_slider_rect.rect)
    audio_entry.gain = (args.inputs.mouse.x - results.gain_slider_rect.x).to_f / (results.gain_slider_rect.w - 1.0)
  elsif args.inputs.mouse.click && args.inputs.mouse.position.inside_rect?(results.looping_checkbox_rect.rect)
    audio_entry.looping = !audio_entry.looping
  elsif args.inputs.mouse.click && args.inputs.mouse.position.inside_rect?(results.paused_checkbox_rect.rect)
    audio_entry.paused = !audio_entry.paused
  elsif args.inputs.mouse.click && args.inputs.mouse.position.inside_rect?(results.delete_button_rect.rect)
    args.audio.delete args.state.selected
  end
end
def input_panel args return unless args . state . panel return if args . state . dragging audio_entry = args . audio [ args . state . selected ] results = args . state . panel if args . state . mouse_state == :held && args . inputs . mouse . position . inside_rect? ( results . pitch_slider_rect . rect ) audio_entry . pitch = 2.0 * ( ( args . inputs . mouse . x - results . pitch_slider_rect . x ) . to_f / ( results . pitch_slider_rect . w - 1.0 ) ) elsif args . state . mouse_state == :held && args . inputs . mouse . position . inside_rect? ( results . playtime_slider_rect . rect ) audio_entry . playtime = audio_entry . length_ * ( ( args . inputs . mouse . x - results . playtime_slider_rect . x ) . to_f / ( results . playtime_slider_rect . w - 1.0 ) ) elsif args . state . mouse_state == :held && args . inputs . mouse . position . inside_rect? ( results . gain_slider_rect . rect ) audio_entry . gain = ( args . inputs . mouse . x - results . gain_slider_rect . x ) . to_f / ( results . gain_slider_rect . w - 1.0 ) elsif args . inputs . mouse . click && args . inputs . mouse . position . inside_rect? ( results . looping_checkbox_rect . rect ) audio_entry . looping = ! audio_entry . looping elsif args . inputs . mouse . click && args . inputs . mouse . position . inside_rect? ( results . paused_checkbox_rect . rect ) audio_entry . paused = ! audio_entry . paused elsif args . inputs . mouse . click && args . inputs . mouse . position . inside_rect? ( results . delete_button_rect . rect ) args . audio . delete args . state . selected end end
these are values you can change on the ~args.audio~ data structure
these are values you can change on the ~args . audio~ data structure
args