1
//----------------------------------------------------------------------------
3
// This file is part of seq24.
5
// seq24 is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2 of the License, or
8
// (at your option) any later version.
10
// seq24 is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with seq24; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
//-----------------------------------------------------------------------------
1
21
#include "perform.h"
2
22
#include "perfroll_input.h"
3
23
#include "perfroll.h"
28
* Instantiate the correct performance input.
30
* @param interaction_method Interaction method to use.
31
* @return PerfInput instance, Seq24PerfInput by default.
34
AbstractPerfInput::get_perf_input(interaction_method_e interaction_method)
36
switch (global_interactionmethod)
38
case e_fruity_interaction:
39
return new FruityPerfInput();
42
case e_seq24_interaction:
44
return new Seq24PerfInput();
50
* FruityPerfInput constructor.
52
FruityPerfInput::FruityPerfInput()
53
: m_adding_pressed( false )
5
59
void FruityPerfInput::updateMousePtr( perfroll& ths )
7
61
// context sensitive mouse
295
/* popup menu calls this */
296
void Seq24PerfInput::set_adding( bool a_adding, perfroll& ths )
300
ths.get_window()->set_cursor( Gdk::Cursor( Gdk::PENCIL ));
305
ths.get_window()->set_cursor( Gdk::Cursor( Gdk::LEFT_PTR ));
310
bool Seq24PerfInput::on_button_press_event(GdkEventButton* a_ev, perfroll& ths)
350
* Seq24PerfInput default constructor.
352
Seq24PerfInput::Seq24PerfInput()
354
, m_adding_pressed( false )
359
* Defines if we are adding or note.
361
* @param a_adding Are we adding ?
362
* @param ths Perfroll instance
365
Seq24PerfInput::set_adding( bool a_adding, perfroll& ths )
367
ths.get_window()->set_cursor( ( a_adding ) ? Gdk::Cursor( Gdk::PENCIL ) : Gdk::Cursor( Gdk::LEFT_PTR ));
372
* Seq24 action when clicking with mouse.
374
* @param a_ev The Gdk Event
375
* @param ths Perfroll instance
379
Seq24PerfInput::on_button_press_event(GdkEventButton* a_ev, perfroll& ths)
312
381
ths.grab_focus( );
315
383
if ( ths.m_mainperf->is_active( ths.m_drop_sequence ))
317
385
ths.m_mainperf->get_sequence( ths.m_drop_sequence )->unselect_triggers( );
326
394
ths.convert_xy( ths.m_drop_x, ths.m_drop_y, &ths.m_drop_tick, &ths.m_drop_sequence );
328
/* left mouse button */
329
if ( a_ev->button == 1 ){
396
/* Left mouse button */
397
if ( a_ev->button == 1 )
331
399
long tick = ths.m_drop_tick;
333
/* add a new note if we didnt select anything */
401
/* Add a new note if we didnt select anything */
336
404
m_adding_pressed = true;
338
if ( ths.m_mainperf->is_active( ths.m_drop_sequence )){
406
if ( ths.m_mainperf->is_active( ths.m_drop_sequence ))
340
408
long seq_length = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_length( );
342
409
bool state = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_trigger_state( tick );
368
if ( ths.m_mainperf->is_active( ths.m_drop_sequence )){
435
if ( ths.m_mainperf->is_active( ths.m_drop_sequence ))
370
437
ths.m_mainperf->push_trigger_undo();
371
438
ths.m_mainperf->get_sequence( ths.m_drop_sequence )->select_trigger( tick );
399
467
ths.m_moving = true;
468
ths.m_selecting = true;
400
469
ths.m_drop_tick_trigger_offset = ths.m_drop_tick -
401
470
ths.m_mainperf->get_sequence( ths.m_drop_sequence )->
402
471
get_selected_trigger_start_tick( );
478
ths.m_selecting = true;
406
ths.draw_background_on( ths.m_pixmap, ths.m_drop_sequence );
407
ths.draw_sequence_on( ths.m_pixmap, ths.m_drop_sequence );
408
ths.draw_drawable_row( ths.m_window, ths.m_pixmap, ths.m_drop_y);
481
ths.draw_background_on( ths.m_pixmap, ths.m_drop_sequence );
482
ths.draw_sequence_on( ths.m_pixmap, ths.m_drop_sequence );
483
ths.draw_drawable_row( ths.m_window, ths.m_pixmap, ths.m_drop_y);
413
/* right mouse button */
414
if ( a_ev->button == 3 ){
487
/* Right mouse button */
488
if ( a_ev->button == 3 )
415
490
set_adding( true, ths );
418
493
/* middle, split */
419
494
if ( a_ev->button == 2 )
421
if ( ths.m_mainperf->is_active( ths.m_drop_sequence )){
496
if ( ths.m_mainperf->is_active( ths.m_drop_sequence ))
423
498
bool state = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_trigger_state( ths.m_drop_tick );
434
bool Seq24PerfInput::on_button_release_event(GdkEventButton* a_ev, perfroll& ths)
511
* Seq24 action when releasing mouse.
513
* @param a_ev The Gdk Event
514
* @param ths Perfroll instance
518
Seq24PerfInput::on_button_release_event(GdkEventButton* a_ev, perfroll& ths)
436
if ( a_ev->button == 1 ){
521
if ( a_ev->button == 1 )
439
525
m_adding_pressed = false;
528
/* Force all lines to be redrawn */
529
if ( ths.m_selecting )
531
ths.fill_background_pixmap();
443
if ( a_ev->button == 3 ){
537
if ( a_ev->button == 3 )
444
539
m_adding_pressed = false;
445
540
set_adding( false, ths );
448
543
ths.m_moving = false;
449
544
ths.m_growing = false;
545
ths.m_selecting = false;
450
547
m_adding_pressed = false;
452
if ( ths.m_mainperf->is_active( ths.m_drop_sequence )){
549
if ( ths.m_mainperf->is_active( ths.m_drop_sequence ))
454
551
ths.draw_background_on( ths.m_pixmap, ths.m_drop_sequence );
455
552
ths.draw_sequence_on( ths.m_pixmap, ths.m_drop_sequence );
456
553
ths.draw_drawable_row( ths.m_window, ths.m_pixmap, ths.m_drop_y );
462
bool Seq24PerfInput::on_motion_notify_event(GdkEventMotion* a_ev, perfroll& ths)
560
* Seq24 action while moving the mouse.
562
* @param a_ev The Gdk Event
563
* @param ths Perfroll instance
567
Seq24PerfInput::on_motion_notify_event(GdkEventMotion* a_ev, perfroll& ths)
465
570
int x = (int) a_ev->x;
467
if ( m_adding && m_adding_pressed ){
572
ths.m_current_x = (int) (a_ev->x);
573
ths.m_current_y = (int) (a_ev->y);
575
if ( m_adding && m_adding_pressed )
469
577
ths.convert_x( x, &tick );
471
if ( ths.m_mainperf->is_active( ths.m_drop_sequence )){
579
if ( ths.m_mainperf->is_active( ths.m_drop_sequence ))
473
581
long seq_length = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_length( );
474
582
tick = tick - (tick % seq_length);
476
584
/*long min_tick = (tick < m_drop_tick) ? tick : m_drop_tick;*/
477
585
long length = seq_length;
479
ths.m_mainperf->get_sequence( ths.m_drop_sequence )
480
->grow_trigger( ths.m_drop_tick, tick, length);
587
ths.m_mainperf->get_sequence( ths.m_drop_sequence )->grow_trigger( ths.m_drop_tick, tick, length);
481
588
ths.draw_background_on( ths.m_pixmap, ths.m_drop_sequence );
482
589
ths.draw_sequence_on( ths.m_pixmap, ths.m_drop_sequence );
483
590
ths.draw_drawable_row( ths.m_window, ths.m_pixmap, ths.m_drop_y);
486
else if ( ths.m_moving || ths.m_growing ){
488
if ( ths.m_mainperf->is_active( ths.m_drop_sequence)){
593
else if ( ths.m_moving || ths.m_growing || ths.m_selecting )
595
if ( ths.m_selecting )
597
ths.draw_selection_on_window();
601
if ( ths.m_mainperf->is_active( ths.m_drop_sequence))
490
603
ths.convert_x( x, &tick );
491
604
tick -= ths.m_drop_tick_trigger_offset;
495
608
if ( ths.m_moving )
497
ths.m_mainperf->get_sequence( ths.m_drop_sequence )
498
->move_selected_triggers_to( tick, true );
610
ths.m_mainperf->get_sequence( ths.m_drop_sequence )->move_selected_triggers_to( tick, true );
500
613
if ( ths.m_growing )
502
615
if ( ths.m_grow_direction )
503
ths.m_mainperf->get_sequence( ths.m_drop_sequence )
504
->move_selected_triggers_to( tick, false, 0 );
617
ths.m_mainperf->get_sequence( ths.m_drop_sequence )->move_selected_triggers_to( tick, false, 0 );
506
ths.m_mainperf->get_sequence( ths.m_drop_sequence )
507
->move_selected_triggers_to( tick-1, false, 1 );
621
ths.m_mainperf->get_sequence( ths.m_drop_sequence )->move_selected_triggers_to( tick-1, false, 1 );
511
625
ths.draw_background_on( ths.m_pixmap, ths.m_drop_sequence );
512
626
ths.draw_sequence_on( ths.m_pixmap, ths.m_drop_sequence );
513
627
ths.draw_drawable_row( ths.m_window, ths.m_pixmap, ths.m_drop_y);