Example #1
0
void NodeRenderer::icon(const Cairo::RefPtr<Cairo::Context>& cr, AssetCache& cache)
{
	// path to icon not set
	if (s->icon_image.str().size() == 0 || s->icon_width == 0.0 || s->icon_height == 0.0)
		return;

	cr->save();

	Cairo::RefPtr<Cairo::ImageSurface> image = cache.getImage(s->icon_image.str());
	double width = s->icon_width < 0 ? image->get_width() : s->icon_width;
	double height = s->icon_height < 0 ? image->get_height() : s->icon_height;
	double x0 = floor(location.x - width/2.0);
	double y0 = floor(location.y - height/2.0);
	cr->translate(x0, y0);
	cr->scale(width / image->get_width(),
			  height / image->get_height());
	cr->set_source(image, 0, 0);

	if (s->icon_opacity < 1.0)
		cr->paint_with_alpha(s->icon_opacity);
	else
		cr->paint();

	cr->restore();
}
Example #2
0
bool Liveplay::window_expose_event(GdkEventExpose *event) {
    Cairo::RefPtr<Cairo::Context> cr = Glib::wrap(event->window, true)->create_cairo_context();
    Gtk::Allocation a = liveplay_canvas->get_allocation();
    Gdk::Region region(a);
    region.intersect(Glib::wrap(event->region, true));
    Gdk::Cairo::add_region_to_path(cr, region);
    cr->clip();
    cr->set_operator(Cairo::OPERATOR_SOURCE);
    cr->set_source_rgb(0,0,0);
    cr->paint();
    //gdk_cairo_set_source_window(cr->cobj(), liveplay_canvas->get_window()->gobj(), a.get_x(), a.get_y()); gtk 2.24
    gdk_cairo_set_source_pixmap(cr->cobj(), liveplay_canvas->get_window()->gobj(), a.get_x(), a.get_y());
    cr->paint_with_alpha(pow(brightness_adj->get_value(),2.2));
    return false;
}
bool GtkApplicationIconSublimer::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
  if (!this->application_icon)
  {
    LOG4CXX_DEBUG(logger, "Got no icon..");
    return false;
  }

  Gtk::Allocation allocation = get_allocation();
  const int height = allocation.get_height();

  Gdk::Cairo::set_source_pixbuf(cr, this->application_icon, 0, (height - this->application_icon->get_height()));
  cr->paint_with_alpha(0.2);

  return true;
}
Example #4
0
void CardWidget::Draw(Cairo::RefPtr<Cairo::Context> cr, int x, int y)
{
	bool highlight = highlightOnHover && isMouseInArea;
	Cairo::RefPtr<Cairo::ImageSurface> image = PrefSlots::getImagesStorage().GetCardImage(card);
	cr->save();
	cr->translate(x, y);
	cr->scale(1.0 * width / image->get_width(), 1.0 * height / image->get_height());
	cr->rectangle(0, 0, image->get_width(), image->get_height());
	cr->clip();
	if( highlight ) {
		cr->save();
		cr->set_source_rgb(0.1, 0.8, 0.1);
		cr->paint();
		cr->restore();
	}
	cr->set_source(image, 0, 0);
	cr->paint_with_alpha( highlight ? 0.7 : 1.0 );
	cr->restore();
}