bool FruityPerfInput::on_button_press_event (GdkEventButton * ev, perfroll & roll) { bool result = false; perform & p = roll.perf(); roll.grab_focus(); int & dropseq = roll.m_drop_sequence; /* reference needed */ sequence * seq = p.get_sequence(dropseq); if (p.is_active(dropseq)) { seq->unselect_triggers(); roll.draw_all(); } else { return false; } roll.m_drop_x = int(ev->x); roll.m_drop_y = int(ev->y); m_current_x = int(ev->x); m_current_y = int(ev->y); roll.convert_xy /* side-effects */ ( roll.m_drop_x, roll.m_drop_y, roll.m_drop_tick, dropseq ); if (SEQ64_CLICK_LEFT(ev->button)) { result = on_left_button_pressed(ev, roll); } else if (SEQ64_CLICK_RIGHT(ev->button)) { result = on_right_button_pressed(ev, roll); } else if (SEQ64_CLICK_MIDDLE(ev->button)) /* left-ctrl???, middle */ { /* * Implements some Stazed fixes now. */ if (p.is_active(dropseq)) { midipulse droptick = roll.m_drop_tick; droptick -= droptick % roll.m_snap; /* stazed fix: grid snap */ bool state = seq->get_trigger_state(droptick); if (state) /* trigger click, split it */ { roll.split_trigger(dropseq, droptick); result = true; } else /* track click, paste trig */ { p.push_trigger_undo(dropseq); seq->paste_trigger(droptick); } } } update_mouse_pointer(roll); return result; }
bool FruityPerfInput::on_button_press_event(GdkEventButton* a_ev, perfroll& ths) { ths.grab_focus( ); if ( ths.m_mainperf->is_active( ths.m_drop_sequence )) { ths.m_mainperf->get_sequence( ths.m_drop_sequence )->unselect_triggers( ); ths.draw_background_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_sequence_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_drawable_row( ths.m_window, ths.m_pixmap, ths.m_drop_y); } ths.m_drop_x = (int) a_ev->x; ths.m_drop_y = (int) a_ev->y; m_current_x = (int) a_ev->x; m_current_y = (int) a_ev->y; ths.convert_xy( ths.m_drop_x, ths.m_drop_y, &ths.m_drop_tick, &ths.m_drop_sequence ); /* left mouse button */ if ( a_ev->button == 1) { on_left_button_pressed(a_ev, ths); } /* right mouse button */ if ( a_ev->button == 3 ) { on_right_button_pressed(a_ev, ths); } /* left-ctrl, or middle: split */ if ( a_ev->button == 2 ) { if ( ths.m_mainperf->is_active( ths.m_drop_sequence )){ bool state = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_trigger_state( ths.m_drop_tick ); if ( state ) { ths.split_trigger(ths.m_drop_sequence, ths.m_drop_tick); } } } updateMousePtr( ths ); return true; }
bool Seq24PerfInput::on_button_press_event (GdkEventButton * ev, perfroll & roll) { bool result = false; perform & p = roll.perf(); int & dropseq = roll.m_drop_sequence; sequence * seq = p.get_sequence(dropseq); bool dropseq_active = p.is_active(dropseq); roll.grab_focus(); if (dropseq_active) { seq->unselect_triggers(); roll.draw_all(); } roll.m_drop_x = int(ev->x); roll.m_drop_y = int(ev->y); roll.convert_drop_xy(); /* affects dropseq */ seq = p.get_sequence(dropseq); dropseq_active = p.is_active(dropseq); if (! dropseq_active) return false; /* * EXPERIMENTAL. * Let's make better use of the Ctrl key here. First, let Ctrl-Left be * handled exactly like the Middle click, then bug out. * * Note that this middle-click code ought to be folded into a function. */ if (is_ctrl_key(ev)) { if (SEQ64_CLICK_LEFT(ev->button)) { bool state = seq->get_trigger_state(roll.m_drop_tick); if (state) { roll.split_trigger(dropseq, roll.m_drop_tick); } else { p.push_trigger_undo(dropseq); seq->paste_trigger(roll.m_drop_tick); } } return true; } if (SEQ64_CLICK_LEFT(ev->button)) { midipulse droptick = roll.m_drop_tick; if (is_adding()) /* add new note if nothing selected */ { set_adding_pressed(true); midipulse seqlength = seq->get_length(); bool state = seq->get_trigger_state(droptick); if (state) { p.push_trigger_undo(dropseq); /* stazed fix */ seq->del_trigger(droptick); } else { droptick -= (droptick % seqlength); /* snap */ p.push_trigger_undo(dropseq); /* stazed fix */ seq->add_trigger(droptick, seqlength); roll.draw_all(); } result = true; } else { /* * Set this flag to tell on_motion_notify() to call * p.push_trigger_undo(). */ roll.m_have_button_press = seq->select_trigger(droptick); midipulse tick0 = seq->selected_trigger_start(); midipulse tick1 = seq->selected_trigger_end(); int wscalex = s_perfroll_size_box_click_w * c_perf_scale_x; int ydrop = roll.m_drop_y % c_names_y; if ( droptick >= tick0 && droptick <= (tick0 + wscalex) && ydrop <= s_perfroll_size_box_click_w + 1 ) { roll.m_growing = true; roll.m_grow_direction = true; roll.m_drop_tick_trigger_offset = droptick - seq->selected_trigger_start(); } else if ( droptick >= (tick1 - wscalex) && droptick <= tick1 && ydrop >= c_names_y - s_perfroll_size_box_click_w - 1 ) { roll.m_growing = true; roll.m_grow_direction = false; roll.m_drop_tick_trigger_offset = droptick - seq->selected_trigger_end(); } else { roll.m_moving = true; roll.m_drop_tick_trigger_offset = droptick - seq->selected_trigger_start(); } roll.draw_all(); } } else if (SEQ64_CLICK_RIGHT(ev->button)) { activate_adding(true, roll); // Should we add this? // result = true; } else if (SEQ64_CLICK_MIDDLE(ev->button)) /* split */ { /* * The middle click in seq24 interaction mode is either for splitting * the triggers or for setting the paste location of copy/paste. */ bool state = seq->get_trigger_state(roll.m_drop_tick); if (state) { roll.split_trigger(dropseq, roll.m_drop_tick); result = true; } else { p.push_trigger_undo(dropseq); seq->paste_trigger(roll.m_drop_tick); // Should we add this? // result = true; } } return result; }
void FruityPerfInput::on_left_button_pressed(GdkEventButton* a_ev, perfroll& ths) { if ( a_ev->state & GDK_CONTROL_MASK ) { if ( ths.m_mainperf->is_active( ths.m_drop_sequence )) { bool state = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_trigger_state( ths.m_drop_tick ); if ( state ) { ths.split_trigger(ths.m_drop_sequence, ths.m_drop_tick); } } } else { long tick = ths.m_drop_tick; /* add a new note if we didnt select anything */ //if (m_adding) { m_adding_pressed = true; if ( ths.m_mainperf->is_active( ths.m_drop_sequence )){ long seq_length = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_length( ); bool state = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_trigger_state( tick ); // resize the event, or move it, depending on where clicked. if ( state ) { //m_adding = false; m_adding_pressed = false; ths.m_mainperf->push_trigger_undo(); ths.m_mainperf->get_sequence( ths.m_drop_sequence )->select_trigger( tick ); long start_tick = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_selected_trigger_start_tick(); long end_tick = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_selected_trigger_end_tick(); if ( tick >= start_tick && tick <= start_tick + (c_perfroll_size_box_click_w * c_perf_scale_x) && (ths.m_drop_y % c_names_y) <= c_perfroll_size_box_click_w + 1 ) { // clicked left side: begin a grow/shrink for the left side ths.m_growing = true; ths.m_grow_direction = true; ths.m_drop_tick_trigger_offset = ths.m_drop_tick - ths.m_mainperf->get_sequence( ths.m_drop_sequence )-> get_selected_trigger_start_tick( ); } else if ( tick >= end_tick - (c_perfroll_size_box_click_w * c_perf_scale_x) && tick <= end_tick && (ths.m_drop_y % c_names_y) >= c_names_y - c_perfroll_size_box_click_w - 1 ) { // clicked right side: grow/shrink the right side ths.m_growing = true; ths.m_grow_direction = false; ths.m_drop_tick_trigger_offset = ths.m_drop_tick - ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_selected_trigger_end_tick( ); } else { // clicked in the middle - move it ths.m_moving = true; ths.m_drop_tick_trigger_offset = ths.m_drop_tick - ths.m_mainperf->get_sequence( ths.m_drop_sequence )-> get_selected_trigger_start_tick( ); } ths.draw_background_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_sequence_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_drawable_row( ths.m_window, ths.m_pixmap, ths.m_drop_y); } // add an event: else { // snap to length of sequence tick = tick - (tick % seq_length); ths.m_mainperf->push_trigger_undo(); ths.m_mainperf->get_sequence( ths.m_drop_sequence )->add_trigger( tick, seq_length ); ths.draw_background_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_sequence_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_drawable_row( ths.m_window, ths.m_pixmap, ths.m_drop_y); //m_drop_tick_last = (m_drop_tick + seq_length - 1); } } } } }
bool Seq24PerfInput::on_button_press_event(GdkEventButton* a_ev, perfroll& ths) { ths.grab_focus( ); if ( ths.m_mainperf->is_active( ths.m_drop_sequence )) { ths.m_mainperf->get_sequence( ths.m_drop_sequence )->unselect_triggers( ); ths.draw_background_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_sequence_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_drawable_row( ths.m_window, ths.m_pixmap, ths.m_drop_y); } ths.m_drop_x = (int) a_ev->x; ths.m_drop_y = (int) a_ev->y; ths.convert_xy( ths.m_drop_x, ths.m_drop_y, &ths.m_drop_tick, &ths.m_drop_sequence ); /* left mouse button */ if ( a_ev->button == 1 ){ long tick = ths.m_drop_tick; /* add a new note if we didnt select anything */ if ( m_adding ){ m_adding_pressed = true; if ( ths.m_mainperf->is_active( ths.m_drop_sequence )){ long seq_length = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_length( ); bool state = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_trigger_state( tick ); if ( state ) { ths.m_mainperf->push_trigger_undo(); ths.m_mainperf->get_sequence( ths.m_drop_sequence )->del_trigger( tick ); } else { // snap to length of sequence tick = tick - (tick % seq_length); //m_adding_pressed_state = true; ths.m_mainperf->push_trigger_undo(); ths.m_mainperf->get_sequence( ths.m_drop_sequence )->add_trigger( tick, seq_length ); ths.draw_background_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_sequence_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_drawable_row( ths.m_window, ths.m_pixmap, ths.m_drop_y); //m_drop_tick_last = (m_drop_tick + seq_length - 1); } } } else { if ( ths.m_mainperf->is_active( ths.m_drop_sequence )){ ths.m_mainperf->push_trigger_undo(); ths.m_mainperf->get_sequence( ths.m_drop_sequence )->select_trigger( tick ); long start_tick = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_selected_trigger_start_tick(); long end_tick = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_selected_trigger_end_tick(); if ( tick >= start_tick && tick <= start_tick + (c_perfroll_size_box_click_w * c_perf_scale_x) && (ths.m_drop_y % c_names_y) <= c_perfroll_size_box_click_w + 1 ) { ths.m_growing = true; ths.m_grow_direction = true; ths.m_drop_tick_trigger_offset = ths.m_drop_tick - ths.m_mainperf->get_sequence( ths.m_drop_sequence )-> get_selected_trigger_start_tick( ); } else if ( tick >= end_tick - (c_perfroll_size_box_click_w * c_perf_scale_x) && tick <= end_tick && (ths.m_drop_y % c_names_y) >= c_names_y - c_perfroll_size_box_click_w - 1 ) { ths.m_growing = true; ths.m_grow_direction = false; ths.m_drop_tick_trigger_offset = ths.m_drop_tick - ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_selected_trigger_end_tick( ); } else { ths.m_moving = true; ths.m_drop_tick_trigger_offset = ths.m_drop_tick - ths.m_mainperf->get_sequence( ths.m_drop_sequence )-> get_selected_trigger_start_tick( ); } ths.draw_background_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_sequence_on( ths.m_pixmap, ths.m_drop_sequence ); ths.draw_drawable_row( ths.m_window, ths.m_pixmap, ths.m_drop_y); } } } /* right mouse button */ if ( a_ev->button == 3 ){ set_adding( true, ths ); } /* middle, split */ if ( a_ev->button == 2 ) { if ( ths.m_mainperf->is_active( ths.m_drop_sequence )){ bool state = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_trigger_state( ths.m_drop_tick ); if ( state ) { ths.split_trigger(ths.m_drop_sequence, ths.m_drop_tick); } } } return true; }
bool FruityPerfInput::on_left_button_pressed (GdkEventButton * ev, perfroll & roll) { bool result = false; perform & p = roll.perf(); int dropseq = roll.m_drop_sequence; sequence * seq = p.get_sequence(dropseq); if (is_ctrl_key(ev)) { if (p.is_active(dropseq)) { midipulse droptick = roll.m_drop_tick; droptick -= droptick % roll.m_snap; /* stazed: grid snap */ bool state = seq->get_trigger_state(droptick); if (state) { roll.split_trigger(dropseq, droptick); result = true; } else /* track click, paste trig */ { p.push_trigger_undo(dropseq); seq->paste_trigger(droptick); } } } else /* add a new note if we didn't select anything */ { midipulse droptick = roll.m_drop_tick; set_adding_pressed(true); if (p.is_active(dropseq)) { midipulse seqlength = seq->get_length(); bool state = seq->get_trigger_state(droptick); if (state) /* resize or move event based on where clicked */ { set_adding_pressed(false); /* * Set the flag that tells the motion-notify callback to call * push_trigger_undo(). */ roll.m_have_button_press = seq->select_trigger(droptick); midipulse starttick = seq->selected_trigger_start(); midipulse endtick = seq->selected_trigger_end(); int wscalex = s_perfroll_size_box_click_w * c_perf_scale_x; int ydrop = roll.m_drop_y % c_names_y; if ( droptick >= starttick && droptick <= (starttick + wscalex) && ydrop <= (s_perfroll_size_box_click_w + 1) ) { /* clicked left side: grow/shrink left side */ roll.m_growing = true; roll.m_grow_direction = true; roll.m_drop_tick_trigger_offset = roll.m_drop_tick - seq->selected_trigger_start(); } else if ( droptick >= (endtick - wscalex) && droptick <= endtick && ydrop >= (c_names_y - s_perfroll_size_box_click_w - 1) ) { /* clicked right side: grow/shrink right side */ roll.m_growing = true; roll.m_grow_direction = false; roll.m_drop_tick_trigger_offset = roll.m_drop_tick - seq->selected_trigger_end(); } else /* clicked in the middle - move it */ { roll.m_moving = true; roll.m_drop_tick_trigger_offset = roll.m_drop_tick - seq->selected_trigger_start(); } roll.draw_all(); } else /* add a trigger */ { droptick -= (droptick % seqlength); /* snap to seqlength */ p.push_trigger_undo(); seq->add_trigger(droptick, seqlength); result = true; roll.draw_all(); } } } return result; }