作図ソフト dia の改良版
Revisión | 6738899880509e7487e1efbbc20cff5d427e63bc (tree) |
---|---|
Tiempo | 2003-11-02 19:58:35 |
Autor | Lars Clausen <lclausen@src....> |
Commiter | Lars Clausen |
Brown Bag 0.92.2
@@ -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 | + | |
1 | 38 | 2003-10-26 Lars Clausen <lrclause@cs.uiuc.edu> |
2 | 39 | |
3 | 40 | * doc/en/dia-manual.xml: |
@@ -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 | + | |
1 | 7 | dia-0.92.1: 26-Oct-2003 |
2 | 8 | |
3 | 9 | * Brown Bag release. Fixes crashbug in the "Analog Clock" symbol, and bug |
@@ -119,9 +119,14 @@ diagram_update_connections_object(Diagram *dia, Object *obj, | ||
119 | 119 | |
120 | 120 | list = g_list_next(list); |
121 | 121 | } |
122 | - | |
123 | 122 | } |
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 | + } | |
125 | 130 | } |
126 | 131 | } |
127 | 132 |
@@ -799,19 +799,28 @@ ddisplay_drop_object(DDisplay *ddisp, gint x, gint y, ObjectType *otype, | ||
799 | 799 | |
800 | 800 | click_distance = ddisplay_untransform_length(ddisp, 3.0); |
801 | 801 | |
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 | + */ | |
802 | 806 | p_obj = diagram_find_clicked_object(ddisp->diagram, &droppoint_orig, |
803 | 807 | click_distance); |
804 | 808 | |
805 | 809 | if (p_obj && p_obj->can_parent) /* the tool was dropped inside an object that takes children*/ |
806 | 810 | { |
807 | 811 | Rectangle *p_ext, *c_ext; |
808 | - int new_height = 0, new_width = 0; | |
809 | 812 | real parent_height, child_height, parent_width, child_width; |
813 | + real vadjust = 0.0, hadjust = 0.0; | |
810 | 814 | Point new_pos; |
811 | 815 | |
812 | 816 | obj->parent = p_obj; |
813 | 817 | p_obj->children = g_list_append(p_obj->children, obj); |
814 | 818 | |
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 | + */ | |
815 | 824 | p_ext = parent_handle_extents(p_obj); |
816 | 825 | c_ext = parent_handle_extents(obj); |
817 | 826 |
@@ -821,64 +830,40 @@ ddisplay_drop_object(DDisplay *ddisp, gint x, gint y, ObjectType *otype, | ||
821 | 830 | parent_width = p_ext->right - p_ext->left; |
822 | 831 | child_width = c_ext->right - c_ext->left; |
823 | 832 | |
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); | |
827 | 837 | c_ext->right = c_ext->left + child_width; |
828 | 838 | c_ext->bottom = c_ext->top + child_height; |
829 | 839 | |
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; | |
839 | 844 | } |
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; | |
857 | 849 | } |
858 | 850 | |
859 | 851 | g_free(p_ext); |
860 | 852 | g_free(c_ext); |
861 | 853 | |
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) { | |
865 | 856 | message_error(_("The object you dropped cannot fit into its parent. \nEither expand the parent object, or drop the object elsewhere.")); |
866 | 857 | obj->parent->children = g_list_remove(obj->parent->children, obj); |
867 | 858 | obj->ops->destroy (obj); |
868 | 859 | return NULL; |
869 | 860 | } |
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); | |
881 | 861 | |
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 | + } | |
882 | 867 | } |
883 | 868 | |
884 | 869 |
@@ -55,6 +55,30 @@ | ||
55 | 55 | #define fchmod(f,m) (0) |
56 | 56 | #endif |
57 | 57 | |
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 | + | |
58 | 82 | static void |
59 | 83 | GHFuncUnknownObjects(gpointer key, |
60 | 84 | gpointer value, |
@@ -134,7 +158,8 @@ read_objects(xmlNodePtr objects, Layer *layer, | ||
134 | 158 | { |
135 | 159 | if (strcmp(child_node->name, "children") == 0) |
136 | 160 | { |
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); | |
138 | 163 | break; |
139 | 164 | } |
140 | 165 | child_node = child_node->next; |
@@ -185,7 +210,7 @@ read_connections(GList *objects, xmlNodePtr layer_node, | ||
185 | 210 | obj_node = layer_node->xmlChildrenNode; |
186 | 211 | while ((list != NULL) && (obj_node != NULL)) { |
187 | 212 | Object *obj = (Object *) list->data; |
188 | - | |
213 | + | |
189 | 214 | while (obj_node && xmlIsBlankNode(obj_node)) obj_node = obj_node->next; |
190 | 215 | if (!obj_node) break; |
191 | 216 |
@@ -233,9 +258,26 @@ read_connections(GList *objects, xmlNodePtr layer_node, | ||
233 | 258 | connection = connection->next; |
234 | 259 | } |
235 | 260 | } |
236 | - | |
237 | 261 | } |
238 | 262 | |
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 | + | |
239 | 281 | list = g_list_next(list); |
240 | 282 | obj_node = obj_node->next; |
241 | 283 | } |
@@ -515,14 +557,13 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data) | ||
515 | 557 | return TRUE; |
516 | 558 | } |
517 | 559 | |
518 | -static void | |
560 | +static gboolean | |
519 | 561 | write_objects(GList *objects, xmlNodePtr objects_node, |
520 | 562 | GHashTable *objects_hash, int *obj_nr, const char *filename) |
521 | 563 | { |
522 | 564 | char buffer[31]; |
523 | 565 | ObjectNode obj_node; |
524 | 566 | xmlNodePtr group_node; |
525 | - xmlNodePtr parent_node; | |
526 | 567 | GList *list; |
527 | 568 | |
528 | 569 | list = objects; |
@@ -543,7 +584,6 @@ write_objects(GList *objects, xmlNodePtr objects_node, | ||
543 | 584 | obj_node = xmlNewChild(objects_node, NULL, "object", NULL); |
544 | 585 | |
545 | 586 | xmlSetProp(obj_node, "type", obj->type->name); |
546 | - | |
547 | 587 | g_snprintf(buffer, 30, "%d", obj->type->version); |
548 | 588 | xmlSetProp(obj_node, "version", buffer); |
549 | 589 |
@@ -555,20 +595,29 @@ write_objects(GList *objects, xmlNodePtr objects_node, | ||
555 | 595 | /* Add object -> obj_nr to hash table */ |
556 | 596 | g_hash_table_insert(objects_hash, obj, GINT_TO_POINTER(*obj_nr)); |
557 | 597 | (*obj_nr)++; |
558 | - | |
598 | + | |
599 | + /* | |
559 | 600 | if (obj->can_parent && obj->children) |
560 | 601 | { |
602 | + int res; | |
603 | + xmlNodePtr parent_node; | |
561 | 604 | 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; | |
564 | 607 | } |
608 | + */ | |
565 | 609 | } |
566 | 610 | |
567 | 611 | list = g_list_next(list); |
568 | 612 | } |
613 | + return TRUE; | |
569 | 614 | } |
570 | 615 | |
571 | -static int | |
616 | +/* Parents broke assumption that both objects and xml nodes are laid out | |
617 | + * linearly. | |
618 | + */ | |
619 | + | |
620 | +static gboolean | |
572 | 621 | write_connections(GList *objects, xmlNodePtr layer_node, |
573 | 622 | GHashTable *objects_hash) |
574 | 623 | { |
@@ -625,13 +674,25 @@ write_connections(GList *objects, xmlNodePtr layer_node, | ||
625 | 674 | g_snprintf(buffer, 30, "O%d", |
626 | 675 | GPOINTER_TO_INT(g_hash_table_lookup(objects_hash, |
627 | 676 | other_obj))); |
677 | + | |
628 | 678 | xmlSetProp(connection, "to", buffer); |
629 | 679 | /* to what connection_point on that object */ |
630 | 680 | g_snprintf(buffer, 30, "%d", con_point_nr); |
631 | 681 | xmlSetProp(connection, "connection", buffer); |
682 | + | |
683 | + | |
632 | 684 | } |
633 | 685 | } |
634 | 686 | } |
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 | + } | |
635 | 696 | |
636 | 697 | list = g_list_next(list); |
637 | 698 | obj_node = obj_node->next; |
@@ -648,7 +709,7 @@ diagram_data_write_doc(DiagramData *data, const char *filename) | ||
648 | 709 | xmlNodePtr pageinfo, gridinfo, guideinfo; |
649 | 710 | xmlNodePtr layer_node; |
650 | 711 | GHashTable *objects_hash; |
651 | - int res; | |
712 | + gboolean res; | |
652 | 713 | int obj_nr; |
653 | 714 | int i; |
654 | 715 | Layer *layer; |
@@ -14,7 +14,7 @@ | ||
14 | 14 | #define GETTEXT_PACKAGE "dia" |
15 | 15 | #define LOCALEDIR "../lib/locale" |
16 | 16 | |
17 | -#define VERSION "0.92.1" | |
17 | +#define VERSION "0.92.2" | |
18 | 18 | |
19 | 19 | /* |
20 | 20 | * We are linking libxml as DLL with either msvc or mingw, but this |
@@ -1,6 +1,6 @@ | ||
1 | 1 | dnl Process this -*- autoconf -*- file with autoconf to produce a |
2 | 2 | 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) | |
4 | 4 | AC_CONFIG_SRCDIR(app/diagram.c) |
5 | 5 | AM_INIT_AUTOMAKE(AC_PACKAGE_NAME,AC_PACKAGE_VERSION) |
6 | 6 |
@@ -1,6 +1,6 @@ | ||
1 | 1 | %define name dia |
2 | 2 | # This is the full Dia version |
3 | -%define ver 0.92.1 | |
3 | +%define ver 0.92.2 | |
4 | 4 | |
5 | 5 | Summary: A gtk+ based diagram creation program. |
6 | 6 | Name: %name |
@@ -8,7 +8,7 @@ | ||
8 | 8 | |
9 | 9 | [ |
10 | 10 | |
11 | - <!ENTITY VERSION "0.92.1"> | |
11 | + <!ENTITY VERSION "0.92.2"> | |
12 | 12 | |
13 | 13 | <!ENTITY INTRODUCTION SYSTEM "intro.xml"> |
14 | 14 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | <!DOCTYPE Book PUBLIC "-//OASIS//DTD DocBook V4.1//EN"[ |
2 | -<!ENTITY VERSION "0.92.1"> | |
2 | +<!ENTITY VERSION "0.92.2"> | |
3 | 3 | <!ENTITY INTRODUCTION SYSTEM "intro.sgml"> |
4 | 4 | <!ENTITY QUICKSTART SYSTEM "usage-quickstart.sgml"> |
5 | 5 | <!ENTITY CANVAS SYSTEM "usage-canvas.sgml"> |
@@ -51,12 +51,8 @@ void dynobj_list_remove_object(Object* obj) { | ||
51 | 51 | |
52 | 52 | if (item) { |
53 | 53 | DynobjRec* dor = item->data; |
54 | - printf("Removing obj %p from list of len %d\n", | |
55 | - obj, g_list_length(dyn_obj_list)); | |
56 | 54 | dyn_obj_list = g_list_remove(dyn_obj_list,dor); |
57 | 55 | g_free(dor); |
58 | - } else { | |
59 | - printf("Dying object %p not found\n", obj); | |
60 | 56 | } |
61 | 57 | } |
62 | 58 |
@@ -166,8 +166,14 @@ branch_move_handle(Branch *branch, Handle *handle, | ||
166 | 166 | |
167 | 167 | assert(handle->id < 8); |
168 | 168 | |
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 | + /* | |
169 | 174 | element_move_handle(&branch->element, handle->id, to, cp, reason, modifiers); |
170 | 175 | branch_update_data(branch); |
176 | + */ | |
171 | 177 | |
172 | 178 | return NULL; |
173 | 179 | } |
@@ -262,8 +268,12 @@ static Object *branch_create(Point *startpoint, void *user_data, Handle **handle | ||
262 | 268 | elem->extra_spacing.border_trans = BRANCH_BORDERWIDTH / 2.0; |
263 | 269 | branch_update_data(branch); |
264 | 270 | |
271 | + for (i=0;i<8;i++) { | |
272 | + obj->handles[i]->type = HANDLE_NON_MOVABLE; | |
273 | + } | |
274 | + | |
265 | 275 | *handle1 = NULL; |
266 | - *handle2 = obj->handles[0]; | |
276 | + *handle2 = NULL; | |
267 | 277 | return &branch->element.object; |
268 | 278 | } |
269 | 279 |
@@ -374,7 +374,7 @@ largepackage_create(Point *startpoint, | ||
374 | 374 | largepackage_update_data(pkg); |
375 | 375 | |
376 | 376 | *handle1 = NULL; |
377 | - *handle2 = obj->handles[0]; | |
377 | + *handle2 = obj->handles[7]; | |
378 | 378 | return &pkg->element.object; |
379 | 379 | } |
380 | 380 |
@@ -361,7 +361,7 @@ static Object *node_create(Point *startpoint, void *user_data, Handle **handle1, | ||
361 | 361 | node_update_data(node); |
362 | 362 | |
363 | 363 | *handle1 = NULL; |
364 | - *handle2 = obj->handles[0]; | |
364 | + *handle2 = obj->handles[7]; | |
365 | 365 | return &node->element.object; |
366 | 366 | } |
367 | 367 |