예제 #1
0
void
seqdata::draw_line_on_window ()
{
    m_gc->set_foreground(black_paint());
    set_line(Gdk::LINE_SOLID);
    draw_drawable                                   /* replace old */
    (
        m_old.x, m_old.y, m_old.x, m_old.y, m_old.width + 1, m_old.height + 1
    );

    int x, y, w, h;
    xy_to_rect(m_drop_x, m_drop_y, m_current_x, m_current_y, x, y, w, h);
    x -= m_scroll_offset_x;
    m_old.x = x;
    m_old.y = y;
    m_old.width = w;
    m_old.height = h;
    draw_line
    (
        black_paint(), m_current_x - m_scroll_offset_x, m_current_y,
        m_drop_x - m_scroll_offset_x, m_drop_y
    );
}
예제 #2
0
void
seqdata::draw_events_on (Glib::RefPtr<Gdk::Drawable> drawable)
{
    midipulse tick;
    midibyte d0, d1;
    bool selected;
    int starttick = m_scroll_offset_ticks;
    int endtick = (m_window_x * m_zoom) + m_scroll_offset_ticks;
    draw_rectangle(drawable, white_paint(), 0, 0, m_window_x, m_window_y);
    m_gc->set_foreground(black_paint());

#ifdef USE_STAZED_SEQDATA_EXTENSIONS
    int numselected = EVENTS_ALL;                   // -1
    int seltype = numselected;
    if (m_status == EVENT_NOTE_ON)                  // ??????? iffy.
    {
        numselected = m_seq.get_num_selected_events(m_status, m_cc);
        if (numselected > 0)
            seltype = EVENTS_UNSELECTED;
    }
    do
    {
#endif

        m_seq.reset_draw_marker();
#ifdef USE_STAZED_SEQDATA_EXTENSIONS
        while
        (
            m_seq.get_next_event(m_status, m_cc, &tick, &d0, &d1, &selected, seltype)
        )
#else
        while (m_seq.get_next_event(m_status, m_cc, &tick, &d0, &d1, &selected))
#endif
        {
            if (tick >= starttick && tick <= endtick)
            {
                int event_x = tick / m_zoom;            /* screen coordinate    */
                int event_height = event::is_one_byte_msg(m_status) ? d0 : d1 ;
                int x = event_x - m_scroll_offset_x + 1;
                set_line(Gdk::LINE_SOLID, 2);           /* vertical event line  */
                draw_line
                (
                    drawable, selected ? dark_orange() : black_paint(),
                    x, c_dataarea_y - event_height, x, c_dataarea_y
                );

#ifdef USE_STAZED_SEQDATA_EXTENSIONS
                draw_rectangle                          /* draw handle          */
                (
                    drawable, selected ? dark_orange() : black_paint(), // true,
                    event_x - m_scroll_offset_x - 3,
                    c_dataarea_y - event_height,
                    c_data_handle_x,
                    c_data_handle_y
                );
#endif

                drawable->draw_drawable
                (
                    m_gc, m_numbers[event_height], 0, 0,
                    x + 2, c_dataarea_y - m_number_h + 3,
                    m_number_w, m_number_h
                );
            }
        }
#ifdef USE_STAZED_SEQDATA_EXTENSIONS
        if (seltype == EVENTS_UNSELECTED)
            seltype = numselected;
        else
            break;

    } while (seltype == EVENTS_UNSELECTED);
#endif
}
예제 #3
0
void
perftime::draw_background ()
{
    draw_rectangle(white_paint(), 0, 0, m_window_x, m_window_y);
    draw_line(black_paint(), 0, m_window_y - 1, m_window_x, m_window_y - 1);
    midipulse first_measure = m_tick_offset / m_measure_length;
    midipulse last_measure = first_measure +
        (m_window_x * m_perf_scale_x / m_measure_length) + 1;

#ifdef USE_STAZED_EXTRAS

    float bar_draw = m_measure_length / float(m_perf_scale_x);
    int bar_skip = 1;
    if (bar_draw < 24)
        bar_skip = 4;

    if (bar_draw < 12)
        bar_skip = 8;

    if (bar_draw < 6)
        bar_skip = 16;

    if (bar_draw < 3)
        bar_skip = 32;

    if (bar_draw < .75)
        bar_skip = 64;
#endif

    m_gc->set_foreground(grey());                   /* draw vertical lines  */

#ifdef USE_STAZED_EXTRAS
    for (midipulse i = first_measure; i < last_measure; i += bar_skip)
    {
        int x_pos = ((i * m_measure_length) - m_tick_offset) / m_perf_scale_x;
#else
    for (midipulse i = first_measure; i < last_measure; ++i)
    {
        int x_pos = tick_to_pixel(i * m_measure_length);
#endif

        char bar[8];
        snprintf(bar, sizeof(bar), "%ld", i + 1);       /* bar numbers      */
        draw_line(x_pos, 0, x_pos, m_window_y);         /* beat             */
        render_string(x_pos + 2, 0, bar, font::BLACK, true);
    }

    midipulse left = tick_to_pixel(perf().get_left_tick());
    midipulse right = tick_to_pixel(perf().get_right_tick());
    if (left >= 0 && left <= m_window_x)                /* draw L marker    */
    {
        draw_rectangle(black_paint(), left, m_window_y - 9, 7, 10);
        render_string(left + 1, 9, "L", font::WHITE, true);
    }
    if (right >= 0 && right <= m_window_x)              /* draw R marker    */
    {
        draw_rectangle(black_paint(), right - 6, m_window_y - 9, 7, 10);
        render_string(right - 6 + 1, 9, "R", font::WHITE, true);
    }
}

/**
 *  Implement the button-press event to set the L and R ticks.  Added
 *  functionality to try to set the start-tick if ctrl-left-click is pressed.
 *
 * \param p0
 *      The button event.
 *
 * \return
 *      Always returns true.
 */

bool
perftime::on_button_press_event (GdkEventButton * p0)
{
    midipulse tick = pixel_to_tick(long(p0->x));
    tick -= tick % m_snap;

    /**
     * Why is setting the start-tick disabled?  We re-enable it and see if it
     * works.  To our surprise, it works, but it sticks between stop/pause and
     * the next playback in the performance editor.  We added a feature where
     * stop sets the start-tick to the left tick (or the beginning tick).
     */

    if (SEQ64_CLICK_MIDDLE(p0->button))
    {
        perf().set_start_tick(tick);
    }
    else if (SEQ64_CLICK_LEFT(p0->button))
    {
        if (is_ctrl_key(p0))
            perf().set_start_tick(tick);
        else
            perf().set_left_tick(tick);
    }
    else if (SEQ64_CLICK_RIGHT(p0->button))
    {
        perf().set_right_tick(tick + m_snap);
    }
    enqueue_draw();
    return true;
}