dia r4108 - in trunk: . objects/custom



Author: hans
Date: Sun Aug 10 10:43:42 2008
New Revision: 4108
URL: http://svn.gnome.org/viewvc/dia?rev=4108&view=rev

Log:
2008-08-10  Hans Breuer  <hans breuer org>

	* objects/custom/shape_info.[hc] objects/custom/custom_object.c : 
	don't normalize ShapeInfo::default_(width|height) to points; everything
	else is in cm. Also some fomatting/coding style issues.
	


Modified:
   trunk/ChangeLog
   trunk/objects/custom/custom_object.c
   trunk/objects/custom/shape_info.c
   trunk/objects/custom/shape_info.h

Modified: trunk/objects/custom/custom_object.c
==============================================================================
--- trunk/objects/custom/custom_object.c	(original)
+++ trunk/objects/custom/custom_object.c	Sun Aug 10 10:43:42 2008
@@ -425,8 +425,7 @@
     real h_scale = info->default_height / svg_height;
     real v_scale = info->default_width / svg_width;
     
-    subshape->default_scale = (v_scale > h_scale ? h_scale : v_scale) /
-                                   units[prefs_get_length_unit()].factor;
+    subshape->default_scale = (v_scale > h_scale ? h_scale : v_scale);
   }
   
   scale = custom->subscale * subshape->default_scale;
@@ -688,9 +687,7 @@
 custom_adjust_scale(Custom *custom, Handle *handle,
 		   Point *to, ConnectionPoint *cp,
 		   HandleMoveReason reason, ModifierKeys modifiers)
-{
-#define IS_MODIFIER_PRESSED(m) ((modifiers&(m)) != 0)
-  
+{  
   static int uniform_scale = FALSE;
   static Point orig_pos;
 
@@ -703,11 +700,13 @@
       orig_pos.y = to->y;
     }
     
-    if (!uniform_scale && IS_MODIFIER_PRESSED(MODIFIER_SHIFT)) {
-      custom->old_subscale = MAX(custom->subscale, 0.0);
+    if ((modifiers & MODIFIER_SHIFT) != 0) {
+      if (!uniform_scale) /* transition */
+        custom->old_subscale = MAX(custom->subscale, 0.0);
+      uniform_scale = TRUE;
+    } else {
+      uniform_scale = FALSE;
     }
-    
-    uniform_scale = IS_MODIFIER_PRESSED(MODIFIER_SHIFT);
 
     delta_max = (to->x - orig_pos.x);
     
@@ -726,7 +725,6 @@
     if( custom->subscale < SUBSCALE_MININUM_SCALE )
       custom->subscale = SUBSCALE_MININUM_SCALE;
 
-#undef IS_MODIFIER_PRESSED
     break;
   case HANDLE_MOVE_USER_FINAL:
     uniform_scale = FALSE;
@@ -851,14 +849,6 @@
                           &cur_line, &cur_dash, &cur_caps, &cur_join, &cur_style);
 
   if (custom->info->has_text) {
-    /*Rectangle tb;
-    
-    if (renderer->is_interactive) {
-    transform_rect(custom, &custom->info->text_bounds, &tb);
-    p1.x = tb.left;  p1.y = tb.top;
-    p2.x = tb.right; p2.y = tb.bottom;
-    renderer_ops->draw_rect(renderer, &p1, &p2, &custom->border_color);
-    }*/
     text_draw(custom->text, renderer);
   }
 }
@@ -1334,6 +1324,7 @@
     switch(el->type) {
     case GE_SUBSHAPE :
       /* if the subshapes leave traces in the diagram here is the place to fix it --hb */
+      continue;
       break;
     case GE_LINE: {
       LineBBExtras extra;
@@ -1465,6 +1456,9 @@
       /*text_calc_boundingbox(el->text.object,&rect); */
       rect = el->text.text_bounds;
       break;
+    default :
+      g_assert_not_reached();
+      continue;
     }
     rectangle_union(&obj->bounding_box,&rect);
   }
@@ -1547,10 +1541,8 @@
 
   elem->corner = *startpoint;
 
-  elem->width = shape_info_get_default_width(info) / 
-                         units[prefs_get_length_unit()].factor;
-  elem->height = shape_info_get_default_height(info) /
-                         units[prefs_get_length_unit()].factor;
+  elem->width = shape_info_get_default_width(info);
+  elem->height = shape_info_get_default_height(info);
 
   custom->info = info;
   
@@ -1639,7 +1631,7 @@
   newcustom->info = custom->info;
 
   newcustom->padding = custom->padding;
-  newcustom->current_subshape = custom->current_subshape;
+  newcustom->current_subshape = NULL; /* it's temporary state, don't copy from wrong object */
   newcustom->old_subscale = custom->old_subscale;
   newcustom->subscale = custom->subscale;
 

Modified: trunk/objects/custom/shape_info.c
==============================================================================
--- trunk/objects/custom/shape_info.c	(original)
+++ trunk/objects/custom/shape_info.c	Sun Aug 10 10:43:42 2008
@@ -133,7 +133,7 @@
 shape_info_get_default_width(ShapeInfo *info)
 {
   if (info->default_width == 0.0)
-    info->default_width = DEFAULT_WIDTH * units[prefs_get_length_unit()].factor;
+    info->default_width = DEFAULT_WIDTH;
   
   return( info->default_width );
 }
@@ -142,7 +142,7 @@
 shape_info_get_default_height(ShapeInfo *info)
 {
   if (info->default_height == 0.0)
-    info->default_height = DEFAULT_HEIGHT * units[prefs_get_length_unit()].factor;
+    info->default_height = DEFAULT_HEIGHT;
   
   return( info->default_height );
 }
@@ -460,16 +460,11 @@
           /* add elements from the group element, but make it a subshape */
         GraphicElementSubShape *subshape = g_new0(GraphicElementSubShape, 1);
         ShapeInfo* tmpinfo = g_new0(ShapeInfo, 1);
-        DiaSvgStyle tmp_s = {
-                1.0, DIA_SVG_COLOUR_FOREGROUND, 
-                DIA_SVG_COLOUR_NONE,
-                DIA_SVG_LINECAPS_DEFAULT, 
-                DIA_SVG_LINEJOIN_DEFAULT,
-                DIA_SVG_LINESTYLE_DEFAULT, 1.0
-        };
+        DiaSvgStyle tmp_s;
         xmlChar *v_anchor_attr = xmlGetProp(node, (const xmlChar*)"v_anchor");
         xmlChar *h_anchor_attr = xmlGetProp(node, (const xmlChar*)"h_anchor");
       
+        dia_svg_style_init (&tmp_s, style);
         parse_svg_node(tmpinfo, node, svg_ns, &tmp_s, filename);
         
         tmpinfo->shape_bounds.top = DBL_MAX;
@@ -845,8 +840,7 @@
       dia_svg_parse_style(node, &s, -1);
       parse_svg_node(info, node, svg_ns, &s, filename);
       update_bounds(info);
-    }
-	else if (!xmlStrcmp(node->name, (const xmlChar *)"ext_attributes")) {
+    } else if (!xmlStrcmp(node->name, (const xmlChar *)"ext_attributes")) {
       ext_node = node;
     }
   }

Modified: trunk/objects/custom/shape_info.h
==============================================================================
--- trunk/objects/custom/shape_info.h	(original)
+++ trunk/objects/custom/shape_info.h	Sun Aug 10 10:43:42 2008
@@ -184,8 +184,9 @@
   ShapeAspectType aspect_type;
   real aspect_min, aspect_max;
 
-  real default_width;  /* default_width normalized in points */
-  real default_height; /* default_height normalized in points */
+  real default_width; /* unit cm as everything else internally in Dia */
+  real default_height;
+
 
   GList *display_list;
   



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