#include "gtktypebuiltins.h"
#include "gtkintl.h"
+
+/**
+ * SECTION:gtkhsv
+ * @Short_description: A 'color wheel' widget
+ * @Title: GtkHSV
+ * @See_also: #GtkColorSelection, #GtkColorSelectionDialog
+ *
+ * #GtkHSV is the 'color wheel' part of a complete color selector widget.
+ * It allows to select a color by determining its HSV components in an
+ * intuitive way. Moving the selection around the outer ring changes the hue,
+ * and moving the selection point inside the inner triangle changes value and
+ * saturation.
+ */
+
+
/* Default width/height */
#define DEFAULT_SIZE 100
widget_class->focus = gtk_hsv_focus;
widget_class->grab_broken_event = gtk_hsv_grab_broken;
+ gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_COLOR_CHOOSER);
+
hsv_class->move = gtk_hsv_move;
hsv_signals[CHANGED] =
cairo_surface_t *source;
cairo_t *source_cr;
gint stride;
- gint focus_width;
- gint focus_pad;
-
- gtk_widget_style_get (widget,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- NULL);
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
/* Paints the HSV triangle */
static void
-paint_triangle (GtkHSV *hsv,
- cairo_t *cr)
+paint_triangle (GtkHSV *hsv,
+ cairo_t *cr,
+ gboolean draw_focus)
{
GtkHSVPrivate *priv = hsv->priv;
GtkWidget *widget = GTK_WIDGET (hsv);
/* Draw focus outline */
- if (gtk_widget_has_focus (widget) &&
- !priv->focus_on_ring)
+ if (draw_focus && !priv->focus_on_ring)
{
gint focus_width;
gint focus_pad;
/* Paints the contents of the HSV color selector */
static gboolean
-gtk_hsv_draw (GtkWidget *widget,
- cairo_t *cr)
+gtk_hsv_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPrivate *priv = hsv->priv;
+ gboolean draw_focus;
+
+ draw_focus = gtk_widget_has_visible_focus (widget);
paint_ring (hsv, cr);
- paint_triangle (hsv, cr);
+ paint_triangle (hsv, cr, draw_focus);
- if (gtk_widget_has_focus (widget) && priv->focus_on_ring)
+
+ if (draw_focus && priv->focus_on_ring)
{
GtkStyleContext *context;
GtkStateFlags state;
double *s,
double *v)
{
- GtkHSVPrivate *priv = hsv->priv;
+ GtkHSVPrivate *priv;
g_return_if_fail (GTK_IS_HSV (hsv));
priv = hsv->priv;
-
+
if (h)
*h = priv->h;
-
+
if (s)
*s = priv->s;
-
+
if (v)
*v = priv->v;
}
gint size,
gint ring_width)
{
- GtkHSVPrivate *priv = hsv->priv;
+ GtkHSVPrivate *priv;
int same_size;
g_return_if_fail (GTK_IS_HSV (hsv));
priv = hsv->priv;
same_size = (priv->size == size);
-
+
priv->size = size;
priv->ring_width = ring_width;
gint *size,
gint *ring_width)
{
- GtkHSVPrivate *priv = hsv->priv;
+ GtkHSVPrivate *priv;
g_return_if_fail (GTK_IS_HSV (hsv));
gboolean
gtk_hsv_is_adjusting (GtkHSV *hsv)
{
- GtkHSVPrivate *priv = hsv->priv;
+ GtkHSVPrivate *priv;
g_return_val_if_fail (GTK_IS_HSV (hsv), FALSE);
gtk_hsv_set_color (hsv, hue, sat, val);
}
+