[glabels/vala] Track raw requested size of barcodes separate from actual size.



commit 4a927adfd0ac4ed9d4bff4742851100643a8a4f4
Author: Jim Evins <evins snaught com>
Date:   Tue Sep 18 20:40:44 2012 -0400

    Track raw requested size of barcodes separate from actual size.

 glabels/label_object_barcode.vala |   52 +++++++++++++++++++++++++-----------
 glabels/xml_label.vala            |    4 +-
 2 files changed, 38 insertions(+), 18 deletions(-)
---
diff --git a/glabels/label_object_barcode.vala b/glabels/label_object_barcode.vala
index c56a153..2be1716 100644
--- a/glabels/label_object_barcode.vala
+++ b/glabels/label_object_barcode.vala
@@ -43,23 +43,43 @@ namespace glabels
 
 
 		/**
+		 * Raw width of bounding box
+		 */
+		public double w_raw
+		{
+			get { return _w_raw; }
+		}
+		private double _w_raw;
+
+
+		/**
+		 * Raw height of bounding box
+		 */
+		public double h_raw
+		{
+			get { return _h_raw; }
+		}
+		private double _h_raw;
+
+
+		/**
 		 * Width of bounding box
 		 */
 		public override double w
 		{
-			get { return _w; }
+			get { return _w_actual; }
 
 			set
 			{
-				if ( _w != value )
+				if ( _w_raw != value )
 				{
-					_w = value;
+					_w_raw = value;
 					update_cached_barcode();
 					changed();
 				}
 			}
 		}
-		private double _w;
+		private double _w_actual;
 
 
 		/**
@@ -67,19 +87,19 @@ namespace glabels
 		 */
 		public override double h
 		{
-			get { return _h; }
+			get { return _h_actual; }
 
 			set
 			{
-				if ( _h != value )
+				if ( _h_raw != value )
 				{
-					_h = value;
+					_h_raw = value;
 					update_cached_barcode();
 					changed();
 				}
 			}
 		}
-		private double _h;
+		private double _h_actual;
 
 
 		/**
@@ -397,32 +417,32 @@ namespace glabels
 				data = bc_data_node.expand( null );
 			}
 
-			cached_bc = glbarcode.Factory.create_barcode( bc_type, bc_text_flag, bc_checksum_flag, w, h, data );
+			cached_bc = glbarcode.Factory.create_barcode( bc_type, bc_text_flag, bc_checksum_flag, _w_raw, _h_raw, data );
 
 			if ( (cached_bc == null) || !cached_bc.is_data_valid )
 			{
 				/* Try again with default digits, but don't save -- just extract size. */
 				data = _bc_style.get_example_digits( bc_format_digits );
 
-				glbarcode.Barcode bc = glbarcode.Factory.create_barcode( bc_type, bc_text_flag, bc_checksum_flag, w, h, data );
+				glbarcode.Barcode bc = glbarcode.Factory.create_barcode( bc_type, bc_text_flag, bc_checksum_flag, _w_raw, _h_raw, data );
 
 				if ( bc != null )
 				{
-					w = bc.w;
-					h = bc.h;
+					_w_actual = bc.w;
+					_h_actual = bc.h;
 				}
 				else
 				{
 					/* If we still can't render, just set a default size. */
-					w = 144;
-					h = 72;
+					_w_actual = 144;
+					_h_actual = 72;
 				}
 
 			}
 			else
 			{
-				w = cached_bc.w;
-				h = cached_bc.h;
+				_w_actual = cached_bc.w;
+				_h_actual = cached_bc.h;
 			}
 
 			if ( !_bc_style.can_text )
diff --git a/glabels/xml_label.vala b/glabels/xml_label.vala
index b81f26f..51635b0 100644
--- a/glabels/xml_label.vala
+++ b/glabels/xml_label.vala
@@ -936,8 +936,8 @@ namespace glabels
 			XmlUtil.set_prop_length( node, "y", object.y0 );
 
 			/* size attrs */
-			XmlUtil.set_prop_length( node, "w", object.w );
-			XmlUtil.set_prop_length( node, "h", object.h );
+			XmlUtil.set_prop_length( node, "w", object.w_raw );
+			XmlUtil.set_prop_length( node, "h", object.h_raw );
 
 			/* style attrs */
 			if ( object.bc_type.contains( ":" ) )



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