• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

作図ソフト dia の改良版


Commit MetaInfo

Revision6738899880509e7487e1efbbc20cff5d427e63bc (tree)
Time2003-11-02 19:58:35
AuthorLars Clausen <lclausen@src....>
CommiterLars Clausen

Log Message

Brown Bag 0.92.2

Change Summary

Incremental Difference

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
1+2003-11-01 Lars Clausen <lrclause@cs.uiuc.edu>
2+
3+ * config.h.win32:
4+ * doc/en/dia-manual.xml:
5+ * dia.spec:
6+ * configure.in:
7+ * NEWS: Another Brown Bag release for parenting problems,
8+ including a crash bug fix.
9+
10+ * app/connectionpoint_ops.c (diagram_update_connections_object):
11+ Also update connections when moving children. This can cause
12+ move_handle to be called twice, so it must be idempotent.
13+
14+ * app/load_save.c: Loading and saving of children totally redone.
15+ Now doesn't violate assumption that all objects in a layer are
16+ placed in order in XML file.
17+
18+ * objects/UML/branch.c (branch_create): Don't lie about being
19+ resizable.
20+
21+ * objects/UML/node.c (node_create):
22+ * objects/UML/large_package.c (largepackage_create): Drag with
23+ lower right-hand handle at creation like all other objects.
24+
25+2003-10-28 Lars Clausen <lrclause@cs.uiuc.edu>
26+
27+ * app/disp_callbacks.c (ddisplay_drop_object): Change initial
28+ parenting drop to behave like a move inside, i.e. constrain place
29+ instead of trying to resize. 'Cause, resizing cannot be done for
30+ all objects (e.g. UML Class). Also simplified the algorithm a lot
31+ at the same time.
32+
33+ * app/load_save.c: Saving and loading of connection points for
34+ children added. Prototypes for static functions added.
35+
36+ * lib/dynamic_obj.c: Removed debugging output.
37+
138 2003-10-26 Lars Clausen <lrclause@cs.uiuc.edu>
239
340 * doc/en/dia-manual.xml:
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
1+dia-0.92.2: 01-Nov-2003
2+
3+* Another Brown Bag release. Parented objects lost all connections, now
4+ retained. Also fixed crash bug that tried to resize unresizable objects
5+ and connections update for children.
6+
17 dia-0.92.1: 26-Oct-2003
28
39 * Brown Bag release. Fixes crashbug in the "Analog Clock" symbol, and bug
--- a/app/connectionpoint_ops.c
+++ b/app/connectionpoint_ops.c
@@ -119,9 +119,14 @@ diagram_update_connections_object(Diagram *dia, Object *obj,
119119
120120 list = g_list_next(list);
121121 }
122-
123122 }
124-
123+ }
124+ if (obj->children) {
125+ GList *child;
126+ for (child = obj->children; child != NULL; child = child->next) {
127+ Object *child_obj = (Object *)child->data;
128+ diagram_update_connections_object(dia, child_obj, update_nonmoved);
129+ }
125130 }
126131 }
127132
--- a/app/disp_callbacks.c
+++ b/app/disp_callbacks.c
@@ -799,19 +799,28 @@ ddisplay_drop_object(DDisplay *ddisp, gint x, gint y, ObjectType *otype,
799799
800800 click_distance = ddisplay_untransform_length(ddisp, 3.0);
801801
802+ /* Notice that using diagram_find_clicked_object doesn't allow any object
803+ * below the first to be a parent. This should be fixed.
804+ * -Lars
805+ */
802806 p_obj = diagram_find_clicked_object(ddisp->diagram, &droppoint_orig,
803807 click_distance);
804808
805809 if (p_obj && p_obj->can_parent) /* the tool was dropped inside an object that takes children*/
806810 {
807811 Rectangle *p_ext, *c_ext;
808- int new_height = 0, new_width = 0;
809812 real parent_height, child_height, parent_width, child_width;
813+ real vadjust = 0.0, hadjust = 0.0;
810814 Point new_pos;
811815
812816 obj->parent = p_obj;
813817 p_obj->children = g_list_append(p_obj->children, obj);
814818
819+ /* This is not really what we want. We want the box containing all
820+ * rendered parts of the object (not the bbox). But it'll do for now,
821+ * since we don't have the 'rendered bbox'.
822+ * -Lars
823+ */
815824 p_ext = parent_handle_extents(p_obj);
816825 c_ext = parent_handle_extents(obj);
817826
@@ -821,64 +830,40 @@ ddisplay_drop_object(DDisplay *ddisp, gint x, gint y, ObjectType *otype,
821830 parent_width = p_ext->right - p_ext->left;
822831 child_width = c_ext->right - c_ext->left;
823832
824- /* we need the pre-snap position */
825- c_ext->left = droppoint_orig.x;
826- c_ext->top = droppoint_orig.y;
833+ /* we need the pre-snap position, but must remember that handles can
834+ * be to the left of the droppoint */
835+ c_ext->left = droppoint_orig.x - (obj->position.x - c_ext->left);
836+ c_ext->top = droppoint_orig.y - (obj->position.y - c_ext->top);
827837 c_ext->right = c_ext->left + child_width;
828838 c_ext->bottom = c_ext->top + child_height;
829839
830- /* check if the top of the child is inside the parent, but the bottom is not */
831- if (c_ext->top < p_ext->bottom && c_ext->bottom > p_ext->bottom)
832- {
833- /* check if child is smaller than parent height wise */
834- if (child_height < parent_height)
835- new_height = child_height;
836- /* check if parent is bigger than 1 in height */
837- else if (parent_height > 1)
838- new_height = round_up(parent_height) - 1;
840+ if (c_ext->left < p_ext->left) {
841+ hadjust = p_ext->left - c_ext->left;
842+ } else if (c_ext->right > p_ext->right) {
843+ hadjust = p_ext->right - c_ext->right;
839844 }
840- else
841- {
842- new_height = child_height;
843- }
844- /* check if the left of the child is inside the partent, but the right is not */
845- if (c_ext->left < p_ext->right && c_ext->right > p_ext->right)
846- {
847- /* check if child is smaller than parent width wise */
848- if (child_width < parent_width)
849- new_width = child_width;
850- /* check if parent is bigger than 1 in width */
851- else if (parent_width > 1)
852- new_width = round_up(parent_width) - 1;
853- }
854- else
855- {
856- new_width = child_width;
845+ if (c_ext->top < p_ext->top) {
846+ vadjust = p_ext->top - c_ext->top;
847+ } else if (c_ext->bottom > p_ext->bottom) {
848+ vadjust = p_ext->bottom - c_ext->bottom;
857849 }
858850
859851 g_free(p_ext);
860852 g_free(c_ext);
861853
862- /* if we can't fit in both directions, produce an error */
863- if (!new_height && !new_width)
864- {
854+ if (child_width > parent_width ||
855+ child_height > parent_height) {
865856 message_error(_("The object you dropped cannot fit into its parent. \nEither expand the parent object, or drop the object elsewhere."));
866857 obj->parent->children = g_list_remove(obj->parent->children, obj);
867858 obj->ops->destroy (obj);
868859 return NULL;
869860 }
870- /* if we can't fit height wise, make height same as of the parent */
871- else if (!new_height)
872- new_height = parent_height;
873- /* if we can't fit width wise, make the width same as of the parent */
874- else if (!new_width)
875- new_width = parent_width;
876-
877- new_pos.x = droppoint.x + new_width;
878- new_pos.y = droppoint.y + new_height;
879- obj->ops->move_handle(obj, handle2, &new_pos, NULL,
880- HANDLE_MOVE_USER, 0);
881861
862+ if (hadjust || vadjust) {
863+ new_pos.x = droppoint.x + hadjust;
864+ new_pos.y = droppoint.y + vadjust;
865+ obj->ops->move(obj, &new_pos);
866+ }
882867 }
883868
884869
--- a/app/load_save.c
+++ b/app/load_save.c
@@ -55,6 +55,30 @@
5555 #define fchmod(f,m) (0)
5656 #endif
5757
58+static void read_connections(GList *objects, xmlNodePtr layer_node,
59+ GHashTable *objects_hash);
60+static void GHFuncUnknownObjects(gpointer key,
61+ gpointer value,
62+ gpointer user_data);
63+static GList *read_objects(xmlNodePtr objects, Layer *layer,
64+ GHashTable *objects_hash,
65+ const char *filename, Object *parent);
66+static void hash_free_string(gpointer key,
67+ gpointer value,
68+ gpointer user_data);
69+static xmlNodePtr find_node_named (xmlNodePtr p, const char *name);
70+static gboolean diagram_data_load(const char *filename, DiagramData *data,
71+ void* user_data);
72+static gboolean write_objects(GList *objects, xmlNodePtr objects_node,
73+ GHashTable *objects_hash, int *obj_nr,
74+ const char *filename);
75+static gboolean write_connections(GList *objects, xmlNodePtr layer_node,
76+ GHashTable *objects_hash);
77+static xmlDocPtr diagram_data_write_doc(DiagramData *data, const char *filename);
78+static int diagram_data_raw_save(DiagramData *data, const char *filename);
79+static int diagram_data_save(DiagramData *data, const char *filename);
80+
81+
5882 static void
5983 GHFuncUnknownObjects(gpointer key,
6084 gpointer value,
@@ -134,7 +158,8 @@ read_objects(xmlNodePtr objects, Layer *layer,
134158 {
135159 if (strcmp(child_node->name, "children") == 0)
136160 {
137- list = g_list_concat(list, read_objects(child_node, layer, objects_hash, filename, obj));
161+ GList *children_read = read_objects(child_node, layer, objects_hash, filename, obj);
162+ list = g_list_concat(list, children_read);
138163 break;
139164 }
140165 child_node = child_node->next;
@@ -185,7 +210,7 @@ read_connections(GList *objects, xmlNodePtr layer_node,
185210 obj_node = layer_node->xmlChildrenNode;
186211 while ((list != NULL) && (obj_node != NULL)) {
187212 Object *obj = (Object *) list->data;
188-
213+
189214 while (obj_node && xmlIsBlankNode(obj_node)) obj_node = obj_node->next;
190215 if (!obj_node) break;
191216
@@ -233,9 +258,26 @@ read_connections(GList *objects, xmlNodePtr layer_node,
233258 connection = connection->next;
234259 }
235260 }
236-
237261 }
238262
263+ /* Now set up parent relationships. */
264+ connections = obj_node->xmlChildrenNode;
265+ while ((connections!=NULL) &&
266+ (strcmp(connections->name, "childnode")!=0))
267+ connections = connections->next;
268+ if (connections != NULL) {
269+ tostr = xmlGetProp(connections, "parent");
270+ if (tostr) {
271+ obj->parent = g_hash_table_lookup(objects_hash, tostr);
272+ if (obj->parent == NULL) {
273+ message_error(_("Can't find parent %s of %s object\n"),
274+ tostr, obj->type->name);
275+ } else {
276+ obj->parent->children = g_list_prepend(obj->parent->children, obj);
277+ }
278+ }
279+ }
280+
239281 list = g_list_next(list);
240282 obj_node = obj_node->next;
241283 }
@@ -515,14 +557,13 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
515557 return TRUE;
516558 }
517559
518-static void
560+static gboolean
519561 write_objects(GList *objects, xmlNodePtr objects_node,
520562 GHashTable *objects_hash, int *obj_nr, const char *filename)
521563 {
522564 char buffer[31];
523565 ObjectNode obj_node;
524566 xmlNodePtr group_node;
525- xmlNodePtr parent_node;
526567 GList *list;
527568
528569 list = objects;
@@ -543,7 +584,6 @@ write_objects(GList *objects, xmlNodePtr objects_node,
543584 obj_node = xmlNewChild(objects_node, NULL, "object", NULL);
544585
545586 xmlSetProp(obj_node, "type", obj->type->name);
546-
547587 g_snprintf(buffer, 30, "%d", obj->type->version);
548588 xmlSetProp(obj_node, "version", buffer);
549589
@@ -555,20 +595,29 @@ write_objects(GList *objects, xmlNodePtr objects_node,
555595 /* Add object -> obj_nr to hash table */
556596 g_hash_table_insert(objects_hash, obj, GINT_TO_POINTER(*obj_nr));
557597 (*obj_nr)++;
558-
598+
599+ /*
559600 if (obj->can_parent && obj->children)
560601 {
602+ int res;
603+ xmlNodePtr parent_node;
561604 parent_node = xmlNewChild(obj_node, NULL, "children", NULL);
562- write_objects(obj->children, parent_node,
563- objects_hash, obj_nr, filename);
605+ res = write_objects(obj->children, parent_node, objects_hash, obj_nr, filename);
606+ if (!res) return FALSE;
564607 }
608+ */
565609 }
566610
567611 list = g_list_next(list);
568612 }
613+ return TRUE;
569614 }
570615
571-static int
616+/* Parents broke assumption that both objects and xml nodes are laid out
617+ * linearly.
618+ */
619+
620+static gboolean
572621 write_connections(GList *objects, xmlNodePtr layer_node,
573622 GHashTable *objects_hash)
574623 {
@@ -625,13 +674,25 @@ write_connections(GList *objects, xmlNodePtr layer_node,
625674 g_snprintf(buffer, 30, "O%d",
626675 GPOINTER_TO_INT(g_hash_table_lookup(objects_hash,
627676 other_obj)));
677+
628678 xmlSetProp(connection, "to", buffer);
629679 /* to what connection_point on that object */
630680 g_snprintf(buffer, 30, "%d", con_point_nr);
631681 xmlSetProp(connection, "connection", buffer);
682+
683+
632684 }
633685 }
634686 }
687+
688+ if (obj->parent) {
689+ Object *other_obj = obj->parent;
690+ xmlNodePtr parent;
691+ g_snprintf(buffer, 30, "O%d",
692+ GPOINTER_TO_INT(g_hash_table_lookup(objects_hash, other_obj)));
693+ parent = xmlNewChild(obj_node, NULL, "childnode", NULL);
694+ xmlSetProp(parent, "parent", buffer);
695+ }
635696
636697 list = g_list_next(list);
637698 obj_node = obj_node->next;
@@ -648,7 +709,7 @@ diagram_data_write_doc(DiagramData *data, const char *filename)
648709 xmlNodePtr pageinfo, gridinfo, guideinfo;
649710 xmlNodePtr layer_node;
650711 GHashTable *objects_hash;
651- int res;
712+ gboolean res;
652713 int obj_nr;
653714 int i;
654715 Layer *layer;
--- a/config.h.win32
+++ b/config.h.win32
@@ -14,7 +14,7 @@
1414 #define GETTEXT_PACKAGE "dia"
1515 #define LOCALEDIR "../lib/locale"
1616
17-#define VERSION "0.92.1"
17+#define VERSION "0.92.2"
1818
1919 /*
2020 * We are linking libxml as DLL with either msvc or mingw, but this
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,6 @@
11 dnl Process this -*- autoconf -*- file with autoconf to produce a
22 dnl configure script.
3-AC_INIT(dia, 0.92.1, http://bugzilla.gnome.org/enter_bug.cgi?product=dia)
3+AC_INIT(dia, 0.92.2, http://bugzilla.gnome.org/enter_bug.cgi?product=dia)
44 AC_CONFIG_SRCDIR(app/diagram.c)
55 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME,AC_PACKAGE_VERSION)
66
--- a/dia.spec
+++ b/dia.spec
@@ -1,6 +1,6 @@
11 %define name dia
22 # This is the full Dia version
3-%define ver 0.92.1
3+%define ver 0.92.2
44
55 Summary: A gtk+ based diagram creation program.
66 Name: %name
--- a/doc/en/dia-manual.xml
+++ b/doc/en/dia-manual.xml
@@ -8,7 +8,7 @@
88
99 [
1010
11- <!ENTITY VERSION "0.92.1">
11+ <!ENTITY VERSION "0.92.2">
1212
1313 <!ENTITY INTRODUCTION SYSTEM "intro.xml">
1414
--- a/doc/pl/dia-manual.sgml
+++ b/doc/pl/dia-manual.sgml
@@ -1,5 +1,5 @@
11 <!DOCTYPE Book PUBLIC "-//OASIS//DTD DocBook V4.1//EN"[
2-<!ENTITY VERSION "0.92.1">
2+<!ENTITY VERSION "0.92.2">
33 <!ENTITY INTRODUCTION SYSTEM "intro.sgml">
44 <!ENTITY QUICKSTART SYSTEM "usage-quickstart.sgml">
55 <!ENTITY CANVAS SYSTEM "usage-canvas.sgml">
--- a/lib/dynamic_obj.c
+++ b/lib/dynamic_obj.c
@@ -51,12 +51,8 @@ void dynobj_list_remove_object(Object* obj) {
5151
5252 if (item) {
5353 DynobjRec* dor = item->data;
54- printf("Removing obj %p from list of len %d\n",
55- obj, g_list_length(dyn_obj_list));
5654 dyn_obj_list = g_list_remove(dyn_obj_list,dor);
5755 g_free(dor);
58- } else {
59- printf("Dying object %p not found\n", obj);
6056 }
6157 }
6258
--- a/objects/UML/branch.c
+++ b/objects/UML/branch.c
@@ -166,8 +166,14 @@ branch_move_handle(Branch *branch, Handle *handle,
166166
167167 assert(handle->id < 8);
168168
169+ /* It smashes size info in update_data anyway. And none of its siblings
170+ * resizable, so until that changes, this should be properly unresizable
171+ */
172+
173+ /*
169174 element_move_handle(&branch->element, handle->id, to, cp, reason, modifiers);
170175 branch_update_data(branch);
176+ */
171177
172178 return NULL;
173179 }
@@ -262,8 +268,12 @@ static Object *branch_create(Point *startpoint, void *user_data, Handle **handle
262268 elem->extra_spacing.border_trans = BRANCH_BORDERWIDTH / 2.0;
263269 branch_update_data(branch);
264270
271+ for (i=0;i<8;i++) {
272+ obj->handles[i]->type = HANDLE_NON_MOVABLE;
273+ }
274+
265275 *handle1 = NULL;
266- *handle2 = obj->handles[0];
276+ *handle2 = NULL;
267277 return &branch->element.object;
268278 }
269279
--- a/objects/UML/large_package.c
+++ b/objects/UML/large_package.c
@@ -374,7 +374,7 @@ largepackage_create(Point *startpoint,
374374 largepackage_update_data(pkg);
375375
376376 *handle1 = NULL;
377- *handle2 = obj->handles[0];
377+ *handle2 = obj->handles[7];
378378 return &pkg->element.object;
379379 }
380380
--- a/objects/UML/node.c
+++ b/objects/UML/node.c
@@ -361,7 +361,7 @@ static Object *node_create(Point *startpoint, void *user_data, Handle **handle1,
361361 node_update_data(node);
362362
363363 *handle1 = NULL;
364- *handle2 = obj->handles[0];
364+ *handle2 = obj->handles[7];
365365 return &node->element.object;
366366 }
367367