From 1e2a5ab9232f284bda98dccaedb6016d6e5f2857 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 26 Jul 2008 02:28:26 +0000 Subject: [PATCH] 2008-07-25 Jim Evins * 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 | 6 ++++++ glabels2/src/object-editor-size-page.c | 21 ++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 543cb073..14857f7c 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,9 @@ +2008-07-25 Jim Evins + + * 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 * configure.in: diff --git a/glabels2/src/object-editor-size-page.c b/glabels2/src/object-editor-size-page.c index 58fbe5fa..58cec074 100644 --- a/glabels2/src/object-editor-size-page.c +++ b/glabels2/src/object-editor-size-page.c @@ -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; -- 2.39.5