Commit 645a1ab6 authored by Simon Budig's avatar Simon Budig Committed by Simon Budig

Store the zoom factor as float, not as a ratio.

2004-01-29  Simon Budig  <simon@gimp.org>

	* app/display/gimpdisplayshell.[ch]: Store the zoom factor as
	float, not as a ratio.

	* app/display/gimpdisplayshell-scale.[ch]: change the API to
	expose the Float instead a weirdly encoded integer. Implement
	functions to get a ratio from the scale factor. Implement a set
	as presets as discussed on the mailinglist. Changed Zoom->Other
	dialog to enable entering a float.

	* app/display/gimpdisplayshell-title.c
	* app/display/gimpnavigationview.c
	* app/gui/image-menu.c
	* app/gui/info-window.c
	* app/tools/gimpmagnifytool.c: changed accordingly.

	* app/core/gimp.[ch]
	* app/display/gimpdisplay.[ch]
	* app/gui/gui-vtable.c
	* app/widgets/widgets-enums.h: Made the various display-creating
	functions accept a float for the scale. Introduce a new
	GimpZoomType: GIMP_ZOOM_TO. Generally adjust the API to use
	floats instead of weird integers.

	* app/core/gimp-edit.c
	* app/core/gimptemplate.c
	* app/display/gimpdisplayshell-callbacks.c
	* app/file/file-open.c
	* app/gui/image-commands.c
	* app/gui/view-commands.[ch]
	* tools/pdbgen/pdb/display.pdb
	* app/widgets/gimpimageview.c
	* app/widgets/gimptoolbox-dnd.c: changed accordingly

	* app/pdb/display_cmds.c: regenerated
parent eca5c99e
2004-01-29 Simon Budig <simon@gimp.org>
* app/display/gimpdisplayshell.[ch]: Store the zoom factor as
float, not as a ratio.
* app/display/gimpdisplayshell-scale.[ch]: change the API to
expose the Float instead a weirdly encoded integer. Implement
functions to get a ratio from the scale factor. Implement a set
as presets as discussed on the mailinglist. Changed Zoom->Other
dialog to enable entering a float.
* app/display/gimpdisplayshell-title.c
* app/display/gimpnavigationview.c
* app/gui/image-menu.c
* app/gui/info-window.c
* app/tools/gimpmagnifytool.c: changed accordingly.
* app/core/gimp.[ch]
* app/display/gimpdisplay.[ch]
* app/gui/gui-vtable.c
* app/widgets/widgets-enums.h: Made the various display-creating
functions accept a float for the scale. Introduce a new
GimpZoomType: GIMP_ZOOM_TO. Generally adjust the API to use
floats instead of weird integers.
* app/core/gimp-edit.c
* app/core/gimptemplate.c
* app/display/gimpdisplayshell-callbacks.c
* app/file/file-open.c
* app/gui/image-commands.c
* app/gui/view-commands.[ch]
* tools/pdbgen/pdb/display.pdb
* app/widgets/gimpimageview.c
* app/widgets/gimptoolbox-dnd.c: changed accordingly
* app/pdb/display_cmds.c: regenerated
2004-01-29 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontext.[ch]: removed the last artefact of context
......@@ -279,7 +279,7 @@ image_duplicate_cmd_callback (GtkWidget *widget,
new_gimage = gimp_image_duplicate (gimage);
gimp_create_display (new_gimage->gimp, new_gimage, 0x0101);
gimp_create_display (new_gimage->gimp, new_gimage, 1.0);
g_object_unref (new_gimage);
}
......
......@@ -68,7 +68,8 @@ view_zoom_out_cmd_callback (GtkWidget *widget,
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (gdisp->shell), GIMP_ZOOM_OUT);
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (gdisp->shell),
GIMP_ZOOM_OUT, 0.0);
}
void
......@@ -78,7 +79,8 @@ view_zoom_in_cmd_callback (GtkWidget *widget,
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (gdisp->shell), GIMP_ZOOM_IN);
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (gdisp->shell),
GIMP_ZOOM_IN, 0.0);
}
void
......@@ -94,12 +96,10 @@ view_zoom_fit_cmd_callback (GtkWidget *widget,
void
view_zoom_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
guint scale)
{
GimpDisplay *gdisp;
GimpDisplayShell *shell;
guchar scalesrc;
guchar scaledest;
return_if_no_display (gdisp, data);
if (! GTK_CHECK_MENU_ITEM (widget)->active)
......@@ -107,11 +107,8 @@ view_zoom_cmd_callback (GtkWidget *widget,
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
scalesrc = CLAMP (action % 100, 1, 0xFF);
scaledest = CLAMP (action / 100, 1, 0xFF);
if (scalesrc != SCALESRC (shell) || scaledest != SCALEDEST (shell))
gimp_display_shell_scale (shell, action);
if (fabs (scale - shell->scale) > 0.0001)
gimp_display_shell_scale (shell, GIMP_ZOOM_TO, (gdouble) scale / 10000);
}
void
......
......@@ -28,7 +28,7 @@ void view_zoom_fit_cmd_callback (GtkWidget *widget,
gpointer data);
void view_zoom_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
guint scale);
void view_zoom_other_cmd_callback (GtkWidget *widget,
gpointer data);
void view_dot_for_dot_cmd_callback (GtkWidget *widget,
......
......@@ -237,7 +237,7 @@ gimp_edit_paste_as_new (Gimp *gimp,
gimp_image_undo_enable (gimage);
gimp_create_display (gimp, gimage, 0x0101);
gimp_create_display (gimp, gimage, 1.0);
g_object_unref (gimage);
return gimage;
......
......@@ -1217,8 +1217,8 @@ gimp_create_image (Gimp *gimp,
GimpObject *
gimp_create_display (Gimp *gimp,
GimpImage *gimage,
guint scale)
GimpImage *gimage,
gdouble scale)
{
GimpObject *display = NULL;
......
......@@ -26,7 +26,7 @@
typedef void (* GimpThreadEnterFunc) (Gimp *gimp);
typedef void (* GimpThreadLeaveFunc) (Gimp *gimp);
typedef GimpObject * (* GimpCreateDisplayFunc) (GimpImage *gimage,
guint scale);
gdouble scale);
typedef void (* GimpSetBusyFunc) (Gimp *gimp);
typedef void (* GimpUnsetBusyFunc) (Gimp *gimp);
typedef void (* GimpMessageFunc) (Gimp *gimp,
......@@ -280,8 +280,8 @@ GimpImage * gimp_create_image (Gimp *gimp,
gboolean attach_comment);
GimpObject * gimp_create_display (Gimp *gimp,
GimpImage *gimage,
guint scale);
GimpImage *gimage,
gdouble scale);
GimpContext * gimp_get_standard_context (Gimp *gimp);
......
......@@ -201,7 +201,7 @@ gimp_display_get_property (GObject *object,
GimpDisplay *
gimp_display_new (GimpImage *gimage,
guint scale,
gdouble scale,
GimpMenuFactory *menu_factory,
GimpItemFactory *popup_factory)
{
......
......@@ -74,7 +74,7 @@ struct _GimpDisplayClass
GType gimp_display_get_type (void) G_GNUC_CONST;
GimpDisplay * gimp_display_new (GimpImage *gimage,
guint scale,
gdouble scale,
GimpMenuFactory *menu_factory,
GimpItemFactory *popup_factory);
void gimp_display_delete (GimpDisplay *gdisp);
......
......@@ -442,7 +442,7 @@ gimp_template_create_image (Gimp *gimp,
gimp_image_undo_enable (gimage);
gimp_image_clean_all (gimage);
gimp_create_display (gimp, gimage, 0x0101);
gimp_create_display (gimp, gimage, 1.0);
g_object_unref (gimage);
......
......@@ -521,8 +521,7 @@ info_window_update (GimpDisplay *gdisp)
res_unit == GIMP_UNIT_INCH ? _("dpi") : format_buf);
/* user zoom ratio */
g_snprintf (iwd->scale_str, MAX_BUF, "%d:%d",
SCALEDEST (shell), SCALESRC (shell));
g_snprintf (iwd->scale_str, MAX_BUF, "%.2f", shell->scale * 100);
/* number of layers */
g_snprintf (iwd->num_layers_str, MAX_BUF, "%d",
......
......@@ -201,7 +201,7 @@ gimp_display_get_property (GObject *object,
GimpDisplay *
gimp_display_new (GimpImage *gimage,
guint scale,
gdouble scale,
GimpMenuFactory *menu_factory,
GimpItemFactory *popup_factory)
{
......
......@@ -74,7 +74,7 @@ struct _GimpDisplayClass
GType gimp_display_get_type (void) G_GNUC_CONST;
GimpDisplay * gimp_display_new (GimpImage *gimage,
guint scale,
gdouble scale,
GimpMenuFactory *menu_factory,
GimpItemFactory *popup_factory);
void gimp_display_delete (GimpDisplay *gdisp);
......
......@@ -823,11 +823,11 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
switch (direction)
{
case GDK_SCROLL_UP:
gimp_display_shell_scale (shell, GIMP_ZOOM_IN);
gimp_display_shell_scale (shell, GIMP_ZOOM_IN, 0.0);
break;
case GDK_SCROLL_DOWN:
gimp_display_shell_scale (shell, GIMP_ZOOM_OUT);
gimp_display_shell_scale (shell, GIMP_ZOOM_OUT, 0.0);
break;
default:
......
......@@ -210,8 +210,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->popup_factory = NULL;
shell->qmask_factory = NULL;
shell->scale = 0x101;
shell->other_scale = 0;
shell->scale = 1.0;
shell->other_scale = 0.0;
shell->dot_for_dot = TRUE;
shell->offset_x = 0;
......@@ -486,7 +486,7 @@ gimp_display_shell_real_scaled (GimpDisplayShell *shell)
GtkWidget *
gimp_display_shell_new (GimpDisplay *gdisp,
guint scale,
gdouble scale,
GimpMenuFactory *menu_factory,
GimpItemFactory *popup_factory)
{
......@@ -504,7 +504,7 @@ gimp_display_shell_new (GimpDisplay *gdisp,
gint image_width, image_height;
gint n_width, n_height;
gint s_width, s_height;
gint scalesrc, scaledest;
gdouble new_scale;
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), NULL);
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
......@@ -548,33 +548,31 @@ gimp_display_shell_new (GimpDisplay *gdisp,
s_width = gdk_screen_get_width (screen) * 0.75;
s_height = gdk_screen_get_height (screen) * 0.75;
scalesrc = SCALESRC (shell);
scaledest = SCALEDEST (shell);
n_width = SCALEX (shell, image_width);
n_height = SCALEX (shell, image_height);
n_height = SCALEY (shell, image_height);
if (config->initial_zoom_to_fit)
{
/* Limit to the size of the screen... */
while (n_width > s_width || n_height > s_height)
if (n_width > s_width || n_height > s_height)
{
if (scaledest > 1)
scaledest--;
else
if (scalesrc < 0xFF)
scalesrc++;
n_width = (image_width *
(scaledest * SCREEN_XRES (shell)) /
(scalesrc * gdisp->gimage->xresolution));
n_height = (image_height *
(scaledest * SCREEN_XRES (shell)) /
(scalesrc * gdisp->gimage->xresolution));
if (scaledest == 1 && scalesrc == 0xFF)
break;
new_scale = shell->scale * MIN (((gdouble) s_height) / n_height,
((gdouble) s_width) / n_width);
new_scale = gimp_display_shell_scale_zoom_step (GIMP_ZOOM_OUT,
new_scale);
/* since zooming out might skip a zoom step we zoom in again
* and test if we are small enough. */
shell->scale = gimp_display_shell_scale_zoom_step (GIMP_ZOOM_IN,
new_scale);
if (SCALEX (shell, image_width) > s_width ||
SCALEY (shell, image_height) > s_height)
shell->scale = new_scale;
n_width = SCALEX (shell, image_width);
n_height = SCALEY (shell, image_height);
}
}
else
......@@ -589,7 +587,6 @@ gimp_display_shell_new (GimpDisplay *gdisp,
n_height = s_height;
}
shell->scale = (scaledest << 8) + scalesrc;
shell->menubar_factory = gimp_menu_factory_menu_new (menu_factory,
"<Image>",
......
......@@ -33,15 +33,11 @@
#define SCREEN_YRES(s) (s->dot_for_dot ? \
s->gdisp->gimage->yresolution : s->monitor_yres)
/* unpacking the user scale level (char) */
#define SCALESRC(s) (s->scale & 0x00ff)
#define SCALEDEST(s) (s->scale >> 8)
/* calculate scale factors (double) */
#define SCALEFACTOR_X(s) ((SCALEDEST(s) * SCREEN_XRES(s)) / \
(SCALESRC(s) * s->gdisp->gimage->xresolution))
#define SCALEFACTOR_Y(s) ((SCALEDEST(s) * SCREEN_YRES(s)) / \
(SCALESRC(s) * s->gdisp->gimage->yresolution))
#define SCALEFACTOR_X(s) (s->scale * SCREEN_XRES(s) / \
s->gdisp->gimage->xresolution)
#define SCALEFACTOR_Y(s) (s->scale * SCREEN_YRES(s) / \
s->gdisp->gimage->yresolution)
/* scale values */
#define SCALEX(s,x) ((gint) (x * SCALEFACTOR_X(s)))
......@@ -78,8 +74,8 @@ struct _GimpDisplayShell
gdouble monitor_xres;
gdouble monitor_yres;
gint scale; /* scale factor from original raw image */
gint other_scale; /* scale factor entered in Zoom->Other */
gdouble scale; /* scale factor from original raw image */
gdouble other_scale; /* scale factor entered in Zoom->Other */
gboolean dot_for_dot; /* is monitor resolution being ignored? */
gint offset_x; /* offset of display image into raw image */
......@@ -174,7 +170,7 @@ struct _GimpDisplayShellClass
GType gimp_display_shell_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_display_shell_new (GimpDisplay *gdisp,
guint scale,
gdouble scale,
GimpMenuFactory *menu_factory,
GimpItemFactory *popup_factory);
......
......@@ -50,8 +50,9 @@ typedef struct _ScaleDialogData ScaleDialogData;
struct _ScaleDialogData
{
GimpDisplayShell *shell;
GtkObject *src_adj;
GtkObject *dest_adj;
GtkObject *scale_adj;
GtkObject *num_adj;
GtkObject *denom_adj;
};
......@@ -60,6 +61,8 @@ struct _ScaleDialogData
static void gimp_display_shell_scale_dialog_response (GtkWidget *widget,
gint response_id,
ScaleDialogData *dialog);
static void update_zoom_values (GtkAdjustment *adj,
ScaleDialogData *dialog);
static gdouble img2real (GimpDisplayShell *shell,
gboolean xdir,
gdouble a);
......@@ -67,51 +70,82 @@ static gdouble img2real (GimpDisplayShell *shell,
/* public functions */
void
gimp_display_shell_scale_zoom_fraction (GimpZoomType zoom_type,
gint *scalesrc,
gint *scaledest)
gdouble
gimp_display_shell_scale_zoom_step (GimpZoomType zoom_type,
gdouble scale)
{
gdouble ratio;
g_return_if_fail (scalesrc != NULL);
g_return_if_fail (scaledest != NULL);
ratio = (double) *scaledest/ *scalesrc;
gint i, n_presets;
gdouble new_scale;
/* This table is constructed to have fractions, that approximate
* sqrt(2)^k. This gives a smooth feeling regardless of the starting
* zoom level.
*
* Zooming in/out always jumps to a zoom step from the list above.
* However, we try to guarantee a certain size of the step, to
* avoid silly jumps from 101% to 100%.
* The factor 1.1 is chosen a bit arbitrary, but feels better
* than the geometric median of the zoom steps (2^(1/4)).
*/
#define ZOOM_MIN_STEP 1.1
gdouble presets[] = {
1.0 / 256, 1.0 / 180, 1.0 / 128, 1.0 / 90,
1.0 / 64, 1.0 / 45, 1.0 / 32, 1.0 / 23,
1.0 / 16, 1.0 / 11, 1.0 / 8, 2.0 / 11,
1.0 / 4, 1.0 / 3, 1.0 / 2, 2.0 / 3,
1.0,
3.0 / 2, 2.0, 3.0,
4.0, 11.0 / 2, 8.0, 11.0,
16.0, 23.0, 32.0, 45.0,
64.0, 90.0, 128.0, 180.0,
256.0,
};
n_presets = G_N_ELEMENTS (presets);
switch (zoom_type)
{
case GIMP_ZOOM_IN:
ratio *= G_SQRT2;
scale *= ZOOM_MIN_STEP;
new_scale = presets[n_presets-1];
for (i = n_presets - 1; i >= 0 && presets[i] > scale; i--)
new_scale = presets[i];
break;
case GIMP_ZOOM_OUT:
ratio /= G_SQRT2;
scale /= ZOOM_MIN_STEP;
new_scale = presets[0];
for (i = 0; i < n_presets && presets[i] < scale; i++)
new_scale = presets[i];
break;
default:
*scalesrc = CLAMP (zoom_type % 100, 1, 0xFF);
*scaledest = CLAMP (zoom_type / 100, 1, 0xFF);
return;
case GIMP_ZOOM_TO:
new_scale = scale;
break;
}
/* set scalesrc and scaledest to a fraction close to ratio */
gimp_display_shell_scale_calc_fraction (ratio, scalesrc, scaledest);
return CLAMP (new_scale, 1.0/256.0, 256.0);
}
void
gimp_display_shell_scale_calc_fraction (gdouble zoom_factor,
gint *scalesrc,
gint *scaledest)
gimp_display_shell_scale_get_fraction (gdouble zoom_factor,
gint *numerator,
gint *denominator)
{
gint p0, p1, p2;
gint q0, q1, q2;
gdouble remainder, next_cf;
gboolean swapped = FALSE;
g_return_if_fail (scalesrc != NULL);
g_return_if_fail (scaledest != NULL);
g_return_if_fail (numerator != NULL && denominator != NULL);
/* make sure that zooming behaves symmetrically */
if (zoom_factor < 1.0)
......@@ -139,9 +173,9 @@ gimp_display_shell_scale_calc_fraction (gdouble zoom_factor,
p2 = next_cf * p1 + p0;
q2 = next_cf * q1 + q0;
/* Numerator and Denominator are limited by 255 */
/* Numerator and Denominator are limited by 256 */
/* also absurd ratios like 170:171 are excluded */
if (p2 > 255 || q2 > 255 || (p2 > 1 && q2 > 1 && p2 * q2 > 200))
if (p2 > 256 || q2 > 256 || (p2 > 1 && q2 > 1 && p2 * q2 > 200))
break;
/* remember the last two fractions */
......@@ -157,26 +191,26 @@ gimp_display_shell_scale_calc_fraction (gdouble zoom_factor,
/* hard upper and lower bounds for zoom ratio */
if (zoom_factor > 255.0)
if (zoom_factor > 256.0)
{
p1 = 255;
p1 = 256;
q1 = 1;
}
else if (zoom_factor < 1.0 / 255.0)
else if (zoom_factor < 1.0 / 256.0)
{
p1 = 1;
q1 = 255;
q1 = 256;
}
if (swapped)
{
*scalesrc = p1;
*scaledest = q1;
*numerator = q1;
*denominator = p1;
}
else
{
*scalesrc = q1;
*scaledest = p1;
*numerator = p1;
*denominator = q1;
}
}
......@@ -319,35 +353,36 @@ gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
void
gimp_display_shell_scale (GimpDisplayShell *shell,
GimpZoomType zoom_type)
GimpZoomType zoom_type,
gdouble new_scale)
{
GimpDisplayConfig *config;
gint scalesrc, scaledest;
gdouble offset_x, offset_y;
gdouble scale;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
/* user zoom control, so resolution versions not needed -- austin */
scalesrc = SCALESRC (shell);
scaledest = SCALEDEST (shell);
offset_x = shell->offset_x + (shell->disp_width / 2.0);
offset_y = shell->offset_y + (shell->disp_height / 2.0);
offset_x *= ((gdouble) scalesrc / (gdouble) scaledest);
offset_y *= ((gdouble) scalesrc / (gdouble) scaledest);
scale = shell->scale;
offset_x /= scale;
offset_y /= scale;
gimp_display_shell_scale_zoom_fraction (zoom_type, &scalesrc, &scaledest);
if (zoom_type == GIMP_ZOOM_TO)
scale = new_scale;
else
scale = gimp_display_shell_scale_zoom_step (zoom_type, scale);
offset_x *= ((gdouble) scaledest / (gdouble) scalesrc);
offset_y *= ((gdouble) scaledest / (gdouble) scalesrc);
offset_x *= scale;
offset_y *= scale;
config = GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config);
gimp_display_shell_scale_by_values (shell,
(scaledest << 8) + scalesrc,
(offset_x - (shell->disp_width / 2)),
(offset_y - (shell->disp_height / 2)),
gimp_display_shell_scale_by_values (shell, scale,
offset_x - (shell->disp_width / 2),
offset_y - (shell->disp_height / 2),
config->resize_windows_on_zoom);
}
......@@ -358,9 +393,6 @@ gimp_display_shell_scale_fit (GimpDisplayShell *shell)
gint image_width;
gint image_height;
gdouble zoom_factor;
gint scalesrc;
gint scaledest;
gint a, b, gcd;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
......@@ -380,42 +412,12 @@ gimp_display_shell_scale_fit (GimpDisplayShell *shell)
zoom_factor = MIN ((gdouble) shell->disp_width / (gdouble) image_width,
(gdouble) shell->disp_height / (gdouble) image_height);
/* choosing 240 because it has a lot of nice divisors and the
* chance of a nice fraction is bigger */
scalesrc = scaledest = 240;
if (zoom_factor > 1.0)
scalesrc = CLAMP (ceil (1.0 / zoom_factor * 240.0), 1, 240);
else
scaledest = CLAMP (floor (zoom_factor * 240.0), 1, 240);
/* determine gcd to shorten the fraction */
a = MAX (scalesrc, scaledest);
b = MIN (scalesrc, scaledest);
gcd = b;
while (a % b != 0)
{
gcd = a % b;
a = b;
b = gcd;
}
scalesrc /= gcd;
scaledest /= gcd;
gimp_display_shell_scale_by_values (shell,
(scaledest << 8) + scalesrc,
0,
0,
FALSE);
gimp_display_shell_scale (shell, GIMP_ZOOM_TO, zoom_factor);
}
void
gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
gint scale,
gdouble scale,
gint offset_x,
gint offset_y,
gboolean resize_window)
......@@ -480,8 +482,10 @@ gimp_display_shell_scale_dialog (GimpDisplayShell *shell)
{
ScaleDialogData *data;
GtkWidget *hbox;
GtkWidget *table;
GtkWidget *spin;
GtkWidget *label;
gint num, denom, row;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
......@@ -521,21 +525,29 @@ gimp_display_shell_scale_dialog (GimpDisplayShell *shell)
G_CALLBACK (gimp_display_shell_scale_dialog_response),
data);
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (shell->scale_dialog)->vbox),
table);
gtk_widget_show (table);
row = 0;
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (shell->scale_dialog)->vbox),
hbox);
gtk_widget_show (hbox);
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("Zoom Ratio:"), 1.0, 0.5,
hbox, 1, FALSE);
label = gtk_label_new (_("Zoom Ratio:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
if (fabs (shell->other_scale) <= 0.0001)
shell->other_scale = shell->scale; /* other_scale not yet initialized */
if ((shell->other_scale & 0xFFFF) == 0)
shell->other_scale = shell->scale;
gimp_display_shell_scale_get_fraction (fabs (shell->other_scale),
&num, &denom);
spin = gimp_spin_button_new (&data->dest_adj,
(shell->other_scale & 0xFF00) >> 8, 1, 0xFF,
spin = gimp_spin_button_new (&data->num_adj,
num, 1, 256,
1, 8, 1, 1, 0);
gtk_box_pack_start (GTK_BOX (hbox), spin, TRUE, TRUE, 0);
gtk_widget_show (spin);
......@@ -544,12 +556,27 @@ gimp_display_shell_scale_dialog (GimpDisplayShell *shell)
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
spin = gimp_spin_button_new (&data->src_adj,
(shell->other_scale & 0xFF), 1, 0xFF,
spin = gimp_spin_button_new (&data->denom_adj,
denom, 1, 256,
1, 8, 1, 1, 0);
gtk_box_pack_start (GTK_BOX (hbox), spin, TRUE, TRUE, 0);
gtk_widget_show (spin);
spin = gimp_spin_button_new (&data->scale_adj,
fabs (shell->other_scale) * 100,
100.0 / 256.0, 25600.0,
10, 50, 0, 1, 2);
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("Zoom:"), 1.0, 0.5,
spin, 1, FALSE);
g_signal_connect (data->scale_adj, "value-changed",
G_CALLBACK (update_zoom_values), data);
g_signal_connect (data->num_adj, "value-changed",
G_CALLBACK (update_zoom_values), data);
g_signal_connect (data->denom_adj, "value-changed",
G_CALLBACK (update_zoom_values), data);
gtk_widget_show (shell->scale_dialog);
}
......@@ -563,13 +590,11 @@ gimp_display_shell_scale_dialog_response (GtkWidget *widget,
{