예제 #1
0
파일: perfroll.cpp 프로젝트: Stazed/seq32
void perfroll::draw_background_on( Glib::RefPtr<Gdk::Drawable> a_draw, int a_sequence )
{
    long tick_offset = m_4bar_offset * c_ppqn * 16;
    long first_measure = tick_offset / m_measure_length;

    a_sequence -= m_sequence_offset;

    int y = c_names_y * a_sequence;
    int h = c_names_y;

    m_gc->set_foreground(m_white);
    a_draw->draw_rectangle(m_gc,true,
                           0,
                           y,
                           m_window_x,
                           h );

    m_gc->set_foreground(m_black);
    for ( int i = first_measure;
            i < first_measure +
            (m_window_x * m_perf_scale_x /
             (m_measure_length)) + 1;
            i++ )
    {
        int x_pos = ((i * m_measure_length) - tick_offset) / m_perf_scale_x;

        a_draw->draw_drawable(m_gc, m_background,
                              0,
                              0,
                              x_pos,
                              y,
                              c_perfroll_background_x,
                              c_names_y );
    }
}
예제 #2
0
void
font::render_string_on_drawable
(
    Glib::RefPtr<Gdk::GC> gc,
    int x, int y,
    Glib::RefPtr<Gdk::Drawable> a_draw,
    const char * str,
    font::Color col,
    bool invert
) const
{
    int length = 0;
    if (not_nullptr(str))
        length = strlen(str);

    if (m_use_new_font)
        y += 1;                         /* make minor correction */
    else
        y += 2;                         /* make minor correction */

    if (col == font::BLACK)
        m_pixmap = &m_black_pixmap;
    else if (col == font::WHITE)
        m_pixmap = &m_white_pixmap;
    else if (col == font::BLACK_ON_YELLOW)
        m_pixmap = &m_b_on_y_pixmap;
    else if (col == font::YELLOW_ON_BLACK)
        m_pixmap = &m_y_on_b_pixmap;
    else if (col == font::BLACK_ON_CYAN)
        m_pixmap = &m_b_on_c_pixmap;
    else if (col == font::CYAN_ON_BLACK)
        m_pixmap = &m_c_on_b_pixmap;
    else
        m_pixmap = &m_black_pixmap;     /* user lied, provide legal pointer */

    if (gui_palette_gtk2::is_inverse() && invert)
        gc->set_function(Gdk::COPY_INVERT);  /* XOR or INVERT?              */

    for (int k = 0; k < length; ++k)
    {
        int c = int(str[k]);
        int pixbuf_index_x = c % cf_grid_w;
        int pixbuf_index_y = c / cf_grid_h;
        pixbuf_index_x *= m_cell_w;     /* width of grid (letter=6 pixels)  */
        pixbuf_index_x += m_offset;     /* add around 2 for border?         */
        pixbuf_index_y *= m_cell_h;     /* height of grid (letter=10 pixel) */
        pixbuf_index_y += m_offset;     /* add around 2 for border?         */
        a_draw->draw_drawable
        (
            gc, *m_pixmap, pixbuf_index_x, pixbuf_index_y,
            x + (k * m_font_w), y, m_font_w, m_font_h
        );
    }
    if (gui_palette_gtk2::is_inverse() && invert)
        gc->set_function(Gdk::COPY);    /* not NOOP or SET                  */
}
 void draw_drawable
 (
     int xsrc, int ysrc,
     int xdest, int ydest,
     int width, int height
 )
 {
     m_window->draw_drawable
     (
         m_gc, m_pixmap, xsrc, ysrc, xdest, ydest, width, height
     );
 }
예제 #4
0
void
perfroll::draw_drawable_row
(
    Glib::RefPtr<Gdk::Drawable> a_dest,
    Glib::RefPtr<Gdk::Drawable> a_src,
    long a_y
)
{
    int s = a_y / m_names_y;
    a_dest->draw_drawable
    (
        m_gc, a_src, 0, s * m_names_y, 0, s * m_names_y, m_window_x, m_names_y
    );
}
예제 #5
0
파일: font.cpp 프로젝트: EQ4/sequencer24
void
font::render_string_on_drawable
(
    Glib::RefPtr<Gdk::GC> a_gc,
    int x, int y,
    Glib::RefPtr<Gdk::Drawable> a_draw,
    const char * str,
    font::Color col
)
{
    int length = 0;
    if (not_nullptr(str))
        length = strlen(str);

    /*
     * The width is identical to c_text_x, but the height is not identical
     * to c_text_y.  Using the latter values causes artifacts on the
     * pattern grid.
     */

    int font_w = 6;                     // c_text_x == 6
    int font_h = 10;                    // c_text_y == 12
    if (col == font::BLACK)
        m_pixmap = &m_black_pixmap;
    else if (col == font::WHITE)
        m_pixmap = &m_white_pixmap;
    else if (col == font::BLACK_ON_YELLOW)
        m_pixmap = &m_b_on_y_pixmap;
    else if (col == font::YELLOW_ON_BLACK)
        m_pixmap = &m_y_on_b_pixmap;
    else
        m_pixmap = &m_black_pixmap; // user lied, provide a legal pointer

    for (int i = 0; i < length; ++i)
    {
        unsigned char c = (unsigned char) str[i];
        int pixbuf_index_x = c % 16;    // number of grids horizontally
        int pixbuf_index_y = c / 16;    // number of grids vertically
        pixbuf_index_x *= 9;            // width of grid (letter is 6 pixels)
        pixbuf_index_x += 2;            // add 2 for border?
        pixbuf_index_y *= 13;           // height of grid (letter is 12 pixels)
        pixbuf_index_y += 2;            // add 2 for border?
        a_draw->draw_drawable
        (
            a_gc, *m_pixmap, pixbuf_index_x, pixbuf_index_y,
            x + (i * font_w), y, font_w, font_h
        );
    }
}
예제 #6
0
파일: perfroll.cpp 프로젝트: Stazed/seq32
void
perfroll::draw_drawable_row( Glib::RefPtr<Gdk::Drawable> a_dest, Glib::RefPtr<Gdk::Drawable> a_src,  long a_y )
{
    if( a_y < 0) // if user scrolled up off the window
        return;

    int s = a_y / c_names_y;
    a_dest->draw_drawable(m_gc, a_src,
                          0,
                          c_names_y * s,
                          0,
                          c_names_y * s,
                          m_window_x,
                          c_names_y );
}
예제 #7
0
파일: font.cpp 프로젝트: vext01/seq24
void
font::render_string_on_drawable(
        Glib::RefPtr<Gdk::GC> a_gc,
        int x, int y,
        Glib::RefPtr<Gdk::Drawable> a_draw,
        char *str, 
        font::Color col )
{
    int length = 0;

    if ( str != NULL )
        length = strlen(str);
    
    int font_w = 6;
    int font_h = 10;

    for( int i=0; i<length; ++i ){

        unsigned char c = (unsigned char) str[i];

        // solid
        //int pixbuf_index_x = 2; 
        //int pixbuf_index_y = 0; 

        int pixbuf_index_x = c % 16;
        int pixbuf_index_y = c / 16;

        pixbuf_index_x *= 9;
        pixbuf_index_y *= 13;

        pixbuf_index_x += 2;
        pixbuf_index_y += 2;
        
        if ( col == font::BLACK )
            m_pixmap = m_black_pixmap;
        if ( col == font::WHITE )
            m_pixmap = m_white_pixmap;

        a_draw->draw_drawable(a_gc, 
                              m_pixmap, 
                              pixbuf_index_x,
                              pixbuf_index_y,
                              x + (i*font_w),
                              y,
                              font_w,
                              font_h );
    }
}
예제 #8
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
}
예제 #9
0
void ValidationPanel::refresh()
{
	// update the label
	crn::StringUTF8 lab = "<span font_desc=\"" + Config::GetFont() + "\">" + title + "</span>";
	lab += " (";
	lab += nelem;
	lab += ")";
	auto *labw = get_label_widget();
	auto *llab = dynamic_cast<Gtk::Label*>(labw);
	if (llab)
		llab->set_markup(lab.CStr());
	else
		set_label(lab.CStr());
	

	if (/*(positions.size() != elements.size()) ||*/ (dispw <= 0) || (disph <= 0) || locked)
		return;

	Glib::RefPtr<Gdk::Window> win = da.get_window();
	if (win)
	{
		// if the drawing area is fully created
		// create a buffer
		Glib::RefPtr<Gdk::Pixmap> pm = Gdk::Pixmap::create(win, dispw, disph);
		// clear the buffer
		pm->draw_rectangle(da_gc, true, 0, 0, dispw, disph);
		int offset = -int(scroll.get_value());

		Cairo::RefPtr<Cairo::Context> cc = pm->create_cairo_context();


		// draw the words
		for (const ValidationPanel::ElementList::value_type &el : elements)
		{
			if (!el.second.empty())
			{
				int by = positions[el.second.begin()->first].Y;
				int ey = by;
				for (const ValidationPanel::ElementCluster::value_type &w : el.second)
				{
					int y = positions[w.first].Y + w.second.img->get_height();
					if (y > ey) ey = y;
				}
				if ((el.first == elements.rbegin()->first) && (ey < disph))
				{
					// fill till the end of the display
					ey = disph;
				}
				ValidationPanel::set_color(cc, el.first);
				cc->rectangle(0, by + offset, dispw, ey - by);
				cc->fill();
			}
			for (const ValidationPanel::ElementCluster::value_type &w : el.second)
			{
				Glib::RefPtr<Gdk::Pixbuf> wpb = w.second.img;

				pm->draw_pixbuf(da_gc, wpb, 0, 0, positions[w.first].X, positions[w.first].Y + offset, w.second.img->get_width(), w.second.img->get_height(), Gdk::RGB_DITHER_NONE, 0, 0);
			}
		}

		// draw the mark
		if (mark.size() > 1)
		{
			cc->set_source_rgb(1.0, 0, 0);
			cc->move_to(mark.front().X, mark.front().Y + offset);
			for (size_t tmp = 1; tmp < mark.size(); ++tmp)
			{
				cc->line_to(mark[tmp].X, mark[tmp].Y + offset);
			}
			cc->stroke();
		}

		// copy pixmap to drawing area
		win->draw_drawable(da_gc, pm, 0, 0, 0, 0);
	}

}