mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-19 09:50:06 +00:00
arrow: Port to draw vfunc
This commit is contained in:
parent
9233a08991
commit
1d5796c95b
@ -74,8 +74,8 @@ static void gtk_arrow_get_property (GObject *object,
|
|||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
static gboolean gtk_arrow_expose (GtkWidget *widget,
|
static gboolean gtk_arrow_draw (GtkWidget *widget,
|
||||||
GdkEventExpose *event);
|
cairo_t *cr);
|
||||||
|
|
||||||
static void gtk_arrow_size_request_init (GtkSizeRequestIface *iface);
|
static void gtk_arrow_size_request_init (GtkSizeRequestIface *iface);
|
||||||
static void gtk_arrow_get_width (GtkSizeRequest *widget,
|
static void gtk_arrow_get_width (GtkSizeRequest *widget,
|
||||||
@ -102,7 +102,7 @@ gtk_arrow_class_init (GtkArrowClass *class)
|
|||||||
gobject_class->set_property = gtk_arrow_set_property;
|
gobject_class->set_property = gtk_arrow_set_property;
|
||||||
gobject_class->get_property = gtk_arrow_get_property;
|
gobject_class->get_property = gtk_arrow_get_property;
|
||||||
|
|
||||||
widget_class->expose_event = gtk_arrow_expose;
|
widget_class->draw = gtk_arrow_draw;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_ARROW_TYPE,
|
PROP_ARROW_TYPE,
|
||||||
@ -311,19 +311,15 @@ gtk_arrow_set (GtkArrow *arrow,
|
|||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_arrow_expose (GtkWidget *widget,
|
gtk_arrow_draw (GtkWidget *widget,
|
||||||
GdkEventExpose *event)
|
cairo_t *cr)
|
||||||
{
|
{
|
||||||
if (gtk_widget_is_drawable (widget))
|
|
||||||
{
|
|
||||||
GtkArrow *arrow = GTK_ARROW (widget);
|
GtkArrow *arrow = GTK_ARROW (widget);
|
||||||
GtkArrowPrivate *priv = arrow->priv;
|
GtkArrowPrivate *priv = arrow->priv;
|
||||||
GtkAllocation allocation;
|
|
||||||
GtkMisc *misc = GTK_MISC (widget);
|
GtkMisc *misc = GTK_MISC (widget);
|
||||||
GtkShadowType shadow_type;
|
GtkShadowType shadow_type;
|
||||||
GtkStateType state;
|
GtkStateType state;
|
||||||
gint width, height;
|
gint x, y, width, height;
|
||||||
gint x, y;
|
|
||||||
gint extent;
|
gint extent;
|
||||||
gint xpad, ypad;
|
gint xpad, ypad;
|
||||||
gfloat xalign, yalign;
|
gfloat xalign, yalign;
|
||||||
@ -332,13 +328,13 @@ gtk_arrow_expose (GtkWidget *widget,
|
|||||||
|
|
||||||
gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL);
|
gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL);
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
|
||||||
gtk_misc_get_padding (misc, &xpad, &ypad);
|
gtk_misc_get_padding (misc, &xpad, &ypad);
|
||||||
gtk_misc_get_alignment (misc, &xalign, &yalign);
|
gtk_misc_get_alignment (misc, &xalign, &yalign);
|
||||||
|
|
||||||
width = allocation.width - xpad * 2;
|
width = gtk_widget_get_allocated_width (widget);
|
||||||
height = allocation.height - ypad * 2;
|
height = gtk_widget_get_allocated_height (widget);
|
||||||
extent = MIN (width, height) * arrow_scaling;
|
|
||||||
|
extent = MIN (width - 2 * xpad, height - 2 * ypad) * arrow_scaling;
|
||||||
effective_arrow_type = priv->arrow_type;
|
effective_arrow_type = priv->arrow_type;
|
||||||
|
|
||||||
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
|
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
|
||||||
@ -350,11 +346,10 @@ gtk_arrow_expose (GtkWidget *widget,
|
|||||||
effective_arrow_type = GTK_ARROW_LEFT;
|
effective_arrow_type = GTK_ARROW_LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
x = floor (allocation.x + xpad + ((allocation.width - extent) * xalign));
|
x = floor (xpad + ((width - extent) * xalign));
|
||||||
y = floor (allocation.y + ypad + ((allocation.height - extent) * yalign));
|
y = floor (ypad + ((height - extent) * yalign));
|
||||||
|
|
||||||
shadow_type = priv->shadow_type;
|
shadow_type = priv->shadow_type;
|
||||||
|
|
||||||
state = gtk_widget_get_state (widget);
|
state = gtk_widget_get_state (widget);
|
||||||
|
|
||||||
if (state == GTK_STATE_ACTIVE)
|
if (state == GTK_STATE_ACTIVE)
|
||||||
@ -369,13 +364,11 @@ gtk_arrow_expose (GtkWidget *widget,
|
|||||||
shadow_type = GTK_SHADOW_ETCHED_IN;
|
shadow_type = GTK_SHADOW_ETCHED_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_paint_arrow (gtk_widget_get_style (widget),
|
gtk_cairo_paint_arrow (gtk_widget_get_style (widget), cr,
|
||||||
gtk_widget_get_window (widget),
|
|
||||||
state, shadow_type,
|
state, shadow_type,
|
||||||
&event->area, widget, "arrow",
|
widget, "arrow",
|
||||||
effective_arrow_type, TRUE,
|
effective_arrow_type, TRUE,
|
||||||
x, y, extent, extent);
|
x, y, extent, extent);
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user