Пример #1
0
static void
unico_draw_focus (DRAW_ARGS)
{
  GdkRGBA *fill_color, *border_color;
  GtkStateFlags state;
  gint focus_pad, line_width;
  gint radius;

  state = gtk_theming_engine_get_state (engine);

  gtk_theming_engine_get_style (engine,
                                "focus-padding", &focus_pad,
                                "focus-line-width", &line_width,
                                NULL);

  /* Skip rendering if focus-line-width is 0 or less. */
  if (line_width < 1)
    return;

  /* Use the outline attributes for the focus properties to avoid using
   * custom attributes. Outlines don't have a fill, so hardcode the fill
   * color to be the same color as the border, but with 20% of its alpha.
   */
  gtk_theming_engine_get (engine, state,
                          "outline-color", &border_color,
                          "outline-offset", &radius,
                          NULL);

  fill_color = gdk_rgba_copy (border_color);
  fill_color->alpha = border_color->alpha * 0.2;

  x += focus_pad;
  y += focus_pad;
  width -= focus_pad * 2;
  height -= focus_pad * 2;

  cairo_save (cr);

  cairo_set_line_width (cr, line_width);

  /* first layer, background */
  unico_cairo_round_rect (cr, x, y,
                              width, height,
                              radius, SIDE_ALL, GTK_JUNCTION_NONE);
  gdk_cairo_set_source_rgba (cr, fill_color);
  cairo_fill (cr);

  /* second layer, border */
  unico_cairo_round_rect_inner (cr, x, y,
                                    width, height,
                                    radius, SIDE_ALL, GTK_JUNCTION_NONE);
  gdk_cairo_set_source_rgba (cr, border_color);
  cairo_stroke (cr);

  cairo_restore (cr);

  gdk_rgba_free (border_color);
  gdk_rgba_free (fill_color);
}
Пример #2
0
static void
camo_engine_render_background (GtkThemingEngine *engine,
                                  cairo_t          *cr,
                                  gdouble           x,
                                  gdouble           y,
                                  gdouble           width,
                                  gdouble           height)
{
  GdkRGBA color;
  GtkStateFlags flags = gtk_theming_engine_get_state (engine);
  gboolean generate = FALSE;
  gint scr_width, scr_height;

  gtk_theming_engine_get_background_color (engine, flags, &color);

  cairo_save (cr);

  if ((color.red == 0) && (color.green == 0) && (color.blue == 0)) {
    if (width > pool_width) {
      generate = TRUE;
      pool_width = width;
    }

    if (height > pool_height) {
      generate = TRUE;
      pool_height = height;
    }

    if (generate) {
      scr_width = gdk_screen_get_width (gdk_window_get_screen (gdk_get_default_root_window ()));
      scr_height = gdk_screen_get_height (gdk_window_get_screen (gdk_get_default_root_window ()));

      if (scr_width > pool_width)
        pool_width = scr_width;
      if (scr_height > pool_height)
        pool_height = scr_height;

      pool_gen ();
    }

    cairo_set_source_surface (cr, pool, 0, 0);
  }
  else
    gdk_cairo_set_source_rgba (cr, &color);

  cairo_rectangle (cr, x, y, width, height);
  cairo_fill (cr);

  cairo_restore (cr);
}
Пример #3
0
static gboolean
draw_arrow_texture (GtkThemingEngine *engine,
                    cairo_t          *cr,
                    gdouble           angle,
                    gdouble           x,
                    gdouble           y,
                    gdouble           size)
{
  GtkStateFlags state;
  GValue value = { 0, };
  cairo_pattern_t *texture = NULL;
  cairo_surface_t *surface = NULL;
  gboolean retval = FALSE;

  state = gtk_theming_engine_get_state (engine);

  gtk_theming_engine_get_property (engine, "-unico-arrow-texture", state, &value);

  if (!G_VALUE_HOLDS_BOXED (&value))
    return FALSE;

  texture = g_value_dup_boxed (&value);
  g_value_unset (&value);

  if (texture != NULL)
    cairo_pattern_get_surface (texture, &surface);

  if (surface != NULL)
    {
      cairo_save (cr);

      cairo_translate (cr, (gint) (x + size / 2), (gint) (y + size / 2));
      cairo_rotate (cr, angle);

      cairo_set_source_surface (cr, surface, - cairo_image_surface_get_width (surface) / 2,
                                             - cairo_image_surface_get_height (surface) / 2);
      cairo_paint (cr);

      cairo_restore (cr);

      retval = TRUE;
    }

  if (texture != NULL)
    cairo_pattern_destroy (texture);

  return retval;
}
Пример #4
0
static void
unico_draw_arrow (GtkThemingEngine *engine,
                  cairo_t          *cr,
                  gdouble           angle,
                  gdouble           x,
                  gdouble           y,
                  gdouble           size)
{
  GtkStateFlags state;
  GdkRGBA color;
  gdouble size_reduction = 4;

  if (draw_arrow_texture (engine, cr, angle, x, y, size))
    return;

  state = gtk_theming_engine_get_state (engine);

  gtk_theming_engine_get_color (engine, state, &color);

  cairo_save (cr);

  /* use floor function to adjust doubles */
  y = floor (y);
  x = floor (x);
  size = floor (size);

  size -= size_reduction;

  cairo_translate (cr, size_reduction / 2, size_reduction / 2);

  cairo_translate (cr, x + (gint)(size / 2) - 0.5, y + (gint)(size / 2) + 0.5);
  cairo_rotate (cr, angle);

  cairo_move_to (cr, 0, - (gint)(size / 2));
  cairo_line_to (cr, - (gint)(size / 2), (gint)(size / 4));
  cairo_line_to (cr, (gint)(size / 2), (gint)(size / 4));
  cairo_close_path (cr);

  cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha * 0.75);
  cairo_fill_preserve (cr);

  gdk_cairo_set_source_rgba (cr, &color);
  cairo_stroke (cr);

  cairo_restore (cr);
}
Пример #5
0
static void
unico_draw_expander (DRAW_ARGS)
{
  GtkStateFlags state;
  GdkRGBA color;
  gint size;
  gdouble angle = G_PI;

  state = gtk_theming_engine_get_state (engine);

  gtk_theming_engine_get_color (engine, state, &color);

  cairo_save (cr);

  /* use floor function to adjust doubles */
  size = floor (MIN (width, height));

  x += (gint) (width / 2) - size / 2;
  y += (gint) (height / 2) - size / 2;

  if ((state & GTK_STATE_FLAG_ACTIVE) == 0)
    angle = G_PI_2;

  cairo_translate (cr, x + (gint)(size / 2) - 0.5, y + (gint)(size / 2) + 0.5);
  cairo_rotate (cr, angle);

  cairo_move_to (cr, 0, - (gint)(size / 2));
  cairo_line_to (cr, - (gint)(size / 2), (gint)(size / 4));
  cairo_line_to (cr, (gint)(size / 2), (gint)(size / 4));
  cairo_close_path (cr);

  cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha * 0.75);
  cairo_fill_preserve (cr);

  gdk_cairo_set_source_rgba (cr, &color);
  cairo_stroke (cr);

  cairo_restore (cr);
}
Пример #6
0
static void
miranda_engine_render_background (GtkThemingEngine *engine,
                                  cairo_t          *cr,
                                  gdouble           x,
                                  gdouble           y,
                                  gdouble           width,
                                  gdouble           height)
{
  GdkRGBA color;
  GtkStateFlags flags = gtk_theming_engine_get_state (engine);
  gboolean generate = FALSE;

  gtk_theming_engine_get_background_color (engine, flags, &color);

  cairo_save (cr);

  if (color.red == color.green == color.blue == 0) {
    if (width > pool_width) {
      generate = TRUE;
      pool_width = width;
    }
    if (height > pool_height) {
      generate = TRUE;
      pool_height = height;
    }
    if (generate) {
      pool_gen (width, height);
    }
    cairo_set_source_surface (cr, pool, 0, 0);
  }
  else
    gdk_cairo_set_source_rgba (cr, &color);

  cairo_rectangle (cr, x, y, width, height);
  cairo_fill (cr);

  cairo_restore (cr);
}