示例#1
0
bool FruityPerfInput::on_motion_notify_event(GdkEventMotion* a_ev, perfroll& ths)
{
    long tick;
    int x = (int) a_ev->x;
    m_current_x = (int) a_ev->x;
    m_current_y = (int) a_ev->y;

    if (  m_adding_pressed ){

        ths.convert_x( x, &tick );

        if ( ths.m_mainperf->is_active( ths.m_drop_sequence )){

            long seq_length = ths.m_mainperf->get_sequence( ths.m_drop_sequence )->get_length( );
            tick = tick - (tick % seq_length);

            /*long min_tick = (tick < m_drop_tick) ? tick : m_drop_tick;*/
            long length = seq_length;

            ths.m_mainperf->get_sequence( ths.m_drop_sequence )
                ->grow_trigger( ths.m_drop_tick, tick, 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);
        }
    }
    else if ( ths.m_moving || ths.m_growing )
    {
        if ( ths.m_mainperf->is_active( ths.m_drop_sequence))
        {
            ths.convert_x( x, &tick );
            tick -= ths.m_drop_tick_trigger_offset;

            tick = tick - tick % ths.m_snap;

            if ( ths.m_moving )
            {
                ths.m_mainperf->get_sequence( ths.m_drop_sequence )
                    ->move_selected_triggers_to( tick, true );
            }
            if ( ths.m_growing )
            {
                if ( ths.m_grow_direction )
                    ths.m_mainperf->get_sequence( ths.m_drop_sequence )
                        ->move_selected_triggers_to( tick, false, 0 );
                else
                    ths.m_mainperf->get_sequence( ths.m_drop_sequence )
                        ->move_selected_triggers_to( tick-1, false, 1 );
            }


            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);
        }
    }

    updateMousePtr( ths );
    return true;
}
bool
Seq24PerfInput::on_motion_notify_event (GdkEventMotion * ev, perfroll & roll)
{
    bool result = false;
    int x = int(ev->x);
    perform & p = roll.perf();
    int dropseq = roll.m_drop_sequence;
    sequence * seq = p.get_sequence(dropseq);
    if (! p.is_active(dropseq))
    {
        return false;
    }
    if (is_adding() && is_adding_pressed())
    {
        midipulse seqlength = seq->get_length();
        midipulse tick;
        roll.convert_x(x, tick);
        tick -= (tick % seqlength);

        midipulse length = seqlength;
        seq->grow_trigger(roll.m_drop_tick, tick, length);
        roll.draw_all();
        result = true;
    }
    else if (roll.m_moving || roll.m_growing)
    {
        /*
         * This code is necessary to insure that there is no push unless
         * we have a motion notification.
         */

        if (roll.m_have_button_press)
        {
            p.push_trigger_undo(dropseq);
            roll.m_have_button_press = false;
        }

        midipulse tick;
        roll.convert_x(x, tick);
        tick -= roll.m_drop_tick_trigger_offset;
        tick -= tick % roll.m_snap;
        if (roll.m_moving)
        {
            seq->move_selected_triggers_to(tick, true);
            result = true;
        }
        if (roll.m_growing)
        {
            if (roll.m_grow_direction)
            {
                seq->move_selected_triggers_to
                (
                    tick, false, triggers::GROW_START
                );
            }
            else
            {
                seq->move_selected_triggers_to
                (
                    tick - 1, false, triggers::GROW_END);
            }
            result = true;
        }
        roll.draw_all();
    }
    return result;
}