Ejemplo n.º 1
0
static void
gtk_scaler_paintable_snapshot (GdkPaintable *paintable,
                               GdkSnapshot  *snapshot,
                               double        width,
                               double        height)
{
  GtkScaler *self = GTK_SCALER (paintable);

  if (self->scale_factor == 1.0)
    {
      gdk_paintable_snapshot (self->paintable, snapshot, width, height);
    }
  else
    {
      graphene_matrix_t scale_matrix;

      graphene_matrix_init_scale (&scale_matrix, 1.0 / self->scale_factor, 1.0 / self->scale_factor, 1.0);
      gtk_snapshot_push_transform (snapshot, &scale_matrix);
      gdk_paintable_snapshot (self->paintable,
                              snapshot,
                              width * self->scale_factor,
                              height * self->scale_factor);
      gtk_snapshot_pop (snapshot);
    }
}
Ejemplo n.º 2
0
/**
 * gtk_snapshot_pop_and_append:
 * @snapshot: a #GtkSnapshot
 *
 * Removes the top element from the stack of render nodes,
 * and appends it to the node underneath it.
 *
 * Since: 3.90
 */
void
gtk_snapshot_pop_and_append (GtkSnapshot *snapshot)
{
  GskRenderNode *node;

  node = gtk_snapshot_pop (snapshot);
  if (node)
    {
      gtk_snapshot_append_node (snapshot, node);
      gsk_render_node_unref (node);
    }
}
Ejemplo n.º 3
0
static void
gtk_render_node_paintable_paintable_snapshot (GdkPaintable *paintable,
                                              GdkSnapshot  *snapshot,
                                              double        width,
                                              double        height)
{
  GtkRenderNodePaintable *self = GTK_RENDER_NODE_PAINTABLE (paintable);
  gboolean needs_transform;

  needs_transform = self->bounds.size.width != width ||
                    self->bounds.size.height != height;

  if (needs_transform)
    {
      graphene_matrix_t transform;

      graphene_matrix_init_scale (&transform,
                                  width / (self->bounds.size.width),
                                  height / (self->bounds.size.height),
                                  1.0);
      gtk_snapshot_push_transform (snapshot,
                                   &transform);
    }

  gtk_snapshot_offset (snapshot, -self->bounds.origin.x, -self->bounds.origin.y);

  gtk_snapshot_push_clip (snapshot, &self->bounds);

  gtk_snapshot_append_node (snapshot, self->node);
  //gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 0, 0, 1 }, &self->bounds);

  gtk_snapshot_pop (snapshot);

  gtk_snapshot_offset (snapshot, self->bounds.origin.x, self->bounds.origin.y);

  if (needs_transform)
    gtk_snapshot_pop (snapshot);
}
Ejemplo n.º 4
0
GskRenderNode *
gtk_snapshot_finish (GtkSnapshot *snapshot)
{
  GskRenderNode *result;
  
  result = gtk_snapshot_pop (snapshot);

  if (snapshot->state != NULL)
    {
      g_warning ("Too many gtk_snapshot_push() calls.");
    }

  return result;
}
Ejemplo n.º 5
0
static void
cb_compose_images_snapshot (GtkWidget   *widget,
                            GtkSnapshot *snapshot)
{
  const int width = gtk_widget_get_width (widget);
  const int height = gtk_widget_get_height (widget);

  /* This is only relevant when an image gets transitioned to being deleted,
   * but we just always push a clip node here, for simplicity. */
  gtk_snapshot_push_clip (snapshot,
                          &GRAPHENE_RECT_INIT (0, 0, width, height),
                          "ComposeImagesClip");

  GTK_WIDGET_CLASS (cb_compose_images_parent_class)->snapshot (widget, snapshot);

  gtk_snapshot_pop (snapshot);
}
Ejemplo n.º 6
0
/* This is the function that draws the puzzle piece.
 * It just draws a rectangular cutout of the puzzle by clipping
 * away the rest.
 */
static void
gtk_puzzle_piece_snapshot (GdkPaintable *paintable,
                           GdkSnapshot  *snapshot,
                           double        width,
                           double        height)
{
  GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable);

  gtk_snapshot_push_clip (snapshot,
                          &GRAPHENE_RECT_INIT (0, 0, width, height));

  gtk_snapshot_offset (snapshot,
                       - width * self->x,
                       - height * self->y);
  gdk_paintable_snapshot (self->puzzle,
                          snapshot,
                          width * self->width,
                          height * self->height);

  gtk_snapshot_pop (snapshot);
}
Ejemplo n.º 7
0
static void
snapshot_background (GtkWidget   *widget,
                     GtkSnapshot *snapshot)
{
  GdkRectangle visible_rect;

  gtk_text_view_get_visible_rect (GTK_TEXT_VIEW (widget), &visible_rect);

  gtk_snapshot_append_color (snapshot,
                             &(GdkRGBA) { CHECK_DARK, CHECK_DARK, CHECK_DARK, 1.0 },
                             &GRAPHENE_RECT_INIT(visible_rect.x, visible_rect.y, visible_rect.width, visible_rect.height));

  gtk_snapshot_push_repeat (snapshot,
                            &GRAPHENE_RECT_INIT(visible_rect.x, visible_rect.y, visible_rect.width, visible_rect.height),
                            &GRAPHENE_RECT_INIT(visible_rect.x, visible_rect.y, CHECK_SIZE * 2, CHECK_SIZE * 2));
  gtk_snapshot_append_color (snapshot,
                             &(GdkRGBA) { CHECK_LIGHT, CHECK_LIGHT, CHECK_LIGHT, 1.0 },
                             &GRAPHENE_RECT_INIT(visible_rect.x, visible_rect.y, CHECK_SIZE, CHECK_SIZE));
  gtk_snapshot_append_color (snapshot,
                             &(GdkRGBA) { CHECK_LIGHT, CHECK_LIGHT, CHECK_LIGHT, 1.0 },
                             &GRAPHENE_RECT_INIT(visible_rect.x + CHECK_SIZE, visible_rect.y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE));
  gtk_snapshot_pop (snapshot);
}