* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <config.h>
#include <glib.h>
+#include <libart_lgpl/libart.h>
#include "label-object.h"
#include "marshal.h"
gchar *name;
gdouble x, y;
gdouble w, h;
- glLabelObjectFlip flip;
- gdouble rotate_degs;
+ gdouble affine[6];
};
enum {
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (glLabelObjectClass, flip_rotate),
NULL, NULL,
- gl_marshal_VOID__INT_DOUBLE,
+ gl_marshal_VOID__VOID,
G_TYPE_NONE,
- 2, G_TYPE_INT, G_TYPE_DOUBLE);
+ 0);
signals[TOP] =
g_signal_new ("top",
G_OBJECT_CLASS_TYPE (object_class),
object->private->name = g_strdup_printf ("object%d", instance++);
+ art_affine_identity (object->private->affine);
+
gl_debug (DEBUG_LABEL, "END");
}
glLabelObject *src_object)
{
gdouble x, y, w, h;
- glLabelObjectFlip flip;
+ gdouble affine[6];
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_get_position (src_object, &x, &y);
+ gl_label_object_get_size (src_object, &w, &h);
+ gl_label_object_get_affine (src_object, affine);
- 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);
+ gl_label_object_set_position (dst_object, x, y);
+ gl_label_object_set_size (dst_object, w, h);
+ gl_label_object_set_affine (dst_object, affine);
}
/*****************************************************************************/
gl_debug (DEBUG_LABEL, "END");
}
-/****************************************************************************/
-/* Set flip state of object. */
-/****************************************************************************/
+/*****************************************************************************/
+/* Get extent of object. */
+/*****************************************************************************/
void
-gl_label_object_set_flip (glLabelObject *object,
- glLabelObjectFlip flip)
+gl_label_object_get_extent (glLabelObject *object,
+ gdouble *x1,
+ gdouble *y1,
+ gdouble *x2,
+ gdouble *y2)
{
+ ArtPoint a1, a2, a3, a4, b1, b2, b3, b4;
+ gdouble affine[6];
+
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);
-
+ /* setup untransformed corners of bounding box */
+ a1.x = 0.0;
+ a1.y = 0.0;
+ a2.x = object->private->w;
+ a2.y = 0.0;
+ a3.x = object->private->w;
+ a3.y = object->private->h;
+ a4.x = 0.0;
+ a4.y = object->private->h;
+
+ /* transform these points */
+ gl_label_object_get_applied_affine (object, affine);
+ art_affine_point (&b1, &a1, affine);
+ art_affine_point (&b2, &a2, affine);
+ art_affine_point (&b3, &a3, affine);
+ art_affine_point (&b4, &a4, affine);
+
+ /* now find the maximum extent of these points in x and y */
+ *x1 = MIN (b1.x, MIN (b2.x, MIN (b3.x, b4.x))) + object->private->x;
+ *y1 = MIN (b1.y, MIN (b2.y, MIN (b3.y, b4.y))) + object->private->y;
+ *x2 = MAX (b1.x, MAX (b2.x, MAX (b3.x, b4.x))) + object->private->x;
+ *y2 = MAX (b1.y, MAX (b2.y, MAX (b3.y, b4.y))) + object->private->y;
+
gl_debug (DEBUG_LABEL, "END");
}
g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
- object->private->flip ^= GL_LABEL_OBJECT_FLIP_HORIZ;
+ art_affine_flip (object->private->affine, object->private->affine, TRUE, FALSE);
- g_signal_emit (G_OBJECT(object), signals[FLIP_ROTATE], 0,
- object->private->flip, object->private->rotate_degs);
+ g_signal_emit (G_OBJECT(object), signals[FLIP_ROTATE], 0);
gl_debug (DEBUG_LABEL, "END");
}
g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
- object->private->flip ^= GL_LABEL_OBJECT_FLIP_VERT;
+ art_affine_flip (object->private->affine, object->private->affine, FALSE, TRUE);
+
+ g_signal_emit (G_OBJECT(object), signals[FLIP_ROTATE], 0);
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/****************************************************************************/
+/* Rotate object. */
+/****************************************************************************/
+void
+gl_label_object_rotate (glLabelObject *object,
+ gdouble theta_degs)
+{
+ gdouble rotate_affine[6];
+
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ art_affine_rotate (rotate_affine, theta_degs);
+ art_affine_multiply (object->private->affine, object->private->affine, rotate_affine);
- g_signal_emit (G_OBJECT(object), signals[FLIP_ROTATE], 0,
- object->private->flip, object->private->rotate_degs);
+ g_signal_emit (G_OBJECT(object), signals[FLIP_ROTATE], 0);
gl_debug (DEBUG_LABEL, "END");
}
/****************************************************************************/
-/* Get flip state of object. */
+/* Set raw affine */
+/****************************************************************************/
+void
+gl_label_object_set_affine (glLabelObject *object,
+ gdouble affine[6])
+{
+ gl_debug (DEBUG_LABEL, "");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ object->private->affine[0] = affine[0];
+ object->private->affine[1] = affine[1];
+ object->private->affine[2] = affine[2];
+ object->private->affine[3] = affine[3];
+ object->private->affine[4] = affine[4];
+ object->private->affine[5] = affine[5];
+}
+
+/****************************************************************************/
+/* Get raw affine */
/****************************************************************************/
-glLabelObjectFlip
-gl_label_object_get_flip (glLabelObject *object)
+void
+gl_label_object_get_affine (glLabelObject *object,
+ gdouble affine[6])
{
gl_debug (DEBUG_LABEL, "");
g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
- return object->private->flip;
+ affine[0] = object->private->affine[0];
+ affine[1] = object->private->affine[1];
+ affine[2] = object->private->affine[2];
+ affine[3] = object->private->affine[3];
+ affine[4] = object->private->affine[4];
+ affine[5] = object->private->affine[5];
+}
+
+/****************************************************************************/
+/* Get applied affine, i.e. translated to center of object and back */
+/****************************************************************************/
+void
+gl_label_object_get_applied_affine (glLabelObject *object,
+ gdouble affine[6])
+{
+ gdouble to_center[6], to_origin[6];
+
+ gl_debug (DEBUG_LABEL, "");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ /* setup transformation affine */
+ art_affine_translate (to_center, -object->private->w/2.0, -object->private->h/2.0);
+ art_affine_multiply (affine, to_center, object->private->affine);
+ art_affine_translate (to_origin, object->private->w/2.0, object->private->h/2.0);
+ art_affine_multiply (affine, affine, to_origin);
}
/****************************************************************************/
glViewHighlightStyle style)
{
glViewHighlight *view_highlight;
+ gdouble affine[6];
gl_debug (DEBUG_VIEW, "START");
}
+
+ gl_label_object_get_applied_affine (view_highlight->private->object, affine);
+ gnome_canvas_item_affine_absolute (view_highlight->private->group, affine);
+
g_signal_connect (G_OBJECT (view_highlight->private->object), "changed",
G_CALLBACK (object_changed_cb), view_highlight);
GdkEvent *event,
glViewHighlight *view_highlight)
{
- gdouble x, y, w, h;
- static gdouble x2, y2;
+ gdouble x0, y0, w, h;
+ gdouble x1, y1, x2, y2;
static gboolean dragging = FALSE;
glLabelObject *object;
GdkCursor *cursor;
}
object = view_highlight->private->object;;
- gl_label_object_get_position (object, &x, &y);
- gl_label_object_get_size (object, &w, &h);
+
+ /* origin, relative to item */
+ gl_label_object_get_position (object, &x0, &y0);
+ gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
+
+ /* Top left corner, relative to item */
+ x1 = 0.0;
+ y1 = 0.0;
+
+ /* Bottom right corner, relative to item */
+ gl_label_object_get_size (object, &x2, &y2);
+
switch (event->type) {
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
- /* Anchor to bottom-right corner */
- x2 = x + w;
- y2 = y + h;
return TRUE;
default:
dragging = FALSE;
gnome_canvas_item_ungrab (handle_item,
event->button.time);
- x = MIN (event->button.x, x2 - MIN_ITEM_SIZE);
- y = MIN (event->button.y, y2 - MIN_ITEM_SIZE);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ x1 = MIN (event->button.x, x2 - MIN_ITEM_SIZE);
+ y1 = MIN (event->button.y, y2 - MIN_ITEM_SIZE);
w = MAX (x2 - event->button.x, MIN_ITEM_SIZE);
h = MAX (y2 - event->button.y, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
case GDK_MOTION_NOTIFY:
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
- x = MIN (event->motion.x, x2 - MIN_ITEM_SIZE);
- y = MIN (event->motion.y, y2 - MIN_ITEM_SIZE);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ x1 = MIN (event->motion.x, x2 - MIN_ITEM_SIZE);
+ y1 = MIN (event->motion.y, y2 - MIN_ITEM_SIZE);
w = MAX (x2 - event->motion.x, MIN_ITEM_SIZE);
h = MAX (y2 - event->motion.y, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
} else {
GdkEvent *event,
glViewHighlight *view_highlight)
{
- gdouble x, y, w, h;
- static gdouble x1, y2;
+ gdouble x0, y0, w, h;
+ gdouble x1, y1, x2, y2;
static gboolean dragging = FALSE;
glLabelObject *object;
GdkCursor *cursor;
}
object = view_highlight->private->object;;
- gl_label_object_get_position (object, &x, &y);
- gl_label_object_get_size (object, &w, &h);
+
+ /* origin, relative to item */
+ gl_label_object_get_position (object, &x0, &y0);
+ gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
+
+ /* Top left corner, relative to item */
+ x1 = 0.0;
+ y1 = 0.0;
+
+ /* Bottom right corner, relative to item */
+ gl_label_object_get_size (object, &x2, &y2);
+
switch (event->type) {
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
- /* Anchor to bottom-left corner */
- x1 = x;
- y2 = y + h;
return TRUE;
default:
dragging = FALSE;
gnome_canvas_item_ungrab (handle_item,
event->button.time);
- x = x1;
- y = MIN (event->button.y, y2 - MIN_ITEM_SIZE);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ y1 = MIN (event->button.y, y2 - MIN_ITEM_SIZE);
w = MAX (event->button.x - x1, MIN_ITEM_SIZE);
h = MAX (y2 - event->button.y, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
case GDK_MOTION_NOTIFY:
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
- x = x1;
- y = MIN (event->motion.y, y2 - MIN_ITEM_SIZE);
- w = MAX (event->motion.x - x1, MIN_ITEM_SIZE);
- h = MAX (y2 - event->motion.y, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ y1 = MIN (event->button.y, y2 - MIN_ITEM_SIZE);
+ w = MAX (event->button.x - x1, MIN_ITEM_SIZE);
+ h = MAX (y2 - event->button.y, MIN_ITEM_SIZE);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
} else {
GdkEvent *event,
glViewHighlight *view_highlight)
{
- gdouble x, y, w, h;
- static gdouble x2, y1;
+ gdouble x0, y0, w, h;
+ gdouble x1, y1, x2, y2;
static gboolean dragging = FALSE;
glLabelObject *object;
GdkCursor *cursor;
}
object = view_highlight->private->object;;
- gl_label_object_get_position (object, &x, &y);
- gl_label_object_get_size (object, &w, &h);
+
+ /* origin, relative to item */
+ gl_label_object_get_position (object, &x0, &y0);
+ gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
+
+ /* Top left corner, relative to item */
+ x1 = 0.0;
+ y1 = 0.0;
+
+ /* Bottom right corner, relative to item */
+ gl_label_object_get_size (object, &x2, &y2);
+
switch (event->type) {
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
- /* Anchor to top-right corner */
- x2 = x + w;
- y1 = y;
return TRUE;
default:
dragging = FALSE;
gnome_canvas_item_ungrab (handle_item,
event->button.time);
- x = MIN (event->button.x, x2 - MIN_ITEM_SIZE);
- y = y1;
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ x1 = MIN (event->button.x, x2 - MIN_ITEM_SIZE);
+ /* y1 unchanged */
w = MAX (x2 - event->button.x, MIN_ITEM_SIZE);
- h = MAX (event->button.y - y1, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ h = MAX (event->button.y - x1, MIN_ITEM_SIZE);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
case GDK_MOTION_NOTIFY:
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
- x = MIN (event->motion.x, x2 - MIN_ITEM_SIZE);
- y = y1;
- w = MAX (x2 - event->motion.x, MIN_ITEM_SIZE);
- h = MAX (event->motion.y - y1, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ x1 = MIN (event->button.x, x2 - MIN_ITEM_SIZE);
+ /* y1 unchanged */
+ w = MAX (x2 - event->button.x, MIN_ITEM_SIZE);
+ h = MAX (event->button.y - x1, MIN_ITEM_SIZE);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
} else {
GdkEvent *event,
glViewHighlight *view_highlight)
{
- gdouble x, y, w, h;
- static gdouble x1, y1;
+ gdouble x0, y0, w, h;
+ gdouble x1, y1, x2, y2;
static gboolean dragging = FALSE;
glLabelObject *object;
GdkCursor *cursor;
}
object = view_highlight->private->object;;
- gl_label_object_get_position (object, &x, &y);
- gl_label_object_get_size (object, &w, &h);
+
+ /* origin, relative to item */
+ gl_label_object_get_position (object, &x0, &y0);
+ gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
+
+ /* Top left corner, relative to item */
+ x1 = 0.0;
+ y1 = 0.0;
+
+ /* Bottom right corner, relative to item */
+ gl_label_object_get_size (object, &x2, &y2);
+
switch (event->type) {
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
- /* Anchor to top-left corner */
- x1 = x;
- y1 = y;
return TRUE;
default:
dragging = FALSE;
gnome_canvas_item_ungrab (handle_item,
event->button.time);
- x = x1;
- y = y1;
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ /* y1 unchanged */
w = MAX (event->button.x - x1, MIN_ITEM_SIZE);
- h = MAX (event->button.y - y1, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ h = MAX (event->button.y - x1, MIN_ITEM_SIZE);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
case GDK_MOTION_NOTIFY:
gl_debug (DEBUG_VIEW, "MOTION_NOTIFY");
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
- x = x1;
- y = y1;
- w = MAX (event->motion.x - x1, MIN_ITEM_SIZE);
- h = MAX (event->motion.y - y1, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ /* y1 unchanged */
+ w = MAX (event->button.x - x1, MIN_ITEM_SIZE);
+ h = MAX (event->button.y - x1, MIN_ITEM_SIZE);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
} else {
GdkEvent *event,
glViewHighlight *view_highlight)
{
- gdouble x, y, w, h;
- static gdouble x2;
+ gdouble x0, y0, w, h;
+ gdouble x1, y1, x2, y2;
static gboolean dragging = FALSE;
glLabelObject *object;
GdkCursor *cursor;
}
object = view_highlight->private->object;;
- gl_label_object_get_position (object, &x, &y);
- gl_label_object_get_size (object, &w, &h);
+
+ /* origin, relative to item */
+ gl_label_object_get_position (object, &x0, &y0);
+ gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
+
+ /* Top left corner, relative to item */
+ x1 = 0.0;
+ y1 = 0.0;
+
+ /* Bottom right corner, relative to item */
+ gl_label_object_get_size (object, &x2, &y2);
+
switch (event->type) {
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
- /* Anchor to right side */
- x2 = x + w;
return TRUE;
default:
dragging = FALSE;
gnome_canvas_item_ungrab (handle_item,
event->button.time);
- x = MIN (event->button.x, x2 - MIN_ITEM_SIZE);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ x1 = MIN (event->button.x, x2 - MIN_ITEM_SIZE);
+ /* y1 unchanged */
w = MAX (x2 - event->button.x, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ h = y2 - y1;
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
case GDK_MOTION_NOTIFY:
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
- x = MIN (event->motion.x, x2 - MIN_ITEM_SIZE);
- w = MAX (x2 - event->motion.x, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ x1 = MIN (event->button.x, x2 - MIN_ITEM_SIZE);
+ /* y1 unchanged */
+ w = MAX (x2 - event->button.x, MIN_ITEM_SIZE);
+ h = y2 - y1;
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
} else {
GdkEvent *event,
glViewHighlight *view_highlight)
{
- gdouble x, y, w, h;
- static gdouble x1;
+ gdouble x0, y0, w, h;
+ gdouble x1, y1, x2, y2;
static gboolean dragging = FALSE;
glLabelObject *object;
GdkCursor *cursor;
}
object = view_highlight->private->object;;
- gl_label_object_get_position (object, &x, &y);
- gl_label_object_get_size (object, &w, &h);
+
+ /* origin, relative to item */
+ gl_label_object_get_position (object, &x0, &y0);
+ gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
+
+ /* Top left corner, relative to item */
+ x1 = 0.0;
+ y1 = 0.0;
+
+ /* Bottom right corner, relative to item */
+ gl_label_object_get_size (object, &x2, &y2);
+
switch (event->type) {
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
- /* Anchor to left side */
- x1 = x;
return TRUE;
default:
dragging = FALSE;
gnome_canvas_item_ungrab (handle_item,
event->button.time);
- x = x1;
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ /* y1 unchanged */
w = MAX (event->button.x - x1, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ h = y2 - y1;
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
case GDK_MOTION_NOTIFY:
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
- x = x1;
- w = MAX (event->motion.x - x1, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ /* y1 unchanged */
+ w = MAX (event->button.x - x1, MIN_ITEM_SIZE);
+ h = y2 - y1;
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
} else {
GdkEvent *event,
glViewHighlight *view_highlight)
{
- gdouble x, y, w, h;
- static gdouble y2;
+ gdouble x0, y0, w, h;
+ gdouble x1, y1, x2, y2;
static gboolean dragging = FALSE;
glLabelObject *object;
GdkCursor *cursor;
}
object = view_highlight->private->object;;
- gl_label_object_get_position (object, &x, &y);
- gl_label_object_get_size (object, &w, &h);
+
+ /* origin, relative to item */
+ gl_label_object_get_position (object, &x0, &y0);
+ gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
+
+ /* Top left corner, relative to item */
+ x1 = 0.0;
+ y1 = 0.0;
+
+ /* Bottom right corner, relative to item */
+ gl_label_object_get_size (object, &x2, &y2);
+
switch (event->type) {
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
- /* Anchor to bottom-right corner */
- y2 = y + h;
return TRUE;
default:
dragging = FALSE;
gnome_canvas_item_ungrab (handle_item,
event->button.time);
- y = MIN (event->button.y, y2 - MIN_ITEM_SIZE);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ y1 = MIN (event->button.y, y2 - MIN_ITEM_SIZE);
+ w = x2 - x1;
h = MAX (y2 - event->button.y, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
case GDK_MOTION_NOTIFY:
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
- y = MIN (event->motion.y, y2 - MIN_ITEM_SIZE);
- h = MAX (y2 - event->motion.y, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ y1 = MIN (event->button.y, y2 - MIN_ITEM_SIZE);
+ w = x2 - x1;
+ h = MAX (y2 - event->button.y, MIN_ITEM_SIZE);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
} else {
GdkEvent *event,
glViewHighlight *view_highlight)
{
- gdouble x, y, w, h;
- static gdouble y1;
+ gdouble x0, y0, w, h;
+ gdouble x1, y1, x2, y2;
static gboolean dragging = FALSE;
glLabelObject *object;
GdkCursor *cursor;
}
object = view_highlight->private->object;;
- gl_label_object_get_position (object, &x, &y);
- gl_label_object_get_size (object, &w, &h);
+
+ /* origin, relative to item */
+ gl_label_object_get_position (object, &x0, &y0);
+ gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
+
+ /* Top left corner, relative to item */
+ x1 = 0.0;
+ y1 = 0.0;
+
+ /* Bottom right corner, relative to item */
+ gl_label_object_get_size (object, &x2, &y2);
+
switch (event->type) {
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
- /* Anchor to top side */
- y1 = y;
return TRUE;
default:
dragging = FALSE;
gnome_canvas_item_ungrab (handle_item,
event->button.time);
- y = y1;
- h = MAX (event->button.y - y1, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ /* y1 unchanged */
+ w = x2 - x1;
+ h = MAX (event->button.y - x1, MIN_ITEM_SIZE);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
case GDK_MOTION_NOTIFY:
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
- y = y1;
- h = MAX (event->motion.y - y1, MIN_ITEM_SIZE);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ /* y1 unchanged */
+ w = x2 - x1;
+ h = MAX (event->button.y - x1, MIN_ITEM_SIZE);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, w, h);
return TRUE;
} else {
GdkEvent *event,
glViewHighlight *view_highlight)
{
- gdouble x, y, dx, dy;
- static gdouble x0, y0;
+ gdouble x0, y0, dx, dy;
+ gdouble x1, y1, x2, y2;
static gboolean dragging = FALSE;
glLabelObject *object;
GdkCursor *cursor;
}
object = view_highlight->private->object;;
- gl_label_object_get_position (object, &x, &y);
- gl_label_object_get_size (object, &dx, &dy);
+
+ /* origin, relative to item */
+ gl_label_object_get_position (object, &x0, &y0);
+ gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
+
+ /* Top left corner, relative to item */
+ x1 = 0.0;
+ y1 = 0.0;
+
+ /* Bottom right corner, relative to item */
+ gl_label_object_get_size (object, &x2, &y2);
+
switch (event->type) {
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
- /* Anchor to P2 */
- x0 = x + dx;
- y0 = y + dy;
return TRUE;
default:
dragging = FALSE;
gnome_canvas_item_ungrab (handle_item,
event->button.time);
- x = x0;
- y = y0;
- dx = (event->button.x - x0);
- dy = (event->button.y - y0);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ x1 = event->button.x;
+ y1 = event->button.y;
+ dx = (x2 - event->button.x);
+ dy = (y2 - event->button.y);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, dx, dy);
return TRUE;
case GDK_MOTION_NOTIFY:
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
- x = x0;
- y = y0;
- dx = (event->motion.x - x0);
- dy = (event->motion.y - y0);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ x1 = event->button.x;
+ y1 = event->button.y;
+ dx = (x2 - event->button.x);
+ dy = (y2 - event->button.y);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, dx, dy);
return TRUE;
} else {
GdkEvent *event,
glViewHighlight *view_highlight)
{
- gdouble x, y, dx, dy;
- static gdouble x0, y0;
+ gdouble x0, y0, dx, dy;
+ gdouble x1, y1, x2, y2;
static gboolean dragging = FALSE;
glLabelObject *object;
GdkCursor *cursor;
}
object = view_highlight->private->object;;
- gl_label_object_get_position (object, &x, &y);
- gl_label_object_get_size (object, &dx, &dy);
+
+ /* origin, relative to item */
+ gl_label_object_get_position (object, &x0, &y0);
+ gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
+
+ /* Top left corner, relative to item */
+ x1 = 0.0;
+ y1 = 0.0;
+
+ /* Bottom right corner, relative to item */
+ gl_label_object_get_size (object, &x2, &y2);
+
switch (event->type) {
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
- /* Anchor to P1 */
- x0 = x;
- y0 = y;
return TRUE;
default:
dragging = FALSE;
gnome_canvas_item_ungrab (handle_item,
event->button.time);
- x = x0;
- y = y0;
- dx = (event->button.x - x0);
- dy = (event->button.y - y0);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ /* y1 unchanged */
+ dx = (event->button.x - x1);
+ dy = (event->button.y - x1);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, dx, dy);
return TRUE;
case GDK_MOTION_NOTIFY:
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
- x = x0;
- y = y0;
- dx = (event->motion.x - x0);
- dy = (event->motion.y - y0);
- gl_label_object_set_position (object, x, y);
+ gnome_canvas_item_w2i (view_highlight->private->group,
+ &event->button.x, &event->button.y);
+ /* x1 unchanged */
+ /* y1 unchanged */
+ dx = (event->button.x - x1);
+ dy = (event->button.y - x1);
+ x0 = x0 + x1;
+ y0 = y0 + y1;
+ gnome_canvas_item_i2w (view_highlight->private->group, &x0, &y0);
+ gl_label_object_set_position (object, x0, y0);
gl_label_object_set_size (object, dx, dy);
return TRUE;
} else {
GnomeCanvasItem *group;
glViewHighlight *highlight;
- gdouble affine[6];
-
GtkWidget *menu;
GtkWidget *property_dialog;
gdouble y,
glViewObject *view_object);
-static void raise_object_cb (GtkWidget *widget,
+static void raise_object_cb (glLabelObject *object,
glViewObject *view_object);
-static void lower_object_cb (GtkWidget *widget,
+static void lower_object_cb (glLabelObject *object,
glViewObject *view_object);
-static void flip_rotate_object_cb (GtkWidget *widget,
- glLabelObjectFlip flip,
- gdouble rotate_degs,
+static void flip_rotate_object_cb (glLabelObject *object,
glViewObject *view_object);
GnomeCanvas *canvas;
GnomeCanvasGroup *root;
gdouble x, y, w, h;
- glLabelObjectFlip flip;
- gdouble a[6];
gl_debug (DEBUG_VIEW, "START");
"y", y,
NULL);
- /* create affine to handle flipping and rotation transformations */
- art_affine_identity (view_object->private->affine);
-#if 1
- /* Apply appropriate flipping */
- flip = gl_label_object_get_flip (object);
- g_print ("Flip = %d\n", flip);
- if ( flip & GL_LABEL_OBJECT_FLIP_HORIZ ) {
- art_affine_translate (a, -w, 0.0);
- art_affine_multiply (view_object->private->affine,
- view_object->private->affine, a);
- art_affine_scale (a, -1.0, 1.0);
- art_affine_multiply (view_object->private->affine,
- view_object->private->affine, a);
- }
- if ( flip & GL_LABEL_OBJECT_FLIP_VERT ) {
- art_affine_translate (a, 0.0, -h);
- art_affine_multiply (view_object->private->affine,
- view_object->private->affine, a);
- art_affine_scale (a, 1.0, -1.0);
- art_affine_multiply (view_object->private->affine,
- view_object->private->affine, a);
- }
-#endif
-
/* Create appropriate selection highlight canvas item. */
view_object->private->highlight =
GL_VIEW_HIGHLIGHT (gl_view_highlight_new (view_object, style));
{
GnomeCanvasItem *item;
va_list args;
+ gdouble affine[6];
gl_debug (DEBUG_VIEW, "START");
gnome_canvas_item_set_valist (item, first_arg_name, args);
va_end (args);
- g_print ("Affine = {%f, %f, %f, %f, %f, %f}\n",
- view_object->private->affine[0],
- view_object->private->affine[1],
- view_object->private->affine[2],
- view_object->private->affine[3],
- view_object->private->affine[4],
- view_object->private->affine[5]);
-
-#if 1
- gnome_canvas_item_affine_absolute (item, view_object->private->affine);
-#endif
+ gl_label_object_get_applied_affine (view_object->private->object, affine);
+ gnome_canvas_item_affine_absolute (item, affine);
gl_debug (DEBUG_VIEW, "END");
/* PRIVATE. raise item to front callback. */
/*---------------------------------------------------------------------------*/
static void
-raise_object_cb (GtkWidget *widget,
- glViewObject *view_object)
+raise_object_cb (glLabelObject *object,
+ glViewObject *view_object)
{
- glLabelObject *object;
-
gl_debug (DEBUG_VIEW, "START");
/* send to top */
/* PRIVATE. lower item to back callback. */
/*---------------------------------------------------------------------------*/
static void
-lower_object_cb (GtkWidget *widget,
- glViewObject *view_object)
+lower_object_cb (glLabelObject *object,
+ glViewObject *view_object)
{
- glLabelObject *object;
-
gl_debug (DEBUG_VIEW, "START");
/* Send to bottom */
/* PRIVATE. Flip/rotate object callback. */
/*---------------------------------------------------------------------------*/
static void
-flip_rotate_object_cb (GtkWidget *widget,
- glLabelObjectFlip flip,
- gdouble rotate_degs,
- glViewObject *view_object)
+flip_rotate_object_cb (glLabelObject *object,
+ glViewObject *view_object)
{
- glLabelObject *object;
- gdouble a[6];
+ gdouble affine[6];
gdouble w, h;
GList *p, *item_list;
GnomeCanvasItem *item;
gl_debug (DEBUG_VIEW, "START");
- gl_label_object_get_size (view_object->private->object, &w, &h);
-
- /* Reset to identity affine */
- art_affine_identity (view_object->private->affine);
-
- /* Apply appropriate flipping */
- if ( flip & GL_LABEL_OBJECT_FLIP_HORIZ ) {
- art_affine_translate (a, -w, 0.0);
- art_affine_multiply (view_object->private->affine, view_object->private->affine, a);
- art_affine_scale (a, -1.0, 1.0);
- art_affine_multiply (view_object->private->affine,
- view_object->private->affine, a);
- }
- if ( flip & GL_LABEL_OBJECT_FLIP_VERT ) {
- art_affine_translate (a, 0.0, -h);
- art_affine_multiply (view_object->private->affine,
- view_object->private->affine, a);
- art_affine_scale (a, 1.0, -1.0);
- art_affine_multiply (view_object->private->affine,
- view_object->private->affine, a);
- }
-
-#if 1
- /* Apply newly constructed affine */
+ gl_label_object_get_applied_affine (object, affine);
item_list = GNOME_CANVAS_GROUP(view_object->private->group)->item_list;
- for ( p=item_list; p != NULL; p=p->next) {
+ for ( p=item_list; p != NULL; p=p->next ) {
item = GNOME_CANVAS_ITEM(p->data);
- gnome_canvas_item_affine_absolute (item, view_object->private->affine);
+ gnome_canvas_item_affine_absolute (item, affine);
}
-#endif
gl_debug (DEBUG_VIEW, "END");
}