Exemplo n.º 1
0
bool RegionChooser::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
    double clipx1, clipx2, clipy1, clipy2;
    cr->get_clip_extents(clipx1, clipy1, clipx2, clipy2);
#endif

    cr->save();
    cr->set_line_width(1);

#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
    const Gdk::Color bg = get_style()->get_bg(Gtk::STATE_NORMAL);
#else
    const Gdk::RGBA bg = get_style_context()->get_background_color();
#endif
    Gdk::Cairo::set_source_rgba(cr, bg);
    cr->paint();

    if (clipy2 > h1) {
        draw_keyboard(cr, clipx1, clipx2);
    }

    if (clipy1 < h1 && instrument) {
        draw_regions(cr, clipx1, clipx2);
    }

    cr->restore();

    return true;
}
bool TransparentSlider::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
    auto window = get_window();

    Cairo::RectangleInt window_size;
    Cairo::RectangleInt clip;
    double x1, y1, x2, y2;
    cr->get_clip_extents(x1, y1, x2, y2);

    clip.height = _round(y2-y1);
    clip.width = _round(x2-x1);
    clip.x = _round(x1);
    clip.y = _round(y1);

    window_size.x = 0;
    window_size.y = 0;
    window_size.height = window->get_height();
    window_size.width = window->get_width();

    cr->save();

    if (_SUPPORTS_ALPHA) {
        cr->set_source_rgba(                    // transparent
                _adjustmentRed->get_value(),
                _adjustmentGreen->get_value(),
                _adjustmentBlue->get_value(),
                _adjustmentAlpha->get_value());
    } else {
        cr->set_source_rgb(                     // opaque
                _adjustmentRed->get_value(),
                _adjustmentGreen->get_value(),
                _adjustmentBlue->get_value());
    }
    cr->set_operator(Cairo::OPERATOR_SOURCE);

    if (clip.height==window_size.height && clip.width==window_size.width && clip.x==window_size.x && clip.y==window_size.y) {
    } else {
        window->invalidate(true);
    }
    cr->reset_clip();
    cr->paint();
    cr->restore();

    return Gtk::Window::on_draw(cr);
}
Exemplo n.º 3
0
static void copyCairoClip(const Cairo::RefPtr<Cairo::Context> &src, const Cairo::RefPtr<Cairo::Context> &dst) {
	try {
		vector<Cairo::Rectangle> rects;
		src->copy_clip_rectangle_list(rects);
		for (auto& rect : rects) {
			//cout << "clip " << rect.x << "x" << rect.y << "+" << rect.width << "+" << rect.height << endl;
			dst->rectangle(rect.x, rect.y, rect.width, rect.height);
		}
		dst->clip();
	} catch (...) {
		Cairo::Rectangle rect;
		src->get_clip_extents(rect.x, rect.y, rect.width, rect.height);
		rect.width -= rect.x;
		rect.height -= rect.y;
		//cout << "clip " << rect.x << "x" << rect.y << "+" << rect.width << "+" << rect.height << endl;
		dst->rectangle(rect.x, rect.y, rect.width, rect.height);
		dst->clip();
	}
}