Пример #1
0
bool ClipSelector::on_button_press_event(GdkEventButton* event)
{
  block = ((int)event->y) / 18;
  
  if ( masterClipSelector )
  {
    if ( event->button == 1 )
    {
      // tell the engine to play a scene
      EngineEvent* x = new EngineEvent();
      x->setSceneNumber(block);
      top->toEngineQueue.push(x);
      
      masterClipPlaying = block;
      redraw();
      
      // harmonySeq integration: send it the scene id OSC tag
      //cout << "ClipSelector: HarmonySeq integration: Sending OSC tag # " << block << " now!" << endl;
      //lo_send( lo_address_new(NULL, "7773") , "/harmonyseq/event", "i", block );
      return true;
    }
    else // rename scene
    {
      Gtk::Dialog dialog("Rename Scene", false); // not modal, leave program update!
      
      Gtk::Entry* entry = new Gtk::Entry();
      entry->set_activates_default (true);
      
      dialog.add_button( Gtk::Stock::OK, Gtk::RESPONSE_OK );
      dialog.add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
      
      dialog.set_default_response( Gtk::RESPONSE_OK );
      dialog.get_vbox()->add( *entry );
      dialog.get_vbox()->show_all();
      
      list<string>::iterator iter = nameList.begin();
      string name;
      
      switch ( dialog.run() )
      {
        case Gtk::RESPONSE_OK:
          name = entry->get_buffer()->get_text();
          cout << " Dialog OK clicked, entry contains: " << name << endl;
          advance(iter, block);
          *iter = name;
          redraw();
          break;
        default: break;
      }
      
    }
    
    return true;
  }
  
  if( event->type == GDK_BUTTON_PRESS && event->button == 1 && event-> x < 20 ) // left
  {
    // so we're gonna play a clip, if the track is record enabled, and the
    // current block is *NOT* recording yet, we set it to record, otherwise
    // we stop it from recording. If the track isn't record armed: then we
    // send a play message
    TrackOutputState* state = &stateStore->trackoutputState.at(ID);
    if ( state->recEnable && stateStore->trackoutputState.at(ID).recEnable == false )
    {
      std::cout << "ClipSelector " << ID << ": Record ON Press on block " << block << std::endl;
    }
    else if (  state->recEnable && stateStore->trackoutputState.at(ID).recEnable == true )
    {
      std::cout << "ClipSelector " << ID << ": Record OFF Press on block " << block << std::endl;
    }
    else
    {
      std::cout << "ClipSelector " << ID << ": Play Button Press on block " << block << std::endl;
    }
    
    // 
    EngineEvent* x = new EngineEvent();
    x->looperSelectBuffer(ID,block);
    top->toEngineQueue.push(x);
  }
  else
  {
    // its a click in the block, but probably for "drag drop" functionality,
    // *dont* set the block to play, jsut storke the block number that we've
    // clicked on so we can send it later (this is done @ top of function already)
  }
  
  
  if( event->type == GDK_BUTTON_PRESS && event->button == 3 ) // right
  {
    std::cout << "ClipSelector " << ID << ": Load event on block " << block << std::endl; 
    loadSample(block);
  }
  
  return true;
}