]> git.sur5r.net Git - glabels/commitdiff
Includes support for flipping.
authorJim Evins <evins@snaught.com>
Mon, 14 Oct 2002 01:53:36 +0000 (01:53 +0000)
committerJim Evins <evins@snaught.com>
Mon, 14 Oct 2002 01:53:36 +0000 (01:53 +0000)
Added function for copying properties from one object to another.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@161 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/label-object.c
glabels2/src/label-object.h

index 4499b57bf1de4e50575185fd09f81d1c920e5464..03eecf6a64cc6f87865f138c6e68f83b63aa5cc7 100644 (file)
 /*========================================================*/
 
 struct _glLabelObjectPrivate {
-       gchar  *name;
-       gdouble x, y;
-       gdouble w, h;
+       gchar             *name;
+       gdouble            x, y;
+       gdouble            w, h;
+       glLabelObjectFlip  flip;
+       gdouble            rotate_degs;
 };
 
 enum {
        CHANGED,
        MOVED,
+       FLIP_ROTATE,
        TOP,
        BOTTOM,
        LAST_SIGNAL
@@ -125,6 +128,15 @@ gl_label_object_class_init (glLabelObjectClass *klass)
                              gl_marshal_VOID__DOUBLE_DOUBLE,
                              G_TYPE_NONE,
                              2, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
+       signals[FLIP_ROTATE] =
+               g_signal_new ("flip_rotate",
+                             G_OBJECT_CLASS_TYPE (object_class),
+                             G_SIGNAL_RUN_LAST,
+                             G_STRUCT_OFFSET (glLabelObjectClass, flip_rotate),
+                             NULL, NULL,
+                             gl_marshal_VOID__INT_DOUBLE,
+                             G_TYPE_NONE,
+                             2, G_TYPE_INT, G_TYPE_DOUBLE);
        signals[TOP] =
                g_signal_new ("top",
                              G_OBJECT_CLASS_TYPE (object_class),
@@ -179,6 +191,9 @@ gl_label_object_finalize (GObject *object)
        gl_debug (DEBUG_LABEL, "END");
 }
 
+/*****************************************************************************/
+/* New label object.                                                         */
+/*****************************************************************************/
 GObject *
 gl_label_object_new (glLabel *label)
 {
@@ -195,6 +210,28 @@ gl_label_object_new (glLabel *label)
        return G_OBJECT (object);
 }
 
+/*****************************************************************************/
+/* Copy properties of one label object to another.                           */
+/*****************************************************************************/
+void
+gl_label_object_copy_props (glLabelObject *dst_object,
+                           glLabelObject *src_object)
+{
+       gdouble           x, y, w, h;
+       glLabelObjectFlip flip;
+
+       g_return_if_fail (src_object && GL_IS_LABEL_OBJECT (src_object));
+       g_return_if_fail (dst_object && GL_IS_LABEL_OBJECT (dst_object));
+
+       gl_label_object_get_position    (src_object, &x, &y);
+       gl_label_object_get_size        (src_object, &w, &h);
+       flip = gl_label_object_get_flip (src_object);
+
+       gl_label_object_set_position (dst_object,  x,  y);
+       gl_label_object_set_size     (dst_object,  w,  h);
+       gl_label_object_set_flip     (dst_object,  flip);
+}
+
 /*****************************************************************************/
 /* Emit "changed" signal (for derived objects).                              */
 /*****************************************************************************/
@@ -395,6 +432,74 @@ gl_label_object_get_size (glLabelObject *object,
        gl_debug (DEBUG_LABEL, "END");
 }
 
+/****************************************************************************/
+/* Set flip state of object.                                                */
+/****************************************************************************/
+void
+gl_label_object_set_flip (glLabelObject     *object,
+                         glLabelObjectFlip  flip)
+{
+       gl_debug (DEBUG_LABEL, "START");
+
+       g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+       object->private->flip = flip;
+
+       g_signal_emit (G_OBJECT(object), signals[FLIP_ROTATE], 0,
+                      flip, object->private->rotate_degs);
+
+       gl_debug (DEBUG_LABEL, "END");
+}
+
+/****************************************************************************/
+/* Flip object horizontally.                                                */
+/****************************************************************************/
+void
+gl_label_object_flip_horiz (glLabelObject *object)
+{
+       gl_debug (DEBUG_LABEL, "START");
+
+       g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+       object->private->flip ^= GL_LABEL_OBJECT_FLIP_HORIZ;
+
+       g_signal_emit (G_OBJECT(object), signals[FLIP_ROTATE], 0,
+                      object->private->flip, object->private->rotate_degs);
+
+       gl_debug (DEBUG_LABEL, "END");
+}
+
+/****************************************************************************/
+/* Flip object vertically.                                                  */
+/****************************************************************************/
+void
+gl_label_object_flip_vert (glLabelObject *object)
+{
+       gl_debug (DEBUG_LABEL, "START");
+
+       g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+       object->private->flip ^= GL_LABEL_OBJECT_FLIP_VERT;
+
+       g_signal_emit (G_OBJECT(object), signals[FLIP_ROTATE], 0,
+                      object->private->flip, object->private->rotate_degs);
+
+       gl_debug (DEBUG_LABEL, "END");
+}
+
+/****************************************************************************/
+/* Get flip state of object.                                                */
+/****************************************************************************/
+glLabelObjectFlip
+gl_label_object_get_flip (glLabelObject      *object)
+{
+       gl_debug (DEBUG_LABEL, "");
+
+       g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+       return object->private->flip;
+}
+
 /****************************************************************************/
 /* Bring label object to front/top.                                         */
 /****************************************************************************/
index 1a24cf6804a76e530372b2867940535cfa6b7f50..0e7d4df872c2463022e33d76b0f5e81e214abf1c 100644 (file)
@@ -38,6 +38,13 @@ typedef enum {
         GL_LABEL_OBJECT_N_TYPES
 } glLabelObjectType;
 
+typedef enum {
+       GL_LABEL_OBJECT_FLIP_NONE  = 0,
+       GL_LABEL_OBJECT_FLIP_HORIZ = 1,
+       GL_LABEL_OBJECT_FLIP_VERT  = 2,
+       GL_LABEL_OBJECT_FLIP_BOTH  = (GL_LABEL_OBJECT_FLIP_HORIZ|GL_LABEL_OBJECT_FLIP_VERT)
+} glLabelObjectFlip;
+
 
 #define GL_TYPE_LABEL_OBJECT            (gl_label_object_get_type ())
 #define GL_LABEL_OBJECT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GL_TYPE_LABEL_OBJECT, glLabelObject))
@@ -63,19 +70,33 @@ struct _glLabelObject {
 struct _glLabelObjectClass {
        GObjectClass          parent_class;
 
-       void (*changed) (glLabelObject *object, gpointer user_data);
+       void (*changed)     (glLabelObject     *object,
+                            gpointer            user_data);
+
+       void (*moved)       (glLabelObject     *object,
+                            gdouble            dx,
+                            gdouble            dy,
+                            gpointer           user_data);
 
-       void (*moved)   (glLabelObject *object,
-                        gdouble dx, gdouble dy, gpointer user_data);
+       void (*flip_rotate) (glLabelObject     *object,
+                            glLabelObjectFlip  flip,
+                            gdouble            rotate,
+                            gpointer           user_data);
 
-       void (*top)     (glLabelObject *object, gpointer user_data);
-       void (*bottom)  (glLabelObject *object, gpointer user_data);
+       void (*top)         (glLabelObject     *object,
+                            gpointer           user_data);
+
+       void (*bottom)      (glLabelObject     *object,
+                            gpointer           user_data);
 };
 
 GType     gl_label_object_get_type              (void);
 
 GObject  *gl_label_object_new                   (glLabel       *label);
 
+void      gl_label_object_copy_props            (glLabelObject *dst_object,
+                                                glLabelObject *src_object);
+
 void      gl_label_object_emit_changed          (glLabelObject *object);
 
 void      gl_label_object_set_parent            (glLabelObject *object,
@@ -105,6 +126,15 @@ void      gl_label_object_get_size              (glLabelObject *object,
 void      gl_label_object_raise_to_top          (glLabelObject *object);
 void      gl_label_object_lower_to_bottom       (glLabelObject *object);
 
+void              gl_label_object_set_flip      (glLabelObject     *object,
+                                                glLabelObjectFlip  flip);
+
+void              gl_label_object_flip_horiz    (glLabelObject     *object);
+
+void              gl_label_object_flip_vert     (glLabelObject     *object);
+
+glLabelObjectFlip gl_label_object_get_flip      (glLabelObject     *object);
+
 G_END_DECLS
 
 #endif /* __LABEL_OBJECT_H__ */