]> git.sur5r.net Git - glabels/commitdiff
2008-07-25 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Sat, 26 Jul 2008 02:28:26 +0000 (02:28 +0000)
committerJim Evins <evins@snaught.com>
Sat, 26 Jul 2008 02:28:26 +0000 (02:28 +0000)
* src/object-editor-size-page.c: (size_reset_cb),
(gl_object_editor_set_max_size):
Bug #1993550.  Set size limits based on longest side of label.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/branches/glabels-2_2@775 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/ChangeLog
glabels2/src/object-editor-size-page.c

index 543cb0732904b6ea3b9326f9f93d4201a82995c8..14857f7c27bb69a54245f33b02af2b7bb4d2fb73 100644 (file)
@@ -1,3 +1,9 @@
+2008-07-25  Jim Evins  <evins@snaught.com>
+
+       * src/object-editor-size-page.c: (size_reset_cb),
+       (gl_object_editor_set_max_size):
+               Bug #1993550.  Set size limits based on longest side of label.
+
 2008-07-19  Jim Evins  <evins@snaught.com>
 
        * configure.in:
index 58fbe5fabe2cdc1aebfbd9ddc55160caf23a105e..58cec07498852ebe583ba049defcf13d05988eaf 100644 (file)
@@ -236,7 +236,7 @@ static void
 size_reset_cb (glObjectEditor *editor)
 {
        gdouble w_base, h_base;
-       gdouble w_max, h_max;
+       gdouble w_max, h_max, wh_max;
        gdouble aspect_ratio;
 
         if (editor->priv->stop_signals) return;
@@ -250,18 +250,19 @@ size_reset_cb (glObjectEditor *editor)
 
        w_max = editor->priv->w_max;
        h_max = editor->priv->h_max;
+        wh_max = MAX( w_max, h_max );
 
-       if ( (w_base > w_max) || (h_base > h_max) ) {
+       if ( (w_base > wh_max) || (h_base > wh_max) ) {
 
                aspect_ratio = h_base / w_base;
 
-               if ( h_max > w_max*aspect_ratio ) {
-                       w_base = w_max;
-                       h_base = w_max * aspect_ratio;
+               if ( aspect_ratio < 1.0 ) {
+                       w_base = wh_max;
+                       h_base = wh_max * aspect_ratio;
 
                } else {
-                       w_base = h_max / aspect_ratio;
-                       h_base = h_max;
+                       w_base = wh_max / aspect_ratio;
+                       h_base = wh_max;
                }
        }
 
@@ -325,6 +326,7 @@ gl_object_editor_set_max_size (glObjectEditor      *editor,
                               gdouble              h_max)
 {
        gdouble tmp;
+        gdouble wh_max;
 
        gl_debug (DEBUG_EDITOR, "START");
 
@@ -341,16 +343,17 @@ gl_object_editor_set_max_size (glObjectEditor      *editor,
                 gl_debug (DEBUG_EDITOR, "internal w_max,h_max = %g, %g", w_max, h_max);
                 w_max *= editor->priv->units_per_point;
                 h_max *= editor->priv->units_per_point;
+                wh_max = MAX( w_max, h_max );
                 gl_debug (DEBUG_EDITOR, "display w_max,h_max = %g, %g", w_max, h_max);
 
                 /* Set widget values */
                 tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->size_w_spin));
                 gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->size_w_spin),
-                                           0.0, 2.0*w_max);
+                                           0.0, 2.0*wh_max);
                 gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->size_w_spin), tmp);
                 tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->size_h_spin));
                 gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->size_h_spin),
-                                           0.0, 2.0*h_max);
+                                           0.0, 2.0*wh_max);
                 gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->size_h_spin), tmp);
 
                 editor->priv->stop_signals = FALSE;