some more code cleanup.
2003-05-05 Michael Natterer <mitch@gimp.org> * app/display/gimpdisplayshell-scale.c: some more code cleanup.
This commit is contained in:

committed by
Michael Natterer

parent
1204865d04
commit
f1d317a302
@ -1,3 +1,7 @@
|
|||||||
|
2003-05-05 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/display/gimpdisplayshell-scale.c: some more code cleanup.
|
||||||
|
|
||||||
2003-05-05 Michael Natterer <mitch@gimp.org>
|
2003-05-05 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/display/gimpdisplayshell-scale.[ch]
|
* app/display/gimpdisplayshell-scale.[ch]
|
||||||
|
@ -48,16 +48,26 @@
|
|||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _ScaleDialogData ScaleDialogData;
|
||||||
|
|
||||||
|
struct _ScaleDialogData
|
||||||
|
{
|
||||||
|
GimpDisplayShell *shell;
|
||||||
|
GtkObject *src_adj;
|
||||||
|
GtkObject *dest_adj;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
static void gimp_display_shell_scale_dialog_ok (GtkWidget *widget,
|
static void gimp_display_shell_scale_dialog_ok (GtkWidget *widget,
|
||||||
gpointer data);
|
ScaleDialogData *dialog);
|
||||||
static void gimp_display_shell_scale_dialog_cancel (GtkWidget *widget,
|
static void gimp_display_shell_scale_dialog_cancel (GtkWidget *widget,
|
||||||
gpointer data);
|
ScaleDialogData *dialog);
|
||||||
|
|
||||||
static gdouble img2real (GimpDisplayShell *shell,
|
static gdouble img2real (GimpDisplayShell *shell,
|
||||||
gboolean xdir,
|
gboolean xdir,
|
||||||
gdouble a);
|
gdouble a);
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
@ -319,7 +329,7 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
|
|||||||
scalesrc = SCALESRC (shell);
|
scalesrc = SCALESRC (shell);
|
||||||
scaledest = SCALEDEST (shell);
|
scaledest = SCALEDEST (shell);
|
||||||
|
|
||||||
offset_x = shell->offset_x + (shell->disp_width / 2.0);
|
offset_x = shell->offset_x + (shell->disp_width / 2.0);
|
||||||
offset_y = shell->offset_y + (shell->disp_height / 2.0);
|
offset_y = shell->offset_y + (shell->disp_height / 2.0);
|
||||||
|
|
||||||
offset_x *= ((gdouble) scalesrc / (gdouble) scaledest);
|
offset_x *= ((gdouble) scalesrc / (gdouble) scaledest);
|
||||||
@ -345,8 +355,6 @@ gimp_display_shell_scale_fit (GimpDisplayShell *shell)
|
|||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
gint image_width;
|
gint image_width;
|
||||||
gint image_height;
|
gint image_height;
|
||||||
gdouble zoom_x;
|
|
||||||
gdouble zoom_y;
|
|
||||||
gdouble zoom_factor;
|
gdouble zoom_factor;
|
||||||
gint scalesrc;
|
gint scalesrc;
|
||||||
gint scaledest;
|
gint scaledest;
|
||||||
@ -368,13 +376,8 @@ gimp_display_shell_scale_fit (GimpDisplayShell *shell)
|
|||||||
config->monitor_yres / gimage->yresolution);
|
config->monitor_yres / gimage->yresolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
zoom_x = (gdouble) shell->disp_width / (gdouble) image_width;
|
zoom_factor = MIN ((gdouble) shell->disp_width / (gdouble) image_width,
|
||||||
zoom_y = (gdouble) shell->disp_height / (gdouble) image_height;
|
(gdouble) shell->disp_height / (gdouble) image_height);
|
||||||
|
|
||||||
if ((gdouble) image_height * zoom_x <= (gdouble) shell->disp_height)
|
|
||||||
zoom_factor = zoom_x;
|
|
||||||
else
|
|
||||||
zoom_factor = zoom_y;
|
|
||||||
|
|
||||||
gimp_display_shell_scale_calc_fraction (zoom_factor,
|
gimp_display_shell_scale_calc_fraction (zoom_factor,
|
||||||
&scalesrc, &scaledest);
|
&scalesrc, &scaledest);
|
||||||
@ -448,14 +451,6 @@ gimp_display_shell_scale_resize (GimpDisplayShell *shell,
|
|||||||
tool_manager_control_active (gimp, RESUME, shell->gdisp);
|
tool_manager_control_active (gimp, RESUME, shell->gdisp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GimpDisplayShell *shell;
|
|
||||||
GtkObject *src_adj;
|
|
||||||
GtkObject *dest_adj;
|
|
||||||
} ScaleDialogData;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_display_shell_scale_dialog (GimpDisplayShell *shell)
|
gimp_display_shell_scale_dialog (GimpDisplayShell *shell)
|
||||||
{
|
{
|
||||||
@ -482,11 +477,13 @@ gimp_display_shell_scale_dialog (GimpDisplayShell *shell)
|
|||||||
_("Select Zoom Ratio"),
|
_("Select Zoom Ratio"),
|
||||||
gimp_standard_help_func,
|
gimp_standard_help_func,
|
||||||
"dialogs/display_scale.html",
|
"dialogs/display_scale.html",
|
||||||
|
|
||||||
GTK_STOCK_CANCEL, gimp_display_shell_scale_dialog_cancel,
|
GTK_STOCK_CANCEL,
|
||||||
|
gimp_display_shell_scale_dialog_cancel,
|
||||||
data, NULL, NULL, FALSE, TRUE,
|
data, NULL, NULL, FALSE, TRUE,
|
||||||
|
|
||||||
GTK_STOCK_OK, gimp_display_shell_scale_dialog_ok,
|
GTK_STOCK_OK,
|
||||||
|
gimp_display_shell_scale_dialog_ok,
|
||||||
data, NULL, NULL, TRUE, FALSE,
|
data, NULL, NULL, TRUE, FALSE,
|
||||||
|
|
||||||
NULL);
|
NULL);
|
||||||
@ -522,7 +519,7 @@ gimp_display_shell_scale_dialog (GimpDisplayShell *shell)
|
|||||||
label = gtk_label_new (":");
|
label = gtk_label_new (":");
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
spin = gimp_spin_button_new (&data->src_adj,
|
spin = gimp_spin_button_new (&data->src_adj,
|
||||||
(shell->other_scale & 0xFF), 1, 0xFF,
|
(shell->other_scale & 0xFF), 1, 0xFF,
|
||||||
1, 8, 1, 1, 0);
|
1, 8, 1, 1, 0);
|
||||||
@ -536,11 +533,9 @@ gimp_display_shell_scale_dialog (GimpDisplayShell *shell)
|
|||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_display_shell_scale_dialog_ok (GtkWidget *widget,
|
gimp_display_shell_scale_dialog_ok (GtkWidget *widget,
|
||||||
gpointer data)
|
ScaleDialogData *dialog)
|
||||||
{
|
{
|
||||||
ScaleDialogData *dialog = (ScaleDialogData *) data;
|
|
||||||
|
|
||||||
gint scale_src;
|
gint scale_src;
|
||||||
gint scale_dest;
|
gint scale_dest;
|
||||||
|
|
||||||
@ -554,11 +549,9 @@ gimp_display_shell_scale_dialog_ok (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_display_shell_scale_dialog_cancel (GtkWidget *widget,
|
gimp_display_shell_scale_dialog_cancel (GtkWidget *widget,
|
||||||
gpointer data)
|
ScaleDialogData *dialog)
|
||||||
{
|
{
|
||||||
ScaleDialogData *dialog = (ScaleDialogData *) data;
|
|
||||||
|
|
||||||
/* need to emit "scaled" to get the menu updated */
|
/* need to emit "scaled" to get the menu updated */
|
||||||
gimp_display_shell_scaled (dialog->shell);
|
gimp_display_shell_scaled (dialog->shell);
|
||||||
dialog->shell->other_scale |= (1 << 30);
|
dialog->shell->other_scale |= (1 << 30);
|
||||||
|
Reference in New Issue
Block a user