gtk+ r21078 - in trunk: . gtk



Author: mitch
Date: Mon Aug 11 19:57:38 2008
New Revision: 21078
URL: http://svn.gnome.org/viewvc/gtk+?rev=21078&view=rev

Log:
2008-08-11  Michael Natterer  <mitch imendio com>

	Bug 547270 â Make GtkHSV public

	* gtk/Makefile.am
	* gtk/gtk.h: install gtkhsv.h as public header (its symbols were
	always public anyway).

	* gtk/gtkhsv.h: add single-include guards, add class struct padding,
	seal the instance member, cleanup.

	* gtk/gtkhsv.c: center the widget in its allocation,
	add "Since: 2.14", cleanup.



Modified:
   trunk/ChangeLog
   trunk/gtk/Makefile.am
   trunk/gtk/gtk.h
   trunk/gtk/gtkhsv.c
   trunk/gtk/gtkhsv.h

Modified: trunk/gtk/Makefile.am
==============================================================================
--- trunk/gtk/Makefile.am	(original)
+++ trunk/gtk/Makefile.am	Mon Aug 11 19:57:38 2008
@@ -212,6 +212,7 @@
 	gtkhscale.h		\
 	gtkhscrollbar.h		\
 	gtkhseparator.h		\
+	gtkhsv.h		\
 	gtkiconfactory.h	\
 	gtkicontheme.h		\
 	gtkiconview.h		\
@@ -354,7 +355,6 @@
 	gtkfilechooserutils.h	\
 	gtkfilesystem.h		\
 	gtkfilesystemmodel.h	\
-	gtkhsv.h		\
 	gtkiconcache.h		\
 	gtkintl.h		\
 	gtkkeyhash.h		\

Modified: trunk/gtk/gtk.h
==============================================================================
--- trunk/gtk/gtk.h	(original)
+++ trunk/gtk/gtk.h	Mon Aug 11 19:57:38 2008
@@ -100,6 +100,7 @@
 #include <gtk/gtkhscale.h>
 #include <gtk/gtkhscrollbar.h>
 #include <gtk/gtkhseparator.h>
+#include <gtk/gtkhsv.h>
 #include <gtk/gtkiconfactory.h>
 #include <gtk/gtkicontheme.h>
 #include <gtk/gtkiconview.h>

Modified: trunk/gtk/gtkhsv.c
==============================================================================
--- trunk/gtk/gtkhsv.c	(original)
+++ trunk/gtk/gtkhsv.c	Mon Aug 11 19:57:38 2008
@@ -22,24 +22,26 @@
  * Boston, MA 02111-1307, USA.
  */
 
+/*
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
 #include "config.h"
+
 #include <math.h>
 #include <string.h>
-#include "gtkhsv.h"
+
 #include "gdk/gdkkeysyms.h"
+
+#include "gtkhsv.h"
 #include "gtkbindings.h"
-#include "gtkcontainer.h"
 #include "gtkmarshalers.h"
 #include "gtkintl.h"
 #include "gtkalias.h"
 
-/*
- * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
 /* Default width/height */
 #define DEFAULT_SIZE 100
 
@@ -537,23 +539,25 @@
 		  gint   *vy)
 {
   HSVPrivate *priv;
-  gdouble center;
+  gdouble center_x;
+  gdouble center_y;
   gdouble inner, outer;
   gdouble angle;
-  
+
   priv = hsv->priv;
-  
-  center = GTK_WIDGET (hsv)->requisition.width / 2.0;
+
+  center_x = GTK_WIDGET (hsv)->allocation.width / 2.0;
+  center_y = GTK_WIDGET (hsv)->allocation.height / 2.0;
   outer = priv->size / 2.0;
   inner = outer - priv->ring_width;
   angle = priv->h * 2.0 * G_PI;
-  
-  *hx = floor (center + cos (angle) * inner + 0.5);
-  *hy = floor (center - sin (angle) * inner + 0.5);
-  *sx = floor (center + cos (angle + 2.0 * G_PI / 3.0) * inner + 0.5);
-  *sy = floor (center - sin (angle + 2.0 * G_PI / 3.0) * inner + 0.5);
-  *vx = floor (center + cos (angle + 4.0 * G_PI / 3.0) * inner + 0.5);
-  *vy = floor (center - sin (angle + 4.0 * G_PI / 3.0) * inner + 0.5);
+
+  *hx = floor (center_x + cos (angle) * inner + 0.5);
+  *hy = floor (center_y - sin (angle) * inner + 0.5);
+  *sx = floor (center_x + cos (angle + 2.0 * G_PI / 3.0) * inner + 0.5);
+  *sy = floor (center_y - sin (angle + 2.0 * G_PI / 3.0) * inner + 0.5);
+  *vx = floor (center_x + cos (angle + 4.0 * G_PI / 3.0) * inner + 0.5);
+  *vy = floor (center_y - sin (angle + 4.0 * G_PI / 3.0) * inner + 0.5);
 }
 
 /* Computes whether a point is inside the hue ring */
@@ -564,18 +568,21 @@
 {
   HSVPrivate *priv;
   gdouble dx, dy, dist;
-  gdouble center, inner, outer;
-  
+  gdouble center_x;
+  gdouble center_y;
+  gdouble inner, outer;
+
   priv = hsv->priv;
-  
-  center = priv->size / 2.0;
+
+  center_x = GTK_WIDGET (hsv)->allocation.width / 2.0;
+  center_y = GTK_WIDGET (hsv)->allocation.height / 2.0;
   outer = priv->size / 2.0;
   inner = outer - priv->ring_width;
-  
-  dx = x - center;
-  dy = center - y;
+
+  dx = x - center_x;
+  dy = center_y - y;
   dist = dx * dx + dy * dy;
-  
+
   return (dist >= inner * inner && dist <= outer * outer);
 }
 
@@ -589,18 +596,20 @@
 {
   int ihx, ihy, isx, isy, ivx, ivy;
   double hx, hy, sx, sy, vx, vy;
-  double center;
-  
+  double center_x;
+  double center_y;
+
   compute_triangle (hsv, &ihx, &ihy, &isx, &isy, &ivx, &ivy);
-  center = GTK_WIDGET (hsv)->requisition.width / 2.0;
-  hx = ihx - center;
-  hy = center - ihy;
-  sx = isx - center;
-  sy = center - isy;
-  vx = ivx - center;
-  vy = center - ivy;
-  x -= center;
-  y = center - y;
+  center_x = GTK_WIDGET (hsv)->allocation.width / 2.0;
+  center_y = GTK_WIDGET (hsv)->allocation.height / 2.0;
+  hx = ihx - center_x;
+  hy = center_y - ihy;
+  sx = isx - center_x;
+  sy = center_y - isy;
+  vx = ivx - center_x;
+  vy = center_y - ivy;
+  x -= center_x;
+  y = center_y - y;
   
   if (vx * (x - sx) + vy * (y - sy) < 0.0)
     {
@@ -688,18 +697,20 @@
 	   gdouble x,
 	   gdouble y)
 {
-  double center;
+  double center_x;
+  double center_y;
   double dx, dy;
   double angle;
-  
-  center = GTK_WIDGET (hsv)->requisition.width / 2.0;
-  dx = x - center;
-  dy = center - y;
-  
+
+  center_x = GTK_WIDGET (hsv)->allocation.width / 2.0;
+  center_y = GTK_WIDGET (hsv)->allocation.height / 2.0;
+  dx = x - center_x;
+  dy = center_y - y;
+
   angle = atan2 (dy, dx);
   if (angle < 0.0)
     angle += 2.0 * G_PI;
-  
+
   return angle / (2.0 * G_PI);
 }
 
@@ -889,7 +900,8 @@
   HSVPrivate *priv;
   int xx, yy;
   gdouble dx, dy, dist;
-  gdouble center;
+  gdouble center_x;
+  gdouble center_y;
   gdouble inner, outer;
   guint32 *buf, *p;
   gdouble angle;
@@ -907,9 +919,10 @@
 			NULL);
   
   priv = hsv->priv;
-  
-  center = widget->requisition.width / 2.0;
-  
+
+  center_x = widget->allocation.width / 2.0;
+  center_y = widget->allocation.height / 2.0;
+
   outer = priv->size / 2.0;
   inner = outer - priv->ring_width;
   
@@ -922,11 +935,11 @@
     {
       p = buf + yy * width;
       
-      dy = -(yy + y - center);
+      dy = -(yy + y - center_y);
       
       for (xx = 0; xx < width; xx++)
 	{
-	  dx = xx + x - center;
+	  dx = xx + x - center_x;
 	  
 	  dist = dx * dx + dy * dy;
 	  if (dist < ((inner-1) * (inner-1)) || dist > ((outer+1) * (outer+1)))
@@ -971,10 +984,10 @@
   else
     cairo_set_source_rgb (source_cr, 1., 1., 1.);
 
-  cairo_move_to (source_cr, -x + center, - y + center);
+  cairo_move_to (source_cr, -x + center_x, - y + center_y);
   cairo_line_to (source_cr,
-		 -x + center + cos (priv->h * 2.0 * G_PI) * center,
-		 -y + center - sin (priv->h * 2.0 * G_PI) * center);
+		 -x + center_x + cos (priv->h * 2.0 * G_PI) * priv->size / 2,
+		 -y + center_y - sin (priv->h * 2.0 * G_PI) * priv->size / 2);
   cairo_stroke (source_cr);
   cairo_destroy (source_cr);
 
@@ -988,7 +1001,7 @@
   cairo_set_line_width (cr, priv->ring_width);
   cairo_new_path (cr);
   cairo_arc (cr,
-	     center, center,
+	     center_x, center_y,
 	     priv->size / 2. - priv->ring_width / 2.,
 	     0, 2 * G_PI);
   cairo_stroke (cr);
@@ -1357,6 +1370,8 @@
  * Creates a new HSV color selector.
  *
  * Return value: A newly-created HSV color selector.
+ *
+ * Since: 2.14
  **/
 GtkWidget*
 gtk_hsv_new (void)
@@ -1373,6 +1388,8 @@
  *
  * Sets the current color in an HSV color selector.  Color component values must
  * be in the [0.0, 1.0] range.
+ *
+ * Since: 2.14
  **/
 void
 gtk_hsv_set_color (GtkHSV *hsv,
@@ -1407,9 +1424,14 @@
  *
  * Queries the current color in an HSV color selector.  Returned values will be
  * in the [0.0, 1.0] range.
+ *
+ * Since: 2.14
  **/
 void
-gtk_hsv_get_color (GtkHSV *hsv, double *h, double *s, double *v)
+gtk_hsv_get_color (GtkHSV *hsv,
+                   double *h,
+                   double *s,
+                   double *v)
 {
   HSVPrivate *priv;
   
@@ -1434,6 +1456,8 @@
  * @ring_width: Width of the hue ring.
  *
  * Sets the size and ring width of an HSV color selector.
+ *
+ * Since: 2.14
  **/
 void
 gtk_hsv_set_metrics (GtkHSV *hsv,
@@ -1468,6 +1492,8 @@
  * @ring_width: Return value for the width of the hue ring.
  *
  * Queries the size and ring width of an HSV color selector.
+ *
+ * Since: 2.14
  **/
 void
 gtk_hsv_get_metrics (GtkHSV *hsv,
@@ -1499,6 +1525,8 @@
  * Return value: TRUE if clients can ignore changes to the color value, since
  * they may be transitory, or FALSE if they should consider the color value
  * status to be final.
+ *
+ * Since: 2.14
  **/
 gboolean
 gtk_hsv_is_adjusting (GtkHSV *hsv)
@@ -1520,9 +1548,11 @@
  * @r: Return value for the red component.
  * @g: Return value for the green component.
  * @b: Return value for the blue component.
- * 
+ *
  * Converts a color from HSV space to RGB.  Input values must be in the
  * [0.0, 1.0] range; output values will be in the same range.
+ *
+ * Since: 2.14
  **/
 void
 gtk_hsv_to_rgb (gdouble  h,
@@ -1556,9 +1586,11 @@
  * @h: Return value for the hue component.
  * @s: Return value for the saturation component.
  * @v: Return value for the value component.
- * 
+ *
  * Converts a color from RGB space to HSV.  Input values must be in the
  * [0.0, 1.0] range; output values will be in the same range.
+ *
+ * Since: 2.14
  **/
 void
 gtk_rgb_to_hsv (gdouble  r,

Modified: trunk/gtk/gtkhsv.h
==============================================================================
--- trunk/gtk/gtkhsv.h	(original)
+++ trunk/gtk/gtkhsv.h	Mon Aug 11 19:57:38 2008
@@ -21,8 +21,6 @@
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
-#ifndef __GTK_HSV_H__
-#define __GTK_HSV_H__
 
 /*
  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
@@ -31,9 +29,16 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  */
 
-#include <gtk/gtkcontainer.h>
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#ifndef __GTK_HSV_H__
+#define __GTK_HSV_H__
+
+#include <gtk/gtkwidget.h>
 
-G_BEGIN_DECLS 
+G_BEGIN_DECLS
 
 #define GTK_TYPE_HSV            (gtk_hsv_get_type ())
 #define GTK_HSV(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_HSV, GtkHSV))
@@ -49,22 +54,27 @@
 struct _GtkHSV
 {
   GtkWidget parent_instance;
-  
+
   /* Private data */
-  gpointer priv;
+  gpointer GSEAL (priv);
 };
 
 struct _GtkHSVClass
 {
   GtkWidgetClass parent_class;
-  
+
   /* Notification signals */
-  
-  void (*changed) (GtkHSV *hsv);
+  void (* changed) (GtkHSV          *hsv);
 
   /* Keybindings */
-  void (* move) (GtkHSV          *hsv,
-                 GtkDirectionType type);
+  void (* move)    (GtkHSV          *hsv,
+                    GtkDirectionType type);
+
+  /* Padding for future expansion */
+  void (*_gtk_reserved1) (void);
+  void (*_gtk_reserved2) (void);
+  void (*_gtk_reserved3) (void);
+  void (*_gtk_reserved4) (void);
 };
 
 
@@ -85,6 +95,8 @@
 				 gint      *size,
 				 gint      *ring_width);
 gboolean   gtk_hsv_is_adjusting (GtkHSV    *hsv);
+
+/* Convert colors between the RGB and HSV color spaces */
 void       gtk_hsv_to_rgb       (gdouble    h,
 				 gdouble    s,
 				 gdouble    v,
@@ -98,7 +110,6 @@
 				 gdouble   *s,
 				 gdouble   *v);
 
-
 G_END_DECLS
 
 #endif /* __GTK_HSV_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]