mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 22:41:43 +00:00
Merge branch 'kill-builtin-image' into 'master'
Kill builtin image See merge request GNOME/gtk!1297
This commit is contained in:
commit
cf1700fd13
@ -48,7 +48,6 @@ private_headers = [
|
||||
'gtkcssfontfeaturesvalueprivate.h',
|
||||
'gtkcssfontvariationsvalueprivate.h',
|
||||
'gtkcssiconthemevalueprivate.h',
|
||||
'gtkcssimagebuiltinprivate.h',
|
||||
'gtkcssimagecrossfadeprivate.h',
|
||||
'gtkcssimagefallbackprivate.h',
|
||||
'gtkcssimageiconthemeprivate.h',
|
||||
|
@ -2395,7 +2395,6 @@ calendar_snapshot_arrow (GtkCalendar *calendar,
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (calendar);
|
||||
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
|
||||
GtkCssImageBuiltinType image_type;
|
||||
GtkStyleContext *context;
|
||||
GtkStateFlags state;
|
||||
GdkRectangle rect;
|
||||
@ -2418,19 +2417,11 @@ calendar_snapshot_arrow (GtkCalendar *calendar,
|
||||
rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
|
||||
if (arrow == ARROW_MONTH_LEFT || arrow == ARROW_YEAR_LEFT)
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_ARROW_LEFT;
|
||||
else
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT;
|
||||
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT(
|
||||
rect.x + (rect.width - 8) / 2,
|
||||
rect.y + (rect.height - 8) / 2));
|
||||
gtk_css_style_snapshot_icon (gtk_style_context_lookup_style (context),
|
||||
snapshot,
|
||||
8, 8,
|
||||
image_type);
|
||||
gtk_css_style_snapshot_icon (gtk_style_context_lookup_style (context), snapshot, 8, 8);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
|
@ -406,7 +406,6 @@ gtk_cell_renderer_toggle_snapshot (GtkCellRenderer *cell,
|
||||
gint xpad, ypad;
|
||||
GtkStateFlags state;
|
||||
GtkBorder padding, border;
|
||||
GtkCssImageBuiltinType image_type;
|
||||
|
||||
gtk_cell_renderer_toggle_get_size (cell, widget, cell_area,
|
||||
&x_offset, &y_offset,
|
||||
@ -452,32 +451,12 @@ gtk_cell_renderer_toggle_snapshot (GtkCellRenderer *cell,
|
||||
gtk_style_context_get_padding (context, &padding);
|
||||
gtk_style_context_get_border (context, &border);
|
||||
|
||||
if (priv->radio)
|
||||
{
|
||||
if (state & GTK_STATE_FLAG_INCONSISTENT)
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_OPTION_INCONSISTENT;
|
||||
else if (state & GTK_STATE_FLAG_CHECKED)
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_OPTION;
|
||||
else
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (state & GTK_STATE_FLAG_INCONSISTENT)
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_CHECK_INCONSISTENT;
|
||||
else if (state & GTK_STATE_FLAG_CHECKED)
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_CHECK;
|
||||
else
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_NONE;
|
||||
}
|
||||
|
||||
gtk_snapshot_translate (snapshot,
|
||||
&GRAPHENE_POINT_INIT (cell_area->x + x_offset + xpad + padding.left + border.left,
|
||||
cell_area->y + y_offset + ypad + padding.top + border.top));
|
||||
gtk_css_style_snapshot_icon (gtk_style_context_lookup_style (context), snapshot,
|
||||
width - padding.left - padding.right - border.left - border.right,
|
||||
height - padding.top - padding.bottom - border.top - border.bottom,
|
||||
image_type);
|
||||
height - padding.top - padding.bottom - border.top - border.bottom);
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
@ -98,7 +98,6 @@ static void
|
||||
gtk_check_button_update_node_state (GtkWidget *widget)
|
||||
{
|
||||
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget));
|
||||
GtkCssImageBuiltinType image_type;
|
||||
GtkStateFlags state;
|
||||
|
||||
if (!priv->indicator_widget)
|
||||
@ -106,17 +105,6 @@ gtk_check_button_update_node_state (GtkWidget *widget)
|
||||
|
||||
state = gtk_widget_get_state_flags (widget);
|
||||
|
||||
/* XXX: This is somewhat awkward here, but there's no better
|
||||
* way to update the icon
|
||||
*/
|
||||
if (state & GTK_STATE_FLAG_CHECKED)
|
||||
image_type = GTK_IS_RADIO_BUTTON (widget) ? GTK_CSS_IMAGE_BUILTIN_OPTION : GTK_CSS_IMAGE_BUILTIN_CHECK;
|
||||
else if (state & GTK_STATE_FLAG_INCONSISTENT)
|
||||
image_type = GTK_IS_RADIO_BUTTON (widget) ? GTK_CSS_IMAGE_BUILTIN_OPTION_INCONSISTENT : GTK_CSS_IMAGE_BUILTIN_CHECK_INCONSISTENT;
|
||||
else
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_NONE;
|
||||
|
||||
gtk_icon_set_image (GTK_ICON (priv->indicator_widget), image_type);
|
||||
gtk_widget_set_state_flags (priv->indicator_widget, state, TRUE);
|
||||
}
|
||||
|
||||
|
@ -1,670 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssimagebuiltinprivate.h"
|
||||
|
||||
#include "gtkcssenumvalueprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssrgbavalueprivate.h"
|
||||
#include "gtkcssstyleprivate.h"
|
||||
#include "gtkhslaprivate.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "fallback-c89.c"
|
||||
|
||||
G_DEFINE_TYPE (GtkCssImageBuiltin, gtk_css_image_builtin, GTK_TYPE_CSS_IMAGE)
|
||||
|
||||
static GtkCssImage *the_one_true_image;
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_draw_check (GtkCssImage *image,
|
||||
cairo_t *cr,
|
||||
double width,
|
||||
double height,
|
||||
gboolean checked,
|
||||
gboolean inconsistent)
|
||||
{
|
||||
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
|
||||
gint x, y, exterior_size, interior_size, pad;
|
||||
|
||||
exterior_size = MIN (width, height);
|
||||
|
||||
if (exterior_size % 2 == 0) /* Ensure odd */
|
||||
exterior_size -= 1;
|
||||
|
||||
pad = 1 + MAX (1, (exterior_size - 2) / 9);
|
||||
interior_size = MAX (1, exterior_size - 2 * pad);
|
||||
|
||||
if (interior_size < 7)
|
||||
pad = MAX (0, (exterior_size - interior_size) / 2);
|
||||
|
||||
x = - (1 + exterior_size - (gint) width) / 2;
|
||||
y = - (1 + exterior_size - (gint) height) / 2;
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
|
||||
|
||||
if (inconsistent)
|
||||
{
|
||||
int line_thickness = MAX (1, (3 + interior_size * 2) / 7);
|
||||
|
||||
cairo_rectangle (cr,
|
||||
x + pad,
|
||||
y + pad + (1 + interior_size - line_thickness) / 2,
|
||||
interior_size,
|
||||
line_thickness);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
cairo_save (cr);
|
||||
cairo_translate (cr,
|
||||
x + pad, y + pad);
|
||||
|
||||
cairo_scale (cr, interior_size / 7., interior_size / 7.);
|
||||
|
||||
cairo_rectangle (cr, 0, 0, 7, 7);
|
||||
cairo_clip (cr);
|
||||
|
||||
cairo_move_to (cr, 7.0, 0.0);
|
||||
cairo_line_to (cr, 7.5, 1.0);
|
||||
cairo_curve_to (cr, 5.3, 2.0,
|
||||
4.3, 4.0,
|
||||
3.5, 7.0);
|
||||
cairo_curve_to (cr, 3.0, 5.7,
|
||||
1.3, 4.7,
|
||||
0.0, 4.7);
|
||||
cairo_line_to (cr, 0.2, 3.5);
|
||||
cairo_curve_to (cr, 1.1, 3.5,
|
||||
2.3, 4.3,
|
||||
3.0, 5.0);
|
||||
cairo_curve_to (cr, 1.0, 3.9,
|
||||
2.4, 4.1,
|
||||
3.2, 4.9);
|
||||
cairo_curve_to (cr, 3.5, 3.1,
|
||||
5.2, 2.0,
|
||||
7.0, 0.0);
|
||||
|
||||
cairo_fill (cr);
|
||||
cairo_restore (cr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_draw_option (GtkCssImage *image,
|
||||
cairo_t *cr,
|
||||
double width,
|
||||
double height,
|
||||
gboolean checked,
|
||||
gboolean inconsistent)
|
||||
{
|
||||
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
|
||||
gint x, y, exterior_size, interior_size, pad;
|
||||
|
||||
exterior_size = MIN (width, height);
|
||||
|
||||
if (exterior_size % 2 == 0) /* Ensure odd */
|
||||
exterior_size -= 1;
|
||||
|
||||
x = - (1 + exterior_size - width) / 2;
|
||||
y = - (1 + exterior_size - height) / 2;
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
|
||||
|
||||
pad = 1 + MAX (1, 2 * (exterior_size - 2) / 9);
|
||||
interior_size = MAX (1, exterior_size - 2 * pad);
|
||||
|
||||
if (interior_size < 7)
|
||||
pad = MAX (0, (exterior_size - interior_size) / 2);
|
||||
|
||||
if (inconsistent)
|
||||
{
|
||||
gint line_thickness;
|
||||
|
||||
line_thickness = MAX (1, (3 + interior_size * 2) / 7);
|
||||
|
||||
cairo_rectangle (cr,
|
||||
x + pad,
|
||||
y + pad + (interior_size - line_thickness) / 2.,
|
||||
interior_size,
|
||||
line_thickness);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
else if (checked)
|
||||
{
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc (cr,
|
||||
x + pad + interior_size / 2.,
|
||||
y + pad + interior_size / 2.,
|
||||
interior_size / 2.,
|
||||
0, 2 * G_PI);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_draw_arrow (GtkCssImage *image,
|
||||
cairo_t *cr,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType image_type)
|
||||
{
|
||||
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
|
||||
double line_width;
|
||||
double size;
|
||||
|
||||
size = MIN (width, height);
|
||||
|
||||
cairo_translate (cr, width / 2.0, height / 2.0);
|
||||
switch ((guint) image_type)
|
||||
{
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_UP:
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_DOWN:
|
||||
cairo_rotate (cr, G_PI);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_LEFT:
|
||||
cairo_rotate (cr, 3 * G_PI / 2);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT:
|
||||
cairo_rotate (cr, G_PI / 2);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
line_width = size / 3.0 / sqrt (2);
|
||||
cairo_set_line_width (cr, line_width);
|
||||
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
|
||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
|
||||
|
||||
cairo_scale (cr,
|
||||
(size / (size + line_width)),
|
||||
(size / (size + line_width)));
|
||||
|
||||
cairo_move_to (cr, -size / 2.0, size / 4.0);
|
||||
cairo_rel_line_to (cr, size / 2.0, -size / 2.0);
|
||||
cairo_rel_line_to (cr, size / 2.0, size / 2.0);
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_draw_expander (GtkCssImage *image,
|
||||
cairo_t *cr,
|
||||
double width,
|
||||
double height,
|
||||
gboolean horizontal,
|
||||
gboolean is_rtl,
|
||||
gboolean expanded)
|
||||
{
|
||||
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
|
||||
double vertical_overshoot;
|
||||
int diameter;
|
||||
double radius;
|
||||
double interp; /* interpolation factor for center position */
|
||||
double x_double_horz, y_double_horz;
|
||||
double x_double_vert, y_double_vert;
|
||||
double x_double, y_double;
|
||||
gdouble angle;
|
||||
gint line_width;
|
||||
gdouble progress;
|
||||
|
||||
line_width = 1;
|
||||
progress = expanded ? 1 : 0;
|
||||
|
||||
if (!horizontal)
|
||||
{
|
||||
if (is_rtl)
|
||||
angle = (G_PI) - ((G_PI / 2) * progress);
|
||||
else
|
||||
angle = (G_PI / 2) * progress;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_rtl)
|
||||
angle = (G_PI / 2) + ((G_PI / 2) * progress);
|
||||
else
|
||||
angle = (G_PI / 2) - ((G_PI / 2) * progress);
|
||||
}
|
||||
|
||||
interp = progress;
|
||||
|
||||
/* Compute distance that the stroke extends beyonds the end
|
||||
* of the triangle we draw.
|
||||
*/
|
||||
vertical_overshoot = line_width / 2.0 * (1. / tan (G_PI / 8));
|
||||
|
||||
/* For odd line widths, we end the vertical line of the triangle
|
||||
* at a half pixel, so we round differently.
|
||||
*/
|
||||
if (line_width % 2 == 1)
|
||||
vertical_overshoot = ceil (0.5 + vertical_overshoot) - 0.5;
|
||||
else
|
||||
vertical_overshoot = ceil (vertical_overshoot);
|
||||
|
||||
/* Adjust the size of the triangle we draw so that the entire stroke fits
|
||||
*/
|
||||
diameter = (gint) MAX (3, width - 2 * vertical_overshoot);
|
||||
|
||||
/* If the line width is odd, we want the diameter to be even,
|
||||
* and vice versa, so force the sum to be odd. This relationship
|
||||
* makes the point of the triangle look right.
|
||||
*/
|
||||
diameter -= (1 - (diameter + line_width) % 2);
|
||||
|
||||
radius = diameter / 2.;
|
||||
|
||||
/* Adjust the center so that the stroke is properly aligned with
|
||||
* the pixel grid. The center adjustment is different for the
|
||||
* horizontal and vertical orientations. For intermediate positions
|
||||
* we interpolate between the two.
|
||||
*/
|
||||
x_double_vert = floor ((width / 2) - (radius + line_width) / 2.) + (radius + line_width) / 2.;
|
||||
y_double_vert = (height / 2) - 0.5;
|
||||
|
||||
x_double_horz = (width / 2) - 0.5;
|
||||
y_double_horz = floor ((height / 2) - (radius + line_width) / 2.) + (radius + line_width) / 2.;
|
||||
|
||||
x_double = x_double_vert * (1 - interp) + x_double_horz * interp;
|
||||
y_double = y_double_vert * (1 - interp) + y_double_horz * interp;
|
||||
|
||||
cairo_translate (cr, x_double, y_double);
|
||||
cairo_rotate (cr, angle);
|
||||
|
||||
cairo_move_to (cr, - radius / 2., - radius);
|
||||
cairo_line_to (cr, radius / 2., 0);
|
||||
cairo_line_to (cr, - radius / 2., radius);
|
||||
cairo_close_path (cr);
|
||||
|
||||
cairo_set_line_width (cr, line_width);
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
|
||||
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
color_shade (const GdkRGBA *color,
|
||||
gdouble factor,
|
||||
GdkRGBA *color_return)
|
||||
{
|
||||
GtkHSLA hsla;
|
||||
|
||||
_gtk_hsla_init_from_rgba (&hsla, color);
|
||||
_gtk_hsla_shade (&hsla, &hsla, factor);
|
||||
_gdk_rgba_init_from_hsla (color_return, &hsla);
|
||||
}
|
||||
|
||||
static void
|
||||
render_dot (cairo_t *cr,
|
||||
const GdkRGBA *lighter,
|
||||
const GdkRGBA *darker,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble size)
|
||||
{
|
||||
size = CLAMP ((gint) size, 2, 3);
|
||||
|
||||
if (size == 2)
|
||||
{
|
||||
gdk_cairo_set_source_rgba (cr, lighter);
|
||||
cairo_rectangle (cr, x, y, 1, 1);
|
||||
cairo_rectangle (cr, x + 1, y + 1, 1, 1);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
else if (size == 3)
|
||||
{
|
||||
gdk_cairo_set_source_rgba (cr, lighter);
|
||||
cairo_rectangle (cr, x, y, 2, 1);
|
||||
cairo_rectangle (cr, x, y, 1, 2);
|
||||
cairo_fill (cr);
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, darker);
|
||||
cairo_rectangle (cr, x + 1, y + 1, 2, 1);
|
||||
cairo_rectangle (cr, x + 2, y, 1, 2);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_draw_pane_separator (GtkCssImage *image,
|
||||
cairo_t *cr,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
|
||||
GdkRGBA lighter, darker;
|
||||
gint xx, yy;
|
||||
|
||||
cairo_set_line_width (cr, 1.0);
|
||||
|
||||
color_shade (&builtin->bg_color, 0.7, &darker);
|
||||
color_shade (&builtin->bg_color, 1.3, &lighter);
|
||||
|
||||
if (width > height)
|
||||
for (xx = width / 2 - 15; xx <= width / 2 + 15; xx += 5)
|
||||
render_dot (cr, &lighter, &darker, xx, height / 2 - 1, 3);
|
||||
else
|
||||
for (yy = height / 2 - 15; yy <= height / 2 + 15; yy += 5)
|
||||
render_dot (cr, &lighter, &darker, width / 2 - 1, yy, 3);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_draw_handle (GtkCssImage *image,
|
||||
cairo_t *cr,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
|
||||
GdkRGBA lighter, darker;
|
||||
gint xx, yy;
|
||||
|
||||
cairo_set_line_width (cr, 1.0);
|
||||
|
||||
color_shade (&builtin->bg_color, 0.7, &darker);
|
||||
color_shade (&builtin->bg_color, 1.3, &lighter);
|
||||
|
||||
for (yy = 0; yy < height; yy += 3)
|
||||
for (xx = 0; xx < width; xx += 6)
|
||||
{
|
||||
render_dot (cr, &lighter, &darker, xx, yy, 2);
|
||||
render_dot (cr, &lighter, &darker, xx + 3, yy + 1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_draw_spinner (GtkCssImage *image,
|
||||
cairo_t *cr,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
|
||||
guint num_steps;
|
||||
gdouble radius;
|
||||
gdouble half;
|
||||
gint i;
|
||||
|
||||
radius = MIN (width / 2, height / 2);
|
||||
|
||||
cairo_translate (cr, width / 2, height / 2);
|
||||
|
||||
num_steps = 12;
|
||||
|
||||
cairo_set_line_width (cr, 2.0);
|
||||
|
||||
half = num_steps / 2;
|
||||
|
||||
for (i = 0; i < num_steps; i++)
|
||||
{
|
||||
gint inset = 0.7 * radius;
|
||||
/* transparency is a function of time and intial value */
|
||||
gdouble t = 1.0 - (gdouble) i / num_steps;
|
||||
gdouble xscale = - sin (i * G_PI / half);
|
||||
gdouble yscale = - cos (i * G_PI / half);
|
||||
|
||||
cairo_move_to (cr,
|
||||
(radius - inset) * xscale,
|
||||
(radius - inset) * yscale);
|
||||
cairo_line_to (cr,
|
||||
radius * xscale,
|
||||
radius * yscale);
|
||||
|
||||
cairo_set_source_rgba (cr,
|
||||
builtin->fg_color.red,
|
||||
builtin->fg_color.green,
|
||||
builtin->fg_color.blue,
|
||||
builtin->fg_color.alpha * t);
|
||||
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_real_snapshot (GtkCssImage *image,
|
||||
GtkSnapshot *snapshot,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
/* It's a builtin image, other code will draw things */
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_builtin_parse (GtkCssImage *image,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
if (!gtk_css_parser_try_ident (parser, "builtin"))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected 'builtin'");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_print (GtkCssImage *image,
|
||||
GString *string)
|
||||
{
|
||||
g_string_append (string, "builtin");
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_builtin_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageBuiltin *result;
|
||||
|
||||
result = g_object_new (GTK_TYPE_CSS_IMAGE_BUILTIN, NULL);
|
||||
|
||||
result->fg_color = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR));
|
||||
result->bg_color = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
|
||||
|
||||
return GTK_CSS_IMAGE (result);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_builtin_equal (GtkCssImage *image1,
|
||||
GtkCssImage *image2)
|
||||
{
|
||||
GtkCssImageBuiltin *builtin1 = (GtkCssImageBuiltin *) image1;
|
||||
GtkCssImageBuiltin *builtin2 = (GtkCssImageBuiltin *) image2;
|
||||
|
||||
return gdk_rgba_equal (&builtin1->fg_color, &builtin2->fg_color)
|
||||
&& gdk_rgba_equal (&builtin1->bg_color, &builtin2->bg_color);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_dispose (GObject *object)
|
||||
{
|
||||
if (the_one_true_image == GTK_CSS_IMAGE (object))
|
||||
the_one_true_image = NULL;
|
||||
|
||||
G_OBJECT_CLASS (gtk_css_image_builtin_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_class_init (GtkCssImageBuiltinClass *klass)
|
||||
{
|
||||
GtkCssImageClass *image_class = GTK_CSS_IMAGE_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
image_class->snapshot = gtk_css_image_builtin_real_snapshot;
|
||||
image_class->parse = gtk_css_image_builtin_parse;
|
||||
image_class->print = gtk_css_image_builtin_print;
|
||||
image_class->compute = gtk_css_image_builtin_compute;
|
||||
image_class->equal = gtk_css_image_builtin_equal;
|
||||
|
||||
object_class->dispose = gtk_css_image_builtin_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_builtin_init (GtkCssImageBuiltin *builtin)
|
||||
{
|
||||
/* white background */
|
||||
builtin->bg_color.red = builtin->bg_color.green = builtin->bg_color.blue = builtin->bg_color.alpha = 1.0;
|
||||
/* black foreground */
|
||||
builtin->fg_color.alpha = 1.0;
|
||||
}
|
||||
|
||||
GtkCssImage *
|
||||
gtk_css_image_builtin_new (void)
|
||||
{
|
||||
if (the_one_true_image == NULL)
|
||||
the_one_true_image = g_object_new (GTK_TYPE_CSS_IMAGE_BUILTIN, NULL);
|
||||
else
|
||||
g_object_ref (the_one_true_image);
|
||||
|
||||
return the_one_true_image;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_image_builtin_draw (GtkCssImage *image,
|
||||
cairo_t *cr,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType image_type)
|
||||
{
|
||||
if (!GTK_IS_CSS_IMAGE_BUILTIN (image))
|
||||
{
|
||||
_gtk_css_image_draw (image, cr, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (image_type)
|
||||
{
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_NONE:
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_CHECK:
|
||||
case GTK_CSS_IMAGE_BUILTIN_CHECK_INCONSISTENT:
|
||||
gtk_css_image_builtin_draw_check (image, cr,
|
||||
width, height,
|
||||
image_type == GTK_CSS_IMAGE_BUILTIN_CHECK,
|
||||
image_type == GTK_CSS_IMAGE_BUILTIN_CHECK_INCONSISTENT);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_OPTION:
|
||||
case GTK_CSS_IMAGE_BUILTIN_OPTION_INCONSISTENT:
|
||||
gtk_css_image_builtin_draw_option (image, cr,
|
||||
width, height,
|
||||
image_type == GTK_CSS_IMAGE_BUILTIN_OPTION,
|
||||
image_type == GTK_CSS_IMAGE_BUILTIN_OPTION_INCONSISTENT);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_UP:
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_DOWN:
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_LEFT:
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT:
|
||||
gtk_css_image_builtin_draw_arrow (image, cr,
|
||||
width, height,
|
||||
image_type);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT:
|
||||
gtk_css_image_builtin_draw_expander (image, cr,
|
||||
width, height,
|
||||
TRUE, FALSE, FALSE);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT:
|
||||
gtk_css_image_builtin_draw_expander (image, cr,
|
||||
width, height,
|
||||
FALSE, FALSE, FALSE);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT:
|
||||
gtk_css_image_builtin_draw_expander (image, cr,
|
||||
width, height,
|
||||
TRUE, TRUE, FALSE);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT:
|
||||
gtk_css_image_builtin_draw_expander (image, cr,
|
||||
width, height,
|
||||
FALSE, TRUE, FALSE);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT_EXPANDED:
|
||||
gtk_css_image_builtin_draw_expander (image, cr,
|
||||
width, height,
|
||||
TRUE, FALSE, TRUE);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT_EXPANDED:
|
||||
gtk_css_image_builtin_draw_expander (image, cr,
|
||||
width, height,
|
||||
FALSE, FALSE, TRUE);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT_EXPANDED:
|
||||
gtk_css_image_builtin_draw_expander (image, cr,
|
||||
width, height,
|
||||
TRUE, TRUE, TRUE);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT_EXPANDED:
|
||||
gtk_css_image_builtin_draw_expander (image, cr,
|
||||
width, height,
|
||||
FALSE, TRUE, TRUE);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_PANE_SEPARATOR:
|
||||
gtk_css_image_builtin_draw_pane_separator (image, cr,
|
||||
width, height);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_HANDLE:
|
||||
gtk_css_image_builtin_draw_handle (image, cr,
|
||||
width, height);
|
||||
break;
|
||||
case GTK_CSS_IMAGE_BUILTIN_SPINNER:
|
||||
gtk_css_image_builtin_draw_spinner (image, cr,
|
||||
width, height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_image_builtin_snapshot (GtkCssImage *image,
|
||||
GtkSnapshot *snapshot,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType image_type)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_CSS_IMAGE (image));
|
||||
g_return_if_fail (snapshot != NULL);
|
||||
g_return_if_fail (width > 0);
|
||||
g_return_if_fail (height > 0);
|
||||
|
||||
if (!GTK_IS_CSS_IMAGE_BUILTIN (image))
|
||||
{
|
||||
gtk_css_image_snapshot (image, snapshot, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
if (image_type != GTK_CSS_IMAGE_BUILTIN_NONE)
|
||||
{
|
||||
cairo_t *cr = gtk_snapshot_append_cairo (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_css_image_builtin_draw (image, cr, width, height, image_type);
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_IMAGE_BUILTIN_PRIVATE_H__
|
||||
#define __GTK_CSS_IMAGE_BUILTIN_PRIVATE_H__
|
||||
|
||||
#include "gtk/gtkcssimageprivate.h"
|
||||
#include "gtk/gtkicontheme.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CSS_IMAGE_BUILTIN (gtk_css_image_builtin_get_type ())
|
||||
#define GTK_CSS_IMAGE_BUILTIN(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_IMAGE_BUILTIN, GtkCssImageBuiltin))
|
||||
#define GTK_CSS_IMAGE_BUILTIN_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_IMAGE_BUILTIN, GtkCssImageBuiltinClass))
|
||||
#define GTK_IS_CSS_IMAGE_BUILTIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_IMAGE_BUILTIN))
|
||||
#define GTK_IS_CSS_IMAGE_BUILTIN_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_IMAGE_BUILTIN))
|
||||
#define GTK_CSS_IMAGE_BUILTIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_IMAGE_BUILTIN, GtkCssImageBuiltinClass))
|
||||
|
||||
typedef struct _GtkCssImageBuiltin GtkCssImageBuiltin;
|
||||
typedef struct _GtkCssImageBuiltinClass GtkCssImageBuiltinClass;
|
||||
|
||||
struct _GtkCssImageBuiltin
|
||||
{
|
||||
GtkCssImage parent;
|
||||
|
||||
GdkRGBA fg_color;
|
||||
GdkRGBA bg_color;
|
||||
};
|
||||
|
||||
struct _GtkCssImageBuiltinClass
|
||||
{
|
||||
GtkCssImageClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_css_image_builtin_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkCssImage * gtk_css_image_builtin_new (void);
|
||||
|
||||
void gtk_css_image_builtin_draw (GtkCssImage *image,
|
||||
cairo_t *cr,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType image_type);
|
||||
void gtk_css_image_builtin_snapshot (GtkCssImage *image,
|
||||
GtkSnapshot *snapshot,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType image_type);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_IMAGE_BUILTIN_PRIVATE_H__ */
|
@ -46,7 +46,6 @@
|
||||
#include "gtkcssfontfeaturesvalueprivate.h"
|
||||
#include "gtkcssiconthemevalueprivate.h"
|
||||
#include "gtkcssimageprivate.h"
|
||||
#include "gtkcssimagebuiltinprivate.h"
|
||||
#include "gtkcssimagevalueprivate.h"
|
||||
#include "gtkcssinitialvalueprivate.h"
|
||||
#include "gtkcssenumvalueprivate.h"
|
||||
@ -677,16 +676,6 @@ css_image_value_parse (GtkCssStyleProperty *property,
|
||||
return _gtk_css_image_value_new (image);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
css_image_value_parse_with_builtin (GtkCssStyleProperty *property,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, "builtin"))
|
||||
return _gtk_css_image_value_new (gtk_css_image_builtin_new ());
|
||||
|
||||
return css_image_value_parse (property, parser);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
background_image_value_parse_one (GtkCssParser *parser)
|
||||
{
|
||||
@ -1512,9 +1501,9 @@ _gtk_css_style_property_init_properties (void)
|
||||
G_TYPE_NONE,
|
||||
GTK_STYLE_PROPERTY_ANIMATED,
|
||||
GTK_CSS_AFFECTS_ICON | GTK_CSS_AFFECTS_SYMBOLIC_ICON,
|
||||
css_image_value_parse_with_builtin,
|
||||
css_image_value_parse,
|
||||
NULL,
|
||||
_gtk_css_image_value_new (gtk_css_image_builtin_new ()));
|
||||
_gtk_css_image_value_new (NULL));
|
||||
gtk_css_style_property_register ("-gtk-icon-size",
|
||||
GTK_CSS_PROPERTY_ICON_SIZE,
|
||||
G_TYPE_NONE,
|
||||
|
@ -247,29 +247,6 @@ enum { /*< skip >*/
|
||||
GTK_CSS_PROPERTY_N_PROPERTIES
|
||||
};
|
||||
|
||||
typedef enum /*< skip >*/ {
|
||||
GTK_CSS_IMAGE_BUILTIN_NONE,
|
||||
GTK_CSS_IMAGE_BUILTIN_CHECK,
|
||||
GTK_CSS_IMAGE_BUILTIN_CHECK_INCONSISTENT,
|
||||
GTK_CSS_IMAGE_BUILTIN_OPTION,
|
||||
GTK_CSS_IMAGE_BUILTIN_OPTION_INCONSISTENT,
|
||||
GTK_CSS_IMAGE_BUILTIN_ARROW_UP,
|
||||
GTK_CSS_IMAGE_BUILTIN_ARROW_DOWN,
|
||||
GTK_CSS_IMAGE_BUILTIN_ARROW_LEFT,
|
||||
GTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT,
|
||||
GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT,
|
||||
GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT,
|
||||
GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT,
|
||||
GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT,
|
||||
GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT_EXPANDED,
|
||||
GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT_EXPANDED,
|
||||
GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT_EXPANDED,
|
||||
GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT_EXPANDED,
|
||||
GTK_CSS_IMAGE_BUILTIN_PANE_SEPARATOR,
|
||||
GTK_CSS_IMAGE_BUILTIN_HANDLE,
|
||||
GTK_CSS_IMAGE_BUILTIN_SPINNER
|
||||
} GtkCssImageBuiltinType;
|
||||
|
||||
typedef enum /*< skip >*/ {
|
||||
GTK_CSS_AREA_BORDER_BOX,
|
||||
GTK_CSS_AREA_PADDING_BOX,
|
||||
|
@ -36,8 +36,6 @@
|
||||
struct _GtkIcon
|
||||
{
|
||||
GtkWidget parent;
|
||||
|
||||
GtkCssImageBuiltinType image;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkIcon, gtk_icon, GTK_TYPE_WIDGET)
|
||||
@ -46,7 +44,6 @@ static void
|
||||
gtk_icon_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkIcon *self = GTK_ICON (widget);
|
||||
GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
|
||||
int width, height;
|
||||
|
||||
@ -54,10 +51,7 @@ gtk_icon_snapshot (GtkWidget *widget,
|
||||
height = gtk_widget_get_height (widget);
|
||||
|
||||
if (width > 0 && height > 0)
|
||||
gtk_css_style_snapshot_icon (style,
|
||||
snapshot,
|
||||
width, height,
|
||||
self->image);
|
||||
gtk_css_style_snapshot_icon (style, snapshot, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -87,7 +81,6 @@ gtk_icon_class_init (GtkIconClass *klass)
|
||||
static void
|
||||
gtk_icon_init (GtkIcon *self)
|
||||
{
|
||||
self->image = GTK_CSS_IMAGE_BUILTIN_NONE;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@ -98,13 +91,6 @@ gtk_icon_new (const char *css_name)
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_icon_set_image (GtkIcon *self,
|
||||
GtkCssImageBuiltinType image)
|
||||
{
|
||||
self->image = image;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_icon_set_css_name (GtkIcon *self,
|
||||
const char *css_name)
|
||||
|
@ -31,9 +31,6 @@ G_DECLARE_FINAL_TYPE (GtkIcon, gtk_icon, GTK, ICON, GtkWidget)
|
||||
|
||||
GtkWidget * gtk_icon_new (const char *css_name);
|
||||
|
||||
void gtk_icon_set_image (GtkIcon *self,
|
||||
GtkCssImageBuiltinType image);
|
||||
|
||||
void gtk_icon_set_css_name (GtkIcon *self,
|
||||
const char *css_name);
|
||||
|
||||
|
@ -583,7 +583,6 @@ gtk_menu_section_box_new_section (GtkMenuTrackerItem *item,
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (box->item_box)), "inline-buttons");
|
||||
|
||||
spacer = gtk_icon_new ("none");
|
||||
gtk_icon_set_image (GTK_ICON (spacer), GTK_CSS_IMAGE_BUILTIN_NONE);
|
||||
gtk_container_add (GTK_CONTAINER (box->item_box), spacer);
|
||||
gtk_size_group_add_widget (box->indicators, spacer);
|
||||
|
||||
|
@ -352,12 +352,6 @@ update_end_indicator (GtkModelButton *self)
|
||||
if (!self->end_indicator)
|
||||
return;
|
||||
|
||||
if (self->role == GTK_BUTTON_ROLE_NORMAL &&
|
||||
(self->menu_name != NULL || self->popover != NULL))
|
||||
{
|
||||
gtk_icon_set_image (GTK_ICON (self->end_indicator), GTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT);
|
||||
}
|
||||
|
||||
context = gtk_widget_get_style_context (self->end_indicator);
|
||||
|
||||
if (is_ltr)
|
||||
@ -398,15 +392,6 @@ update_start_indicator (GtkModelButton *self)
|
||||
if (!self->start_indicator)
|
||||
return;
|
||||
|
||||
if (self->role == GTK_BUTTON_ROLE_CHECK)
|
||||
gtk_icon_set_image (GTK_ICON (self->start_indicator), GTK_CSS_IMAGE_BUILTIN_CHECK);
|
||||
else if (self->role == GTK_BUTTON_ROLE_RADIO)
|
||||
gtk_icon_set_image (GTK_ICON (self->start_indicator), GTK_CSS_IMAGE_BUILTIN_OPTION);
|
||||
else if (self->role == GTK_BUTTON_ROLE_TITLE)
|
||||
gtk_icon_set_image (GTK_ICON (self->start_indicator), GTK_CSS_IMAGE_BUILTIN_ARROW_LEFT);
|
||||
else
|
||||
gtk_icon_set_image (GTK_ICON (self->start_indicator), GTK_CSS_IMAGE_BUILTIN_NONE);
|
||||
|
||||
gtk_widget_set_state_flags (self->start_indicator, get_start_indicator_state (self), TRUE);
|
||||
|
||||
context = gtk_widget_get_style_context (self->start_indicator);
|
||||
|
@ -1326,10 +1326,7 @@ gtk_paned_render_handle (GtkGizmo *gizmo,
|
||||
height = gtk_widget_get_height (widget);
|
||||
|
||||
if (width > 0 && height > 0)
|
||||
gtk_css_style_snapshot_icon (style,
|
||||
snapshot,
|
||||
width, height,
|
||||
GTK_CSS_IMAGE_BUILTIN_PANE_SEPARATOR);
|
||||
gtk_css_style_snapshot_icon (style, snapshot, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
|
101
gtk/gtkrender.c
101
gtk/gtkrender.c
@ -22,7 +22,6 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "gtkcsscornervalueprivate.h"
|
||||
#include "gtkcssimagebuiltinprivate.h"
|
||||
#include "gtkcssimagevalueprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssrgbavalueprivate.h"
|
||||
@ -40,7 +39,6 @@
|
||||
static void
|
||||
gtk_do_render_icon (GtkStyleContext *context,
|
||||
cairo_t *cr,
|
||||
GtkCssImageBuiltinType image_type,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
@ -50,7 +48,7 @@ gtk_do_render_icon (GtkStyleContext *context,
|
||||
GskRenderNode *node;
|
||||
|
||||
snapshot = gtk_snapshot_new ();
|
||||
gtk_css_style_snapshot_icon (gtk_style_context_lookup_style (context), snapshot, width, height, image_type);
|
||||
gtk_css_style_snapshot_icon (gtk_style_context_lookup_style (context), snapshot, width, height);
|
||||
node = gtk_snapshot_free_to_node (snapshot);
|
||||
if (node == NULL)
|
||||
return;
|
||||
@ -90,24 +88,13 @@ gtk_render_check (GtkStyleContext *context,
|
||||
gdouble width,
|
||||
gdouble height)
|
||||
{
|
||||
GtkStateFlags state;
|
||||
GtkCssImageBuiltinType image_type;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
state = gtk_style_context_get_state (context);
|
||||
if (state & GTK_STATE_FLAG_INCONSISTENT)
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_CHECK_INCONSISTENT;
|
||||
else if (state & GTK_STATE_FLAG_CHECKED)
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_CHECK;
|
||||
else
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_NONE;
|
||||
|
||||
gtk_do_render_icon (context, cr, image_type, x, y, width, height);
|
||||
gtk_do_render_icon (context, cr, x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,24 +122,13 @@ gtk_render_option (GtkStyleContext *context,
|
||||
gdouble width,
|
||||
gdouble height)
|
||||
{
|
||||
GtkStateFlags state;
|
||||
GtkCssImageBuiltinType image_type;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
state = gtk_style_context_get_state (context);
|
||||
if (state & GTK_STATE_FLAG_INCONSISTENT)
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_OPTION_INCONSISTENT;
|
||||
else if (state & GTK_STATE_FLAG_CHECKED)
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_OPTION;
|
||||
else
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_NONE;
|
||||
|
||||
gtk_do_render_icon (context, cr, image_type, x, y, width, height);
|
||||
gtk_do_render_icon (context, cr, x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -178,38 +154,13 @@ gtk_render_arrow (GtkStyleContext *context,
|
||||
gdouble y,
|
||||
gdouble size)
|
||||
{
|
||||
GtkCssImageBuiltinType image_type;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
if (size <= 0)
|
||||
return;
|
||||
|
||||
/* map [0, 2 * pi) to [0, 4) */
|
||||
angle = round (2 * angle / G_PI);
|
||||
|
||||
switch (((int) angle) & 3)
|
||||
{
|
||||
case 0:
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_ARROW_UP;
|
||||
break;
|
||||
case 1:
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT;
|
||||
break;
|
||||
case 2:
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_ARROW_DOWN;
|
||||
break;
|
||||
case 3:
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_ARROW_LEFT;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_ARROW_UP;
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_do_render_icon (context, cr, image_type, x, y, size, size);
|
||||
gtk_do_render_icon (context, cr, x, y, size, size);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -360,40 +311,13 @@ gtk_render_expander (GtkStyleContext *context,
|
||||
gdouble width,
|
||||
gdouble height)
|
||||
{
|
||||
GtkCssImageBuiltinType image_type;
|
||||
GtkStateFlags state;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
state = gtk_style_context_get_state (context);
|
||||
if (gtk_style_context_has_class (context, "horizontal"))
|
||||
{
|
||||
if (state & GTK_STATE_FLAG_DIR_RTL)
|
||||
image_type = (state & GTK_STATE_FLAG_CHECKED)
|
||||
? GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT_EXPANDED
|
||||
: GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT;
|
||||
else
|
||||
image_type = (state & GTK_STATE_FLAG_CHECKED)
|
||||
? GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT_EXPANDED
|
||||
: GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (state & GTK_STATE_FLAG_DIR_RTL)
|
||||
image_type = (state & GTK_STATE_FLAG_CHECKED)
|
||||
? GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT_EXPANDED
|
||||
: GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT;
|
||||
else
|
||||
image_type = (state & GTK_STATE_FLAG_CHECKED)
|
||||
? GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT_EXPANDED
|
||||
: GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT;
|
||||
}
|
||||
|
||||
gtk_do_render_icon (context, cr, image_type, x, y, width, height);
|
||||
gtk_do_render_icon (context, cr, x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -554,8 +478,6 @@ gtk_render_handle (GtkStyleContext *context,
|
||||
gdouble width,
|
||||
gdouble height)
|
||||
{
|
||||
GtkCssImageBuiltinType type;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
@ -565,16 +487,7 @@ gtk_render_handle (GtkStyleContext *context,
|
||||
gtk_render_background (context, cr, x, y, width, height);
|
||||
gtk_render_frame (context, cr, x, y, width, height);
|
||||
|
||||
if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_PANE_SEPARATOR))
|
||||
{
|
||||
type = GTK_CSS_IMAGE_BUILTIN_PANE_SEPARATOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = GTK_CSS_IMAGE_BUILTIN_HANDLE;
|
||||
}
|
||||
|
||||
gtk_do_render_icon (context, cr, x, y, width, height, type);
|
||||
gtk_do_render_icon (context, cr, x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -604,7 +517,7 @@ gtk_render_activity (GtkStyleContext *context,
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
gtk_do_render_icon (context, cr, x, y, width, height, GTK_CSS_IMAGE_BUILTIN_SPINNER);
|
||||
gtk_do_render_icon (context, cr, x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "gtkrendericonprivate.h"
|
||||
|
||||
#include "gtkcssfiltervalueprivate.h"
|
||||
#include "gtkcssimagebuiltinprivate.h"
|
||||
#include "gtkcssimagevalueprivate.h"
|
||||
#include "gtkcssshadowsvalueprivate.h"
|
||||
#include "gtkcssstyleprivate.h"
|
||||
@ -37,8 +36,7 @@ void
|
||||
gtk_css_style_snapshot_icon (GtkCssStyle *style,
|
||||
GtkSnapshot *snapshot,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType builtin_type)
|
||||
double height)
|
||||
{
|
||||
const GtkCssValue *shadows_value, *transform_value, *filter_value;
|
||||
GskTransform *transform;
|
||||
@ -69,7 +67,7 @@ gtk_css_style_snapshot_icon (GtkCssStyle *style,
|
||||
|
||||
if (transform == NULL)
|
||||
{
|
||||
gtk_css_image_builtin_snapshot (image, snapshot, width, height, builtin_type);
|
||||
gtk_css_image_snapshot (image, snapshot, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -80,7 +78,7 @@ gtk_css_style_snapshot_icon (GtkCssStyle *style,
|
||||
gtk_snapshot_transform (snapshot, transform);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (- width / 2.0, - height / 2.0));
|
||||
|
||||
gtk_css_image_builtin_snapshot (image, snapshot, width, height, builtin_type);
|
||||
gtk_css_image_snapshot (image, snapshot, width, height);
|
||||
|
||||
gtk_snapshot_restore (snapshot);
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ G_BEGIN_DECLS
|
||||
void gtk_css_style_snapshot_icon (GtkCssStyle *style,
|
||||
GtkSnapshot *snapshot,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType builtin_type);
|
||||
double height);
|
||||
|
||||
void gtk_css_style_snapshot_icon_paintable (GtkCssStyle *style,
|
||||
GtkSnapshot *snapshot,
|
||||
|
@ -120,8 +120,7 @@ gtk_spinner_snapshot (GtkWidget *widget,
|
||||
gtk_css_style_snapshot_icon (style,
|
||||
snapshot,
|
||||
gtk_widget_get_width (widget),
|
||||
gtk_widget_get_height (widget),
|
||||
GTK_CSS_IMAGE_BUILTIN_SPINNER);
|
||||
gtk_widget_get_height (widget));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -185,8 +185,7 @@ snapshot_func (GtkGizmo *gizmo,
|
||||
gtk_css_style_snapshot_icon (style,
|
||||
snapshot,
|
||||
gtk_widget_get_width (GTK_WIDGET (gizmo)),
|
||||
gtk_widget_get_height (GTK_WIDGET (gizmo)),
|
||||
GTK_CSS_IMAGE_BUILTIN_HANDLE);
|
||||
gtk_widget_get_height (GTK_WIDGET (gizmo)));
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
|
@ -687,7 +687,6 @@ gtk_tree_popover_create_item (GtkTreePopover *popover,
|
||||
if (header_item)
|
||||
{
|
||||
indicator = gtk_icon_new ("arrow");
|
||||
gtk_icon_set_image (GTK_ICON (indicator), GTK_CSS_IMAGE_BUILTIN_ARROW_LEFT);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (indicator), "left");
|
||||
gtk_widget_set_parent (indicator, item);
|
||||
}
|
||||
@ -695,8 +694,6 @@ gtk_tree_popover_create_item (GtkTreePopover *popover,
|
||||
gtk_widget_set_parent (view, item);
|
||||
|
||||
indicator = gtk_icon_new (has_submenu ? "arrow" : "none");
|
||||
gtk_icon_set_image (GTK_ICON (indicator), has_submenu ? GTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT
|
||||
: GTK_CSS_IMAGE_BUILTIN_NONE);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (indicator), "right");
|
||||
gtk_widget_set_parent (indicator, item);
|
||||
|
||||
|
@ -9338,12 +9338,9 @@ gtk_tree_view_snapshot_arrow (GtkTreeView *tree_view,
|
||||
gint x_offset = 0;
|
||||
gint x2;
|
||||
GtkCellRendererState flags = 0;
|
||||
GtkCssImageBuiltinType image_type;
|
||||
gboolean rtl;
|
||||
|
||||
widget = GTK_WIDGET (tree_view);
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
rtl = (_gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
|
||||
|
||||
if (! GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_PARENT))
|
||||
return;
|
||||
@ -9365,17 +9362,9 @@ gtk_tree_view_snapshot_arrow (GtkTreeView *tree_view,
|
||||
state = gtk_cell_renderer_get_state (NULL, widget, flags);
|
||||
|
||||
if (node->children != NULL)
|
||||
{
|
||||
state |= GTK_STATE_FLAG_CHECKED;
|
||||
image_type = rtl ? GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT_EXPANDED
|
||||
: GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT_EXPANDED;
|
||||
}
|
||||
state |= GTK_STATE_FLAG_CHECKED;
|
||||
else
|
||||
{
|
||||
state &= ~(GTK_STATE_FLAG_CHECKED);
|
||||
image_type = rtl ? GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT
|
||||
: GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT;
|
||||
}
|
||||
state &= ~(GTK_STATE_FLAG_CHECKED);
|
||||
|
||||
gtk_style_context_save (context);
|
||||
|
||||
@ -9385,7 +9374,7 @@ gtk_tree_view_snapshot_arrow (GtkTreeView *tree_view,
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (area.x, area.y));
|
||||
gtk_css_style_snapshot_icon (gtk_style_context_lookup_style (context), snapshot,
|
||||
area.width, area.height, image_type);
|
||||
area.width, area.height);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
|
@ -57,7 +57,6 @@ gtk_private_sources = files([
|
||||
'gtkcssfontvariationsvalue.c',
|
||||
'gtkcssiconthemevalue.c',
|
||||
'gtkcssimage.c',
|
||||
'gtkcssimagebuiltin.c',
|
||||
'gtkcssimagecrossfade.c',
|
||||
'gtkcssimagefallback.c',
|
||||
'gtkcssimageicontheme.c',
|
||||
|
Loading…
Reference in New Issue
Block a user