[Fwd: A zigzag line orientation patch...]
- From: Alexander Larsson <alla lysator liu se>
- To: dia-list gnome org
- Cc: mvoase midcoast com au
- Subject: [Fwd: A zigzag line orientation patch...]
- Date: 29 Aug 2002 09:24:40 +0200
Forwarding to mailing list.
-----Forwarded Message-----
From: Michael H. Voase <mvoase midcoast com au>
To: alla lysator liu se
Subject: A zigzag line orientation patch...
Date: 25 Aug 2002 17:34:55 +1000
Gday,
First up I would like to say great work on Dia. Its a very handy tool.
Second up, I have attached a patch for 0.88.1 that adds an orientation
feature to the middle-button menu for the zigzag line. This allows you
to set wether the next zigzag line will have a vertical control bar or a
horizontal control bar.
The patch is setup as a batch to be applied to 0.88.1 using the following:
patch -p1 -tud dia-0.88.1 < dia-0.88.1mv.patch
In the directory above the source tree.
Cheers Mik.
----
diff -ur dia-0.88.1/lib/orth_conn.c dia-0.88.1mv/lib/orth_conn.c
--- dia-0.88.1/lib/orth_conn.c Mon Mar 26 11:05:21 2001
+++ dia-0.88.1mv/lib/orth_conn.c Sun Aug 25 15:07:26 2002
@@ -30,9 +30,13 @@
enum change_type {
TYPE_ADD_SEGMENT,
- TYPE_REMOVE_SEGMENT
+ TYPE_REMOVE_SEGMENT,
+ TYPE_ORIENT_VERT,
+ TYPE_ORIENT_HORIZ
};
+static enum change_type orthconn_orientation = TYPE_ORIENT_HORIZ;
+
static ObjectChange *
midsegment_create_change(OrthConn *orth, enum change_type type,
int segment,
@@ -88,6 +92,17 @@
remove segment */
};
+static ObjectChange *
+orient_change_create(OrthConn *orth, enum change_type change);
+
+struct OrientChange
+{
+ ObjectChange obj_change;
+ enum change_type type;
+ int applied;
+ enum change_type previous_value;
+};
+
static void set_midpoint(Point *point, OrthConn *orth, int segment)
{
@@ -399,18 +414,33 @@
obj->handles[2] = orth->handles[2];
/* Just so we have some position: */
- orth->points[0] = *startpoint;
- orth->points[1].x = startpoint->x;
- orth->points[1].y = startpoint->y + 1.0;
- orth->points[2].x = startpoint->x + 1.0;
- orth->points[2].y = startpoint->y + 1.0;
- orth->points[3].x = startpoint->x + 2.0;
- orth->points[3].y = startpoint->y + 1.0;
-
- orth->orientation[0] = VERTICAL;
- orth->orientation[1] = HORIZONTAL;
- orth->orientation[2] = VERTICAL;
-
+ if (orthconn_orientation == TYPE_ORIENT_HORIZ)
+ {
+ orth->points[0] = *startpoint;
+ orth->points[1].x = startpoint->x;
+ orth->points[1].y = startpoint->y + 1.0;
+ orth->points[2].x = startpoint->x + 1.0;
+ orth->points[2].y = startpoint->y + 1.0;
+ orth->points[3].x = startpoint->x + 2.0;
+ orth->points[3].y = startpoint->y + 1.0;
+
+ orth->orientation[0] = VERTICAL;
+ orth->orientation[1] = HORIZONTAL;
+ orth->orientation[2] = VERTICAL;
+ } else
+ {
+ orth->points[0] = *startpoint;
+ orth->points[1].x = startpoint->x + 1.0;
+ orth->points[1].y = startpoint->y;
+ orth->points[2].x = startpoint->x + 1.0;
+ orth->points[2].y = startpoint->y + 1.0;
+ orth->points[3].x = startpoint->x + 1.0;
+ orth->points[3].y = startpoint->y + 2.0;
+
+ orth->orientation[0] = HORIZONTAL;
+ orth->orientation[1] = VERTICAL;
+ orth->orientation[2] = HORIZONTAL;
+ }
orthconn_update_data(orth);
}
@@ -662,6 +692,26 @@
return change;
}
+ObjectChange *
+orthconn_orient_vert(OrthConn *orth, Point *clicked)
+{
+ ObjectChange *change = NULL;
+
+ change = orient_change_create(orth, TYPE_ORIENT_VERT);
+ change->apply(change, (Object *) orth);
+ return change;
+}
+
+ObjectChange *
+orthconn_orient_horiz(OrthConn *orth, Point *clicked)
+{
+ ObjectChange *change = NULL;
+
+ change = orient_change_create(orth, TYPE_ORIENT_HORIZ);
+ change->apply(change, (Object *) orth);
+ return change;
+}
+
static void
delete_point(OrthConn *orth, int pos)
{
@@ -790,6 +840,8 @@
HANDLE_MOVE_ENDPOINT);
}
break;
+ default:
+ break;
}
}
@@ -831,6 +883,8 @@
if (change->cp)
object_connect(obj, change->old_end_handle, change->cp);
break;
+ default:
+ break;
}
change->applied = 0;
}
@@ -903,6 +957,8 @@
orth->points[change->segment].y = change->points[0].y;
}
break;
+ default:
+ break;
}
}
@@ -931,6 +987,8 @@
insert_handle(orth, change->segment, change->handles[0],
FLIP_ORIENT(orth->orientation[change->segment-1]) );
break;
+ default:
+ break;
}
change->applied = 0;
}
@@ -961,5 +1019,47 @@
}
+static void orient_change_free(struct OrientChange *change)
+{
+}
+
+static void orient_change_apply(struct OrientChange *change, Object *obj)
+{
+ change->applied = 1;
+
+ switch (change->type)
+ {
+ case TYPE_ORIENT_HORIZ:
+ orthconn_orientation = TYPE_ORIENT_HORIZ;
+ break;
+ case TYPE_ORIENT_VERT:
+ orthconn_orientation = TYPE_ORIENT_VERT;
+ break;
+ default:
+ break;
+ }
+
+}
+static void orient_change_revert(struct OrientChange *change, Object *obj)
+{
+ change->applied = 0;
+ orthconn_orientation = change->previous_value;
+}
+static ObjectChange *
+orient_change_create(OrthConn *orth, enum change_type type)
+{
+ struct OrientChange *change;
+
+ change = g_new(struct OrientChange, 1);
+
+ change->obj_change.apply = (ObjectChangeApplyFunc) orient_change_apply;
+ change->obj_change.revert = (ObjectChangeRevertFunc) orient_change_revert;
+ change->obj_change.free = (ObjectChangeFreeFunc) orient_change_free;
+
+ change->type = type;
+ change->previous_value = orthconn_orientation;
+ change->applied = 0;
+ return (ObjectChange *)change;
+}
diff -ur dia-0.88.1/lib/orth_conn.h dia-0.88.1mv/lib/orth_conn.h
--- dia-0.88.1/lib/orth_conn.h Sat Feb 24 01:45:45 2001
+++ dia-0.88.1mv/lib/orth_conn.h Sun Aug 25 14:35:01 2002
@@ -78,6 +78,8 @@
int orthconn_can_add_segment(OrthConn *orth, Point *clickedpoint);
ObjectChange *orthconn_delete_segment(OrthConn *orth, Point *clickedpoint);
ObjectChange *orthconn_add_segment(OrthConn *orth, Point *clickedpoint);
+ObjectChange *orthconn_orient_vert(OrthConn *orth, Point *clickedpoint);
+ObjectChange *orthconn_orient_horiz(OrthConn *orth, Point *clickedpoint);
#endif /* ORTH_CONN_H */
Only in dia-0.88.1mv: libtool
diff -ur dia-0.88.1/objects/standard/zigzagline.c dia-0.88.1mv/objects/standard/zigzagline.c
--- dia-0.88.1/objects/standard/zigzagline.c Tue May 1 10:56:01 2001
+++ dia-0.88.1mv/objects/standard/zigzagline.c Sun Aug 25 14:58:35 2002
@@ -335,9 +335,29 @@
return change;
}
+static ObjectChange *
+zigzagline_vertical_callback(Object *obj, Point *clicked, gpointer data)
+{
+ ObjectChange *change = NULL;
+ change = orthconn_orient_vert((OrthConn *)obj, clicked);
+ return change;
+}
+
+static ObjectChange *
+zigzagline_horizontal_callback(Object *obj, Point *clicked, gpointer data)
+{
+ ObjectChange *change = NULL;
+ change = orthconn_orient_horiz((OrthConn *)obj, clicked);
+ return change;
+}
+
+
static DiaMenuItem object_menu_items[] = {
{ N_("Add segment"), zigzagline_add_segment_callback, NULL, 1 },
{ N_("Delete segment"), zigzagline_delete_segment_callback, NULL, 1 },
+ { NULL, NULL, NULL, 1 },
+ { N_("Vertical Orientation"), zigzagline_vertical_callback, NULL, 1 },
+ { N_("Horizontal Orientation"), zigzagline_horizontal_callback, NULL, 1 }
};
static DiaMenu object_menu = {
diff -ur dia-0.88.1/po/en_GB.po dia-0.88.1mv/po/en_GB.po
--- dia-0.88.1/po/en_GB.po Sat May 19 16:34:47 2001
+++ dia-0.88.1mv/po/en_GB.po Sun Aug 25 16:20:00 2002
@@ -201,7 +201,7 @@
#: app/dia-props.c:189
#, fuzzy
msgid "Background Colour"
-msgstr "Background colour:"
+msgstr "Background Colour:"
#: app/dia-props.c:200 lib/diagramdata.c:59
msgid "Background"
Only in dia-0.88.1/sheets: sheet-translation-report
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]