dia r3951 - in trunk: . app objects/UML



Author: hans
Date: Sun Apr 20 11:32:53 2008
New Revision: 3951
URL: http://svn.gnome.org/viewvc/dia?rev=3951&view=rev

Log:
2008-04-20  Hans Breuer  <hans breuer org>

	* objects/UML/object.c : also write 'name' in text_color
	* objects/UML/association.c : line_color and text_color
	* objects/UML/component_feature.c : added line_color
	* objects/UML/fork.c : added fill_color
	* objects/UML/state_term.c : fill_color and line_color
	* objects/UML/transition.c : fill_color and text_color
	=> all UML shapes can be tinted now

	* app/load_save.c : use 'obl->ops-move(obj,obj->position)'



Modified:
   trunk/ChangeLog
   trunk/app/load_save.c
   trunk/objects/UML/association.c
   trunk/objects/UML/component_feature.c
   trunk/objects/UML/fork.c
   trunk/objects/UML/state_term.c
   trunk/objects/UML/transition.c

Modified: trunk/app/load_save.c
==============================================================================
--- trunk/app/load_save.c	(original)
+++ trunk/app/load_save.c	Sun Apr 20 11:32:53 2008
@@ -348,10 +348,8 @@
          * may screw the auto-routing algorithm.
          */
         if (!broken && obj && obj->ops->set_props) {
-	  GPtrArray *props = g_ptr_array_new();
 	  /* called for it's side-effect of update_data */
-	  obj->ops->set_props (obj, props);
-	  g_ptr_array_free (props, TRUE);
+	  obj->ops->move(obj,&obj->position);
 
 	  for (handle = 0; handle < obj->num_handles; ++handle) {
 	    if (obj->handles[handle]->connected_to)
@@ -828,7 +826,7 @@
   GHashTable *objects_hash;
   gboolean res;
   int obj_nr;
-  int i;
+  guint i;
   Layer *layer;
   AttributeNode attr;
   xmlNs *name_space;

Modified: trunk/objects/UML/association.c
==============================================================================
--- trunk/objects/UML/association.c	(original)
+++ trunk/objects/UML/association.c	Sun Apr 20 11:32:53 2008
@@ -134,6 +134,9 @@
 
   AssociationEnd end[2];
   
+  Color text_color;
+  Color line_color;
+
   AssociationPropertiesDialog* properties_dialog;
 };
 
@@ -252,6 +255,8 @@
 
 static PropOffset association_offsets[] = {
   ORTHCONN_COMMON_PROPERTIES_OFFSETS,
+  { "line_colour",PROP_TYPE_COLOUR,offsetof(Association, line_color) },
+  { "text_colour", PROP_TYPE_COLOUR, offsetof(Association, text_color) },
   { "name", PROP_TYPE_STRING, offsetof(Association, name) },
   { NULL, 0, 0 }
 };
@@ -357,7 +362,7 @@
   }
   renderer_ops->draw_polyline_with_arrows(renderer, points, n,
 					   ASSOCIATION_WIDTH,
-					   &color_black,
+					   &assoc->line_color,
 					   &startarrow, &endarrow);
 
   /* Name: */
@@ -367,7 +372,7 @@
     pos = assoc->text_pos;
     renderer_ops->draw_string(renderer, assoc->name,
 			       &pos, assoc->text_align,
-			       &color_black);
+			       &assoc->text_color);
   }
 
   /* Direction: */
@@ -385,7 +390,7 @@
     poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
     poly[2].x = poly[0].x + ASSOCIATION_FONTHEIGHT*0.5;
     poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
-    renderer_ops->fill_polygon(renderer, poly, 3, &color_black);
+    renderer_ops->fill_polygon(renderer, poly, 3, &assoc->line_color);
     break;
   case ASSOC_LEFT:
     poly[0].x = assoc->text_pos.x - 0.2;
@@ -396,7 +401,7 @@
     poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
     poly[2].x = poly[0].x - ASSOCIATION_FONTHEIGHT*0.5;
     poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
-    renderer_ops->fill_polygon(renderer, poly, 3, &color_black);
+    renderer_ops->fill_polygon(renderer, poly, 3, &assoc->line_color);
     break;
   }
 
@@ -411,14 +416,14 @@
                                 role_name,
 				&pos, 
 				end->text_align,
-				&color_black);
+				&assoc->text_color);
       g_free (role_name);
       pos.y += ASSOCIATION_FONTHEIGHT;
     }
     if (end->multiplicity != NULL) {
       renderer_ops->draw_string(renderer, end->multiplicity,
 				 &pos, end->text_align,
-				 &color_black);
+				 &assoc->text_color);
     }
   }
 }
@@ -717,6 +722,8 @@
 
   orthconn_init(orth, startpoint);
   
+  assoc->text_color = color_black;
+  assoc->line_color = attributes_get_foreground();
   assoc->name = NULL;
   assoc->direction = ASSOC_NODIR;
   for (i=0;i<2;i++) {

Modified: trunk/objects/UML/component_feature.c
==============================================================================
--- trunk/objects/UML/component_feature.c	(original)
+++ trunk/objects/UML/component_feature.c	Sun Apr 20 11:32:53 2008
@@ -35,6 +35,7 @@
 #include "orth_conn.h"
 #include "connectionpoint.h"
 #include "diarenderer.h"
+#include "attributes.h"
 #include "handle.h"
 #include "properties.h"
 #include "text.h"
@@ -70,6 +71,8 @@
   TextAttributes attrs;
   Point text_pos;
   Handle text_handle;
+  
+  Color line_color;
 };
 
 #define COMPPROP_WIDTH 0.1
@@ -153,6 +156,7 @@
 
 static PropDescription compfeat_props[] = {
   ORTHCONN_COMMON_PROPERTIES,
+  PROP_STD_LINE_COLOUR_OPTIONAL, 
   { "role", PROP_TYPE_ENUM, 0, NULL, NULL, prop_compfeat_type_data },
   { "text", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
   PROP_STD_TEXT_FONT,
@@ -220,6 +224,7 @@
 
 static PropOffset compfeat_offsets[] = {
   ORTHCONN_COMMON_PROPERTIES_OFFSETS,
+  { "line_colour",PROP_TYPE_COLOUR,offsetof(Compfeat, line_color) },
   { "role", PROP_TYPE_ENUM, offsetof(Compfeat, role) },
   { "text", PROP_TYPE_TEXT, offsetof(Compfeat, text) },
   { "text_font", PROP_TYPE_FONT, offsetof(Compfeat, attrs.font) },
@@ -349,7 +354,7 @@
   endarrow.type = compprop_arrow[compfeat->role];
   renderer_ops->draw_polyline_with_arrows(renderer, points, n,
  					  COMPPROP_WIDTH,
- 					  &color_black,
+ 					  &compfeat->line_color,
  					  &startarrow, &endarrow);
 
   text_draw(compfeat->text, renderer);
@@ -383,8 +388,9 @@
   p = *startpoint;
   p.y -= COMPPROP_TEXTOFFSET;
 
+  compfeat->line_color = attributes_get_foreground();
   compfeat->text = new_text("", font,
-			    COMPPROP_FONTHEIGHT, &p, &color_black,
+			    COMPPROP_FONTHEIGHT, &p, &compfeat->line_color,
 			    ALIGN_CENTER);
   dia_font_unref(font);
   text_get_attributes(compfeat->text, &compfeat->attrs);

Modified: trunk/objects/UML/fork.c
==============================================================================
--- trunk/objects/UML/fork.c	(original)
+++ trunk/objects/UML/fork.c	Sun Apr 20 11:32:53 2008
@@ -44,6 +44,7 @@
 struct _Fork
 {
   Element element;
+  Color fill_color;
   ConnectionPoint connections[8];
 };
 
@@ -112,7 +113,7 @@
 
 static PropDescription fork_props[] = {
   ELEMENT_COMMON_PROPERTIES,
-  
+  PROP_STD_FILL_COLOUR_OPTIONAL,   
   PROP_DESC_END
 };
 
@@ -127,6 +128,7 @@
 
 static PropOffset fork_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
+  { "fill_colour",PROP_TYPE_COLOUR,offsetof(Fork, fill_color) },
   { NULL, 0, 0 },
 };
 
@@ -221,7 +223,7 @@
    
   renderer_ops->fill_rect(renderer, 
 			   &p1, &p2,
-			   &color_black);
+			   &branch->fill_color);
 }
 
 static void fork_update_data(Fork *branch)
@@ -269,6 +271,8 @@
   elem->height = FORK_HEIGHT;
   element_init(elem, 8, 8);
 
+  branch->fill_color = attributes_get_foreground();
+
   for (i=0;i<8;i++)
     {
       obj->connections[i] = &branch->connections[i];

Modified: trunk/objects/UML/state_term.c
==============================================================================
--- trunk/objects/UML/state_term.c	(original)
+++ trunk/objects/UML/state_term.c	Sun Apr 20 11:32:53 2008
@@ -46,6 +46,9 @@
   ConnectionPoint connections[NUM_CONNECTIONS];
 
   int is_final;
+  
+  Color line_color;
+  Color fill_color;
 };
 
 
@@ -118,6 +121,8 @@
 
 static PropDescription state_props[] = {
   ELEMENT_COMMON_PROPERTIES,
+  PROP_STD_LINE_COLOUR_OPTIONAL, 
+  PROP_STD_FILL_COLOUR_OPTIONAL, 
   { "is_final", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE,
   N_("Is final"), NULL, NULL },
   PROP_DESC_END
@@ -134,6 +139,8 @@
 
 static PropOffset state_offsets[] = {
   ELEMENT_COMMON_PROPERTIES_OFFSETS,
+  { "line_colour",PROP_TYPE_COLOUR,offsetof(State, line_color) },
+  { "fill_colour",PROP_TYPE_COLOUR,offsetof(State, fill_color) },
   { "is_final", PROP_TYPE_BOOL, offsetof(State, is_final) },
   
   { NULL, 0, 0 },
@@ -220,18 +227,18 @@
       renderer_ops->fill_ellipse(renderer, 
 				  &p1,
 				  r, r,
-				  &color_white);
+				  &state->fill_color);
       
       renderer_ops->draw_ellipse(renderer, 
 				  &p1,
 				  r, r,
-				  &color_black);
+				  &state->line_color);
    }  
    r = STATE_RATIO;
    renderer_ops->fill_ellipse(renderer, 
 			       &p1,
 			       r, r,
-			       &color_black);
+			       &state->line_color); /* line_color not a typo! */
 }
 
 
@@ -286,6 +293,8 @@
   p.x += STATE_WIDTH/2.0;
   p.y += STATE_HEIGHT/2.0;
   
+  state->line_color = attributes_get_foreground();
+  state->fill_color = attributes_get_background();
   state->is_final = 0;
   element_init(elem, 8, NUM_CONNECTIONS);
   

Modified: trunk/objects/UML/transition.c
==============================================================================
--- trunk/objects/UML/transition.c	(original)
+++ trunk/objects/UML/transition.c	Sun Apr 20 11:32:53 2008
@@ -26,6 +26,7 @@
 
 #include "orth_conn.h"
 #include "diarenderer.h"
+#include "attributes.h"
 
 #include "pixmaps/transition.xpm"
 
@@ -36,6 +37,9 @@
 struct _Transition {
   OrthConn orth;
   
+  Color text_color;
+  Color line_color;
+
   Handle trigger_text_handle;
   Point trigger_text_pos;
   gchar *trigger_text;
@@ -131,6 +135,9 @@
 
 static PropDescription transition_props[] = {
   ORTHCONN_COMMON_PROPERTIES,
+  /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
+  PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+  PROP_STD_LINE_COLOUR_OPTIONAL, 
   { "trigger", PROP_TYPE_STRING, PROP_FLAG_VISIBLE, N_("Trigger"), 
     N_("The event that causes this transition to be taken"), NULL },
   { "action", PROP_TYPE_STRING, PROP_FLAG_VISIBLE, N_("Action"),
@@ -145,7 +152,9 @@
 
 
 static PropOffset transition_offsets[] = {
-  ORTHCONN_COMMON_PROPERTIES_OFFSETS,           
+  ORTHCONN_COMMON_PROPERTIES_OFFSETS,
+  { "text_colour",PROP_TYPE_COLOUR,offsetof(Transition, text_color) },
+  { "line_colour",PROP_TYPE_COLOUR,offsetof(Transition, line_color) },
   { "trigger", PROP_TYPE_STRING, offsetof(Transition, trigger_text) },
   { "action", PROP_TYPE_STRING, offsetof(Transition, action_text) },
   { "guard", PROP_TYPE_STRING, offsetof(Transition, guard_text) },
@@ -199,6 +208,8 @@
   
   orthconn_init(orth, startpoint);
   
+  transition->text_color = color_black;
+  transition->line_color = attributes_get_foreground();
   /* Prepare the handles for trigger and guard text */
   transition->trigger_text_handle.id = HANDLE_MOVE_TRIGGER_TEXT;
   transition->trigger_text_handle.type = HANDLE_MINOR_CONTROL;
@@ -358,7 +369,7 @@
   }
   renderer_ops->draw_polyline_with_arrows(renderer, points, num_points,
                                           TRANSITION_WIDTH,
-                                          &color_black, /* TODO, allow colors */
+                                          &transition->line_color,
                                           start_arrow, end_arrow);
 
 
@@ -373,7 +384,7 @@
                               text,
                               &transition->guard_text_pos,
                               ALIGN_CENTER,
-                              &color_black); /* TODO, allow other colors */
+                              &transition->text_color);
     g_free(text);
   }
   
@@ -385,7 +396,7 @@
                               text,
                               &transition->trigger_text_pos,
                               ALIGN_CENTER,
-                              &color_black); /* TODO, allow other colors */
+                              &transition->text_color);
     g_free(text);
   }
   



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]