mirror of https://github.com/GNOME/gimp.git
major cleanup. After being finished, I decided that it needs to be
2001-06-18 Michael Natterer <mitch@gimp.org> * app/nav_window.[ch]: major cleanup. After being finished, I decided that it needs to be factored out to a widget (see below), so like 90% of this file will go away soon. * app/apptypes.h: added opaque NavigationDialog typedef. * app/gdisplay.[ch]: Added gdisplay_selection_visibility() which is called from gdisplays_selection_visibility(). Capitalized the SelectionControl enum values. Cleaned up the GDisplay struct and it's initialisation while i was on it. * app/gimage.c: gimage_size_changed_handler(): removed stuff which is now done by GimpImage itself. * app/scale.c * app/scroll.c: also update the navigation popup, not only the dialog. * app/selection.[ch]: major indentation & cleanup attack. Maybe found the "Selection vanishes" bug (the timeout id was assinged to a gint, not a _guint_). * app/undo.c: s/gimp_image_size_changed/gimp_viweable_size_changed/ * app/core/gimpdrawable.c: invalidate the image's preview from our "invalidate_preview" implementation. This means that the image's preview is invalidated way too often currently, which cries for some general freeze/thaw mechanism on the GimpViewable level. (Note that previews are rendered in the idle loop, so this is not really a major performance impact, it's just ugly). * app/core/gimpimage.[ch]: removed the "size_changed" signal... * app/core/gimpviewable.[ch]: ...and added it here. * app/core/gimplayer.c: invalidate_preview(): always chain up, also if it's a floating selection. * app/gui/info-dialog.[ch] * app/gui/info-window.c: minor cleanups. * app/gui/preferences-dialog.c: no need to invalidate the image after we have invalidated all it's layers. * app/core/gimpimage-mask.c * app/gui/commands.c * app/tools/gimpeditselectiontool.c * app/tools/gimpinktool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c: capitalized the SelectionCommand enum values. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpnavigationpreview.[ch]: new widget. * app/widgets/gimppreview.[ch]: added a non-working non-dot-for-dot mode. Added xres/yres params to the gimp_preview_calc_size() helper function. Cache the "size" value which was passed to the simple function variants (gimp_preview_new() and gimp_preview_set_size()) so we can re-calculate the preview's extents on the underlying viewable's "size_changed" signal and on gimp_preview_set_viewable(). * app/widgets/gimpdrawablepreview.c * app/widgets/gimpimagepreview.c: changed accordingly.
This commit is contained in:
parent
45ecf78e0c
commit
3ef20cd842
70
ChangeLog
70
ChangeLog
|
@ -1,3 +1,73 @@
|
|||
2001-06-18 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/nav_window.[ch]: major cleanup. After being finished, I
|
||||
decided that it needs to be factored out to a widget (see below),
|
||||
so like 90% of this file will go away soon.
|
||||
|
||||
* app/apptypes.h: added opaque NavigationDialog typedef.
|
||||
|
||||
* app/gdisplay.[ch]: Added gdisplay_selection_visibility() which
|
||||
is called from gdisplays_selection_visibility(). Capitalized the
|
||||
SelectionControl enum values. Cleaned up the GDisplay struct and
|
||||
it's initialisation while i was on it.
|
||||
|
||||
* app/gimage.c: gimage_size_changed_handler(): removed stuff which
|
||||
is now done by GimpImage itself.
|
||||
|
||||
* app/scale.c
|
||||
* app/scroll.c: also update the navigation popup, not only the
|
||||
dialog.
|
||||
|
||||
* app/selection.[ch]: major indentation & cleanup attack. Maybe
|
||||
found the "Selection vanishes" bug (the timeout id was assinged to
|
||||
a gint, not a _guint_).
|
||||
|
||||
* app/undo.c: s/gimp_image_size_changed/gimp_viweable_size_changed/
|
||||
|
||||
* app/core/gimpdrawable.c: invalidate the image's preview from our
|
||||
"invalidate_preview" implementation. This means that the image's
|
||||
preview is invalidated way too often currently, which cries for
|
||||
some general freeze/thaw mechanism on the GimpViewable level.
|
||||
(Note that previews are rendered in the idle loop, so this is not
|
||||
really a major performance impact, it's just ugly).
|
||||
|
||||
* app/core/gimpimage.[ch]: removed the "size_changed" signal...
|
||||
|
||||
* app/core/gimpviewable.[ch]: ...and added it here.
|
||||
|
||||
* app/core/gimplayer.c: invalidate_preview(): always chain up,
|
||||
also if it's a floating selection.
|
||||
|
||||
* app/gui/info-dialog.[ch]
|
||||
* app/gui/info-window.c: minor cleanups.
|
||||
|
||||
* app/gui/preferences-dialog.c: no need to invalidate the image
|
||||
after we have invalidated all it's layers.
|
||||
|
||||
* app/core/gimpimage-mask.c
|
||||
* app/gui/commands.c
|
||||
* app/tools/gimpeditselectiontool.c
|
||||
* app/tools/gimpinktool.c
|
||||
* app/tools/gimpmovetool.c
|
||||
* app/tools/gimppainttool.c: capitalized the SelectionCommand enum
|
||||
values.
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimpnavigationpreview.[ch]: new widget.
|
||||
|
||||
* app/widgets/gimppreview.[ch]: added a non-working
|
||||
non-dot-for-dot mode. Added xres/yres params to the
|
||||
gimp_preview_calc_size() helper function.
|
||||
|
||||
Cache the "size" value which was passed to the simple function
|
||||
variants (gimp_preview_new() and gimp_preview_set_size()) so we
|
||||
can re-calculate the preview's extents on the underlying
|
||||
viewable's "size_changed" signal and on gimp_preview_set_viewable().
|
||||
|
||||
* app/widgets/gimpdrawablepreview.c
|
||||
* app/widgets/gimpimagepreview.c: changed accordingly.
|
||||
|
||||
2001-06-18 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/gfig/gfig.c
|
||||
|
|
|
@ -592,7 +592,7 @@ view_info_window_cmd_callback (GtkWidget *widget,
|
|||
if (! gimprc.info_window_follows_mouse)
|
||||
{
|
||||
if (! gdisp->window_info_dialog)
|
||||
gdisp->window_info_dialog = info_window_create ((void *) gdisp);
|
||||
gdisp->window_info_dialog = info_window_create (gdisp);
|
||||
|
||||
info_window_update (gdisp);
|
||||
info_dialog_popup (gdisp->window_info_dialog);
|
||||
|
@ -613,13 +613,13 @@ view_nav_window_cmd_callback (GtkWidget *widget,
|
|||
if (gimprc.nav_window_per_display)
|
||||
{
|
||||
if (! gdisp->window_nav_dialog)
|
||||
gdisp->window_nav_dialog = nav_window_create ((void *) gdisp);
|
||||
gdisp->window_nav_dialog = nav_dialog_create (gdisp);
|
||||
|
||||
nav_dialog_popup (gdisp->window_nav_dialog);
|
||||
}
|
||||
else
|
||||
{
|
||||
nav_window_follow_auto ();
|
||||
nav_dialog_follow_auto ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -637,7 +637,8 @@ view_toggle_selection_cmd_callback (GtkWidget *widget,
|
|||
/* hidden == TRUE corresponds to the menu toggle being FALSE */
|
||||
if (new_val == gdisp->select->hidden)
|
||||
{
|
||||
selection_hide (gdisp->select, (void *) gdisp);
|
||||
selection_toggle (gdisp->select);
|
||||
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ typedef struct _ImageMap ImageMap;
|
|||
|
||||
typedef struct _InfoDialog InfoDialog;
|
||||
|
||||
typedef struct _NavigationDialog NavigationDialog;
|
||||
|
||||
typedef struct _Path Path;
|
||||
typedef struct _PathPoint PathPoint;
|
||||
typedef struct _PathList PathList;
|
||||
|
|
|
@ -312,7 +312,7 @@ gimp_drawable_invalidate_preview (GimpViewable *viewable)
|
|||
gimage = gimp_drawable_gimage (drawable);
|
||||
|
||||
if (gimage)
|
||||
gimage->comp_preview_valid = FALSE;
|
||||
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -74,6 +74,7 @@ static void gimp_image_init (GimpImage *gimage);
|
|||
static void gimp_image_destroy (GtkObject *object);
|
||||
static void gimp_image_name_changed (GimpObject *object);
|
||||
static void gimp_image_invalidate_preview (GimpViewable *viewable);
|
||||
static void gimp_image_size_changed (GimpViewable *viewable);
|
||||
static void gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol);
|
||||
static TempBuf *gimp_image_get_preview (GimpViewable *gimage,
|
||||
|
@ -160,7 +161,6 @@ enum
|
|||
{
|
||||
MODE_CHANGED,
|
||||
ALPHA_CHANGED,
|
||||
SIZE_CHANGED,
|
||||
FLOATING_SELECTION_CHANGED,
|
||||
ACTIVE_LAYER_CHANGED,
|
||||
ACTIVE_CHANNEL_CHANGED,
|
||||
|
@ -242,15 +242,6 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SIZE_CHANGED] =
|
||||
gtk_signal_new ("size_changed",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpImageClass,
|
||||
size_changed),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[FLOATING_SELECTION_CHANGED] =
|
||||
gtk_signal_new ("floating_selection_changed",
|
||||
GTK_RUN_FIRST,
|
||||
|
@ -365,12 +356,12 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gimp_object_class->name_changed = gimp_image_name_changed;
|
||||
|
||||
viewable_class->invalidate_preview = gimp_image_invalidate_preview;
|
||||
viewable_class->size_changed = gimp_image_size_changed;
|
||||
viewable_class->get_preview = gimp_image_get_preview;
|
||||
viewable_class->get_new_preview = gimp_image_get_new_preview;
|
||||
|
||||
klass->mode_changed = NULL;
|
||||
klass->alpha_changed = NULL;
|
||||
klass->size_changed = NULL;
|
||||
klass->floating_selection_changed = NULL;
|
||||
klass->active_layer_changed = NULL;
|
||||
klass->active_channel_changed = NULL;
|
||||
|
@ -525,20 +516,29 @@ static void
|
|||
gimp_image_invalidate_preview (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpLayer *layer;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
/* Invalidate the floating sel if it exists */
|
||||
if ((layer = gimp_image_floating_sel (gimage)))
|
||||
floating_sel_invalidate (layer);
|
||||
|
||||
gimage->comp_preview_valid = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_size_changed (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->size_changed)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->size_changed (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
gimp_image_invalidate_layer_previews (gimage);
|
||||
gimp_image_invalidate_channel_previews (gimage);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol)
|
||||
|
@ -841,7 +841,7 @@ gimp_image_resize (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -1726,14 +1726,6 @@ gimp_image_alpha_changed (GimpImage *gimage)
|
|||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[ALPHA_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_size_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[SIZE_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_floating_selection_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -137,7 +137,6 @@ struct _GimpImageClass
|
|||
|
||||
void (* mode_changed) (GimpImage *gimage);
|
||||
void (* alpha_changed) (GimpImage *gimage);
|
||||
void (* size_changed) (GimpImage *gimage);
|
||||
void (* floating_selection_changed) (GimpImage *gimage);
|
||||
void (* active_layer_changed) (GimpImage *gimage);
|
||||
void (* active_channel_changed) (GimpImage *gimage);
|
||||
|
@ -280,7 +279,6 @@ void gimp_image_colormap_changed (GimpImage *gimage,
|
|||
|
||||
void gimp_image_mode_changed (GimpImage *gimage);
|
||||
void gimp_image_alpha_changed (GimpImage *gimage);
|
||||
void gimp_image_size_changed (GimpImage *gimage);
|
||||
void gimp_image_floating_selection_changed (GimpImage *gimage);
|
||||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ gimage_mask_invalidate (GimpImage *gimage)
|
|||
GimpChannel *mask;
|
||||
|
||||
/* Turn the current selection off */
|
||||
gdisplays_selection_visibility (gimage, SelectionOff);
|
||||
gdisplays_selection_visibility (gimage, SELECTION_OFF);
|
||||
|
||||
mask = gimp_image_get_mask (gimage);
|
||||
mask->boundary_known = FALSE;
|
||||
|
|
|
@ -74,6 +74,7 @@ static void gimp_image_init (GimpImage *gimage);
|
|||
static void gimp_image_destroy (GtkObject *object);
|
||||
static void gimp_image_name_changed (GimpObject *object);
|
||||
static void gimp_image_invalidate_preview (GimpViewable *viewable);
|
||||
static void gimp_image_size_changed (GimpViewable *viewable);
|
||||
static void gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol);
|
||||
static TempBuf *gimp_image_get_preview (GimpViewable *gimage,
|
||||
|
@ -160,7 +161,6 @@ enum
|
|||
{
|
||||
MODE_CHANGED,
|
||||
ALPHA_CHANGED,
|
||||
SIZE_CHANGED,
|
||||
FLOATING_SELECTION_CHANGED,
|
||||
ACTIVE_LAYER_CHANGED,
|
||||
ACTIVE_CHANNEL_CHANGED,
|
||||
|
@ -242,15 +242,6 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SIZE_CHANGED] =
|
||||
gtk_signal_new ("size_changed",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpImageClass,
|
||||
size_changed),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[FLOATING_SELECTION_CHANGED] =
|
||||
gtk_signal_new ("floating_selection_changed",
|
||||
GTK_RUN_FIRST,
|
||||
|
@ -365,12 +356,12 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gimp_object_class->name_changed = gimp_image_name_changed;
|
||||
|
||||
viewable_class->invalidate_preview = gimp_image_invalidate_preview;
|
||||
viewable_class->size_changed = gimp_image_size_changed;
|
||||
viewable_class->get_preview = gimp_image_get_preview;
|
||||
viewable_class->get_new_preview = gimp_image_get_new_preview;
|
||||
|
||||
klass->mode_changed = NULL;
|
||||
klass->alpha_changed = NULL;
|
||||
klass->size_changed = NULL;
|
||||
klass->floating_selection_changed = NULL;
|
||||
klass->active_layer_changed = NULL;
|
||||
klass->active_channel_changed = NULL;
|
||||
|
@ -525,20 +516,29 @@ static void
|
|||
gimp_image_invalidate_preview (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpLayer *layer;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
/* Invalidate the floating sel if it exists */
|
||||
if ((layer = gimp_image_floating_sel (gimage)))
|
||||
floating_sel_invalidate (layer);
|
||||
|
||||
gimage->comp_preview_valid = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_size_changed (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->size_changed)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->size_changed (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
gimp_image_invalidate_layer_previews (gimage);
|
||||
gimp_image_invalidate_channel_previews (gimage);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol)
|
||||
|
@ -841,7 +841,7 @@ gimp_image_resize (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -1726,14 +1726,6 @@ gimp_image_alpha_changed (GimpImage *gimage)
|
|||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[ALPHA_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_size_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[SIZE_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_floating_selection_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -137,7 +137,6 @@ struct _GimpImageClass
|
|||
|
||||
void (* mode_changed) (GimpImage *gimage);
|
||||
void (* alpha_changed) (GimpImage *gimage);
|
||||
void (* size_changed) (GimpImage *gimage);
|
||||
void (* floating_selection_changed) (GimpImage *gimage);
|
||||
void (* active_layer_changed) (GimpImage *gimage);
|
||||
void (* active_channel_changed) (GimpImage *gimage);
|
||||
|
@ -280,7 +279,6 @@ void gimp_image_colormap_changed (GimpImage *gimage,
|
|||
|
||||
void gimp_image_mode_changed (GimpImage *gimage);
|
||||
void gimp_image_alpha_changed (GimpImage *gimage);
|
||||
void gimp_image_size_changed (GimpImage *gimage);
|
||||
void gimp_image_floating_selection_changed (GimpImage *gimage);
|
||||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ static void gimp_image_init (GimpImage *gimage);
|
|||
static void gimp_image_destroy (GtkObject *object);
|
||||
static void gimp_image_name_changed (GimpObject *object);
|
||||
static void gimp_image_invalidate_preview (GimpViewable *viewable);
|
||||
static void gimp_image_size_changed (GimpViewable *viewable);
|
||||
static void gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol);
|
||||
static TempBuf *gimp_image_get_preview (GimpViewable *gimage,
|
||||
|
@ -160,7 +161,6 @@ enum
|
|||
{
|
||||
MODE_CHANGED,
|
||||
ALPHA_CHANGED,
|
||||
SIZE_CHANGED,
|
||||
FLOATING_SELECTION_CHANGED,
|
||||
ACTIVE_LAYER_CHANGED,
|
||||
ACTIVE_CHANNEL_CHANGED,
|
||||
|
@ -242,15 +242,6 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SIZE_CHANGED] =
|
||||
gtk_signal_new ("size_changed",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpImageClass,
|
||||
size_changed),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[FLOATING_SELECTION_CHANGED] =
|
||||
gtk_signal_new ("floating_selection_changed",
|
||||
GTK_RUN_FIRST,
|
||||
|
@ -365,12 +356,12 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gimp_object_class->name_changed = gimp_image_name_changed;
|
||||
|
||||
viewable_class->invalidate_preview = gimp_image_invalidate_preview;
|
||||
viewable_class->size_changed = gimp_image_size_changed;
|
||||
viewable_class->get_preview = gimp_image_get_preview;
|
||||
viewable_class->get_new_preview = gimp_image_get_new_preview;
|
||||
|
||||
klass->mode_changed = NULL;
|
||||
klass->alpha_changed = NULL;
|
||||
klass->size_changed = NULL;
|
||||
klass->floating_selection_changed = NULL;
|
||||
klass->active_layer_changed = NULL;
|
||||
klass->active_channel_changed = NULL;
|
||||
|
@ -525,20 +516,29 @@ static void
|
|||
gimp_image_invalidate_preview (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpLayer *layer;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
/* Invalidate the floating sel if it exists */
|
||||
if ((layer = gimp_image_floating_sel (gimage)))
|
||||
floating_sel_invalidate (layer);
|
||||
|
||||
gimage->comp_preview_valid = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_size_changed (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->size_changed)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->size_changed (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
gimp_image_invalidate_layer_previews (gimage);
|
||||
gimp_image_invalidate_channel_previews (gimage);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol)
|
||||
|
@ -841,7 +841,7 @@ gimp_image_resize (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -1726,14 +1726,6 @@ gimp_image_alpha_changed (GimpImage *gimage)
|
|||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[ALPHA_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_size_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[SIZE_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_floating_selection_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -137,7 +137,6 @@ struct _GimpImageClass
|
|||
|
||||
void (* mode_changed) (GimpImage *gimage);
|
||||
void (* alpha_changed) (GimpImage *gimage);
|
||||
void (* size_changed) (GimpImage *gimage);
|
||||
void (* floating_selection_changed) (GimpImage *gimage);
|
||||
void (* active_layer_changed) (GimpImage *gimage);
|
||||
void (* active_channel_changed) (GimpImage *gimage);
|
||||
|
@ -280,7 +279,6 @@ void gimp_image_colormap_changed (GimpImage *gimage,
|
|||
|
||||
void gimp_image_mode_changed (GimpImage *gimage);
|
||||
void gimp_image_alpha_changed (GimpImage *gimage);
|
||||
void gimp_image_size_changed (GimpImage *gimage);
|
||||
void gimp_image_floating_selection_changed (GimpImage *gimage);
|
||||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ static void gimp_image_init (GimpImage *gimage);
|
|||
static void gimp_image_destroy (GtkObject *object);
|
||||
static void gimp_image_name_changed (GimpObject *object);
|
||||
static void gimp_image_invalidate_preview (GimpViewable *viewable);
|
||||
static void gimp_image_size_changed (GimpViewable *viewable);
|
||||
static void gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol);
|
||||
static TempBuf *gimp_image_get_preview (GimpViewable *gimage,
|
||||
|
@ -160,7 +161,6 @@ enum
|
|||
{
|
||||
MODE_CHANGED,
|
||||
ALPHA_CHANGED,
|
||||
SIZE_CHANGED,
|
||||
FLOATING_SELECTION_CHANGED,
|
||||
ACTIVE_LAYER_CHANGED,
|
||||
ACTIVE_CHANNEL_CHANGED,
|
||||
|
@ -242,15 +242,6 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SIZE_CHANGED] =
|
||||
gtk_signal_new ("size_changed",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpImageClass,
|
||||
size_changed),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[FLOATING_SELECTION_CHANGED] =
|
||||
gtk_signal_new ("floating_selection_changed",
|
||||
GTK_RUN_FIRST,
|
||||
|
@ -365,12 +356,12 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gimp_object_class->name_changed = gimp_image_name_changed;
|
||||
|
||||
viewable_class->invalidate_preview = gimp_image_invalidate_preview;
|
||||
viewable_class->size_changed = gimp_image_size_changed;
|
||||
viewable_class->get_preview = gimp_image_get_preview;
|
||||
viewable_class->get_new_preview = gimp_image_get_new_preview;
|
||||
|
||||
klass->mode_changed = NULL;
|
||||
klass->alpha_changed = NULL;
|
||||
klass->size_changed = NULL;
|
||||
klass->floating_selection_changed = NULL;
|
||||
klass->active_layer_changed = NULL;
|
||||
klass->active_channel_changed = NULL;
|
||||
|
@ -525,20 +516,29 @@ static void
|
|||
gimp_image_invalidate_preview (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpLayer *layer;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
/* Invalidate the floating sel if it exists */
|
||||
if ((layer = gimp_image_floating_sel (gimage)))
|
||||
floating_sel_invalidate (layer);
|
||||
|
||||
gimage->comp_preview_valid = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_size_changed (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->size_changed)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->size_changed (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
gimp_image_invalidate_layer_previews (gimage);
|
||||
gimp_image_invalidate_channel_previews (gimage);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol)
|
||||
|
@ -841,7 +841,7 @@ gimp_image_resize (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -1726,14 +1726,6 @@ gimp_image_alpha_changed (GimpImage *gimage)
|
|||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[ALPHA_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_size_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[SIZE_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_floating_selection_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -137,7 +137,6 @@ struct _GimpImageClass
|
|||
|
||||
void (* mode_changed) (GimpImage *gimage);
|
||||
void (* alpha_changed) (GimpImage *gimage);
|
||||
void (* size_changed) (GimpImage *gimage);
|
||||
void (* floating_selection_changed) (GimpImage *gimage);
|
||||
void (* active_layer_changed) (GimpImage *gimage);
|
||||
void (* active_channel_changed) (GimpImage *gimage);
|
||||
|
@ -280,7 +279,6 @@ void gimp_image_colormap_changed (GimpImage *gimage,
|
|||
|
||||
void gimp_image_mode_changed (GimpImage *gimage);
|
||||
void gimp_image_alpha_changed (GimpImage *gimage);
|
||||
void gimp_image_size_changed (GimpImage *gimage);
|
||||
void gimp_image_floating_selection_changed (GimpImage *gimage);
|
||||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ static void gimp_image_init (GimpImage *gimage);
|
|||
static void gimp_image_destroy (GtkObject *object);
|
||||
static void gimp_image_name_changed (GimpObject *object);
|
||||
static void gimp_image_invalidate_preview (GimpViewable *viewable);
|
||||
static void gimp_image_size_changed (GimpViewable *viewable);
|
||||
static void gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol);
|
||||
static TempBuf *gimp_image_get_preview (GimpViewable *gimage,
|
||||
|
@ -160,7 +161,6 @@ enum
|
|||
{
|
||||
MODE_CHANGED,
|
||||
ALPHA_CHANGED,
|
||||
SIZE_CHANGED,
|
||||
FLOATING_SELECTION_CHANGED,
|
||||
ACTIVE_LAYER_CHANGED,
|
||||
ACTIVE_CHANNEL_CHANGED,
|
||||
|
@ -242,15 +242,6 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SIZE_CHANGED] =
|
||||
gtk_signal_new ("size_changed",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpImageClass,
|
||||
size_changed),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[FLOATING_SELECTION_CHANGED] =
|
||||
gtk_signal_new ("floating_selection_changed",
|
||||
GTK_RUN_FIRST,
|
||||
|
@ -365,12 +356,12 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gimp_object_class->name_changed = gimp_image_name_changed;
|
||||
|
||||
viewable_class->invalidate_preview = gimp_image_invalidate_preview;
|
||||
viewable_class->size_changed = gimp_image_size_changed;
|
||||
viewable_class->get_preview = gimp_image_get_preview;
|
||||
viewable_class->get_new_preview = gimp_image_get_new_preview;
|
||||
|
||||
klass->mode_changed = NULL;
|
||||
klass->alpha_changed = NULL;
|
||||
klass->size_changed = NULL;
|
||||
klass->floating_selection_changed = NULL;
|
||||
klass->active_layer_changed = NULL;
|
||||
klass->active_channel_changed = NULL;
|
||||
|
@ -525,20 +516,29 @@ static void
|
|||
gimp_image_invalidate_preview (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpLayer *layer;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
/* Invalidate the floating sel if it exists */
|
||||
if ((layer = gimp_image_floating_sel (gimage)))
|
||||
floating_sel_invalidate (layer);
|
||||
|
||||
gimage->comp_preview_valid = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_size_changed (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->size_changed)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->size_changed (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
gimp_image_invalidate_layer_previews (gimage);
|
||||
gimp_image_invalidate_channel_previews (gimage);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol)
|
||||
|
@ -841,7 +841,7 @@ gimp_image_resize (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -1726,14 +1726,6 @@ gimp_image_alpha_changed (GimpImage *gimage)
|
|||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[ALPHA_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_size_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[SIZE_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_floating_selection_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -137,7 +137,6 @@ struct _GimpImageClass
|
|||
|
||||
void (* mode_changed) (GimpImage *gimage);
|
||||
void (* alpha_changed) (GimpImage *gimage);
|
||||
void (* size_changed) (GimpImage *gimage);
|
||||
void (* floating_selection_changed) (GimpImage *gimage);
|
||||
void (* active_layer_changed) (GimpImage *gimage);
|
||||
void (* active_channel_changed) (GimpImage *gimage);
|
||||
|
@ -280,7 +279,6 @@ void gimp_image_colormap_changed (GimpImage *gimage,
|
|||
|
||||
void gimp_image_mode_changed (GimpImage *gimage);
|
||||
void gimp_image_alpha_changed (GimpImage *gimage);
|
||||
void gimp_image_size_changed (GimpImage *gimage);
|
||||
void gimp_image_floating_selection_changed (GimpImage *gimage);
|
||||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
|
||||
|
|
|
@ -487,7 +487,7 @@ pop_stack (GimpImage *gimage,
|
|||
/* If the size_changed flag was set */
|
||||
if (size_changed)
|
||||
{
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
size_changed = FALSE;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ static void gimp_image_init (GimpImage *gimage);
|
|||
static void gimp_image_destroy (GtkObject *object);
|
||||
static void gimp_image_name_changed (GimpObject *object);
|
||||
static void gimp_image_invalidate_preview (GimpViewable *viewable);
|
||||
static void gimp_image_size_changed (GimpViewable *viewable);
|
||||
static void gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol);
|
||||
static TempBuf *gimp_image_get_preview (GimpViewable *gimage,
|
||||
|
@ -160,7 +161,6 @@ enum
|
|||
{
|
||||
MODE_CHANGED,
|
||||
ALPHA_CHANGED,
|
||||
SIZE_CHANGED,
|
||||
FLOATING_SELECTION_CHANGED,
|
||||
ACTIVE_LAYER_CHANGED,
|
||||
ACTIVE_CHANNEL_CHANGED,
|
||||
|
@ -242,15 +242,6 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SIZE_CHANGED] =
|
||||
gtk_signal_new ("size_changed",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpImageClass,
|
||||
size_changed),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[FLOATING_SELECTION_CHANGED] =
|
||||
gtk_signal_new ("floating_selection_changed",
|
||||
GTK_RUN_FIRST,
|
||||
|
@ -365,12 +356,12 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gimp_object_class->name_changed = gimp_image_name_changed;
|
||||
|
||||
viewable_class->invalidate_preview = gimp_image_invalidate_preview;
|
||||
viewable_class->size_changed = gimp_image_size_changed;
|
||||
viewable_class->get_preview = gimp_image_get_preview;
|
||||
viewable_class->get_new_preview = gimp_image_get_new_preview;
|
||||
|
||||
klass->mode_changed = NULL;
|
||||
klass->alpha_changed = NULL;
|
||||
klass->size_changed = NULL;
|
||||
klass->floating_selection_changed = NULL;
|
||||
klass->active_layer_changed = NULL;
|
||||
klass->active_channel_changed = NULL;
|
||||
|
@ -525,20 +516,29 @@ static void
|
|||
gimp_image_invalidate_preview (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpLayer *layer;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
/* Invalidate the floating sel if it exists */
|
||||
if ((layer = gimp_image_floating_sel (gimage)))
|
||||
floating_sel_invalidate (layer);
|
||||
|
||||
gimage->comp_preview_valid = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_size_changed (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->size_changed)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->size_changed (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
gimp_image_invalidate_layer_previews (gimage);
|
||||
gimp_image_invalidate_channel_previews (gimage);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol)
|
||||
|
@ -841,7 +841,7 @@ gimp_image_resize (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -1726,14 +1726,6 @@ gimp_image_alpha_changed (GimpImage *gimage)
|
|||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[ALPHA_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_size_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[SIZE_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_floating_selection_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -137,7 +137,6 @@ struct _GimpImageClass
|
|||
|
||||
void (* mode_changed) (GimpImage *gimage);
|
||||
void (* alpha_changed) (GimpImage *gimage);
|
||||
void (* size_changed) (GimpImage *gimage);
|
||||
void (* floating_selection_changed) (GimpImage *gimage);
|
||||
void (* active_layer_changed) (GimpImage *gimage);
|
||||
void (* active_channel_changed) (GimpImage *gimage);
|
||||
|
@ -280,7 +279,6 @@ void gimp_image_colormap_changed (GimpImage *gimage,
|
|||
|
||||
void gimp_image_mode_changed (GimpImage *gimage);
|
||||
void gimp_image_alpha_changed (GimpImage *gimage);
|
||||
void gimp_image_size_changed (GimpImage *gimage);
|
||||
void gimp_image_floating_selection_changed (GimpImage *gimage);
|
||||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
|
||||
|
|
|
@ -194,17 +194,13 @@ gimp_layer_invalidate_preview (GimpViewable *viewable)
|
|||
{
|
||||
GimpLayer *layer;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
||||
|
||||
layer = GIMP_LAYER (viewable);
|
||||
|
||||
if (gimp_layer_is_floating_sel (layer))
|
||||
{
|
||||
floating_sel_invalidate (layer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
||||
}
|
||||
floating_sel_invalidate (layer);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1300,10 +1296,10 @@ gimp_layer_invalidate_boundary (GimpLayer *layer)
|
|||
return;
|
||||
|
||||
/* Turn the current selection off */
|
||||
gdisplays_selection_visibility (gimage, SelectionOff);
|
||||
gdisplays_selection_visibility (gimage, SELECTION_OFF);
|
||||
|
||||
/* clear the affected region surrounding the layer */
|
||||
gdisplays_selection_visibility (gimage, SelectionLayerOff);
|
||||
gdisplays_selection_visibility (gimage, SELECTION_LAYER_OFF);
|
||||
|
||||
/* get the selection mask channel */
|
||||
mask = gimp_image_get_mask (gimage);
|
||||
|
|
|
@ -74,6 +74,7 @@ static void gimp_image_init (GimpImage *gimage);
|
|||
static void gimp_image_destroy (GtkObject *object);
|
||||
static void gimp_image_name_changed (GimpObject *object);
|
||||
static void gimp_image_invalidate_preview (GimpViewable *viewable);
|
||||
static void gimp_image_size_changed (GimpViewable *viewable);
|
||||
static void gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol);
|
||||
static TempBuf *gimp_image_get_preview (GimpViewable *gimage,
|
||||
|
@ -160,7 +161,6 @@ enum
|
|||
{
|
||||
MODE_CHANGED,
|
||||
ALPHA_CHANGED,
|
||||
SIZE_CHANGED,
|
||||
FLOATING_SELECTION_CHANGED,
|
||||
ACTIVE_LAYER_CHANGED,
|
||||
ACTIVE_CHANNEL_CHANGED,
|
||||
|
@ -242,15 +242,6 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SIZE_CHANGED] =
|
||||
gtk_signal_new ("size_changed",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpImageClass,
|
||||
size_changed),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[FLOATING_SELECTION_CHANGED] =
|
||||
gtk_signal_new ("floating_selection_changed",
|
||||
GTK_RUN_FIRST,
|
||||
|
@ -365,12 +356,12 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
gimp_object_class->name_changed = gimp_image_name_changed;
|
||||
|
||||
viewable_class->invalidate_preview = gimp_image_invalidate_preview;
|
||||
viewable_class->size_changed = gimp_image_size_changed;
|
||||
viewable_class->get_preview = gimp_image_get_preview;
|
||||
viewable_class->get_new_preview = gimp_image_get_new_preview;
|
||||
|
||||
klass->mode_changed = NULL;
|
||||
klass->alpha_changed = NULL;
|
||||
klass->size_changed = NULL;
|
||||
klass->floating_selection_changed = NULL;
|
||||
klass->active_layer_changed = NULL;
|
||||
klass->active_channel_changed = NULL;
|
||||
|
@ -525,20 +516,29 @@ static void
|
|||
gimp_image_invalidate_preview (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpLayer *layer;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
/* Invalidate the floating sel if it exists */
|
||||
if ((layer = gimp_image_floating_sel (gimage)))
|
||||
floating_sel_invalidate (layer);
|
||||
|
||||
gimage->comp_preview_valid = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_size_changed (GimpViewable *viewable)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
|
||||
if (GIMP_VIEWABLE_CLASS (parent_class)->size_changed)
|
||||
GIMP_VIEWABLE_CLASS (parent_class)->size_changed (viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (viewable);
|
||||
|
||||
gimp_image_invalidate_layer_previews (gimage);
|
||||
gimp_image_invalidate_channel_previews (gimage);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_real_colormap_changed (GimpImage *gimage,
|
||||
gint ncol)
|
||||
|
@ -841,7 +841,7 @@ gimp_image_resize (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ gimp_image_scale (GimpImage *gimage,
|
|||
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_unset_busy ();
|
||||
}
|
||||
|
@ -1726,14 +1726,6 @@ gimp_image_alpha_changed (GimpImage *gimage)
|
|||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[ALPHA_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_size_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[SIZE_CHANGED]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_floating_selection_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -137,7 +137,6 @@ struct _GimpImageClass
|
|||
|
||||
void (* mode_changed) (GimpImage *gimage);
|
||||
void (* alpha_changed) (GimpImage *gimage);
|
||||
void (* size_changed) (GimpImage *gimage);
|
||||
void (* floating_selection_changed) (GimpImage *gimage);
|
||||
void (* active_layer_changed) (GimpImage *gimage);
|
||||
void (* active_channel_changed) (GimpImage *gimage);
|
||||
|
@ -280,7 +279,6 @@ void gimp_image_colormap_changed (GimpImage *gimage,
|
|||
|
||||
void gimp_image_mode_changed (GimpImage *gimage);
|
||||
void gimp_image_alpha_changed (GimpImage *gimage);
|
||||
void gimp_image_size_changed (GimpImage *gimage);
|
||||
void gimp_image_floating_selection_changed (GimpImage *gimage);
|
||||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
|
||||
|
|
|
@ -143,40 +143,79 @@ gdisplay_new (GimpImage *gimage,
|
|||
/*
|
||||
* Set all GDisplay parameters...
|
||||
*/
|
||||
gdisp = g_new (GDisplay, 1);
|
||||
gdisp = g_new0 (GDisplay, 1);
|
||||
|
||||
gdisp->offset_x = 0;
|
||||
gdisp->offset_y = 0;
|
||||
gdisp->scale = scale;
|
||||
gdisp->dot_for_dot = gimprc.default_dot_for_dot;
|
||||
gdisp->gimage = gimage;
|
||||
gdisp->window_info_dialog = NULL;
|
||||
gdisp->window_nav_dialog = NULL;
|
||||
gdisp->nav_popup = NULL;
|
||||
gdisp->select = NULL;
|
||||
gdisp->ID = display_num++;
|
||||
gdisp->instance = gimage->instance_count;
|
||||
gdisp->update_areas = NULL;
|
||||
gdisp->display_areas = NULL;
|
||||
gdisp->disp_xoffset = 0;
|
||||
gdisp->disp_yoffset = 0;
|
||||
gdisp->current_cursor = (GdkCursorType) -1;
|
||||
gdisp->tool_cursor = GIMP_TOOL_CURSOR_NONE;
|
||||
gdisp->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
|
||||
gdisp->draw_guides = TRUE;
|
||||
gdisp->snap_to_guides = TRUE;
|
||||
gdisp->ID = display_num++;
|
||||
|
||||
gdisp->draw_cursor = FALSE;
|
||||
gdisp->proximity = FALSE;
|
||||
gdisp->have_cursor = FALSE;
|
||||
gdisp->cursor_x = 0;
|
||||
gdisp->cursor_y = 0;
|
||||
gdisp->using_override_cursor = FALSE;
|
||||
gdisp->ifactory = NULL;
|
||||
|
||||
gdisp->shell = NULL;
|
||||
gdisp->canvas = NULL;
|
||||
gdisp->hsb = NULL;
|
||||
gdisp->vsb = NULL;
|
||||
gdisp->qmaskoff = NULL;
|
||||
gdisp->qmaskon = NULL;
|
||||
gdisp->hrule = NULL;
|
||||
gdisp->vrule = NULL;
|
||||
gdisp->origin = NULL;
|
||||
gdisp->statusarea = NULL;
|
||||
gdisp->progressbar = NULL;
|
||||
gdisp->cursor_label = NULL;
|
||||
gdisp->cursor_format_str[0] = '\0';
|
||||
gdisp->cancelbutton = NULL;
|
||||
gdisp->progressid = FALSE;
|
||||
|
||||
gdisp->window_info_dialog = NULL;
|
||||
gdisp->window_nav_dialog = NULL;
|
||||
gdisp->nav_popup = NULL;
|
||||
gdisp->warning_dialog = NULL;
|
||||
|
||||
gdisp->hsbdata = NULL;
|
||||
gdisp->vsbdata = NULL;
|
||||
|
||||
gdisp->icon = NULL;
|
||||
gdisp->iconmask = NULL;
|
||||
gdisp->iconsize = 0;
|
||||
gdisp->icon_needs_update = FALSE;
|
||||
gdisp->icon_timeout_id = 0;
|
||||
gdisp->icon_idle_id = 0;
|
||||
|
||||
gdisp->gimage = gimage;
|
||||
gdisp->instance = gimage->instance_count;
|
||||
|
||||
gdisp->disp_width = 0;
|
||||
gdisp->disp_height = 0;
|
||||
gdisp->disp_xoffset = 0;
|
||||
gdisp->disp_yoffset = 0;
|
||||
|
||||
gdisp->offset_x = 0;
|
||||
gdisp->offset_y = 0;
|
||||
gdisp->scale = scale;
|
||||
gdisp->dot_for_dot = gimprc.default_dot_for_dot;
|
||||
gdisp->draw_guides = TRUE;
|
||||
gdisp->snap_to_guides = TRUE;
|
||||
|
||||
gdisp->select = NULL;
|
||||
|
||||
gdisp->scroll_gc = NULL;
|
||||
|
||||
gdisp->update_areas = NULL;
|
||||
gdisp->display_areas = NULL;
|
||||
|
||||
gdisp->current_cursor = (GdkCursorType) -1;
|
||||
gdisp->tool_cursor = GIMP_TOOL_CURSOR_NONE;
|
||||
gdisp->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
|
||||
|
||||
gdisp->override_cursor = (GdkCursorType) -1;
|
||||
gdisp->using_override_cursor = FALSE;
|
||||
|
||||
gdisp->draw_cursor = FALSE;
|
||||
gdisp->cursor_x = 0;
|
||||
gdisp->cursor_y = 0;
|
||||
gdisp->proximity = FALSE;
|
||||
gdisp->have_cursor = FALSE;
|
||||
|
||||
gdisp->idle_render.idleid = -1;
|
||||
/*gdisp->idle_render.handlerid = -1;*/
|
||||
gdisp->idle_render.update_areas = NULL;
|
||||
gdisp->idle_render.active = FALSE;
|
||||
|
||||
|
@ -185,13 +224,11 @@ gdisplay_new (GimpImage *gimage,
|
|||
gdisp->cd_ui = NULL;
|
||||
#endif /* DISPLAY_FILTERS */
|
||||
|
||||
gdisp->warning_dialog = NULL;
|
||||
|
||||
/* format the title */
|
||||
gdisplay_format_title (gdisp, title, MAX_TITLE_BUF);
|
||||
|
||||
/* add the new display to the list so that it isn't lost */
|
||||
display_list = g_slist_append (display_list, (void *) gdisp);
|
||||
display_list = g_slist_append (display_list, gdisp);
|
||||
|
||||
/* create the shell for the image */
|
||||
create_display_shell (gdisp, gimage->width, gimage->height,
|
||||
|
@ -223,7 +260,8 @@ gdisplay_new (GimpImage *gimage,
|
|||
gtk_object_sink (GTK_OBJECT (gimage));
|
||||
|
||||
/* We're interested in clean and dirty signals so we can update the
|
||||
* title if need be. */
|
||||
* title if need be.
|
||||
*/
|
||||
gtk_signal_connect (GTK_OBJECT (gimage), "dirty",
|
||||
GTK_SIGNAL_FUNC (gdisplay_cleandirty_handler), gdisp);
|
||||
gtk_signal_connect (GTK_OBJECT (gimage), "clean",
|
||||
|
@ -421,14 +459,14 @@ gdisplay_delete (GDisplay *gdisp)
|
|||
info_window_free (gdisp->window_info_dialog);
|
||||
|
||||
/* Remove navigation dialog */
|
||||
nav_window_free (gdisp, gdisp->window_nav_dialog);
|
||||
nav_dialog_free (gdisp, gdisp->window_nav_dialog);
|
||||
|
||||
/* free the gimage */
|
||||
gdisp->gimage->disp_count--;
|
||||
gtk_object_unref (GTK_OBJECT (gdisp->gimage));
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_popup_free (gdisp->nav_popup);
|
||||
nav_dialog_free (gdisp, gdisp->nav_popup);
|
||||
|
||||
if (gdisp->icon_timeout_id)
|
||||
g_source_remove (gdisp->icon_timeout_id);
|
||||
|
@ -2146,6 +2184,33 @@ gdisplay_expose_full (GDisplay *gdisp)
|
|||
gdisp->disp_height);
|
||||
}
|
||||
|
||||
void
|
||||
gdisplay_selection_visibility (GDisplay *gdisp,
|
||||
SelectionControl function)
|
||||
{
|
||||
if (gdisp->select)
|
||||
{
|
||||
switch (function)
|
||||
{
|
||||
case SELECTION_OFF:
|
||||
selection_invis (gdisp->select);
|
||||
break;
|
||||
case SELECTION_LAYER_OFF:
|
||||
selection_layer_invis (gdisp->select);
|
||||
break;
|
||||
case SELECTION_ON:
|
||||
selection_start (gdisp->select, TRUE);
|
||||
break;
|
||||
case SELECTION_PAUSE:
|
||||
selection_pause (gdisp->select);
|
||||
break;
|
||||
case SELECTION_RESUME:
|
||||
selection_resume (gdisp->select);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
/* Functions independent of a specific gdisplay */
|
||||
/**************************************************/
|
||||
|
@ -2414,10 +2479,13 @@ gdisplays_nav_preview_resized (void)
|
|||
gdisp = (GDisplay *) list->data;
|
||||
|
||||
if (gdisp->window_nav_dialog)
|
||||
nav_window_preview_resized (gdisp->window_nav_dialog);
|
||||
nav_dialog_preview_resized (gdisp->window_nav_dialog);
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_window_popup_preview_resized (&gdisp->nav_popup);
|
||||
{
|
||||
nav_dialog_free (NULL, gdisp->nav_popup);
|
||||
gdisp->nav_popup = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2427,35 +2495,14 @@ gdisplays_selection_visibility (GimpImage *gimage,
|
|||
{
|
||||
GDisplay *gdisp;
|
||||
GSList *list;
|
||||
gint count = 0;
|
||||
|
||||
/* traverse the linked list of displays, handling each one */
|
||||
for (list = display_list; list; list = g_slist_next (list))
|
||||
{
|
||||
gdisp = (GDisplay *) list->data;
|
||||
|
||||
if (gdisp->gimage == gimage && gdisp->select)
|
||||
{
|
||||
switch (function)
|
||||
{
|
||||
case SelectionOff:
|
||||
selection_invis (gdisp->select);
|
||||
break;
|
||||
case SelectionLayerOff:
|
||||
selection_layer_invis (gdisp->select);
|
||||
break;
|
||||
case SelectionOn:
|
||||
selection_start (gdisp->select, TRUE);
|
||||
break;
|
||||
case SelectionPause:
|
||||
selection_pause (gdisp->select);
|
||||
break;
|
||||
case SelectionResume:
|
||||
selection_resume (gdisp->select);
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
if (gdisp->gimage == gimage)
|
||||
gdisplay_selection_visibility (gdisp, function);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
|
||||
typedef enum
|
||||
{
|
||||
SelectionOff,
|
||||
SelectionLayerOff,
|
||||
SelectionOn,
|
||||
SelectionPause,
|
||||
SelectionResume
|
||||
SELECTION_OFF,
|
||||
SELECTION_LAYER_OFF,
|
||||
SELECTION_ON,
|
||||
SELECTION_PAUSE,
|
||||
SELECTION_RESUME
|
||||
} SelectionControl;
|
||||
|
||||
|
||||
|
@ -87,7 +87,6 @@ struct _IdleRenderStruct
|
|||
gint basex;
|
||||
gint basey;
|
||||
guint idleid;
|
||||
/*guint handlerid;*/
|
||||
gboolean active;
|
||||
GSList *update_areas; /* flushed update areas */
|
||||
};
|
||||
|
@ -101,7 +100,8 @@ struct _GDisplay
|
|||
|
||||
GtkWidget *shell; /* shell widget for this gdisplay */
|
||||
GtkWidget *canvas; /* canvas widget for this gdisplay */
|
||||
GtkWidget *hsb, *vsb; /* widgets for scroll bars */
|
||||
GtkWidget *hsb; /* widgets for scroll bars */
|
||||
GtkWidget *vsb;
|
||||
GtkWidget *qmaskoff; /* widgets for qmask buttons */
|
||||
GtkWidget *qmaskon;
|
||||
GtkWidget *hrule; /* widgets for rulers */
|
||||
|
@ -119,9 +119,10 @@ struct _GDisplay
|
|||
GtkWidget *cancelbutton; /* widget for cancel button */
|
||||
guint progressid; /* id of statusbar message for progress */
|
||||
|
||||
InfoDialog *window_info_dialog; /* dialog box for image information */
|
||||
InfoDialog *window_nav_dialog; /* dialog box for image navigation */
|
||||
GtkWidget *nav_popup; /* widget for the popup navigation window */
|
||||
InfoDialog *window_info_dialog; /* dialog box for image information */
|
||||
NavigationDialog *window_nav_dialog; /* dialog box for image navigation */
|
||||
NavigationDialog *nav_popup; /* the popup navigation window */
|
||||
GtkWidget *warning_dialog; /* "Changes were made to %s. Close anyway?" */
|
||||
|
||||
GtkAdjustment *hsbdata; /* horizontal data information */
|
||||
GtkAdjustment *vsbdata; /* vertical data information */
|
||||
|
@ -129,9 +130,9 @@ struct _GDisplay
|
|||
GdkPixmap *icon; /* Pixmap for the icon */
|
||||
GdkBitmap *iconmask; /* Bitmap for the icon mask */
|
||||
guint iconsize; /* The size of the icon pixmap */
|
||||
guint icon_needs_update; /* Do we need to render a new icon? */
|
||||
gint icon_timeout_id; /* The ID of the timeout-function */
|
||||
gint icon_idle_id; /* The ID of the idle-function */
|
||||
gboolean icon_needs_update; /* Do we need to render a new icon? */
|
||||
guint icon_timeout_id; /* The ID of the timeout-function */
|
||||
guint icon_idle_id; /* The ID of the idle-function */
|
||||
|
||||
GimpImage *gimage; /* pointer to the associated gimage struct */
|
||||
gint instance; /* the instance # of this gdisplay as */
|
||||
|
@ -175,8 +176,6 @@ struct _GDisplay
|
|||
GList *cd_list; /* color display conversion stuff */
|
||||
GtkWidget *cd_ui; /* color display filter dialog */
|
||||
#endif /* DISPLAY_FILTERS */
|
||||
|
||||
GtkWidget *warning_dialog; /* "Changes were made to %s. Close anyway?" */
|
||||
};
|
||||
|
||||
|
||||
|
@ -245,6 +244,8 @@ void gdisplay_expose_area (GDisplay *gdisp,
|
|||
void gdisplay_expose_guide (GDisplay *gdisp,
|
||||
GimpGuide *guide);
|
||||
void gdisplay_expose_full (GDisplay *gdisp);
|
||||
void gdisplay_selection_visibility (GDisplay *gdisp,
|
||||
SelectionControl function);
|
||||
void gdisplay_flush (GDisplay *gdisp);
|
||||
void gdisplay_flush_now (GDisplay *gdisp);
|
||||
void gdisplay_update_icon (GDisplay *gdisp);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
enum
|
||||
{
|
||||
INVALIDATE_PREVIEW,
|
||||
SIZE_CHANGED,
|
||||
GET_PREVIEW,
|
||||
GET_NEW_PREVIEW,
|
||||
LAST_SIGNAL
|
||||
|
@ -94,6 +95,15 @@ gimp_viewable_class_init (GimpViewableClass *klass)
|
|||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
viewable_signals[SIZE_CHANGED] =
|
||||
gtk_signal_new ("size_changed",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpViewableClass,
|
||||
size_changed),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
viewable_signals[GET_PREVIEW] =
|
||||
gtk_signal_new ("get_preview",
|
||||
GTK_RUN_LAST,
|
||||
|
@ -121,6 +131,7 @@ gimp_viewable_class_init (GimpViewableClass *klass)
|
|||
gtk_object_class_add_signals (object_class, viewable_signals, LAST_SIGNAL);
|
||||
|
||||
klass->invalidate_preview = gimp_viewable_real_invalidate_preview;
|
||||
klass->size_changed = NULL;
|
||||
klass->get_preview = NULL;
|
||||
klass->get_new_preview = NULL;
|
||||
}
|
||||
|
@ -139,6 +150,15 @@ gimp_viewable_invalidate_preview (GimpViewable *viewable)
|
|||
gtk_signal_emit (GTK_OBJECT (viewable), viewable_signals[INVALIDATE_PREVIEW]);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_viewable_size_changed (GimpViewable *viewable)
|
||||
{
|
||||
g_return_if_fail (viewable);
|
||||
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (viewable), viewable_signals[SIZE_CHANGED]);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_viewable_real_invalidate_preview (GimpViewable *viewable)
|
||||
{
|
||||
|
|
|
@ -45,6 +45,8 @@ struct _GimpViewableClass
|
|||
GimpObjectClass parent_class;
|
||||
|
||||
void (* invalidate_preview) (GimpViewable *viewable);
|
||||
void (* size_changed) (GimpViewable *viewable);
|
||||
|
||||
TempBuf * (* get_preview) (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height);
|
||||
|
@ -57,6 +59,8 @@ struct _GimpViewableClass
|
|||
GtkType gimp_viewable_get_type (void);
|
||||
|
||||
void gimp_viewable_invalidate_preview (GimpViewable *viewable);
|
||||
void gimp_viewable_size_changed (GimpViewable *viewable);
|
||||
|
||||
TempBuf * gimp_viewable_get_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height);
|
||||
|
|
|
@ -42,7 +42,7 @@ static void info_field_new (InfoDialog *idialog,
|
|||
GtkObject *object,
|
||||
gpointer value_ptr,
|
||||
GtkSignalFunc callback,
|
||||
gpointer client_data);
|
||||
gpointer callback_data);
|
||||
static void update_field (InfoField *info_field);
|
||||
static gint info_dialog_delete_callback (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
|
@ -55,9 +55,9 @@ info_field_new (InfoDialog *idialog,
|
|||
gchar *title,
|
||||
GtkWidget *widget,
|
||||
GtkObject *obj,
|
||||
void *value_ptr,
|
||||
gpointer value_ptr,
|
||||
GtkSignalFunc callback,
|
||||
gpointer client_data)
|
||||
gpointer callback_data)
|
||||
{
|
||||
GtkWidget *label;
|
||||
InfoField *field;
|
||||
|
@ -83,16 +83,17 @@ info_field_new (InfoDialog *idialog,
|
|||
gtk_table_set_row_spacings (GTK_TABLE (idialog->info_table), 2);
|
||||
|
||||
field->field_type = field_type;
|
||||
|
||||
if (obj == NULL)
|
||||
field->obj = GTK_OBJECT (widget);
|
||||
else
|
||||
field->obj = obj;
|
||||
field->value_ptr = value_ptr;
|
||||
field->callback = callback;
|
||||
field->client_data = client_data;
|
||||
|
||||
idialog->field_list =
|
||||
g_slist_prepend (idialog->field_list, (void *) field);
|
||||
field->value_ptr = value_ptr;
|
||||
field->callback = callback;
|
||||
field->callback_data = callback_data;
|
||||
|
||||
idialog->field_list = g_slist_prepend (idialog->field_list, field);
|
||||
idialog->nfields++;
|
||||
}
|
||||
|
||||
|
@ -107,8 +108,9 @@ update_field (InfoField *field)
|
|||
return;
|
||||
|
||||
if (field->field_type != INFO_LABEL)
|
||||
gtk_signal_handler_block_by_data (GTK_OBJECT (field->obj),
|
||||
field->client_data);
|
||||
gtk_signal_handler_block_by_func (GTK_OBJECT (field->obj),
|
||||
field->callback,
|
||||
field->callback_data);
|
||||
|
||||
switch (field->field_type)
|
||||
{
|
||||
|
@ -143,8 +145,9 @@ update_field (InfoField *field)
|
|||
}
|
||||
|
||||
if (field->field_type != INFO_LABEL)
|
||||
gtk_signal_handler_unblock_by_data (GTK_OBJECT (field->obj),
|
||||
field->client_data);
|
||||
gtk_signal_handler_unblock_by_func (GTK_OBJECT (field->obj),
|
||||
field->callback,
|
||||
field->callback_data);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
|
|
@ -36,10 +36,10 @@ struct _InfoField
|
|||
InfoFieldType field_type;
|
||||
|
||||
GtkObject *obj;
|
||||
void *value_ptr;
|
||||
gpointer value_ptr;
|
||||
|
||||
GtkSignalFunc callback;
|
||||
gpointer client_data;
|
||||
gpointer callback_data;
|
||||
};
|
||||
|
||||
struct _InfoDialog
|
||||
|
|
|
@ -101,7 +101,7 @@ info_window_image_rename_callback (GimpImage *gimage,
|
|||
|
||||
gdisp = (GDisplay *) iwd->gdisp;
|
||||
|
||||
title = info_window_title(gdisp);
|
||||
title = info_window_title (gdisp);
|
||||
gtk_window_set_title (GTK_WINDOW (id->shell), title);
|
||||
g_free (title);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ info_window_page_switch (GtkWidget *widget,
|
|||
{
|
||||
InfoDialog *info_win;
|
||||
InfoWinData *iwd;
|
||||
|
||||
|
||||
info_win = (InfoDialog *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
iwd = (InfoWinData *) info_win->user_data;
|
||||
|
||||
|
@ -317,18 +317,15 @@ info_window_create (GDisplay *gdisp)
|
|||
InfoDialog *info_win;
|
||||
InfoWinData *iwd;
|
||||
gchar *title;
|
||||
gchar *title_buf;
|
||||
gint type;
|
||||
|
||||
title = g_basename (gimp_image_filename (gdisp->gimage));
|
||||
type = gimp_image_base_type (gdisp->gimage);
|
||||
|
||||
/* create the info dialog */
|
||||
title_buf = info_window_title (gdisp);
|
||||
info_win = info_dialog_notebook_new (title_buf,
|
||||
title = info_window_title (gdisp);
|
||||
info_win = info_dialog_notebook_new (title,
|
||||
gimp_standard_help_func,
|
||||
"dialogs/info_window.html");
|
||||
g_free (title_buf);
|
||||
g_free (title);
|
||||
|
||||
/* create the action area */
|
||||
gimp_dialog_create_action_area (GTK_DIALOG (info_win->shell),
|
||||
|
@ -377,24 +374,23 @@ static InfoDialog *info_window_auto = NULL;
|
|||
static gchar *
|
||||
info_window_title (GDisplay *gdisp)
|
||||
{
|
||||
gchar *basename;
|
||||
gchar *title;
|
||||
gchar *title_buf;
|
||||
|
||||
title = g_basename (gimp_image_filename (gdisp->gimage));
|
||||
|
||||
/* create the info dialog */
|
||||
title_buf = g_strdup_printf (_("Info: %s-%d.%d"),
|
||||
title,
|
||||
gimp_image_get_ID (gdisp->gimage),
|
||||
gdisp->instance);
|
||||
|
||||
return title_buf;
|
||||
basename = g_basename (gimp_image_filename (gdisp->gimage));
|
||||
|
||||
title = g_strdup_printf (_("Info: %s-%d.%d"),
|
||||
basename,
|
||||
gimp_image_get_ID (gdisp->gimage),
|
||||
gdisp->instance);
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
static void
|
||||
info_window_change_display (GimpContext *context, /* NOT USED */
|
||||
info_window_change_display (GimpContext *context,
|
||||
GDisplay *newdisp,
|
||||
gpointer data /* Not used */)
|
||||
gpointer data)
|
||||
{
|
||||
GDisplay *gdisp = newdisp;
|
||||
GDisplay *old_gdisp;
|
||||
|
@ -420,29 +416,28 @@ info_window_change_display (GimpContext *context, /* NOT USED */
|
|||
void
|
||||
info_window_follow_auto (void)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
GimpContext *context;
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = gdisplay_active ();
|
||||
|
||||
if (!gdisp)
|
||||
context = gimp_context_get_user ();
|
||||
|
||||
gdisp = gimp_context_get_display (context);
|
||||
|
||||
if (! gdisp)
|
||||
return;
|
||||
|
||||
if(!info_window_auto)
|
||||
if (! info_window_auto)
|
||||
{
|
||||
info_window_auto = info_window_create ((void *) gdisp);
|
||||
gtk_signal_connect (GTK_OBJECT (gimp_context_get_user ()),
|
||||
"display_changed",
|
||||
info_window_auto = info_window_create (gdisp);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (context), "display_changed",
|
||||
GTK_SIGNAL_FUNC (info_window_change_display),
|
||||
NULL);
|
||||
info_window_update (gdisp); /* Update to include the info */
|
||||
|
||||
info_window_update (gdisp);
|
||||
}
|
||||
|
||||
info_dialog_popup (info_window_auto);
|
||||
/*
|
||||
iwd = (NavWinData *)nav_window_auto->user_data;
|
||||
gtk_widget_set_sensitive(nav_window_auto->vbox,TRUE);
|
||||
iwd->frozen = FALSE;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -464,10 +459,10 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
gboolean force_update = FALSE;
|
||||
gint i;
|
||||
|
||||
if (!info_win && info_window_auto != NULL)
|
||||
if (! info_win && info_window_auto != NULL)
|
||||
info_win = info_window_auto;
|
||||
|
||||
if (!info_win)
|
||||
if (! info_win)
|
||||
return;
|
||||
|
||||
iwd = (InfoWinData *) info_win->user_data;
|
||||
|
@ -482,17 +477,18 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
gchar *title;
|
||||
|
||||
info_window_update (gdisp);
|
||||
|
||||
title = info_window_title (gdisp);
|
||||
gtk_window_set_title (GTK_WINDOW (info_window_auto->shell), title);
|
||||
g_free (title);
|
||||
}
|
||||
|
||||
if (!iwd || !iwd->showing_extended)
|
||||
if (! iwd || ! iwd->showing_extended)
|
||||
return;
|
||||
|
||||
/* fill in position information */
|
||||
|
||||
if ( tx < 0.0 && ty < 0.0 )
|
||||
if (tx < 0.0 && ty < 0.0)
|
||||
{
|
||||
iwd->unit_str = NULL;
|
||||
for (i = 0; i < 4; i++)
|
||||
|
@ -506,9 +502,10 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
|
||||
unit_digits = gimp_unit_get_digits (gdisp->gimage->unit);
|
||||
|
||||
if (iwd->unit_str != gimp_unit_get_plural (gdisp->gimage->unit))
|
||||
if (iwd->unit_str != gimp_unit_get_abbreviation (gdisp->gimage->unit))
|
||||
{
|
||||
iwd->unit_str = gimp_unit_get_plural (gdisp->gimage->unit);
|
||||
iwd->unit_str = gimp_unit_get_abbreviation (gdisp->gimage->unit);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (iwd->unit_labels[0]), iwd->unit_str);
|
||||
gtk_label_set_text (GTK_LABEL (iwd->unit_labels[1]), iwd->unit_str);
|
||||
}
|
||||
|
@ -533,9 +530,8 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
}
|
||||
|
||||
/* fill in color information */
|
||||
/* gimp_image_active_drawable (gdisp->gimage) */
|
||||
if (!(color = gimp_image_get_color_at (gdisp->gimage, tx, ty))
|
||||
|| (tx < 0.0 && ty < 0.0))
|
||||
if (! (color = gimp_image_get_color_at (gdisp->gimage, tx, ty))
|
||||
|| (tx < 0.0 && ty < 0.0))
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
gtk_label_set_text (GTK_LABEL (iwd->color_labels[i]), _("N/A"));
|
||||
|
@ -544,7 +540,7 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
{
|
||||
sample_type = gimp_image_composite_type (gdisp->gimage);
|
||||
|
||||
for (i = RED_PIX;
|
||||
for (i = RED_PIX;
|
||||
i <= (GIMP_IMAGE_TYPE_HAS_ALPHA (sample_type) ?
|
||||
ALPHA_PIX : BLUE_PIX);
|
||||
i++)
|
||||
|
@ -555,8 +551,8 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
|
||||
if (i == ALPHA_PIX)
|
||||
gtk_label_set_text (GTK_LABEL (iwd->color_labels[i]), _("N/A"));
|
||||
|
||||
g_free(color);
|
||||
|
||||
g_free (color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -565,13 +561,13 @@ info_window_free (InfoDialog *info_win)
|
|||
{
|
||||
InfoWinData *iwd;
|
||||
|
||||
if (!info_win && info_window_auto)
|
||||
if (! info_win && info_window_auto)
|
||||
{
|
||||
gtk_widget_set_sensitive (info_window_auto->vbox, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!info_win)
|
||||
if (! info_win)
|
||||
return;
|
||||
|
||||
iwd = (InfoWinData *) info_win->user_data;
|
||||
|
@ -592,28 +588,27 @@ info_window_update (GDisplay *gdisp)
|
|||
gchar format_buf[32];
|
||||
InfoDialog *info_win = gdisp->window_info_dialog;
|
||||
|
||||
if (!info_win && info_window_auto != NULL)
|
||||
if (! info_win && info_window_auto != NULL)
|
||||
info_win = info_window_auto;
|
||||
|
||||
if (!info_win)
|
||||
if (! info_win)
|
||||
return;
|
||||
|
||||
iwd = (InfoWinData *) info_win->user_data;
|
||||
|
||||
/* Make it sensitive... */
|
||||
if (info_window_auto)
|
||||
gtk_widget_set_sensitive (info_window_auto->vbox, TRUE);
|
||||
|
||||
/* If doing info_window_auto then return if this display
|
||||
* is not the one we are showing.
|
||||
*/
|
||||
|
||||
if (info_window_auto && iwd->gdisp != gdisp)
|
||||
return;
|
||||
|
||||
/* width and height */
|
||||
unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
|
||||
unit_digits = gimp_unit_get_digits (gdisp->gimage->unit);
|
||||
|
||||
g_snprintf (iwd->dimensions_str, MAX_BUF,
|
||||
_("%d x %d pixels"),
|
||||
(int) gdisp->gimage->width,
|
||||
|
@ -633,7 +628,7 @@ info_window_update (GDisplay *gdisp)
|
|||
|
||||
/* user zoom ratio */
|
||||
g_snprintf (iwd->scale_str, MAX_BUF, "%d:%d",
|
||||
SCALEDEST (gdisp), SCALESRC (gdisp));
|
||||
SCALEDEST (gdisp), SCALESRC (gdisp));
|
||||
|
||||
type = gimp_image_base_type (gdisp->gimage);
|
||||
|
||||
|
@ -647,11 +642,12 @@ info_window_update (GDisplay *gdisp)
|
|||
_("Indexed Color"), gdisp->gimage->num_cols, _("colors"));
|
||||
|
||||
/* visual class */
|
||||
if (type == RGB ||
|
||||
type == INDEXED)
|
||||
g_snprintf (iwd->visual_class_str, MAX_BUF, "%s", gettext (visual_classes[g_visual->type]));
|
||||
if (type == RGB || type == INDEXED)
|
||||
g_snprintf (iwd->visual_class_str, MAX_BUF, "%s",
|
||||
gettext (visual_classes[g_visual->type]));
|
||||
else if (type == GRAY)
|
||||
g_snprintf (iwd->visual_class_str, MAX_BUF, "%s", gettext (visual_classes[g_visual->type]));
|
||||
g_snprintf (iwd->visual_class_str, MAX_BUF, "%s",
|
||||
gettext (visual_classes[g_visual->type]));
|
||||
|
||||
/* visual depth */
|
||||
g_snprintf (iwd->visual_depth_str, MAX_BUF, "%d", g_visual->depth);
|
||||
|
|
|
@ -900,12 +900,11 @@ prefs_cancel_callback (GtkWidget *widget,
|
|||
gimprc.transparency_size = old_transparency_size;
|
||||
|
||||
render_setup (gimprc.transparency_type, gimprc.transparency_size);
|
||||
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_image_invalidate_layer_previews,
|
||||
NULL);
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_viewable_invalidate_preview,
|
||||
NULL);
|
||||
|
||||
gdisplays_expose_full ();
|
||||
gdisplays_flush ();
|
||||
}
|
||||
|
|
|
@ -277,5 +277,8 @@ setup_scale (GDisplay *gdisp)
|
|||
gtk_widget_queue_draw (GTK_WIDGET (hruler));
|
||||
gtk_widget_queue_draw (GTK_WIDGET (vruler));
|
||||
|
||||
nav_window_update_window_marker (gdisp->window_nav_dialog);
|
||||
nav_dialog_update_window_marker (gdisp->window_nav_dialog);
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_dialog_update_window_marker (gdisp->nav_popup);
|
||||
}
|
||||
|
|
|
@ -193,24 +193,26 @@ scroll_display (GDisplay *gdisp,
|
|||
if (x_offset || y_offset)
|
||||
gdisplays_flush ();
|
||||
|
||||
nav_window_update_window_marker(gdisp->window_nav_dialog);
|
||||
nav_dialog_update_window_marker (gdisp->window_nav_dialog);
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_dialog_update_window_marker (gdisp->nav_popup);
|
||||
|
||||
/* Make sure graphics expose events are processed before scrolling
|
||||
* again */
|
||||
|
||||
while ((event = gdk_event_get_graphics_expose (gdisp->canvas->window))
|
||||
!= NULL)
|
||||
{
|
||||
gtk_widget_event (gdisp->canvas, event);
|
||||
* again
|
||||
*/
|
||||
while ((event = gdk_event_get_graphics_expose (gdisp->canvas->window)))
|
||||
{
|
||||
gtk_widget_event (gdisp->canvas, event);
|
||||
|
||||
if (event->expose.count == 0)
|
||||
{
|
||||
gdk_event_free (event);
|
||||
break;
|
||||
}
|
||||
if (event->expose.count == 0)
|
||||
{
|
||||
gdk_event_free (event);
|
||||
break;
|
||||
}
|
||||
|
||||
gdk_event_free (event);
|
||||
}
|
||||
gdk_event_free (event);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -46,29 +46,302 @@
|
|||
#define INITIAL_DELAY 15 /* in milleseconds */
|
||||
|
||||
|
||||
/* static function prototypes */
|
||||
/* local function prototypes */
|
||||
|
||||
static GdkPixmap * create_cycled_ants_pixmap (GdkWindow *window,
|
||||
gint depth);
|
||||
static void cycle_ant_colors (Selection *);
|
||||
|
||||
static void selection_draw (Selection *);
|
||||
static void selection_transform_segs (Selection *,
|
||||
BoundSeg *,
|
||||
GdkSegment *,
|
||||
gint );
|
||||
static void selection_generate_segs (Selection *);
|
||||
static void selection_free_segs (Selection *);
|
||||
static gint selection_march_ants (gpointer );
|
||||
static gint selection_start_marching (gpointer );
|
||||
static void cycle_ant_colors (Selection *select);
|
||||
static void selection_add_point (GdkPoint *points[8],
|
||||
gint max_npoints[8],
|
||||
gint npoints[8],
|
||||
gint x,
|
||||
gint y);
|
||||
static void selection_render_points (Selection *select);
|
||||
static void selection_draw (Selection *select);
|
||||
static void selection_transform_segs (Selection *select,
|
||||
BoundSeg *src_segs,
|
||||
GdkSegment *dest_segs,
|
||||
gint num_segs);
|
||||
static void selection_generate_segs (Selection *select);
|
||||
static void selection_free_segs (Selection *select);
|
||||
static gboolean selection_start_marching (gpointer data);
|
||||
static gboolean selection_march_ants (gpointer data);
|
||||
|
||||
|
||||
GdkPixmap * marching_ants[9] = { NULL };
|
||||
GdkPixmap * cycled_ants_pixmap = NULL;
|
||||
|
||||
|
||||
/*********************************/
|
||||
/* Local function definitions */
|
||||
/*********************************/
|
||||
/* public functions */
|
||||
|
||||
Selection *
|
||||
selection_create (GdkWindow *win,
|
||||
GDisplay *gdisp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed)
|
||||
{
|
||||
GdkColor fg, bg;
|
||||
Selection *new;
|
||||
gint base_type;
|
||||
gint i;
|
||||
|
||||
new = g_new (Selection, 1);
|
||||
base_type = gimp_image_base_type (gdisp->gimage);
|
||||
|
||||
if (gimprc.cycled_marching_ants)
|
||||
{
|
||||
new->cycle = TRUE;
|
||||
if (!cycled_ants_pixmap)
|
||||
cycled_ants_pixmap = create_cycled_ants_pixmap (win, g_visual->depth);
|
||||
|
||||
new->cycle_pix = cycled_ants_pixmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
new->cycle = FALSE;
|
||||
if (!marching_ants[0])
|
||||
for (i = 0; i < 8; i++)
|
||||
marching_ants[i] = gdk_bitmap_create_from_data (win, (char*) ant_data[i], 8, 8);
|
||||
}
|
||||
|
||||
new->win = win;
|
||||
new->gdisp = gdisp;
|
||||
new->segs_in = NULL;
|
||||
new->segs_out = NULL;
|
||||
new->segs_layer = NULL;
|
||||
new->num_segs_in = 0;
|
||||
new->num_segs_out = 0;
|
||||
new->num_segs_layer = 0;
|
||||
new->index_in = 0;
|
||||
new->index_out = 0;
|
||||
new->index_layer = 0;
|
||||
new->state = INVISIBLE;
|
||||
new->paused = 0;
|
||||
new->recalc = TRUE;
|
||||
new->speed = speed;
|
||||
new->hidden = FALSE;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
new->points_in[i] = NULL;
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_in = gdk_gc_new (new->win);
|
||||
|
||||
if (new->cycle)
|
||||
{
|
||||
gdk_gc_set_fill (new->gc_in, GDK_TILED);
|
||||
gdk_gc_set_tile (new->gc_in, new->cycle_pix);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get black and white pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_white_pixel (gdisp);
|
||||
|
||||
gdk_gc_set_foreground (new->gc_in, &fg);
|
||||
gdk_gc_set_background (new->gc_in, &bg);
|
||||
gdk_gc_set_fill (new->gc_in, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
new->gc_white = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_white, &bg);
|
||||
|
||||
new->gc_black = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_black, &fg);
|
||||
#endif
|
||||
|
||||
/* Setup 2nd & 3rd GCs */
|
||||
fg.pixel = gdisplay_white_pixel (gdisp);
|
||||
bg.pixel = gdisplay_gray_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_out = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_out, &fg);
|
||||
gdk_gc_set_background (new->gc_out, &bg);
|
||||
gdk_gc_set_fill (new->gc_out, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_out, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
/* get black and color pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_color_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_layer = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_layer, &fg);
|
||||
gdk_gc_set_background (new->gc_layer, &bg);
|
||||
gdk_gc_set_fill (new->gc_layer, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_layer, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_free (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
g_source_remove (select->timeout_id);
|
||||
|
||||
if (select->gc_in)
|
||||
gdk_gc_destroy (select->gc_in);
|
||||
if (select->gc_out)
|
||||
gdk_gc_destroy (select->gc_out);
|
||||
if (select->gc_layer)
|
||||
gdk_gc_destroy (select->gc_layer);
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
if (select->gc_white)
|
||||
gdk_gc_destroy (select->gc_white);
|
||||
if (select->gc_black)
|
||||
gdk_gc_destroy (select->gc_black);
|
||||
#endif
|
||||
selection_free_segs (select);
|
||||
|
||||
g_free (select);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_pause (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
g_source_remove (select->timeout_id);
|
||||
select->timeout_id = 0;
|
||||
}
|
||||
|
||||
select->paused ++;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_resume (Selection *select)
|
||||
{
|
||||
if (select->paused == 1)
|
||||
{
|
||||
select->state = INTRO;
|
||||
select->timeout_id = g_timeout_add (INITIAL_DELAY,
|
||||
selection_start_marching,
|
||||
select);
|
||||
}
|
||||
|
||||
select->paused--;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_start (Selection *select,
|
||||
gboolean recalc)
|
||||
{
|
||||
/* A call to selection_start with recalc == TRUE means that
|
||||
* we want to recalculate the selection boundary--usually
|
||||
* after scaling or panning the display, or modifying the
|
||||
* selection in some way. If recalc == FALSE, the already
|
||||
* calculated boundary is simply redrawn.
|
||||
*/
|
||||
if (recalc)
|
||||
select->recalc = TRUE;
|
||||
|
||||
/* If this selection is paused, do not start it */
|
||||
if (select->paused > 0)
|
||||
return;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
g_source_remove (select->timeout_id);
|
||||
|
||||
select->state = INTRO; /* The state before the first draw */
|
||||
select->timeout_id = g_timeout_add (INITIAL_DELAY,
|
||||
selection_start_marching,
|
||||
select);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_invis (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
g_source_remove (select->timeout_id);
|
||||
select->timeout_id = 0;
|
||||
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
/* Find the bounds of the selection */
|
||||
if (gdisplay_mask_bounds (gdisp, &x1, &y1, &x2, &y2))
|
||||
{
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
|
||||
}
|
||||
else
|
||||
{
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_layer_invis (Selection *select)
|
||||
{
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gint x3, y3;
|
||||
gint x4, y4;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
g_source_remove (select->timeout_id);
|
||||
select->timeout_id = 0;
|
||||
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
|
||||
if (select->segs_layer != NULL && select->num_segs_layer == 4)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = select->gdisp;
|
||||
|
||||
x1 = select->segs_layer[0].x1 - 1;
|
||||
y1 = select->segs_layer[0].y1 - 1;
|
||||
x2 = select->segs_layer[3].x2 + 1;
|
||||
y2 = select->segs_layer[3].y2 + 1;
|
||||
|
||||
x3 = select->segs_layer[0].x1 + 1;
|
||||
y3 = select->segs_layer[0].y1 + 1;
|
||||
x4 = select->segs_layer[3].x2 - 1;
|
||||
y4 = select->segs_layer[3].y2 - 1;
|
||||
|
||||
/* expose the region */
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1) + 1, (y3 - y1) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y3, (x3 - x1) + 1, (y4 - y3) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y4, (x2 - x1) + 1, (y2 - y4) + 1);
|
||||
gdisplay_expose_area (gdisp, x4, y3, (x2 - x4) + 1, (y4 - y3) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_toggle (Selection *select)
|
||||
{
|
||||
selection_invis (select);
|
||||
selection_layer_invis (select);
|
||||
|
||||
/* toggle the visibility */
|
||||
select->hidden = select->hidden ? FALSE : TRUE;
|
||||
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static GdkPixmap *
|
||||
create_cycled_ants_pixmap (GdkWindow *window,
|
||||
|
@ -112,6 +385,7 @@ cycle_ant_colors (Selection *select)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#define MAX_POINTS_INC 2048
|
||||
|
||||
static void
|
||||
|
@ -228,6 +502,7 @@ selection_render_points (Selection *select)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
selection_draw (Selection *select)
|
||||
{
|
||||
|
@ -290,11 +565,11 @@ static void
|
|||
selection_transform_segs (Selection *select,
|
||||
BoundSeg *src_segs,
|
||||
GdkSegment *dest_segs,
|
||||
int num_segs)
|
||||
gint num_segs)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x, y;
|
||||
int i;
|
||||
GDisplay *gdisp;
|
||||
gint x, y;
|
||||
gint i;
|
||||
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
|
@ -338,7 +613,7 @@ selection_transform_segs (Selection *select,
|
|||
static void
|
||||
selection_generate_segs (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
GDisplay *gdisp;
|
||||
BoundSeg *segs_in;
|
||||
BoundSeg *segs_out;
|
||||
BoundSeg *segs_layer;
|
||||
|
@ -399,6 +674,7 @@ static void
|
|||
selection_free_segs (Selection *select)
|
||||
{
|
||||
gint j;
|
||||
|
||||
if (select->segs_in)
|
||||
g_free (select->segs_in);
|
||||
if (select->segs_out)
|
||||
|
@ -410,7 +686,8 @@ selection_free_segs (Selection *select)
|
|||
{
|
||||
if (select->points_in[j])
|
||||
g_free (select->points_in[j]);
|
||||
select->points_in[j] = NULL;
|
||||
|
||||
select->points_in[j] = NULL;
|
||||
select->num_points_in[j] = 0;
|
||||
}
|
||||
|
||||
|
@ -423,10 +700,10 @@ selection_free_segs (Selection *select)
|
|||
}
|
||||
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
selection_start_marching (gpointer data)
|
||||
{
|
||||
Selection * select;
|
||||
Selection *select;
|
||||
|
||||
select = (Selection *) data;
|
||||
|
||||
|
@ -435,12 +712,13 @@ selection_start_marching (gpointer data)
|
|||
{
|
||||
selection_free_segs (select);
|
||||
selection_generate_segs (select);
|
||||
|
||||
/* Toggle the RECALC flag */
|
||||
select->recalc = FALSE;
|
||||
}
|
||||
|
||||
select->index_in = 0;
|
||||
select->index_out = 0;
|
||||
select->index_in = 0;
|
||||
select->index_out = 0;
|
||||
select->index_layer = 0;
|
||||
|
||||
/* Make sure the state is set to marching */
|
||||
|
@ -459,22 +737,24 @@ selection_start_marching (gpointer data)
|
|||
selection_draw (select);
|
||||
|
||||
/* Reset the timer */
|
||||
select->timer = gtk_timeout_add (select->speed,
|
||||
selection_march_ants,
|
||||
(gpointer) select);
|
||||
select->timeout_id = g_timeout_add (select->speed,
|
||||
selection_march_ants,
|
||||
select);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
|
||||
static gboolean
|
||||
selection_march_ants (gpointer data)
|
||||
{
|
||||
Selection * select;
|
||||
Selection *select;
|
||||
|
||||
select = (Selection *) data;
|
||||
|
||||
/* increment stipple index */
|
||||
select->index_in++;
|
||||
|
||||
#ifndef USE_XDRAWPOINTS
|
||||
if (select->index_in > 7)
|
||||
select->index_in = 0;
|
||||
|
@ -500,260 +780,3 @@ selection_march_ants (gpointer data)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*********************************/
|
||||
/* Public function definitions */
|
||||
/*********************************/
|
||||
|
||||
Selection *
|
||||
selection_create (GdkWindow *win,
|
||||
GDisplay *gdisp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed)
|
||||
{
|
||||
GdkColor fg, bg;
|
||||
Selection *new;
|
||||
gint base_type;
|
||||
gint i;
|
||||
|
||||
new = g_new (Selection, 1);
|
||||
base_type = gimp_image_base_type (gdisp->gimage);
|
||||
|
||||
if (gimprc.cycled_marching_ants)
|
||||
{
|
||||
new->cycle = TRUE;
|
||||
if (!cycled_ants_pixmap)
|
||||
cycled_ants_pixmap = create_cycled_ants_pixmap (win, g_visual->depth);
|
||||
|
||||
new->cycle_pix = cycled_ants_pixmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
new->cycle = FALSE;
|
||||
if (!marching_ants[0])
|
||||
for (i = 0; i < 8; i++)
|
||||
marching_ants[i] = gdk_bitmap_create_from_data (win, (char*) ant_data[i], 8, 8);
|
||||
}
|
||||
|
||||
new->win = win;
|
||||
new->gdisp = gdisp;
|
||||
new->segs_in = NULL;
|
||||
new->segs_out = NULL;
|
||||
new->segs_layer = NULL;
|
||||
new->num_segs_in = 0;
|
||||
new->num_segs_out = 0;
|
||||
new->num_segs_layer = 0;
|
||||
new->index_in = 0;
|
||||
new->index_out = 0;
|
||||
new->index_layer = 0;
|
||||
new->state = INVISIBLE;
|
||||
new->paused = 0;
|
||||
new->recalc = TRUE;
|
||||
new->speed = speed;
|
||||
new->hidden = FALSE;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
new->points_in[i] = NULL;
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_in = gdk_gc_new (new->win);
|
||||
|
||||
if (new->cycle)
|
||||
{
|
||||
gdk_gc_set_fill (new->gc_in, GDK_TILED);
|
||||
gdk_gc_set_tile (new->gc_in, new->cycle_pix);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get black and white pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_white_pixel (gdisp);
|
||||
|
||||
gdk_gc_set_foreground (new->gc_in, &fg);
|
||||
gdk_gc_set_background (new->gc_in, &bg);
|
||||
gdk_gc_set_fill (new->gc_in, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
new->gc_white = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_white, &bg);
|
||||
|
||||
new->gc_black = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_black, &fg);
|
||||
#endif
|
||||
|
||||
/* Setup 2nd & 3rd GCs */
|
||||
fg.pixel = gdisplay_white_pixel (gdisp);
|
||||
bg.pixel = gdisplay_gray_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_out = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_out, &fg);
|
||||
gdk_gc_set_background (new->gc_out, &bg);
|
||||
gdk_gc_set_fill (new->gc_out, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_out, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
/* get black and color pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_color_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_layer = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_layer, &fg);
|
||||
gdk_gc_set_background (new->gc_layer, &bg);
|
||||
gdk_gc_set_fill (new->gc_layer, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_layer, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_pause (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
gtk_timeout_remove (select->timer);
|
||||
|
||||
select->paused ++;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_resume (Selection *select)
|
||||
{
|
||||
if (select->paused == 1)
|
||||
{
|
||||
select->state = INTRO;
|
||||
select->timer = gtk_timeout_add (INITIAL_DELAY, selection_start_marching,
|
||||
(gpointer) select);
|
||||
}
|
||||
|
||||
select->paused--;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_start (Selection *select,
|
||||
int recalc)
|
||||
{
|
||||
/* A call to selection_start with recalc == TRUE means that
|
||||
* we want to recalculate the selection boundary--usually
|
||||
* after scaling or panning the display, or modifying the
|
||||
* selection in some way. If recalc == FALSE, the already
|
||||
* calculated boundary is simply redrawn.
|
||||
*/
|
||||
if (recalc)
|
||||
select->recalc = TRUE;
|
||||
|
||||
/* If this selection is paused, do not start it */
|
||||
if (select->paused > 0)
|
||||
return;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
gtk_timeout_remove (select->timer);
|
||||
|
||||
select->state = INTRO; /* The state before the first draw */
|
||||
select->timer = gtk_timeout_add (INITIAL_DELAY, selection_start_marching,
|
||||
(gpointer) select);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_invis (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
gtk_timeout_remove (select->timer);
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
/* Find the bounds of the selection */
|
||||
if (gdisplay_mask_bounds (gdisp, &x1, &y1, &x2, &y2))
|
||||
{
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
|
||||
}
|
||||
else
|
||||
{
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_layer_invis (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2;
|
||||
int x3, y3, x4, y4;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
gtk_timeout_remove (select->timer);
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
if (select->segs_layer != NULL && select->num_segs_layer == 4)
|
||||
{
|
||||
x1 = select->segs_layer[0].x1 - 1;
|
||||
y1 = select->segs_layer[0].y1 - 1;
|
||||
x2 = select->segs_layer[3].x2 + 1;
|
||||
y2 = select->segs_layer[3].y2 + 1;
|
||||
|
||||
x3 = select->segs_layer[0].x1 + 1;
|
||||
y3 = select->segs_layer[0].y1 + 1;
|
||||
x4 = select->segs_layer[3].x2 - 1;
|
||||
y4 = select->segs_layer[3].y2 - 1;
|
||||
|
||||
/* expose the region */
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1) + 1, (y3 - y1) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y3, (x3 - x1) + 1, (y4 - y3) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y4, (x2 - x1) + 1, (y2 - y4) + 1);
|
||||
gdisplay_expose_area (gdisp, x4, y3, (x2 - x4) + 1, (y4 - y3) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_hide (Selection *select,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
selection_invis (select);
|
||||
selection_layer_invis (select);
|
||||
|
||||
/* toggle the visibility */
|
||||
select->hidden = select->hidden ? FALSE : TRUE;
|
||||
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_free (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
gtk_timeout_remove (select->timer);
|
||||
|
||||
if (select->gc_in)
|
||||
gdk_gc_destroy (select->gc_in);
|
||||
if (select->gc_out)
|
||||
gdk_gc_destroy (select->gc_out);
|
||||
if (select->gc_layer)
|
||||
gdk_gc_destroy (select->gc_layer);
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
if (select->gc_white)
|
||||
gdk_gc_destroy (select->gc_white);
|
||||
if (select->gc_black)
|
||||
gdk_gc_destroy (select->gc_black);
|
||||
#endif
|
||||
selection_free_segs (select);
|
||||
g_free (select);
|
||||
}
|
||||
|
|
|
@ -42,10 +42,10 @@ struct _Selection
|
|||
gint index_layer; /* index of current stipple pattern */
|
||||
gint state; /* internal drawing state */
|
||||
gint paused; /* count of pause requests */
|
||||
gint recalc; /* flag to recalculate the selection */
|
||||
gboolean recalc; /* flag to recalculate the selection */
|
||||
gint speed; /* speed of marching ants */
|
||||
gint hidden; /* is the selection hidden? */
|
||||
gint timer; /* timer for successive draws */
|
||||
gboolean hidden; /* is the selection hidden? */
|
||||
guint timeout_id; /* timer for successive draws */
|
||||
gint cycle; /* color cycling turned on */
|
||||
GdkPixmap *cycle_pix; /* cycling pixmap */
|
||||
|
||||
|
@ -57,22 +57,22 @@ struct _Selection
|
|||
};
|
||||
|
||||
|
||||
/* Function declarations */
|
||||
Selection * selection_create (GdkWindow *window,
|
||||
GDisplay *gdisp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed);
|
||||
void selection_free (Selection *select);
|
||||
|
||||
Selection * selection_create (GdkWindow *win,
|
||||
GDisplay *disp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed);
|
||||
void selection_pause (Selection *select);
|
||||
void selection_resume (Selection *select);
|
||||
void selection_start (Selection *select,
|
||||
gint recalc);
|
||||
void selection_invis (Selection *select);
|
||||
void selection_layer_invis (Selection *select);
|
||||
void selection_hide (Selection *select,
|
||||
GDisplay *gdisp);
|
||||
void selection_free (Selection *select);
|
||||
void selection_pause (Selection *select);
|
||||
void selection_resume (Selection *select);
|
||||
|
||||
void selection_start (Selection *select,
|
||||
gboolean recalc);
|
||||
void selection_invis (Selection *select);
|
||||
void selection_layer_invis (Selection *select);
|
||||
|
||||
void selection_toggle (Selection *select);
|
||||
|
||||
|
||||
#endif /* __SELECTION_H__ */
|
||||
|
|
|
@ -143,40 +143,79 @@ gdisplay_new (GimpImage *gimage,
|
|||
/*
|
||||
* Set all GDisplay parameters...
|
||||
*/
|
||||
gdisp = g_new (GDisplay, 1);
|
||||
gdisp = g_new0 (GDisplay, 1);
|
||||
|
||||
gdisp->offset_x = 0;
|
||||
gdisp->offset_y = 0;
|
||||
gdisp->scale = scale;
|
||||
gdisp->dot_for_dot = gimprc.default_dot_for_dot;
|
||||
gdisp->gimage = gimage;
|
||||
gdisp->window_info_dialog = NULL;
|
||||
gdisp->window_nav_dialog = NULL;
|
||||
gdisp->nav_popup = NULL;
|
||||
gdisp->select = NULL;
|
||||
gdisp->ID = display_num++;
|
||||
gdisp->instance = gimage->instance_count;
|
||||
gdisp->update_areas = NULL;
|
||||
gdisp->display_areas = NULL;
|
||||
gdisp->disp_xoffset = 0;
|
||||
gdisp->disp_yoffset = 0;
|
||||
gdisp->current_cursor = (GdkCursorType) -1;
|
||||
gdisp->tool_cursor = GIMP_TOOL_CURSOR_NONE;
|
||||
gdisp->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
|
||||
gdisp->draw_guides = TRUE;
|
||||
gdisp->snap_to_guides = TRUE;
|
||||
gdisp->ID = display_num++;
|
||||
|
||||
gdisp->draw_cursor = FALSE;
|
||||
gdisp->proximity = FALSE;
|
||||
gdisp->have_cursor = FALSE;
|
||||
gdisp->cursor_x = 0;
|
||||
gdisp->cursor_y = 0;
|
||||
gdisp->using_override_cursor = FALSE;
|
||||
gdisp->ifactory = NULL;
|
||||
|
||||
gdisp->shell = NULL;
|
||||
gdisp->canvas = NULL;
|
||||
gdisp->hsb = NULL;
|
||||
gdisp->vsb = NULL;
|
||||
gdisp->qmaskoff = NULL;
|
||||
gdisp->qmaskon = NULL;
|
||||
gdisp->hrule = NULL;
|
||||
gdisp->vrule = NULL;
|
||||
gdisp->origin = NULL;
|
||||
gdisp->statusarea = NULL;
|
||||
gdisp->progressbar = NULL;
|
||||
gdisp->cursor_label = NULL;
|
||||
gdisp->cursor_format_str[0] = '\0';
|
||||
gdisp->cancelbutton = NULL;
|
||||
gdisp->progressid = FALSE;
|
||||
|
||||
gdisp->window_info_dialog = NULL;
|
||||
gdisp->window_nav_dialog = NULL;
|
||||
gdisp->nav_popup = NULL;
|
||||
gdisp->warning_dialog = NULL;
|
||||
|
||||
gdisp->hsbdata = NULL;
|
||||
gdisp->vsbdata = NULL;
|
||||
|
||||
gdisp->icon = NULL;
|
||||
gdisp->iconmask = NULL;
|
||||
gdisp->iconsize = 0;
|
||||
gdisp->icon_needs_update = FALSE;
|
||||
gdisp->icon_timeout_id = 0;
|
||||
gdisp->icon_idle_id = 0;
|
||||
|
||||
gdisp->gimage = gimage;
|
||||
gdisp->instance = gimage->instance_count;
|
||||
|
||||
gdisp->disp_width = 0;
|
||||
gdisp->disp_height = 0;
|
||||
gdisp->disp_xoffset = 0;
|
||||
gdisp->disp_yoffset = 0;
|
||||
|
||||
gdisp->offset_x = 0;
|
||||
gdisp->offset_y = 0;
|
||||
gdisp->scale = scale;
|
||||
gdisp->dot_for_dot = gimprc.default_dot_for_dot;
|
||||
gdisp->draw_guides = TRUE;
|
||||
gdisp->snap_to_guides = TRUE;
|
||||
|
||||
gdisp->select = NULL;
|
||||
|
||||
gdisp->scroll_gc = NULL;
|
||||
|
||||
gdisp->update_areas = NULL;
|
||||
gdisp->display_areas = NULL;
|
||||
|
||||
gdisp->current_cursor = (GdkCursorType) -1;
|
||||
gdisp->tool_cursor = GIMP_TOOL_CURSOR_NONE;
|
||||
gdisp->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
|
||||
|
||||
gdisp->override_cursor = (GdkCursorType) -1;
|
||||
gdisp->using_override_cursor = FALSE;
|
||||
|
||||
gdisp->draw_cursor = FALSE;
|
||||
gdisp->cursor_x = 0;
|
||||
gdisp->cursor_y = 0;
|
||||
gdisp->proximity = FALSE;
|
||||
gdisp->have_cursor = FALSE;
|
||||
|
||||
gdisp->idle_render.idleid = -1;
|
||||
/*gdisp->idle_render.handlerid = -1;*/
|
||||
gdisp->idle_render.update_areas = NULL;
|
||||
gdisp->idle_render.active = FALSE;
|
||||
|
||||
|
@ -185,13 +224,11 @@ gdisplay_new (GimpImage *gimage,
|
|||
gdisp->cd_ui = NULL;
|
||||
#endif /* DISPLAY_FILTERS */
|
||||
|
||||
gdisp->warning_dialog = NULL;
|
||||
|
||||
/* format the title */
|
||||
gdisplay_format_title (gdisp, title, MAX_TITLE_BUF);
|
||||
|
||||
/* add the new display to the list so that it isn't lost */
|
||||
display_list = g_slist_append (display_list, (void *) gdisp);
|
||||
display_list = g_slist_append (display_list, gdisp);
|
||||
|
||||
/* create the shell for the image */
|
||||
create_display_shell (gdisp, gimage->width, gimage->height,
|
||||
|
@ -223,7 +260,8 @@ gdisplay_new (GimpImage *gimage,
|
|||
gtk_object_sink (GTK_OBJECT (gimage));
|
||||
|
||||
/* We're interested in clean and dirty signals so we can update the
|
||||
* title if need be. */
|
||||
* title if need be.
|
||||
*/
|
||||
gtk_signal_connect (GTK_OBJECT (gimage), "dirty",
|
||||
GTK_SIGNAL_FUNC (gdisplay_cleandirty_handler), gdisp);
|
||||
gtk_signal_connect (GTK_OBJECT (gimage), "clean",
|
||||
|
@ -421,14 +459,14 @@ gdisplay_delete (GDisplay *gdisp)
|
|||
info_window_free (gdisp->window_info_dialog);
|
||||
|
||||
/* Remove navigation dialog */
|
||||
nav_window_free (gdisp, gdisp->window_nav_dialog);
|
||||
nav_dialog_free (gdisp, gdisp->window_nav_dialog);
|
||||
|
||||
/* free the gimage */
|
||||
gdisp->gimage->disp_count--;
|
||||
gtk_object_unref (GTK_OBJECT (gdisp->gimage));
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_popup_free (gdisp->nav_popup);
|
||||
nav_dialog_free (gdisp, gdisp->nav_popup);
|
||||
|
||||
if (gdisp->icon_timeout_id)
|
||||
g_source_remove (gdisp->icon_timeout_id);
|
||||
|
@ -2146,6 +2184,33 @@ gdisplay_expose_full (GDisplay *gdisp)
|
|||
gdisp->disp_height);
|
||||
}
|
||||
|
||||
void
|
||||
gdisplay_selection_visibility (GDisplay *gdisp,
|
||||
SelectionControl function)
|
||||
{
|
||||
if (gdisp->select)
|
||||
{
|
||||
switch (function)
|
||||
{
|
||||
case SELECTION_OFF:
|
||||
selection_invis (gdisp->select);
|
||||
break;
|
||||
case SELECTION_LAYER_OFF:
|
||||
selection_layer_invis (gdisp->select);
|
||||
break;
|
||||
case SELECTION_ON:
|
||||
selection_start (gdisp->select, TRUE);
|
||||
break;
|
||||
case SELECTION_PAUSE:
|
||||
selection_pause (gdisp->select);
|
||||
break;
|
||||
case SELECTION_RESUME:
|
||||
selection_resume (gdisp->select);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
/* Functions independent of a specific gdisplay */
|
||||
/**************************************************/
|
||||
|
@ -2414,10 +2479,13 @@ gdisplays_nav_preview_resized (void)
|
|||
gdisp = (GDisplay *) list->data;
|
||||
|
||||
if (gdisp->window_nav_dialog)
|
||||
nav_window_preview_resized (gdisp->window_nav_dialog);
|
||||
nav_dialog_preview_resized (gdisp->window_nav_dialog);
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_window_popup_preview_resized (&gdisp->nav_popup);
|
||||
{
|
||||
nav_dialog_free (NULL, gdisp->nav_popup);
|
||||
gdisp->nav_popup = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2427,35 +2495,14 @@ gdisplays_selection_visibility (GimpImage *gimage,
|
|||
{
|
||||
GDisplay *gdisp;
|
||||
GSList *list;
|
||||
gint count = 0;
|
||||
|
||||
/* traverse the linked list of displays, handling each one */
|
||||
for (list = display_list; list; list = g_slist_next (list))
|
||||
{
|
||||
gdisp = (GDisplay *) list->data;
|
||||
|
||||
if (gdisp->gimage == gimage && gdisp->select)
|
||||
{
|
||||
switch (function)
|
||||
{
|
||||
case SelectionOff:
|
||||
selection_invis (gdisp->select);
|
||||
break;
|
||||
case SelectionLayerOff:
|
||||
selection_layer_invis (gdisp->select);
|
||||
break;
|
||||
case SelectionOn:
|
||||
selection_start (gdisp->select, TRUE);
|
||||
break;
|
||||
case SelectionPause:
|
||||
selection_pause (gdisp->select);
|
||||
break;
|
||||
case SelectionResume:
|
||||
selection_resume (gdisp->select);
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
if (gdisp->gimage == gimage)
|
||||
gdisplay_selection_visibility (gdisp, function);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
|
||||
typedef enum
|
||||
{
|
||||
SelectionOff,
|
||||
SelectionLayerOff,
|
||||
SelectionOn,
|
||||
SelectionPause,
|
||||
SelectionResume
|
||||
SELECTION_OFF,
|
||||
SELECTION_LAYER_OFF,
|
||||
SELECTION_ON,
|
||||
SELECTION_PAUSE,
|
||||
SELECTION_RESUME
|
||||
} SelectionControl;
|
||||
|
||||
|
||||
|
@ -87,7 +87,6 @@ struct _IdleRenderStruct
|
|||
gint basex;
|
||||
gint basey;
|
||||
guint idleid;
|
||||
/*guint handlerid;*/
|
||||
gboolean active;
|
||||
GSList *update_areas; /* flushed update areas */
|
||||
};
|
||||
|
@ -101,7 +100,8 @@ struct _GDisplay
|
|||
|
||||
GtkWidget *shell; /* shell widget for this gdisplay */
|
||||
GtkWidget *canvas; /* canvas widget for this gdisplay */
|
||||
GtkWidget *hsb, *vsb; /* widgets for scroll bars */
|
||||
GtkWidget *hsb; /* widgets for scroll bars */
|
||||
GtkWidget *vsb;
|
||||
GtkWidget *qmaskoff; /* widgets for qmask buttons */
|
||||
GtkWidget *qmaskon;
|
||||
GtkWidget *hrule; /* widgets for rulers */
|
||||
|
@ -119,9 +119,10 @@ struct _GDisplay
|
|||
GtkWidget *cancelbutton; /* widget for cancel button */
|
||||
guint progressid; /* id of statusbar message for progress */
|
||||
|
||||
InfoDialog *window_info_dialog; /* dialog box for image information */
|
||||
InfoDialog *window_nav_dialog; /* dialog box for image navigation */
|
||||
GtkWidget *nav_popup; /* widget for the popup navigation window */
|
||||
InfoDialog *window_info_dialog; /* dialog box for image information */
|
||||
NavigationDialog *window_nav_dialog; /* dialog box for image navigation */
|
||||
NavigationDialog *nav_popup; /* the popup navigation window */
|
||||
GtkWidget *warning_dialog; /* "Changes were made to %s. Close anyway?" */
|
||||
|
||||
GtkAdjustment *hsbdata; /* horizontal data information */
|
||||
GtkAdjustment *vsbdata; /* vertical data information */
|
||||
|
@ -129,9 +130,9 @@ struct _GDisplay
|
|||
GdkPixmap *icon; /* Pixmap for the icon */
|
||||
GdkBitmap *iconmask; /* Bitmap for the icon mask */
|
||||
guint iconsize; /* The size of the icon pixmap */
|
||||
guint icon_needs_update; /* Do we need to render a new icon? */
|
||||
gint icon_timeout_id; /* The ID of the timeout-function */
|
||||
gint icon_idle_id; /* The ID of the idle-function */
|
||||
gboolean icon_needs_update; /* Do we need to render a new icon? */
|
||||
guint icon_timeout_id; /* The ID of the timeout-function */
|
||||
guint icon_idle_id; /* The ID of the idle-function */
|
||||
|
||||
GimpImage *gimage; /* pointer to the associated gimage struct */
|
||||
gint instance; /* the instance # of this gdisplay as */
|
||||
|
@ -175,8 +176,6 @@ struct _GDisplay
|
|||
GList *cd_list; /* color display conversion stuff */
|
||||
GtkWidget *cd_ui; /* color display filter dialog */
|
||||
#endif /* DISPLAY_FILTERS */
|
||||
|
||||
GtkWidget *warning_dialog; /* "Changes were made to %s. Close anyway?" */
|
||||
};
|
||||
|
||||
|
||||
|
@ -245,6 +244,8 @@ void gdisplay_expose_area (GDisplay *gdisp,
|
|||
void gdisplay_expose_guide (GDisplay *gdisp,
|
||||
GimpGuide *guide);
|
||||
void gdisplay_expose_full (GDisplay *gdisp);
|
||||
void gdisplay_selection_visibility (GDisplay *gdisp,
|
||||
SelectionControl function);
|
||||
void gdisplay_flush (GDisplay *gdisp);
|
||||
void gdisplay_flush_now (GDisplay *gdisp);
|
||||
void gdisplay_update_icon (GDisplay *gdisp);
|
||||
|
|
|
@ -277,5 +277,8 @@ setup_scale (GDisplay *gdisp)
|
|||
gtk_widget_queue_draw (GTK_WIDGET (hruler));
|
||||
gtk_widget_queue_draw (GTK_WIDGET (vruler));
|
||||
|
||||
nav_window_update_window_marker (gdisp->window_nav_dialog);
|
||||
nav_dialog_update_window_marker (gdisp->window_nav_dialog);
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_dialog_update_window_marker (gdisp->nav_popup);
|
||||
}
|
||||
|
|
|
@ -193,24 +193,26 @@ scroll_display (GDisplay *gdisp,
|
|||
if (x_offset || y_offset)
|
||||
gdisplays_flush ();
|
||||
|
||||
nav_window_update_window_marker(gdisp->window_nav_dialog);
|
||||
nav_dialog_update_window_marker (gdisp->window_nav_dialog);
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_dialog_update_window_marker (gdisp->nav_popup);
|
||||
|
||||
/* Make sure graphics expose events are processed before scrolling
|
||||
* again */
|
||||
|
||||
while ((event = gdk_event_get_graphics_expose (gdisp->canvas->window))
|
||||
!= NULL)
|
||||
{
|
||||
gtk_widget_event (gdisp->canvas, event);
|
||||
* again
|
||||
*/
|
||||
while ((event = gdk_event_get_graphics_expose (gdisp->canvas->window)))
|
||||
{
|
||||
gtk_widget_event (gdisp->canvas, event);
|
||||
|
||||
if (event->expose.count == 0)
|
||||
{
|
||||
gdk_event_free (event);
|
||||
break;
|
||||
}
|
||||
if (event->expose.count == 0)
|
||||
{
|
||||
gdk_event_free (event);
|
||||
break;
|
||||
}
|
||||
|
||||
gdk_event_free (event);
|
||||
}
|
||||
gdk_event_free (event);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -46,29 +46,302 @@
|
|||
#define INITIAL_DELAY 15 /* in milleseconds */
|
||||
|
||||
|
||||
/* static function prototypes */
|
||||
/* local function prototypes */
|
||||
|
||||
static GdkPixmap * create_cycled_ants_pixmap (GdkWindow *window,
|
||||
gint depth);
|
||||
static void cycle_ant_colors (Selection *);
|
||||
|
||||
static void selection_draw (Selection *);
|
||||
static void selection_transform_segs (Selection *,
|
||||
BoundSeg *,
|
||||
GdkSegment *,
|
||||
gint );
|
||||
static void selection_generate_segs (Selection *);
|
||||
static void selection_free_segs (Selection *);
|
||||
static gint selection_march_ants (gpointer );
|
||||
static gint selection_start_marching (gpointer );
|
||||
static void cycle_ant_colors (Selection *select);
|
||||
static void selection_add_point (GdkPoint *points[8],
|
||||
gint max_npoints[8],
|
||||
gint npoints[8],
|
||||
gint x,
|
||||
gint y);
|
||||
static void selection_render_points (Selection *select);
|
||||
static void selection_draw (Selection *select);
|
||||
static void selection_transform_segs (Selection *select,
|
||||
BoundSeg *src_segs,
|
||||
GdkSegment *dest_segs,
|
||||
gint num_segs);
|
||||
static void selection_generate_segs (Selection *select);
|
||||
static void selection_free_segs (Selection *select);
|
||||
static gboolean selection_start_marching (gpointer data);
|
||||
static gboolean selection_march_ants (gpointer data);
|
||||
|
||||
|
||||
GdkPixmap * marching_ants[9] = { NULL };
|
||||
GdkPixmap * cycled_ants_pixmap = NULL;
|
||||
|
||||
|
||||
/*********************************/
|
||||
/* Local function definitions */
|
||||
/*********************************/
|
||||
/* public functions */
|
||||
|
||||
Selection *
|
||||
selection_create (GdkWindow *win,
|
||||
GDisplay *gdisp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed)
|
||||
{
|
||||
GdkColor fg, bg;
|
||||
Selection *new;
|
||||
gint base_type;
|
||||
gint i;
|
||||
|
||||
new = g_new (Selection, 1);
|
||||
base_type = gimp_image_base_type (gdisp->gimage);
|
||||
|
||||
if (gimprc.cycled_marching_ants)
|
||||
{
|
||||
new->cycle = TRUE;
|
||||
if (!cycled_ants_pixmap)
|
||||
cycled_ants_pixmap = create_cycled_ants_pixmap (win, g_visual->depth);
|
||||
|
||||
new->cycle_pix = cycled_ants_pixmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
new->cycle = FALSE;
|
||||
if (!marching_ants[0])
|
||||
for (i = 0; i < 8; i++)
|
||||
marching_ants[i] = gdk_bitmap_create_from_data (win, (char*) ant_data[i], 8, 8);
|
||||
}
|
||||
|
||||
new->win = win;
|
||||
new->gdisp = gdisp;
|
||||
new->segs_in = NULL;
|
||||
new->segs_out = NULL;
|
||||
new->segs_layer = NULL;
|
||||
new->num_segs_in = 0;
|
||||
new->num_segs_out = 0;
|
||||
new->num_segs_layer = 0;
|
||||
new->index_in = 0;
|
||||
new->index_out = 0;
|
||||
new->index_layer = 0;
|
||||
new->state = INVISIBLE;
|
||||
new->paused = 0;
|
||||
new->recalc = TRUE;
|
||||
new->speed = speed;
|
||||
new->hidden = FALSE;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
new->points_in[i] = NULL;
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_in = gdk_gc_new (new->win);
|
||||
|
||||
if (new->cycle)
|
||||
{
|
||||
gdk_gc_set_fill (new->gc_in, GDK_TILED);
|
||||
gdk_gc_set_tile (new->gc_in, new->cycle_pix);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get black and white pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_white_pixel (gdisp);
|
||||
|
||||
gdk_gc_set_foreground (new->gc_in, &fg);
|
||||
gdk_gc_set_background (new->gc_in, &bg);
|
||||
gdk_gc_set_fill (new->gc_in, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
new->gc_white = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_white, &bg);
|
||||
|
||||
new->gc_black = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_black, &fg);
|
||||
#endif
|
||||
|
||||
/* Setup 2nd & 3rd GCs */
|
||||
fg.pixel = gdisplay_white_pixel (gdisp);
|
||||
bg.pixel = gdisplay_gray_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_out = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_out, &fg);
|
||||
gdk_gc_set_background (new->gc_out, &bg);
|
||||
gdk_gc_set_fill (new->gc_out, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_out, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
/* get black and color pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_color_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_layer = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_layer, &fg);
|
||||
gdk_gc_set_background (new->gc_layer, &bg);
|
||||
gdk_gc_set_fill (new->gc_layer, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_layer, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_free (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
g_source_remove (select->timeout_id);
|
||||
|
||||
if (select->gc_in)
|
||||
gdk_gc_destroy (select->gc_in);
|
||||
if (select->gc_out)
|
||||
gdk_gc_destroy (select->gc_out);
|
||||
if (select->gc_layer)
|
||||
gdk_gc_destroy (select->gc_layer);
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
if (select->gc_white)
|
||||
gdk_gc_destroy (select->gc_white);
|
||||
if (select->gc_black)
|
||||
gdk_gc_destroy (select->gc_black);
|
||||
#endif
|
||||
selection_free_segs (select);
|
||||
|
||||
g_free (select);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_pause (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
g_source_remove (select->timeout_id);
|
||||
select->timeout_id = 0;
|
||||
}
|
||||
|
||||
select->paused ++;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_resume (Selection *select)
|
||||
{
|
||||
if (select->paused == 1)
|
||||
{
|
||||
select->state = INTRO;
|
||||
select->timeout_id = g_timeout_add (INITIAL_DELAY,
|
||||
selection_start_marching,
|
||||
select);
|
||||
}
|
||||
|
||||
select->paused--;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_start (Selection *select,
|
||||
gboolean recalc)
|
||||
{
|
||||
/* A call to selection_start with recalc == TRUE means that
|
||||
* we want to recalculate the selection boundary--usually
|
||||
* after scaling or panning the display, or modifying the
|
||||
* selection in some way. If recalc == FALSE, the already
|
||||
* calculated boundary is simply redrawn.
|
||||
*/
|
||||
if (recalc)
|
||||
select->recalc = TRUE;
|
||||
|
||||
/* If this selection is paused, do not start it */
|
||||
if (select->paused > 0)
|
||||
return;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
g_source_remove (select->timeout_id);
|
||||
|
||||
select->state = INTRO; /* The state before the first draw */
|
||||
select->timeout_id = g_timeout_add (INITIAL_DELAY,
|
||||
selection_start_marching,
|
||||
select);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_invis (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
g_source_remove (select->timeout_id);
|
||||
select->timeout_id = 0;
|
||||
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
/* Find the bounds of the selection */
|
||||
if (gdisplay_mask_bounds (gdisp, &x1, &y1, &x2, &y2))
|
||||
{
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
|
||||
}
|
||||
else
|
||||
{
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_layer_invis (Selection *select)
|
||||
{
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gint x3, y3;
|
||||
gint x4, y4;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
g_source_remove (select->timeout_id);
|
||||
select->timeout_id = 0;
|
||||
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
|
||||
if (select->segs_layer != NULL && select->num_segs_layer == 4)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = select->gdisp;
|
||||
|
||||
x1 = select->segs_layer[0].x1 - 1;
|
||||
y1 = select->segs_layer[0].y1 - 1;
|
||||
x2 = select->segs_layer[3].x2 + 1;
|
||||
y2 = select->segs_layer[3].y2 + 1;
|
||||
|
||||
x3 = select->segs_layer[0].x1 + 1;
|
||||
y3 = select->segs_layer[0].y1 + 1;
|
||||
x4 = select->segs_layer[3].x2 - 1;
|
||||
y4 = select->segs_layer[3].y2 - 1;
|
||||
|
||||
/* expose the region */
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1) + 1, (y3 - y1) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y3, (x3 - x1) + 1, (y4 - y3) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y4, (x2 - x1) + 1, (y2 - y4) + 1);
|
||||
gdisplay_expose_area (gdisp, x4, y3, (x2 - x4) + 1, (y4 - y3) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_toggle (Selection *select)
|
||||
{
|
||||
selection_invis (select);
|
||||
selection_layer_invis (select);
|
||||
|
||||
/* toggle the visibility */
|
||||
select->hidden = select->hidden ? FALSE : TRUE;
|
||||
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static GdkPixmap *
|
||||
create_cycled_ants_pixmap (GdkWindow *window,
|
||||
|
@ -112,6 +385,7 @@ cycle_ant_colors (Selection *select)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#define MAX_POINTS_INC 2048
|
||||
|
||||
static void
|
||||
|
@ -228,6 +502,7 @@ selection_render_points (Selection *select)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
selection_draw (Selection *select)
|
||||
{
|
||||
|
@ -290,11 +565,11 @@ static void
|
|||
selection_transform_segs (Selection *select,
|
||||
BoundSeg *src_segs,
|
||||
GdkSegment *dest_segs,
|
||||
int num_segs)
|
||||
gint num_segs)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x, y;
|
||||
int i;
|
||||
GDisplay *gdisp;
|
||||
gint x, y;
|
||||
gint i;
|
||||
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
|
@ -338,7 +613,7 @@ selection_transform_segs (Selection *select,
|
|||
static void
|
||||
selection_generate_segs (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
GDisplay *gdisp;
|
||||
BoundSeg *segs_in;
|
||||
BoundSeg *segs_out;
|
||||
BoundSeg *segs_layer;
|
||||
|
@ -399,6 +674,7 @@ static void
|
|||
selection_free_segs (Selection *select)
|
||||
{
|
||||
gint j;
|
||||
|
||||
if (select->segs_in)
|
||||
g_free (select->segs_in);
|
||||
if (select->segs_out)
|
||||
|
@ -410,7 +686,8 @@ selection_free_segs (Selection *select)
|
|||
{
|
||||
if (select->points_in[j])
|
||||
g_free (select->points_in[j]);
|
||||
select->points_in[j] = NULL;
|
||||
|
||||
select->points_in[j] = NULL;
|
||||
select->num_points_in[j] = 0;
|
||||
}
|
||||
|
||||
|
@ -423,10 +700,10 @@ selection_free_segs (Selection *select)
|
|||
}
|
||||
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
selection_start_marching (gpointer data)
|
||||
{
|
||||
Selection * select;
|
||||
Selection *select;
|
||||
|
||||
select = (Selection *) data;
|
||||
|
||||
|
@ -435,12 +712,13 @@ selection_start_marching (gpointer data)
|
|||
{
|
||||
selection_free_segs (select);
|
||||
selection_generate_segs (select);
|
||||
|
||||
/* Toggle the RECALC flag */
|
||||
select->recalc = FALSE;
|
||||
}
|
||||
|
||||
select->index_in = 0;
|
||||
select->index_out = 0;
|
||||
select->index_in = 0;
|
||||
select->index_out = 0;
|
||||
select->index_layer = 0;
|
||||
|
||||
/* Make sure the state is set to marching */
|
||||
|
@ -459,22 +737,24 @@ selection_start_marching (gpointer data)
|
|||
selection_draw (select);
|
||||
|
||||
/* Reset the timer */
|
||||
select->timer = gtk_timeout_add (select->speed,
|
||||
selection_march_ants,
|
||||
(gpointer) select);
|
||||
select->timeout_id = g_timeout_add (select->speed,
|
||||
selection_march_ants,
|
||||
select);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
|
||||
static gboolean
|
||||
selection_march_ants (gpointer data)
|
||||
{
|
||||
Selection * select;
|
||||
Selection *select;
|
||||
|
||||
select = (Selection *) data;
|
||||
|
||||
/* increment stipple index */
|
||||
select->index_in++;
|
||||
|
||||
#ifndef USE_XDRAWPOINTS
|
||||
if (select->index_in > 7)
|
||||
select->index_in = 0;
|
||||
|
@ -500,260 +780,3 @@ selection_march_ants (gpointer data)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*********************************/
|
||||
/* Public function definitions */
|
||||
/*********************************/
|
||||
|
||||
Selection *
|
||||
selection_create (GdkWindow *win,
|
||||
GDisplay *gdisp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed)
|
||||
{
|
||||
GdkColor fg, bg;
|
||||
Selection *new;
|
||||
gint base_type;
|
||||
gint i;
|
||||
|
||||
new = g_new (Selection, 1);
|
||||
base_type = gimp_image_base_type (gdisp->gimage);
|
||||
|
||||
if (gimprc.cycled_marching_ants)
|
||||
{
|
||||
new->cycle = TRUE;
|
||||
if (!cycled_ants_pixmap)
|
||||
cycled_ants_pixmap = create_cycled_ants_pixmap (win, g_visual->depth);
|
||||
|
||||
new->cycle_pix = cycled_ants_pixmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
new->cycle = FALSE;
|
||||
if (!marching_ants[0])
|
||||
for (i = 0; i < 8; i++)
|
||||
marching_ants[i] = gdk_bitmap_create_from_data (win, (char*) ant_data[i], 8, 8);
|
||||
}
|
||||
|
||||
new->win = win;
|
||||
new->gdisp = gdisp;
|
||||
new->segs_in = NULL;
|
||||
new->segs_out = NULL;
|
||||
new->segs_layer = NULL;
|
||||
new->num_segs_in = 0;
|
||||
new->num_segs_out = 0;
|
||||
new->num_segs_layer = 0;
|
||||
new->index_in = 0;
|
||||
new->index_out = 0;
|
||||
new->index_layer = 0;
|
||||
new->state = INVISIBLE;
|
||||
new->paused = 0;
|
||||
new->recalc = TRUE;
|
||||
new->speed = speed;
|
||||
new->hidden = FALSE;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
new->points_in[i] = NULL;
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_in = gdk_gc_new (new->win);
|
||||
|
||||
if (new->cycle)
|
||||
{
|
||||
gdk_gc_set_fill (new->gc_in, GDK_TILED);
|
||||
gdk_gc_set_tile (new->gc_in, new->cycle_pix);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get black and white pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_white_pixel (gdisp);
|
||||
|
||||
gdk_gc_set_foreground (new->gc_in, &fg);
|
||||
gdk_gc_set_background (new->gc_in, &bg);
|
||||
gdk_gc_set_fill (new->gc_in, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
new->gc_white = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_white, &bg);
|
||||
|
||||
new->gc_black = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_black, &fg);
|
||||
#endif
|
||||
|
||||
/* Setup 2nd & 3rd GCs */
|
||||
fg.pixel = gdisplay_white_pixel (gdisp);
|
||||
bg.pixel = gdisplay_gray_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_out = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_out, &fg);
|
||||
gdk_gc_set_background (new->gc_out, &bg);
|
||||
gdk_gc_set_fill (new->gc_out, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_out, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
/* get black and color pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_color_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_layer = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_layer, &fg);
|
||||
gdk_gc_set_background (new->gc_layer, &bg);
|
||||
gdk_gc_set_fill (new->gc_layer, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_layer, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_pause (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
gtk_timeout_remove (select->timer);
|
||||
|
||||
select->paused ++;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_resume (Selection *select)
|
||||
{
|
||||
if (select->paused == 1)
|
||||
{
|
||||
select->state = INTRO;
|
||||
select->timer = gtk_timeout_add (INITIAL_DELAY, selection_start_marching,
|
||||
(gpointer) select);
|
||||
}
|
||||
|
||||
select->paused--;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_start (Selection *select,
|
||||
int recalc)
|
||||
{
|
||||
/* A call to selection_start with recalc == TRUE means that
|
||||
* we want to recalculate the selection boundary--usually
|
||||
* after scaling or panning the display, or modifying the
|
||||
* selection in some way. If recalc == FALSE, the already
|
||||
* calculated boundary is simply redrawn.
|
||||
*/
|
||||
if (recalc)
|
||||
select->recalc = TRUE;
|
||||
|
||||
/* If this selection is paused, do not start it */
|
||||
if (select->paused > 0)
|
||||
return;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
gtk_timeout_remove (select->timer);
|
||||
|
||||
select->state = INTRO; /* The state before the first draw */
|
||||
select->timer = gtk_timeout_add (INITIAL_DELAY, selection_start_marching,
|
||||
(gpointer) select);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_invis (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
gtk_timeout_remove (select->timer);
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
/* Find the bounds of the selection */
|
||||
if (gdisplay_mask_bounds (gdisp, &x1, &y1, &x2, &y2))
|
||||
{
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
|
||||
}
|
||||
else
|
||||
{
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_layer_invis (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2;
|
||||
int x3, y3, x4, y4;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
gtk_timeout_remove (select->timer);
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
if (select->segs_layer != NULL && select->num_segs_layer == 4)
|
||||
{
|
||||
x1 = select->segs_layer[0].x1 - 1;
|
||||
y1 = select->segs_layer[0].y1 - 1;
|
||||
x2 = select->segs_layer[3].x2 + 1;
|
||||
y2 = select->segs_layer[3].y2 + 1;
|
||||
|
||||
x3 = select->segs_layer[0].x1 + 1;
|
||||
y3 = select->segs_layer[0].y1 + 1;
|
||||
x4 = select->segs_layer[3].x2 - 1;
|
||||
y4 = select->segs_layer[3].y2 - 1;
|
||||
|
||||
/* expose the region */
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1) + 1, (y3 - y1) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y3, (x3 - x1) + 1, (y4 - y3) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y4, (x2 - x1) + 1, (y2 - y4) + 1);
|
||||
gdisplay_expose_area (gdisp, x4, y3, (x2 - x4) + 1, (y4 - y3) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_hide (Selection *select,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
selection_invis (select);
|
||||
selection_layer_invis (select);
|
||||
|
||||
/* toggle the visibility */
|
||||
select->hidden = select->hidden ? FALSE : TRUE;
|
||||
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_free (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
gtk_timeout_remove (select->timer);
|
||||
|
||||
if (select->gc_in)
|
||||
gdk_gc_destroy (select->gc_in);
|
||||
if (select->gc_out)
|
||||
gdk_gc_destroy (select->gc_out);
|
||||
if (select->gc_layer)
|
||||
gdk_gc_destroy (select->gc_layer);
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
if (select->gc_white)
|
||||
gdk_gc_destroy (select->gc_white);
|
||||
if (select->gc_black)
|
||||
gdk_gc_destroy (select->gc_black);
|
||||
#endif
|
||||
selection_free_segs (select);
|
||||
g_free (select);
|
||||
}
|
||||
|
|
|
@ -42,10 +42,10 @@ struct _Selection
|
|||
gint index_layer; /* index of current stipple pattern */
|
||||
gint state; /* internal drawing state */
|
||||
gint paused; /* count of pause requests */
|
||||
gint recalc; /* flag to recalculate the selection */
|
||||
gboolean recalc; /* flag to recalculate the selection */
|
||||
gint speed; /* speed of marching ants */
|
||||
gint hidden; /* is the selection hidden? */
|
||||
gint timer; /* timer for successive draws */
|
||||
gboolean hidden; /* is the selection hidden? */
|
||||
guint timeout_id; /* timer for successive draws */
|
||||
gint cycle; /* color cycling turned on */
|
||||
GdkPixmap *cycle_pix; /* cycling pixmap */
|
||||
|
||||
|
@ -57,22 +57,22 @@ struct _Selection
|
|||
};
|
||||
|
||||
|
||||
/* Function declarations */
|
||||
Selection * selection_create (GdkWindow *window,
|
||||
GDisplay *gdisp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed);
|
||||
void selection_free (Selection *select);
|
||||
|
||||
Selection * selection_create (GdkWindow *win,
|
||||
GDisplay *disp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed);
|
||||
void selection_pause (Selection *select);
|
||||
void selection_resume (Selection *select);
|
||||
void selection_start (Selection *select,
|
||||
gint recalc);
|
||||
void selection_invis (Selection *select);
|
||||
void selection_layer_invis (Selection *select);
|
||||
void selection_hide (Selection *select,
|
||||
GDisplay *gdisp);
|
||||
void selection_free (Selection *select);
|
||||
void selection_pause (Selection *select);
|
||||
void selection_resume (Selection *select);
|
||||
|
||||
void selection_start (Selection *select,
|
||||
gboolean recalc);
|
||||
void selection_invis (Selection *select);
|
||||
void selection_layer_invis (Selection *select);
|
||||
|
||||
void selection_toggle (Selection *select);
|
||||
|
||||
|
||||
#endif /* __SELECTION_H__ */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
165
app/gdisplay.c
165
app/gdisplay.c
|
@ -143,40 +143,79 @@ gdisplay_new (GimpImage *gimage,
|
|||
/*
|
||||
* Set all GDisplay parameters...
|
||||
*/
|
||||
gdisp = g_new (GDisplay, 1);
|
||||
gdisp = g_new0 (GDisplay, 1);
|
||||
|
||||
gdisp->offset_x = 0;
|
||||
gdisp->offset_y = 0;
|
||||
gdisp->scale = scale;
|
||||
gdisp->dot_for_dot = gimprc.default_dot_for_dot;
|
||||
gdisp->gimage = gimage;
|
||||
gdisp->window_info_dialog = NULL;
|
||||
gdisp->window_nav_dialog = NULL;
|
||||
gdisp->nav_popup = NULL;
|
||||
gdisp->select = NULL;
|
||||
gdisp->ID = display_num++;
|
||||
gdisp->instance = gimage->instance_count;
|
||||
gdisp->update_areas = NULL;
|
||||
gdisp->display_areas = NULL;
|
||||
gdisp->disp_xoffset = 0;
|
||||
gdisp->disp_yoffset = 0;
|
||||
gdisp->current_cursor = (GdkCursorType) -1;
|
||||
gdisp->tool_cursor = GIMP_TOOL_CURSOR_NONE;
|
||||
gdisp->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
|
||||
gdisp->draw_guides = TRUE;
|
||||
gdisp->snap_to_guides = TRUE;
|
||||
gdisp->ID = display_num++;
|
||||
|
||||
gdisp->draw_cursor = FALSE;
|
||||
gdisp->proximity = FALSE;
|
||||
gdisp->have_cursor = FALSE;
|
||||
gdisp->cursor_x = 0;
|
||||
gdisp->cursor_y = 0;
|
||||
gdisp->using_override_cursor = FALSE;
|
||||
gdisp->ifactory = NULL;
|
||||
|
||||
gdisp->shell = NULL;
|
||||
gdisp->canvas = NULL;
|
||||
gdisp->hsb = NULL;
|
||||
gdisp->vsb = NULL;
|
||||
gdisp->qmaskoff = NULL;
|
||||
gdisp->qmaskon = NULL;
|
||||
gdisp->hrule = NULL;
|
||||
gdisp->vrule = NULL;
|
||||
gdisp->origin = NULL;
|
||||
gdisp->statusarea = NULL;
|
||||
gdisp->progressbar = NULL;
|
||||
gdisp->cursor_label = NULL;
|
||||
gdisp->cursor_format_str[0] = '\0';
|
||||
gdisp->cancelbutton = NULL;
|
||||
gdisp->progressid = FALSE;
|
||||
|
||||
gdisp->window_info_dialog = NULL;
|
||||
gdisp->window_nav_dialog = NULL;
|
||||
gdisp->nav_popup = NULL;
|
||||
gdisp->warning_dialog = NULL;
|
||||
|
||||
gdisp->hsbdata = NULL;
|
||||
gdisp->vsbdata = NULL;
|
||||
|
||||
gdisp->icon = NULL;
|
||||
gdisp->iconmask = NULL;
|
||||
gdisp->iconsize = 0;
|
||||
gdisp->icon_needs_update = FALSE;
|
||||
gdisp->icon_timeout_id = 0;
|
||||
gdisp->icon_idle_id = 0;
|
||||
|
||||
gdisp->gimage = gimage;
|
||||
gdisp->instance = gimage->instance_count;
|
||||
|
||||
gdisp->disp_width = 0;
|
||||
gdisp->disp_height = 0;
|
||||
gdisp->disp_xoffset = 0;
|
||||
gdisp->disp_yoffset = 0;
|
||||
|
||||
gdisp->offset_x = 0;
|
||||
gdisp->offset_y = 0;
|
||||
gdisp->scale = scale;
|
||||
gdisp->dot_for_dot = gimprc.default_dot_for_dot;
|
||||
gdisp->draw_guides = TRUE;
|
||||
gdisp->snap_to_guides = TRUE;
|
||||
|
||||
gdisp->select = NULL;
|
||||
|
||||
gdisp->scroll_gc = NULL;
|
||||
|
||||
gdisp->update_areas = NULL;
|
||||
gdisp->display_areas = NULL;
|
||||
|
||||
gdisp->current_cursor = (GdkCursorType) -1;
|
||||
gdisp->tool_cursor = GIMP_TOOL_CURSOR_NONE;
|
||||
gdisp->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
|
||||
|
||||
gdisp->override_cursor = (GdkCursorType) -1;
|
||||
gdisp->using_override_cursor = FALSE;
|
||||
|
||||
gdisp->draw_cursor = FALSE;
|
||||
gdisp->cursor_x = 0;
|
||||
gdisp->cursor_y = 0;
|
||||
gdisp->proximity = FALSE;
|
||||
gdisp->have_cursor = FALSE;
|
||||
|
||||
gdisp->idle_render.idleid = -1;
|
||||
/*gdisp->idle_render.handlerid = -1;*/
|
||||
gdisp->idle_render.update_areas = NULL;
|
||||
gdisp->idle_render.active = FALSE;
|
||||
|
||||
|
@ -185,13 +224,11 @@ gdisplay_new (GimpImage *gimage,
|
|||
gdisp->cd_ui = NULL;
|
||||
#endif /* DISPLAY_FILTERS */
|
||||
|
||||
gdisp->warning_dialog = NULL;
|
||||
|
||||
/* format the title */
|
||||
gdisplay_format_title (gdisp, title, MAX_TITLE_BUF);
|
||||
|
||||
/* add the new display to the list so that it isn't lost */
|
||||
display_list = g_slist_append (display_list, (void *) gdisp);
|
||||
display_list = g_slist_append (display_list, gdisp);
|
||||
|
||||
/* create the shell for the image */
|
||||
create_display_shell (gdisp, gimage->width, gimage->height,
|
||||
|
@ -223,7 +260,8 @@ gdisplay_new (GimpImage *gimage,
|
|||
gtk_object_sink (GTK_OBJECT (gimage));
|
||||
|
||||
/* We're interested in clean and dirty signals so we can update the
|
||||
* title if need be. */
|
||||
* title if need be.
|
||||
*/
|
||||
gtk_signal_connect (GTK_OBJECT (gimage), "dirty",
|
||||
GTK_SIGNAL_FUNC (gdisplay_cleandirty_handler), gdisp);
|
||||
gtk_signal_connect (GTK_OBJECT (gimage), "clean",
|
||||
|
@ -421,14 +459,14 @@ gdisplay_delete (GDisplay *gdisp)
|
|||
info_window_free (gdisp->window_info_dialog);
|
||||
|
||||
/* Remove navigation dialog */
|
||||
nav_window_free (gdisp, gdisp->window_nav_dialog);
|
||||
nav_dialog_free (gdisp, gdisp->window_nav_dialog);
|
||||
|
||||
/* free the gimage */
|
||||
gdisp->gimage->disp_count--;
|
||||
gtk_object_unref (GTK_OBJECT (gdisp->gimage));
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_popup_free (gdisp->nav_popup);
|
||||
nav_dialog_free (gdisp, gdisp->nav_popup);
|
||||
|
||||
if (gdisp->icon_timeout_id)
|
||||
g_source_remove (gdisp->icon_timeout_id);
|
||||
|
@ -2146,6 +2184,33 @@ gdisplay_expose_full (GDisplay *gdisp)
|
|||
gdisp->disp_height);
|
||||
}
|
||||
|
||||
void
|
||||
gdisplay_selection_visibility (GDisplay *gdisp,
|
||||
SelectionControl function)
|
||||
{
|
||||
if (gdisp->select)
|
||||
{
|
||||
switch (function)
|
||||
{
|
||||
case SELECTION_OFF:
|
||||
selection_invis (gdisp->select);
|
||||
break;
|
||||
case SELECTION_LAYER_OFF:
|
||||
selection_layer_invis (gdisp->select);
|
||||
break;
|
||||
case SELECTION_ON:
|
||||
selection_start (gdisp->select, TRUE);
|
||||
break;
|
||||
case SELECTION_PAUSE:
|
||||
selection_pause (gdisp->select);
|
||||
break;
|
||||
case SELECTION_RESUME:
|
||||
selection_resume (gdisp->select);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
/* Functions independent of a specific gdisplay */
|
||||
/**************************************************/
|
||||
|
@ -2414,10 +2479,13 @@ gdisplays_nav_preview_resized (void)
|
|||
gdisp = (GDisplay *) list->data;
|
||||
|
||||
if (gdisp->window_nav_dialog)
|
||||
nav_window_preview_resized (gdisp->window_nav_dialog);
|
||||
nav_dialog_preview_resized (gdisp->window_nav_dialog);
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_window_popup_preview_resized (&gdisp->nav_popup);
|
||||
{
|
||||
nav_dialog_free (NULL, gdisp->nav_popup);
|
||||
gdisp->nav_popup = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2427,35 +2495,14 @@ gdisplays_selection_visibility (GimpImage *gimage,
|
|||
{
|
||||
GDisplay *gdisp;
|
||||
GSList *list;
|
||||
gint count = 0;
|
||||
|
||||
/* traverse the linked list of displays, handling each one */
|
||||
for (list = display_list; list; list = g_slist_next (list))
|
||||
{
|
||||
gdisp = (GDisplay *) list->data;
|
||||
|
||||
if (gdisp->gimage == gimage && gdisp->select)
|
||||
{
|
||||
switch (function)
|
||||
{
|
||||
case SelectionOff:
|
||||
selection_invis (gdisp->select);
|
||||
break;
|
||||
case SelectionLayerOff:
|
||||
selection_layer_invis (gdisp->select);
|
||||
break;
|
||||
case SelectionOn:
|
||||
selection_start (gdisp->select, TRUE);
|
||||
break;
|
||||
case SelectionPause:
|
||||
selection_pause (gdisp->select);
|
||||
break;
|
||||
case SelectionResume:
|
||||
selection_resume (gdisp->select);
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
if (gdisp->gimage == gimage)
|
||||
gdisplay_selection_visibility (gdisp, function);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
|
||||
typedef enum
|
||||
{
|
||||
SelectionOff,
|
||||
SelectionLayerOff,
|
||||
SelectionOn,
|
||||
SelectionPause,
|
||||
SelectionResume
|
||||
SELECTION_OFF,
|
||||
SELECTION_LAYER_OFF,
|
||||
SELECTION_ON,
|
||||
SELECTION_PAUSE,
|
||||
SELECTION_RESUME
|
||||
} SelectionControl;
|
||||
|
||||
|
||||
|
@ -87,7 +87,6 @@ struct _IdleRenderStruct
|
|||
gint basex;
|
||||
gint basey;
|
||||
guint idleid;
|
||||
/*guint handlerid;*/
|
||||
gboolean active;
|
||||
GSList *update_areas; /* flushed update areas */
|
||||
};
|
||||
|
@ -101,7 +100,8 @@ struct _GDisplay
|
|||
|
||||
GtkWidget *shell; /* shell widget for this gdisplay */
|
||||
GtkWidget *canvas; /* canvas widget for this gdisplay */
|
||||
GtkWidget *hsb, *vsb; /* widgets for scroll bars */
|
||||
GtkWidget *hsb; /* widgets for scroll bars */
|
||||
GtkWidget *vsb;
|
||||
GtkWidget *qmaskoff; /* widgets for qmask buttons */
|
||||
GtkWidget *qmaskon;
|
||||
GtkWidget *hrule; /* widgets for rulers */
|
||||
|
@ -119,9 +119,10 @@ struct _GDisplay
|
|||
GtkWidget *cancelbutton; /* widget for cancel button */
|
||||
guint progressid; /* id of statusbar message for progress */
|
||||
|
||||
InfoDialog *window_info_dialog; /* dialog box for image information */
|
||||
InfoDialog *window_nav_dialog; /* dialog box for image navigation */
|
||||
GtkWidget *nav_popup; /* widget for the popup navigation window */
|
||||
InfoDialog *window_info_dialog; /* dialog box for image information */
|
||||
NavigationDialog *window_nav_dialog; /* dialog box for image navigation */
|
||||
NavigationDialog *nav_popup; /* the popup navigation window */
|
||||
GtkWidget *warning_dialog; /* "Changes were made to %s. Close anyway?" */
|
||||
|
||||
GtkAdjustment *hsbdata; /* horizontal data information */
|
||||
GtkAdjustment *vsbdata; /* vertical data information */
|
||||
|
@ -129,9 +130,9 @@ struct _GDisplay
|
|||
GdkPixmap *icon; /* Pixmap for the icon */
|
||||
GdkBitmap *iconmask; /* Bitmap for the icon mask */
|
||||
guint iconsize; /* The size of the icon pixmap */
|
||||
guint icon_needs_update; /* Do we need to render a new icon? */
|
||||
gint icon_timeout_id; /* The ID of the timeout-function */
|
||||
gint icon_idle_id; /* The ID of the idle-function */
|
||||
gboolean icon_needs_update; /* Do we need to render a new icon? */
|
||||
guint icon_timeout_id; /* The ID of the timeout-function */
|
||||
guint icon_idle_id; /* The ID of the idle-function */
|
||||
|
||||
GimpImage *gimage; /* pointer to the associated gimage struct */
|
||||
gint instance; /* the instance # of this gdisplay as */
|
||||
|
@ -175,8 +176,6 @@ struct _GDisplay
|
|||
GList *cd_list; /* color display conversion stuff */
|
||||
GtkWidget *cd_ui; /* color display filter dialog */
|
||||
#endif /* DISPLAY_FILTERS */
|
||||
|
||||
GtkWidget *warning_dialog; /* "Changes were made to %s. Close anyway?" */
|
||||
};
|
||||
|
||||
|
||||
|
@ -245,6 +244,8 @@ void gdisplay_expose_area (GDisplay *gdisp,
|
|||
void gdisplay_expose_guide (GDisplay *gdisp,
|
||||
GimpGuide *guide);
|
||||
void gdisplay_expose_full (GDisplay *gdisp);
|
||||
void gdisplay_selection_visibility (GDisplay *gdisp,
|
||||
SelectionControl function);
|
||||
void gdisplay_flush (GDisplay *gdisp);
|
||||
void gdisplay_flush_now (GDisplay *gdisp);
|
||||
void gdisplay_update_icon (GDisplay *gdisp);
|
||||
|
|
|
@ -144,9 +144,6 @@ static void
|
|||
gimage_size_changed_handler (GimpImage *gimage)
|
||||
{
|
||||
/* shrink wrap and update all views */
|
||||
gimp_image_invalidate_layer_previews (gimage);
|
||||
gimp_image_invalidate_channel_previews (gimage);
|
||||
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage));
|
||||
gdisplays_resize_cursor_label (gimage);
|
||||
gdisplays_update_full (gimage);
|
||||
gdisplays_shrink_wrap (gimage);
|
||||
|
|
|
@ -592,7 +592,7 @@ view_info_window_cmd_callback (GtkWidget *widget,
|
|||
if (! gimprc.info_window_follows_mouse)
|
||||
{
|
||||
if (! gdisp->window_info_dialog)
|
||||
gdisp->window_info_dialog = info_window_create ((void *) gdisp);
|
||||
gdisp->window_info_dialog = info_window_create (gdisp);
|
||||
|
||||
info_window_update (gdisp);
|
||||
info_dialog_popup (gdisp->window_info_dialog);
|
||||
|
@ -613,13 +613,13 @@ view_nav_window_cmd_callback (GtkWidget *widget,
|
|||
if (gimprc.nav_window_per_display)
|
||||
{
|
||||
if (! gdisp->window_nav_dialog)
|
||||
gdisp->window_nav_dialog = nav_window_create ((void *) gdisp);
|
||||
gdisp->window_nav_dialog = nav_dialog_create (gdisp);
|
||||
|
||||
nav_dialog_popup (gdisp->window_nav_dialog);
|
||||
}
|
||||
else
|
||||
{
|
||||
nav_window_follow_auto ();
|
||||
nav_dialog_follow_auto ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -637,7 +637,8 @@ view_toggle_selection_cmd_callback (GtkWidget *widget,
|
|||
/* hidden == TRUE corresponds to the menu toggle being FALSE */
|
||||
if (new_val == gdisp->select->hidden)
|
||||
{
|
||||
selection_hide (gdisp->select, (void *) gdisp);
|
||||
selection_toggle (gdisp->select);
|
||||
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -592,7 +592,7 @@ view_info_window_cmd_callback (GtkWidget *widget,
|
|||
if (! gimprc.info_window_follows_mouse)
|
||||
{
|
||||
if (! gdisp->window_info_dialog)
|
||||
gdisp->window_info_dialog = info_window_create ((void *) gdisp);
|
||||
gdisp->window_info_dialog = info_window_create (gdisp);
|
||||
|
||||
info_window_update (gdisp);
|
||||
info_dialog_popup (gdisp->window_info_dialog);
|
||||
|
@ -613,13 +613,13 @@ view_nav_window_cmd_callback (GtkWidget *widget,
|
|||
if (gimprc.nav_window_per_display)
|
||||
{
|
||||
if (! gdisp->window_nav_dialog)
|
||||
gdisp->window_nav_dialog = nav_window_create ((void *) gdisp);
|
||||
gdisp->window_nav_dialog = nav_dialog_create (gdisp);
|
||||
|
||||
nav_dialog_popup (gdisp->window_nav_dialog);
|
||||
}
|
||||
else
|
||||
{
|
||||
nav_window_follow_auto ();
|
||||
nav_dialog_follow_auto ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -637,7 +637,8 @@ view_toggle_selection_cmd_callback (GtkWidget *widget,
|
|||
/* hidden == TRUE corresponds to the menu toggle being FALSE */
|
||||
if (new_val == gdisp->select->hidden)
|
||||
{
|
||||
selection_hide (gdisp->select, (void *) gdisp);
|
||||
selection_toggle (gdisp->select);
|
||||
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ static void info_field_new (InfoDialog *idialog,
|
|||
GtkObject *object,
|
||||
gpointer value_ptr,
|
||||
GtkSignalFunc callback,
|
||||
gpointer client_data);
|
||||
gpointer callback_data);
|
||||
static void update_field (InfoField *info_field);
|
||||
static gint info_dialog_delete_callback (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
|
@ -55,9 +55,9 @@ info_field_new (InfoDialog *idialog,
|
|||
gchar *title,
|
||||
GtkWidget *widget,
|
||||
GtkObject *obj,
|
||||
void *value_ptr,
|
||||
gpointer value_ptr,
|
||||
GtkSignalFunc callback,
|
||||
gpointer client_data)
|
||||
gpointer callback_data)
|
||||
{
|
||||
GtkWidget *label;
|
||||
InfoField *field;
|
||||
|
@ -83,16 +83,17 @@ info_field_new (InfoDialog *idialog,
|
|||
gtk_table_set_row_spacings (GTK_TABLE (idialog->info_table), 2);
|
||||
|
||||
field->field_type = field_type;
|
||||
|
||||
if (obj == NULL)
|
||||
field->obj = GTK_OBJECT (widget);
|
||||
else
|
||||
field->obj = obj;
|
||||
field->value_ptr = value_ptr;
|
||||
field->callback = callback;
|
||||
field->client_data = client_data;
|
||||
|
||||
idialog->field_list =
|
||||
g_slist_prepend (idialog->field_list, (void *) field);
|
||||
field->value_ptr = value_ptr;
|
||||
field->callback = callback;
|
||||
field->callback_data = callback_data;
|
||||
|
||||
idialog->field_list = g_slist_prepend (idialog->field_list, field);
|
||||
idialog->nfields++;
|
||||
}
|
||||
|
||||
|
@ -107,8 +108,9 @@ update_field (InfoField *field)
|
|||
return;
|
||||
|
||||
if (field->field_type != INFO_LABEL)
|
||||
gtk_signal_handler_block_by_data (GTK_OBJECT (field->obj),
|
||||
field->client_data);
|
||||
gtk_signal_handler_block_by_func (GTK_OBJECT (field->obj),
|
||||
field->callback,
|
||||
field->callback_data);
|
||||
|
||||
switch (field->field_type)
|
||||
{
|
||||
|
@ -143,8 +145,9 @@ update_field (InfoField *field)
|
|||
}
|
||||
|
||||
if (field->field_type != INFO_LABEL)
|
||||
gtk_signal_handler_unblock_by_data (GTK_OBJECT (field->obj),
|
||||
field->client_data);
|
||||
gtk_signal_handler_unblock_by_func (GTK_OBJECT (field->obj),
|
||||
field->callback,
|
||||
field->callback_data);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
|
|
@ -36,10 +36,10 @@ struct _InfoField
|
|||
InfoFieldType field_type;
|
||||
|
||||
GtkObject *obj;
|
||||
void *value_ptr;
|
||||
gpointer value_ptr;
|
||||
|
||||
GtkSignalFunc callback;
|
||||
gpointer client_data;
|
||||
gpointer callback_data;
|
||||
};
|
||||
|
||||
struct _InfoDialog
|
||||
|
|
|
@ -101,7 +101,7 @@ info_window_image_rename_callback (GimpImage *gimage,
|
|||
|
||||
gdisp = (GDisplay *) iwd->gdisp;
|
||||
|
||||
title = info_window_title(gdisp);
|
||||
title = info_window_title (gdisp);
|
||||
gtk_window_set_title (GTK_WINDOW (id->shell), title);
|
||||
g_free (title);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ info_window_page_switch (GtkWidget *widget,
|
|||
{
|
||||
InfoDialog *info_win;
|
||||
InfoWinData *iwd;
|
||||
|
||||
|
||||
info_win = (InfoDialog *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
iwd = (InfoWinData *) info_win->user_data;
|
||||
|
||||
|
@ -317,18 +317,15 @@ info_window_create (GDisplay *gdisp)
|
|||
InfoDialog *info_win;
|
||||
InfoWinData *iwd;
|
||||
gchar *title;
|
||||
gchar *title_buf;
|
||||
gint type;
|
||||
|
||||
title = g_basename (gimp_image_filename (gdisp->gimage));
|
||||
type = gimp_image_base_type (gdisp->gimage);
|
||||
|
||||
/* create the info dialog */
|
||||
title_buf = info_window_title (gdisp);
|
||||
info_win = info_dialog_notebook_new (title_buf,
|
||||
title = info_window_title (gdisp);
|
||||
info_win = info_dialog_notebook_new (title,
|
||||
gimp_standard_help_func,
|
||||
"dialogs/info_window.html");
|
||||
g_free (title_buf);
|
||||
g_free (title);
|
||||
|
||||
/* create the action area */
|
||||
gimp_dialog_create_action_area (GTK_DIALOG (info_win->shell),
|
||||
|
@ -377,24 +374,23 @@ static InfoDialog *info_window_auto = NULL;
|
|||
static gchar *
|
||||
info_window_title (GDisplay *gdisp)
|
||||
{
|
||||
gchar *basename;
|
||||
gchar *title;
|
||||
gchar *title_buf;
|
||||
|
||||
title = g_basename (gimp_image_filename (gdisp->gimage));
|
||||
|
||||
/* create the info dialog */
|
||||
title_buf = g_strdup_printf (_("Info: %s-%d.%d"),
|
||||
title,
|
||||
gimp_image_get_ID (gdisp->gimage),
|
||||
gdisp->instance);
|
||||
|
||||
return title_buf;
|
||||
basename = g_basename (gimp_image_filename (gdisp->gimage));
|
||||
|
||||
title = g_strdup_printf (_("Info: %s-%d.%d"),
|
||||
basename,
|
||||
gimp_image_get_ID (gdisp->gimage),
|
||||
gdisp->instance);
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
static void
|
||||
info_window_change_display (GimpContext *context, /* NOT USED */
|
||||
info_window_change_display (GimpContext *context,
|
||||
GDisplay *newdisp,
|
||||
gpointer data /* Not used */)
|
||||
gpointer data)
|
||||
{
|
||||
GDisplay *gdisp = newdisp;
|
||||
GDisplay *old_gdisp;
|
||||
|
@ -420,29 +416,28 @@ info_window_change_display (GimpContext *context, /* NOT USED */
|
|||
void
|
||||
info_window_follow_auto (void)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
GimpContext *context;
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = gdisplay_active ();
|
||||
|
||||
if (!gdisp)
|
||||
context = gimp_context_get_user ();
|
||||
|
||||
gdisp = gimp_context_get_display (context);
|
||||
|
||||
if (! gdisp)
|
||||
return;
|
||||
|
||||
if(!info_window_auto)
|
||||
if (! info_window_auto)
|
||||
{
|
||||
info_window_auto = info_window_create ((void *) gdisp);
|
||||
gtk_signal_connect (GTK_OBJECT (gimp_context_get_user ()),
|
||||
"display_changed",
|
||||
info_window_auto = info_window_create (gdisp);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (context), "display_changed",
|
||||
GTK_SIGNAL_FUNC (info_window_change_display),
|
||||
NULL);
|
||||
info_window_update (gdisp); /* Update to include the info */
|
||||
|
||||
info_window_update (gdisp);
|
||||
}
|
||||
|
||||
info_dialog_popup (info_window_auto);
|
||||
/*
|
||||
iwd = (NavWinData *)nav_window_auto->user_data;
|
||||
gtk_widget_set_sensitive(nav_window_auto->vbox,TRUE);
|
||||
iwd->frozen = FALSE;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -464,10 +459,10 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
gboolean force_update = FALSE;
|
||||
gint i;
|
||||
|
||||
if (!info_win && info_window_auto != NULL)
|
||||
if (! info_win && info_window_auto != NULL)
|
||||
info_win = info_window_auto;
|
||||
|
||||
if (!info_win)
|
||||
if (! info_win)
|
||||
return;
|
||||
|
||||
iwd = (InfoWinData *) info_win->user_data;
|
||||
|
@ -482,17 +477,18 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
gchar *title;
|
||||
|
||||
info_window_update (gdisp);
|
||||
|
||||
title = info_window_title (gdisp);
|
||||
gtk_window_set_title (GTK_WINDOW (info_window_auto->shell), title);
|
||||
g_free (title);
|
||||
}
|
||||
|
||||
if (!iwd || !iwd->showing_extended)
|
||||
if (! iwd || ! iwd->showing_extended)
|
||||
return;
|
||||
|
||||
/* fill in position information */
|
||||
|
||||
if ( tx < 0.0 && ty < 0.0 )
|
||||
if (tx < 0.0 && ty < 0.0)
|
||||
{
|
||||
iwd->unit_str = NULL;
|
||||
for (i = 0; i < 4; i++)
|
||||
|
@ -506,9 +502,10 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
|
||||
unit_digits = gimp_unit_get_digits (gdisp->gimage->unit);
|
||||
|
||||
if (iwd->unit_str != gimp_unit_get_plural (gdisp->gimage->unit))
|
||||
if (iwd->unit_str != gimp_unit_get_abbreviation (gdisp->gimage->unit))
|
||||
{
|
||||
iwd->unit_str = gimp_unit_get_plural (gdisp->gimage->unit);
|
||||
iwd->unit_str = gimp_unit_get_abbreviation (gdisp->gimage->unit);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (iwd->unit_labels[0]), iwd->unit_str);
|
||||
gtk_label_set_text (GTK_LABEL (iwd->unit_labels[1]), iwd->unit_str);
|
||||
}
|
||||
|
@ -533,9 +530,8 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
}
|
||||
|
||||
/* fill in color information */
|
||||
/* gimp_image_active_drawable (gdisp->gimage) */
|
||||
if (!(color = gimp_image_get_color_at (gdisp->gimage, tx, ty))
|
||||
|| (tx < 0.0 && ty < 0.0))
|
||||
if (! (color = gimp_image_get_color_at (gdisp->gimage, tx, ty))
|
||||
|| (tx < 0.0 && ty < 0.0))
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
gtk_label_set_text (GTK_LABEL (iwd->color_labels[i]), _("N/A"));
|
||||
|
@ -544,7 +540,7 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
{
|
||||
sample_type = gimp_image_composite_type (gdisp->gimage);
|
||||
|
||||
for (i = RED_PIX;
|
||||
for (i = RED_PIX;
|
||||
i <= (GIMP_IMAGE_TYPE_HAS_ALPHA (sample_type) ?
|
||||
ALPHA_PIX : BLUE_PIX);
|
||||
i++)
|
||||
|
@ -555,8 +551,8 @@ info_window_update_extended (GDisplay *gdisp,
|
|||
|
||||
if (i == ALPHA_PIX)
|
||||
gtk_label_set_text (GTK_LABEL (iwd->color_labels[i]), _("N/A"));
|
||||
|
||||
g_free(color);
|
||||
|
||||
g_free (color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -565,13 +561,13 @@ info_window_free (InfoDialog *info_win)
|
|||
{
|
||||
InfoWinData *iwd;
|
||||
|
||||
if (!info_win && info_window_auto)
|
||||
if (! info_win && info_window_auto)
|
||||
{
|
||||
gtk_widget_set_sensitive (info_window_auto->vbox, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!info_win)
|
||||
if (! info_win)
|
||||
return;
|
||||
|
||||
iwd = (InfoWinData *) info_win->user_data;
|
||||
|
@ -592,28 +588,27 @@ info_window_update (GDisplay *gdisp)
|
|||
gchar format_buf[32];
|
||||
InfoDialog *info_win = gdisp->window_info_dialog;
|
||||
|
||||
if (!info_win && info_window_auto != NULL)
|
||||
if (! info_win && info_window_auto != NULL)
|
||||
info_win = info_window_auto;
|
||||
|
||||
if (!info_win)
|
||||
if (! info_win)
|
||||
return;
|
||||
|
||||
iwd = (InfoWinData *) info_win->user_data;
|
||||
|
||||
/* Make it sensitive... */
|
||||
if (info_window_auto)
|
||||
gtk_widget_set_sensitive (info_window_auto->vbox, TRUE);
|
||||
|
||||
/* If doing info_window_auto then return if this display
|
||||
* is not the one we are showing.
|
||||
*/
|
||||
|
||||
if (info_window_auto && iwd->gdisp != gdisp)
|
||||
return;
|
||||
|
||||
/* width and height */
|
||||
unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
|
||||
unit_digits = gimp_unit_get_digits (gdisp->gimage->unit);
|
||||
|
||||
g_snprintf (iwd->dimensions_str, MAX_BUF,
|
||||
_("%d x %d pixels"),
|
||||
(int) gdisp->gimage->width,
|
||||
|
@ -633,7 +628,7 @@ info_window_update (GDisplay *gdisp)
|
|||
|
||||
/* user zoom ratio */
|
||||
g_snprintf (iwd->scale_str, MAX_BUF, "%d:%d",
|
||||
SCALEDEST (gdisp), SCALESRC (gdisp));
|
||||
SCALEDEST (gdisp), SCALESRC (gdisp));
|
||||
|
||||
type = gimp_image_base_type (gdisp->gimage);
|
||||
|
||||
|
@ -647,11 +642,12 @@ info_window_update (GDisplay *gdisp)
|
|||
_("Indexed Color"), gdisp->gimage->num_cols, _("colors"));
|
||||
|
||||
/* visual class */
|
||||
if (type == RGB ||
|
||||
type == INDEXED)
|
||||
g_snprintf (iwd->visual_class_str, MAX_BUF, "%s", gettext (visual_classes[g_visual->type]));
|
||||
if (type == RGB || type == INDEXED)
|
||||
g_snprintf (iwd->visual_class_str, MAX_BUF, "%s",
|
||||
gettext (visual_classes[g_visual->type]));
|
||||
else if (type == GRAY)
|
||||
g_snprintf (iwd->visual_class_str, MAX_BUF, "%s", gettext (visual_classes[g_visual->type]));
|
||||
g_snprintf (iwd->visual_class_str, MAX_BUF, "%s",
|
||||
gettext (visual_classes[g_visual->type]));
|
||||
|
||||
/* visual depth */
|
||||
g_snprintf (iwd->visual_depth_str, MAX_BUF, "%d", g_visual->depth);
|
||||
|
|
|
@ -900,12 +900,11 @@ prefs_cancel_callback (GtkWidget *widget,
|
|||
gimprc.transparency_size = old_transparency_size;
|
||||
|
||||
render_setup (gimprc.transparency_type, gimprc.transparency_size);
|
||||
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_image_invalidate_layer_previews,
|
||||
NULL);
|
||||
gimp_container_foreach (image_context,
|
||||
(GFunc) gimp_viewable_invalidate_preview,
|
||||
NULL);
|
||||
|
||||
gdisplays_expose_full ();
|
||||
gdisplays_flush ();
|
||||
}
|
||||
|
|
2038
app/nav_window.c
2038
app/nav_window.c
File diff suppressed because it is too large
Load Diff
|
@ -21,20 +21,19 @@
|
|||
#define __NAV_WINDOW_H__
|
||||
|
||||
|
||||
InfoDialog * nav_window_create (GDisplay *gdisp);
|
||||
void nav_window_free (GDisplay *gdisp,
|
||||
InfoDialog *idialog);
|
||||
void nav_window_update_window_marker (InfoDialog *idialog);
|
||||
void nav_dialog_popup (InfoDialog *idialog);
|
||||
void nav_window_preview_resized (InfoDialog *idialog);
|
||||
void nav_window_popup_preview_resized (GtkWidget **widget);
|
||||
void nav_window_follow_auto (void);
|
||||
NavigationDialog * nav_dialog_create (GDisplay *gdisp);
|
||||
void nav_dialog_free (GDisplay *gdisp,
|
||||
NavigationDialog *nav_dialog);
|
||||
|
||||
/* popup functions */
|
||||
void nav_popup_click_handler (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data);
|
||||
void nav_popup_free (GtkWidget *widget);
|
||||
void nav_dialog_popup (NavigationDialog *nav_dialog);
|
||||
void nav_dialog_follow_auto (void);
|
||||
|
||||
void nav_dialog_update_window_marker (NavigationDialog *nav_dialog);
|
||||
void nav_dialog_preview_resized (NavigationDialog *nav_dialog);
|
||||
|
||||
void nav_popup_click_handler (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data);
|
||||
|
||||
|
||||
#endif /* __NAV_WINDOW_H__ */
|
||||
|
|
|
@ -925,7 +925,7 @@ ink_button_press (GimpTool *tool,
|
|||
tool->paused_count = 0;
|
||||
|
||||
/* pause the current selection and grab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionPause);
|
||||
gdisplays_selection_visibility (gdisp->gimage, SELECTION_PAUSE);
|
||||
|
||||
/* add motion memory if you press mod1 first ^ perfectmouse */
|
||||
if (((bevent->state & GDK_MOD1_MASK) != 0) != (gimprc.perfectmouse != 0))
|
||||
|
@ -970,7 +970,7 @@ ink_button_release (GimpTool *tool,
|
|||
gimage = gdisp->gimage;
|
||||
|
||||
/* resume the current selection and ungrab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionResume);
|
||||
gdisplays_selection_visibility (gdisp->gimage, SELECTION_RESUME);
|
||||
|
||||
gdk_pointer_ungrab (bevent->time);
|
||||
gdk_flush ();
|
||||
|
|
|
@ -419,7 +419,7 @@ gimp_paint_tool_button_press (GimpTool *tool,
|
|||
tool->paused_count = 0;
|
||||
|
||||
/* pause the current selection and grab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionPause);
|
||||
gdisplays_selection_visibility (gdisp->gimage, SELECTION_PAUSE);
|
||||
|
||||
/* add motion memory if perfectmouse is set */
|
||||
if (gimprc.perfectmouse != 0)
|
||||
|
@ -508,7 +508,7 @@ gimp_paint_tool_button_release (GimpTool *tool,
|
|||
paint_tool = GIMP_PAINT_TOOL (tool);
|
||||
|
||||
/* resume the current selection and ungrab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionResume);
|
||||
gdisplays_selection_visibility (gdisp->gimage, SELECTION_RESUME);
|
||||
|
||||
gdk_pointer_ungrab (bevent->time);
|
||||
gdk_flush ();
|
||||
|
|
|
@ -277,5 +277,8 @@ setup_scale (GDisplay *gdisp)
|
|||
gtk_widget_queue_draw (GTK_WIDGET (hruler));
|
||||
gtk_widget_queue_draw (GTK_WIDGET (vruler));
|
||||
|
||||
nav_window_update_window_marker (gdisp->window_nav_dialog);
|
||||
nav_dialog_update_window_marker (gdisp->window_nav_dialog);
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_dialog_update_window_marker (gdisp->nav_popup);
|
||||
}
|
||||
|
|
30
app/scroll.c
30
app/scroll.c
|
@ -193,24 +193,26 @@ scroll_display (GDisplay *gdisp,
|
|||
if (x_offset || y_offset)
|
||||
gdisplays_flush ();
|
||||
|
||||
nav_window_update_window_marker(gdisp->window_nav_dialog);
|
||||
nav_dialog_update_window_marker (gdisp->window_nav_dialog);
|
||||
|
||||
if (gdisp->nav_popup)
|
||||
nav_dialog_update_window_marker (gdisp->nav_popup);
|
||||
|
||||
/* Make sure graphics expose events are processed before scrolling
|
||||
* again */
|
||||
|
||||
while ((event = gdk_event_get_graphics_expose (gdisp->canvas->window))
|
||||
!= NULL)
|
||||
{
|
||||
gtk_widget_event (gdisp->canvas, event);
|
||||
* again
|
||||
*/
|
||||
while ((event = gdk_event_get_graphics_expose (gdisp->canvas->window)))
|
||||
{
|
||||
gtk_widget_event (gdisp->canvas, event);
|
||||
|
||||
if (event->expose.count == 0)
|
||||
{
|
||||
gdk_event_free (event);
|
||||
break;
|
||||
}
|
||||
if (event->expose.count == 0)
|
||||
{
|
||||
gdk_event_free (event);
|
||||
break;
|
||||
}
|
||||
|
||||
gdk_event_free (event);
|
||||
}
|
||||
gdk_event_free (event);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
597
app/selection.c
597
app/selection.c
|
@ -46,29 +46,302 @@
|
|||
#define INITIAL_DELAY 15 /* in milleseconds */
|
||||
|
||||
|
||||
/* static function prototypes */
|
||||
/* local function prototypes */
|
||||
|
||||
static GdkPixmap * create_cycled_ants_pixmap (GdkWindow *window,
|
||||
gint depth);
|
||||
static void cycle_ant_colors (Selection *);
|
||||
|
||||
static void selection_draw (Selection *);
|
||||
static void selection_transform_segs (Selection *,
|
||||
BoundSeg *,
|
||||
GdkSegment *,
|
||||
gint );
|
||||
static void selection_generate_segs (Selection *);
|
||||
static void selection_free_segs (Selection *);
|
||||
static gint selection_march_ants (gpointer );
|
||||
static gint selection_start_marching (gpointer );
|
||||
static void cycle_ant_colors (Selection *select);
|
||||
static void selection_add_point (GdkPoint *points[8],
|
||||
gint max_npoints[8],
|
||||
gint npoints[8],
|
||||
gint x,
|
||||
gint y);
|
||||
static void selection_render_points (Selection *select);
|
||||
static void selection_draw (Selection *select);
|
||||
static void selection_transform_segs (Selection *select,
|
||||
BoundSeg *src_segs,
|
||||
GdkSegment *dest_segs,
|
||||
gint num_segs);
|
||||
static void selection_generate_segs (Selection *select);
|
||||
static void selection_free_segs (Selection *select);
|
||||
static gboolean selection_start_marching (gpointer data);
|
||||
static gboolean selection_march_ants (gpointer data);
|
||||
|
||||
|
||||
GdkPixmap * marching_ants[9] = { NULL };
|
||||
GdkPixmap * cycled_ants_pixmap = NULL;
|
||||
|
||||
|
||||
/*********************************/
|
||||
/* Local function definitions */
|
||||
/*********************************/
|
||||
/* public functions */
|
||||
|
||||
Selection *
|
||||
selection_create (GdkWindow *win,
|
||||
GDisplay *gdisp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed)
|
||||
{
|
||||
GdkColor fg, bg;
|
||||
Selection *new;
|
||||
gint base_type;
|
||||
gint i;
|
||||
|
||||
new = g_new (Selection, 1);
|
||||
base_type = gimp_image_base_type (gdisp->gimage);
|
||||
|
||||
if (gimprc.cycled_marching_ants)
|
||||
{
|
||||
new->cycle = TRUE;
|
||||
if (!cycled_ants_pixmap)
|
||||
cycled_ants_pixmap = create_cycled_ants_pixmap (win, g_visual->depth);
|
||||
|
||||
new->cycle_pix = cycled_ants_pixmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
new->cycle = FALSE;
|
||||
if (!marching_ants[0])
|
||||
for (i = 0; i < 8; i++)
|
||||
marching_ants[i] = gdk_bitmap_create_from_data (win, (char*) ant_data[i], 8, 8);
|
||||
}
|
||||
|
||||
new->win = win;
|
||||
new->gdisp = gdisp;
|
||||
new->segs_in = NULL;
|
||||
new->segs_out = NULL;
|
||||
new->segs_layer = NULL;
|
||||
new->num_segs_in = 0;
|
||||
new->num_segs_out = 0;
|
||||
new->num_segs_layer = 0;
|
||||
new->index_in = 0;
|
||||
new->index_out = 0;
|
||||
new->index_layer = 0;
|
||||
new->state = INVISIBLE;
|
||||
new->paused = 0;
|
||||
new->recalc = TRUE;
|
||||
new->speed = speed;
|
||||
new->hidden = FALSE;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
new->points_in[i] = NULL;
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_in = gdk_gc_new (new->win);
|
||||
|
||||
if (new->cycle)
|
||||
{
|
||||
gdk_gc_set_fill (new->gc_in, GDK_TILED);
|
||||
gdk_gc_set_tile (new->gc_in, new->cycle_pix);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get black and white pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_white_pixel (gdisp);
|
||||
|
||||
gdk_gc_set_foreground (new->gc_in, &fg);
|
||||
gdk_gc_set_background (new->gc_in, &bg);
|
||||
gdk_gc_set_fill (new->gc_in, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
new->gc_white = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_white, &bg);
|
||||
|
||||
new->gc_black = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_black, &fg);
|
||||
#endif
|
||||
|
||||
/* Setup 2nd & 3rd GCs */
|
||||
fg.pixel = gdisplay_white_pixel (gdisp);
|
||||
bg.pixel = gdisplay_gray_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_out = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_out, &fg);
|
||||
gdk_gc_set_background (new->gc_out, &bg);
|
||||
gdk_gc_set_fill (new->gc_out, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_out, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
/* get black and color pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_color_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_layer = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_layer, &fg);
|
||||
gdk_gc_set_background (new->gc_layer, &bg);
|
||||
gdk_gc_set_fill (new->gc_layer, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_layer, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_free (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
g_source_remove (select->timeout_id);
|
||||
|
||||
if (select->gc_in)
|
||||
gdk_gc_destroy (select->gc_in);
|
||||
if (select->gc_out)
|
||||
gdk_gc_destroy (select->gc_out);
|
||||
if (select->gc_layer)
|
||||
gdk_gc_destroy (select->gc_layer);
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
if (select->gc_white)
|
||||
gdk_gc_destroy (select->gc_white);
|
||||
if (select->gc_black)
|
||||
gdk_gc_destroy (select->gc_black);
|
||||
#endif
|
||||
selection_free_segs (select);
|
||||
|
||||
g_free (select);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_pause (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
g_source_remove (select->timeout_id);
|
||||
select->timeout_id = 0;
|
||||
}
|
||||
|
||||
select->paused ++;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_resume (Selection *select)
|
||||
{
|
||||
if (select->paused == 1)
|
||||
{
|
||||
select->state = INTRO;
|
||||
select->timeout_id = g_timeout_add (INITIAL_DELAY,
|
||||
selection_start_marching,
|
||||
select);
|
||||
}
|
||||
|
||||
select->paused--;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_start (Selection *select,
|
||||
gboolean recalc)
|
||||
{
|
||||
/* A call to selection_start with recalc == TRUE means that
|
||||
* we want to recalculate the selection boundary--usually
|
||||
* after scaling or panning the display, or modifying the
|
||||
* selection in some way. If recalc == FALSE, the already
|
||||
* calculated boundary is simply redrawn.
|
||||
*/
|
||||
if (recalc)
|
||||
select->recalc = TRUE;
|
||||
|
||||
/* If this selection is paused, do not start it */
|
||||
if (select->paused > 0)
|
||||
return;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
g_source_remove (select->timeout_id);
|
||||
|
||||
select->state = INTRO; /* The state before the first draw */
|
||||
select->timeout_id = g_timeout_add (INITIAL_DELAY,
|
||||
selection_start_marching,
|
||||
select);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_invis (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
g_source_remove (select->timeout_id);
|
||||
select->timeout_id = 0;
|
||||
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
/* Find the bounds of the selection */
|
||||
if (gdisplay_mask_bounds (gdisp, &x1, &y1, &x2, &y2))
|
||||
{
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
|
||||
}
|
||||
else
|
||||
{
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_layer_invis (Selection *select)
|
||||
{
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gint x3, y3;
|
||||
gint x4, y4;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
g_source_remove (select->timeout_id);
|
||||
select->timeout_id = 0;
|
||||
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
|
||||
if (select->segs_layer != NULL && select->num_segs_layer == 4)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = select->gdisp;
|
||||
|
||||
x1 = select->segs_layer[0].x1 - 1;
|
||||
y1 = select->segs_layer[0].y1 - 1;
|
||||
x2 = select->segs_layer[3].x2 + 1;
|
||||
y2 = select->segs_layer[3].y2 + 1;
|
||||
|
||||
x3 = select->segs_layer[0].x1 + 1;
|
||||
y3 = select->segs_layer[0].y1 + 1;
|
||||
x4 = select->segs_layer[3].x2 - 1;
|
||||
y4 = select->segs_layer[3].y2 - 1;
|
||||
|
||||
/* expose the region */
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1) + 1, (y3 - y1) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y3, (x3 - x1) + 1, (y4 - y3) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y4, (x2 - x1) + 1, (y2 - y4) + 1);
|
||||
gdisplay_expose_area (gdisp, x4, y3, (x2 - x4) + 1, (y4 - y3) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_toggle (Selection *select)
|
||||
{
|
||||
selection_invis (select);
|
||||
selection_layer_invis (select);
|
||||
|
||||
/* toggle the visibility */
|
||||
select->hidden = select->hidden ? FALSE : TRUE;
|
||||
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static GdkPixmap *
|
||||
create_cycled_ants_pixmap (GdkWindow *window,
|
||||
|
@ -112,6 +385,7 @@ cycle_ant_colors (Selection *select)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#define MAX_POINTS_INC 2048
|
||||
|
||||
static void
|
||||
|
@ -228,6 +502,7 @@ selection_render_points (Selection *select)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
selection_draw (Selection *select)
|
||||
{
|
||||
|
@ -290,11 +565,11 @@ static void
|
|||
selection_transform_segs (Selection *select,
|
||||
BoundSeg *src_segs,
|
||||
GdkSegment *dest_segs,
|
||||
int num_segs)
|
||||
gint num_segs)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x, y;
|
||||
int i;
|
||||
GDisplay *gdisp;
|
||||
gint x, y;
|
||||
gint i;
|
||||
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
|
@ -338,7 +613,7 @@ selection_transform_segs (Selection *select,
|
|||
static void
|
||||
selection_generate_segs (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
GDisplay *gdisp;
|
||||
BoundSeg *segs_in;
|
||||
BoundSeg *segs_out;
|
||||
BoundSeg *segs_layer;
|
||||
|
@ -399,6 +674,7 @@ static void
|
|||
selection_free_segs (Selection *select)
|
||||
{
|
||||
gint j;
|
||||
|
||||
if (select->segs_in)
|
||||
g_free (select->segs_in);
|
||||
if (select->segs_out)
|
||||
|
@ -410,7 +686,8 @@ selection_free_segs (Selection *select)
|
|||
{
|
||||
if (select->points_in[j])
|
||||
g_free (select->points_in[j]);
|
||||
select->points_in[j] = NULL;
|
||||
|
||||
select->points_in[j] = NULL;
|
||||
select->num_points_in[j] = 0;
|
||||
}
|
||||
|
||||
|
@ -423,10 +700,10 @@ selection_free_segs (Selection *select)
|
|||
}
|
||||
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
selection_start_marching (gpointer data)
|
||||
{
|
||||
Selection * select;
|
||||
Selection *select;
|
||||
|
||||
select = (Selection *) data;
|
||||
|
||||
|
@ -435,12 +712,13 @@ selection_start_marching (gpointer data)
|
|||
{
|
||||
selection_free_segs (select);
|
||||
selection_generate_segs (select);
|
||||
|
||||
/* Toggle the RECALC flag */
|
||||
select->recalc = FALSE;
|
||||
}
|
||||
|
||||
select->index_in = 0;
|
||||
select->index_out = 0;
|
||||
select->index_in = 0;
|
||||
select->index_out = 0;
|
||||
select->index_layer = 0;
|
||||
|
||||
/* Make sure the state is set to marching */
|
||||
|
@ -459,22 +737,24 @@ selection_start_marching (gpointer data)
|
|||
selection_draw (select);
|
||||
|
||||
/* Reset the timer */
|
||||
select->timer = gtk_timeout_add (select->speed,
|
||||
selection_march_ants,
|
||||
(gpointer) select);
|
||||
select->timeout_id = g_timeout_add (select->speed,
|
||||
selection_march_ants,
|
||||
select);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
|
||||
static gboolean
|
||||
selection_march_ants (gpointer data)
|
||||
{
|
||||
Selection * select;
|
||||
Selection *select;
|
||||
|
||||
select = (Selection *) data;
|
||||
|
||||
/* increment stipple index */
|
||||
select->index_in++;
|
||||
|
||||
#ifndef USE_XDRAWPOINTS
|
||||
if (select->index_in > 7)
|
||||
select->index_in = 0;
|
||||
|
@ -500,260 +780,3 @@ selection_march_ants (gpointer data)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*********************************/
|
||||
/* Public function definitions */
|
||||
/*********************************/
|
||||
|
||||
Selection *
|
||||
selection_create (GdkWindow *win,
|
||||
GDisplay *gdisp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed)
|
||||
{
|
||||
GdkColor fg, bg;
|
||||
Selection *new;
|
||||
gint base_type;
|
||||
gint i;
|
||||
|
||||
new = g_new (Selection, 1);
|
||||
base_type = gimp_image_base_type (gdisp->gimage);
|
||||
|
||||
if (gimprc.cycled_marching_ants)
|
||||
{
|
||||
new->cycle = TRUE;
|
||||
if (!cycled_ants_pixmap)
|
||||
cycled_ants_pixmap = create_cycled_ants_pixmap (win, g_visual->depth);
|
||||
|
||||
new->cycle_pix = cycled_ants_pixmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
new->cycle = FALSE;
|
||||
if (!marching_ants[0])
|
||||
for (i = 0; i < 8; i++)
|
||||
marching_ants[i] = gdk_bitmap_create_from_data (win, (char*) ant_data[i], 8, 8);
|
||||
}
|
||||
|
||||
new->win = win;
|
||||
new->gdisp = gdisp;
|
||||
new->segs_in = NULL;
|
||||
new->segs_out = NULL;
|
||||
new->segs_layer = NULL;
|
||||
new->num_segs_in = 0;
|
||||
new->num_segs_out = 0;
|
||||
new->num_segs_layer = 0;
|
||||
new->index_in = 0;
|
||||
new->index_out = 0;
|
||||
new->index_layer = 0;
|
||||
new->state = INVISIBLE;
|
||||
new->paused = 0;
|
||||
new->recalc = TRUE;
|
||||
new->speed = speed;
|
||||
new->hidden = FALSE;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
new->points_in[i] = NULL;
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_in = gdk_gc_new (new->win);
|
||||
|
||||
if (new->cycle)
|
||||
{
|
||||
gdk_gc_set_fill (new->gc_in, GDK_TILED);
|
||||
gdk_gc_set_tile (new->gc_in, new->cycle_pix);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get black and white pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_white_pixel (gdisp);
|
||||
|
||||
gdk_gc_set_foreground (new->gc_in, &fg);
|
||||
gdk_gc_set_background (new->gc_in, &bg);
|
||||
gdk_gc_set_fill (new->gc_in, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_in, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
new->gc_white = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_white, &bg);
|
||||
|
||||
new->gc_black = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_black, &fg);
|
||||
#endif
|
||||
|
||||
/* Setup 2nd & 3rd GCs */
|
||||
fg.pixel = gdisplay_white_pixel (gdisp);
|
||||
bg.pixel = gdisplay_gray_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_out = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_out, &fg);
|
||||
gdk_gc_set_background (new->gc_out, &bg);
|
||||
gdk_gc_set_fill (new->gc_out, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_out, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
/* get black and color pixels for this gdisplay */
|
||||
fg.pixel = gdisplay_black_pixel (gdisp);
|
||||
bg.pixel = gdisplay_color_pixel (gdisp);
|
||||
|
||||
/* create a new graphics context */
|
||||
new->gc_layer = gdk_gc_new (new->win);
|
||||
gdk_gc_set_foreground (new->gc_layer, &fg);
|
||||
gdk_gc_set_background (new->gc_layer, &bg);
|
||||
gdk_gc_set_fill (new->gc_layer, GDK_OPAQUE_STIPPLED);
|
||||
gdk_gc_set_line_attributes (new->gc_layer, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_pause (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
gtk_timeout_remove (select->timer);
|
||||
|
||||
select->paused ++;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_resume (Selection *select)
|
||||
{
|
||||
if (select->paused == 1)
|
||||
{
|
||||
select->state = INTRO;
|
||||
select->timer = gtk_timeout_add (INITIAL_DELAY, selection_start_marching,
|
||||
(gpointer) select);
|
||||
}
|
||||
|
||||
select->paused--;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_start (Selection *select,
|
||||
int recalc)
|
||||
{
|
||||
/* A call to selection_start with recalc == TRUE means that
|
||||
* we want to recalculate the selection boundary--usually
|
||||
* after scaling or panning the display, or modifying the
|
||||
* selection in some way. If recalc == FALSE, the already
|
||||
* calculated boundary is simply redrawn.
|
||||
*/
|
||||
if (recalc)
|
||||
select->recalc = TRUE;
|
||||
|
||||
/* If this selection is paused, do not start it */
|
||||
if (select->paused > 0)
|
||||
return;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
gtk_timeout_remove (select->timer);
|
||||
|
||||
select->state = INTRO; /* The state before the first draw */
|
||||
select->timer = gtk_timeout_add (INITIAL_DELAY, selection_start_marching,
|
||||
(gpointer) select);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_invis (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
gtk_timeout_remove (select->timer);
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
/* Find the bounds of the selection */
|
||||
if (gdisplay_mask_bounds (gdisp, &x1, &y1, &x2, &y2))
|
||||
{
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
|
||||
}
|
||||
else
|
||||
{
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_layer_invis (Selection *select)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2;
|
||||
int x3, y3, x4, y4;
|
||||
|
||||
if (select->state != INVISIBLE)
|
||||
{
|
||||
gtk_timeout_remove (select->timer);
|
||||
select->state = INVISIBLE;
|
||||
}
|
||||
gdisp = (GDisplay *) select->gdisp;
|
||||
|
||||
if (select->segs_layer != NULL && select->num_segs_layer == 4)
|
||||
{
|
||||
x1 = select->segs_layer[0].x1 - 1;
|
||||
y1 = select->segs_layer[0].y1 - 1;
|
||||
x2 = select->segs_layer[3].x2 + 1;
|
||||
y2 = select->segs_layer[3].y2 + 1;
|
||||
|
||||
x3 = select->segs_layer[0].x1 + 1;
|
||||
y3 = select->segs_layer[0].y1 + 1;
|
||||
x4 = select->segs_layer[3].x2 - 1;
|
||||
y4 = select->segs_layer[3].y2 - 1;
|
||||
|
||||
/* expose the region */
|
||||
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1) + 1, (y3 - y1) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y3, (x3 - x1) + 1, (y4 - y3) + 1);
|
||||
gdisplay_expose_area (gdisp, x1, y4, (x2 - x1) + 1, (y2 - y4) + 1);
|
||||
gdisplay_expose_area (gdisp, x4, y3, (x2 - x4) + 1, (y4 - y3) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_hide (Selection *select,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
selection_invis (select);
|
||||
selection_layer_invis (select);
|
||||
|
||||
/* toggle the visibility */
|
||||
select->hidden = select->hidden ? FALSE : TRUE;
|
||||
|
||||
selection_start (select, TRUE);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
selection_free (Selection *select)
|
||||
{
|
||||
if (select->state != INVISIBLE)
|
||||
gtk_timeout_remove (select->timer);
|
||||
|
||||
if (select->gc_in)
|
||||
gdk_gc_destroy (select->gc_in);
|
||||
if (select->gc_out)
|
||||
gdk_gc_destroy (select->gc_out);
|
||||
if (select->gc_layer)
|
||||
gdk_gc_destroy (select->gc_layer);
|
||||
#ifdef USE_XDRAWPOINTS
|
||||
if (select->gc_white)
|
||||
gdk_gc_destroy (select->gc_white);
|
||||
if (select->gc_black)
|
||||
gdk_gc_destroy (select->gc_black);
|
||||
#endif
|
||||
selection_free_segs (select);
|
||||
g_free (select);
|
||||
}
|
||||
|
|
|
@ -42,10 +42,10 @@ struct _Selection
|
|||
gint index_layer; /* index of current stipple pattern */
|
||||
gint state; /* internal drawing state */
|
||||
gint paused; /* count of pause requests */
|
||||
gint recalc; /* flag to recalculate the selection */
|
||||
gboolean recalc; /* flag to recalculate the selection */
|
||||
gint speed; /* speed of marching ants */
|
||||
gint hidden; /* is the selection hidden? */
|
||||
gint timer; /* timer for successive draws */
|
||||
gboolean hidden; /* is the selection hidden? */
|
||||
guint timeout_id; /* timer for successive draws */
|
||||
gint cycle; /* color cycling turned on */
|
||||
GdkPixmap *cycle_pix; /* cycling pixmap */
|
||||
|
||||
|
@ -57,22 +57,22 @@ struct _Selection
|
|||
};
|
||||
|
||||
|
||||
/* Function declarations */
|
||||
Selection * selection_create (GdkWindow *window,
|
||||
GDisplay *gdisp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed);
|
||||
void selection_free (Selection *select);
|
||||
|
||||
Selection * selection_create (GdkWindow *win,
|
||||
GDisplay *disp,
|
||||
gint size,
|
||||
gint width,
|
||||
gint speed);
|
||||
void selection_pause (Selection *select);
|
||||
void selection_resume (Selection *select);
|
||||
void selection_start (Selection *select,
|
||||
gint recalc);
|
||||
void selection_invis (Selection *select);
|
||||
void selection_layer_invis (Selection *select);
|
||||
void selection_hide (Selection *select,
|
||||
GDisplay *gdisp);
|
||||
void selection_free (Selection *select);
|
||||
void selection_pause (Selection *select);
|
||||
void selection_resume (Selection *select);
|
||||
|
||||
void selection_start (Selection *select,
|
||||
gboolean recalc);
|
||||
void selection_invis (Selection *select);
|
||||
void selection_layer_invis (Selection *select);
|
||||
|
||||
void selection_toggle (Selection *select);
|
||||
|
||||
|
||||
#endif /* __SELECTION_H__ */
|
||||
|
|
|
@ -419,7 +419,7 @@ gimp_paint_tool_button_press (GimpTool *tool,
|
|||
tool->paused_count = 0;
|
||||
|
||||
/* pause the current selection and grab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionPause);
|
||||
gdisplays_selection_visibility (gdisp->gimage, SELECTION_PAUSE);
|
||||
|
||||
/* add motion memory if perfectmouse is set */
|
||||
if (gimprc.perfectmouse != 0)
|
||||
|
@ -508,7 +508,7 @@ gimp_paint_tool_button_release (GimpTool *tool,
|
|||
paint_tool = GIMP_PAINT_TOOL (tool);
|
||||
|
||||
/* resume the current selection and ungrab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionResume);
|
||||
gdisplays_selection_visibility (gdisp->gimage, SELECTION_RESUME);
|
||||
|
||||
gdk_pointer_ungrab (bevent->time);
|
||||
gdk_flush ();
|
||||
|
|
|
@ -297,7 +297,7 @@ init_edit_selection (GimpTool *tool,
|
|||
tool_manager_push_tool (GIMP_TOOL (edit_select));
|
||||
|
||||
/* pause the current selection */
|
||||
selection_pause (gdisp->select);
|
||||
gdisplay_selection_visibility (gdisp, SELECTION_PAUSE);
|
||||
|
||||
/* initialize the statusbar display */
|
||||
edit_select->context_id
|
||||
|
@ -325,7 +325,7 @@ gimp_edit_selection_tool_button_release (GimpTool *tool,
|
|||
edit_select = GIMP_EDIT_SELECTION_TOOL (tool);
|
||||
|
||||
/* resume the current selection and ungrab the pointer */
|
||||
selection_resume (gdisp->select);
|
||||
gdisplay_selection_visibility (gdisp, SELECTION_RESUME);
|
||||
|
||||
gdk_pointer_ungrab (bevent->time);
|
||||
gdk_flush ();
|
||||
|
|
|
@ -925,7 +925,7 @@ ink_button_press (GimpTool *tool,
|
|||
tool->paused_count = 0;
|
||||
|
||||
/* pause the current selection and grab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionPause);
|
||||
gdisplays_selection_visibility (gdisp->gimage, SELECTION_PAUSE);
|
||||
|
||||
/* add motion memory if you press mod1 first ^ perfectmouse */
|
||||
if (((bevent->state & GDK_MOD1_MASK) != 0) != (gimprc.perfectmouse != 0))
|
||||
|
@ -970,7 +970,7 @@ ink_button_release (GimpTool *tool,
|
|||
gimage = gdisp->gimage;
|
||||
|
||||
/* resume the current selection and ungrab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionResume);
|
||||
gdisplays_selection_visibility (gdisp->gimage, SELECTION_RESUME);
|
||||
|
||||
gdk_pointer_ungrab (bevent->time);
|
||||
gdk_flush ();
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "floating_sel.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gdisplay_ops.h"
|
||||
#include "selection.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "gimpeditselectiontool.h"
|
||||
|
@ -368,7 +367,7 @@ move_tool_button_release (GimpTool *tool,
|
|||
move_tool_motion (tool, NULL, gdisp);
|
||||
}
|
||||
|
||||
selection_resume (gdisp->select);
|
||||
gdisplay_selection_visibility (gdisp, SELECTION_RESUME);
|
||||
gdisplays_flush ();
|
||||
|
||||
if (move->guide)
|
||||
|
@ -558,7 +557,7 @@ gimp_move_tool_start_hguide (GimpTool *tool,
|
|||
|
||||
move = GIMP_MOVE_TOOL (tool);
|
||||
|
||||
selection_pause (gdisp->select);
|
||||
gdisplay_selection_visibility (gdisp, SELECTION_PAUSE);
|
||||
|
||||
tool->gdisp = gdisp;
|
||||
tool->scroll_lock = TRUE;
|
||||
|
@ -582,7 +581,7 @@ gimp_move_tool_start_vguide (GimpTool *tool,
|
|||
|
||||
move = GIMP_MOVE_TOOL (tool);
|
||||
|
||||
selection_pause (gdisp->select);
|
||||
gdisplay_selection_visibility (gdisp, SELECTION_PAUSE);
|
||||
|
||||
tool->gdisp = gdisp;
|
||||
tool->scroll_lock = TRUE;
|
||||
|
|
|
@ -419,7 +419,7 @@ gimp_paint_tool_button_press (GimpTool *tool,
|
|||
tool->paused_count = 0;
|
||||
|
||||
/* pause the current selection and grab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionPause);
|
||||
gdisplays_selection_visibility (gdisp->gimage, SELECTION_PAUSE);
|
||||
|
||||
/* add motion memory if perfectmouse is set */
|
||||
if (gimprc.perfectmouse != 0)
|
||||
|
@ -508,7 +508,7 @@ gimp_paint_tool_button_release (GimpTool *tool,
|
|||
paint_tool = GIMP_PAINT_TOOL (tool);
|
||||
|
||||
/* resume the current selection and ungrab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionResume);
|
||||
gdisplays_selection_visibility (gdisp->gimage, SELECTION_RESUME);
|
||||
|
||||
gdk_pointer_ungrab (bevent->time);
|
||||
gdk_flush ();
|
||||
|
|
|
@ -487,7 +487,7 @@ pop_stack (GimpImage *gimage,
|
|||
/* If the size_changed flag was set */
|
||||
if (size_changed)
|
||||
{
|
||||
gimp_image_size_changed (gimage);
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
||||
size_changed = FALSE;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,8 @@ libappwidgets_a_SOURCES = @STRIP_BEGIN@ \
|
|||
gimplistitem.h \
|
||||
gimpmenuitem.c \
|
||||
gimpmenuitem.h \
|
||||
gimpnavigationpreview.c \
|
||||
gimpnavigationpreview.h \
|
||||
gimppalettepreview.c \
|
||||
gimppalettepreview.h \
|
||||
gimppatternpreview.c \
|
||||
|
|
|
@ -106,24 +106,30 @@ gimp_drawable_preview_get_size (GimpPreview *preview,
|
|||
gboolean scaling_up;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = drawable->gimage;
|
||||
gimage = gimp_drawable_gimage (drawable);
|
||||
|
||||
if (gimage)
|
||||
{
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
size,
|
||||
size,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
width,
|
||||
height,
|
||||
&scaling_up);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
size,
|
||||
size,
|
||||
1.0,
|
||||
1.0,
|
||||
width,
|
||||
height,
|
||||
&scaling_up);
|
||||
|
@ -143,7 +149,7 @@ gimp_drawable_preview_render (GimpPreview *preview)
|
|||
TempBuf *render_buf;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = drawable->gimage;
|
||||
gimage = gimp_drawable_gimage (drawable);
|
||||
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
|
@ -155,20 +161,26 @@ gimp_drawable_preview_render (GimpPreview *preview)
|
|||
height = MAX (1, ROUND ((((gdouble) height / (gdouble) gimage->height) *
|
||||
(gdouble) drawable->height)));
|
||||
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
width,
|
||||
height,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&preview_width,
|
||||
&preview_height,
|
||||
&scaling_up);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
width,
|
||||
height,
|
||||
gimage ? gimage->xresolution : 1.0,
|
||||
gimage ? gimage->yresolution : 1.0,
|
||||
&preview_width,
|
||||
&preview_height,
|
||||
&scaling_up);
|
||||
|
@ -252,16 +264,21 @@ static GtkWidget *
|
|||
gimp_drawable_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
GimpImage *gimage;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean scaling_up;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = gimp_drawable_gimage (drawable);
|
||||
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
MIN (preview->width * 2, 256),
|
||||
MIN (preview->height * 2, 256),
|
||||
gimage ? gimage->xresolution : 1.0,
|
||||
gimage ? gimage->yresolution : 1.0,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
|
|
@ -104,10 +104,13 @@ gimp_image_preview_get_size (GimpPreview *preview,
|
|||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
size,
|
||||
size,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
width,
|
||||
height,
|
||||
&scaling_up);
|
||||
|
@ -129,10 +132,13 @@ gimp_image_preview_render (GimpPreview *preview)
|
|||
width = preview->width;
|
||||
height = preview->height;
|
||||
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
width,
|
||||
height,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&preview_width,
|
||||
&preview_height,
|
||||
&scaling_up);
|
||||
|
@ -203,10 +209,13 @@ gimp_image_preview_create_popup (GimpPreview *preview)
|
|||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
MIN (preview->width * 2, 256),
|
||||
MIN (preview->height * 2, 256),
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
|
|
@ -0,0 +1,565 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* GimpNavigationPreview Widget
|
||||
* Copyright (C) 2001 Michael Natterer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "base/temp-buf.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gimpnavigationpreview.h"
|
||||
|
||||
|
||||
#define BORDER_PEN_WIDTH 3
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
MARKER_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
static void gimp_navigation_preview_class_init (GimpNavigationPreviewClass *klass);
|
||||
static void gimp_navigation_preview_init (GimpNavigationPreview *preview);
|
||||
|
||||
static void gimp_navigation_preview_destroy (GtkObject *object);
|
||||
static void gimp_navigation_preview_realize (GtkWidget *widget);
|
||||
static gboolean gimp_navigation_preview_expose (GtkWidget *widget,
|
||||
GdkEventExpose *eevent);
|
||||
static gboolean gimp_navigation_preview_button_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent);
|
||||
static gboolean gimp_navigation_preview_button_release (GtkWidget *widget,
|
||||
GdkEventButton *bevent);
|
||||
static gboolean gimp_navigation_preview_motion_notify (GtkWidget *widget,
|
||||
GdkEventMotion *mevent);
|
||||
static gboolean gimp_navigation_preview_key_press (GtkWidget *widget,
|
||||
GdkEventKey *kevent);
|
||||
static void gimp_navigation_preview_render (GimpPreview *preview);
|
||||
static void gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||
GdkRectangle *area);
|
||||
|
||||
|
||||
static guint preview_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GimpImagePreviewClass *parent_class = NULL;
|
||||
|
||||
|
||||
GtkType
|
||||
gimp_navigation_preview_get_type (void)
|
||||
{
|
||||
static GtkType preview_type = 0;
|
||||
|
||||
if (! preview_type)
|
||||
{
|
||||
GtkTypeInfo preview_info =
|
||||
{
|
||||
"GimpNavigationPreview",
|
||||
sizeof (GimpNavigationPreview),
|
||||
sizeof (GimpNavigationPreviewClass),
|
||||
(GtkClassInitFunc) gimp_navigation_preview_class_init,
|
||||
(GtkObjectInitFunc) gimp_navigation_preview_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
preview_type = gtk_type_unique (GIMP_TYPE_IMAGE_PREVIEW, &preview_info);
|
||||
}
|
||||
|
||||
return preview_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_class_init (GimpNavigationPreviewClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GimpPreviewClass *preview_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
widget_class = (GtkWidgetClass *) klass;
|
||||
preview_class = (GimpPreviewClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_IMAGE_PREVIEW);
|
||||
|
||||
preview_signals[MARKER_CHANGED] =
|
||||
gtk_signal_new ("marker_changed",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpNavigationPreviewClass,
|
||||
marker_changed),
|
||||
gtk_marshal_NONE__INT_INT,
|
||||
GTK_TYPE_NONE, 2,
|
||||
GTK_TYPE_INT,
|
||||
GTK_TYPE_INT);
|
||||
|
||||
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_navigation_preview_destroy;
|
||||
|
||||
widget_class->realize = gimp_navigation_preview_realize;
|
||||
widget_class->expose_event = gimp_navigation_preview_expose;
|
||||
widget_class->button_press_event = gimp_navigation_preview_button_press;
|
||||
widget_class->button_release_event = gimp_navigation_preview_button_release;
|
||||
widget_class->motion_notify_event = gimp_navigation_preview_motion_notify;
|
||||
widget_class->key_press_event = gimp_navigation_preview_key_press;
|
||||
|
||||
preview_class->render = gimp_navigation_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_init (GimpNavigationPreview *preview)
|
||||
{
|
||||
GTK_WIDGET_SET_FLAGS (preview, GTK_CAN_FOCUS);
|
||||
|
||||
preview->x = 0;
|
||||
preview->y = 0;
|
||||
preview->width = 0;
|
||||
preview->height = 0;
|
||||
|
||||
preview->p_x = 0;
|
||||
preview->p_y = 0;
|
||||
preview->p_width = 0;
|
||||
preview->p_height = 0;
|
||||
|
||||
preview->motion_offset_x = 0;
|
||||
preview->motion_offset_y = 0;
|
||||
preview->has_grab = FALSE;
|
||||
|
||||
preview->gc = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_destroy (GtkObject *object)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (object);
|
||||
|
||||
if (nav_preview->gc)
|
||||
{
|
||||
gdk_gc_unref (nav_preview->gc);
|
||||
nav_preview->gc = NULL;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_realize (GtkWidget *widget)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (widget);
|
||||
|
||||
if (GTK_WIDGET_CLASS (parent_class)->realize)
|
||||
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
||||
|
||||
nav_preview->gc = gdk_gc_new (widget->window);
|
||||
|
||||
gdk_gc_set_function (nav_preview->gc, GDK_INVERT);
|
||||
gdk_gc_set_line_attributes (nav_preview->gc,
|
||||
BORDER_PEN_WIDTH,
|
||||
GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_ROUND);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_navigation_preview_expose (GtkWidget *widget,
|
||||
GdkEventExpose *eevent)
|
||||
{
|
||||
if (GTK_WIDGET_DRAWABLE (widget))
|
||||
{
|
||||
if (GTK_WIDGET_CLASS (parent_class)->expose_event)
|
||||
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, eevent);
|
||||
|
||||
gimp_navigation_preview_draw_marker (GIMP_NAVIGATION_PREVIEW (widget),
|
||||
&eevent->area);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_move_to (GimpNavigationPreview *nav_preview,
|
||||
gint tx,
|
||||
gint ty)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
GimpImage *gimage;
|
||||
gdouble ratiox, ratioy;
|
||||
gint x, y;
|
||||
|
||||
preview = GIMP_PREVIEW (nav_preview);
|
||||
|
||||
tx = CLAMP (tx, 0, preview->width);
|
||||
ty = CLAMP (ty, 0, preview->height);
|
||||
|
||||
if ((tx + nav_preview->p_width) >= preview->width)
|
||||
{
|
||||
tx = preview->width - nav_preview->p_width;
|
||||
}
|
||||
|
||||
if ((ty + nav_preview->p_height) >= preview->height)
|
||||
{
|
||||
ty = preview->height - nav_preview->p_height;
|
||||
}
|
||||
|
||||
if (nav_preview->p_x == tx && nav_preview->p_y == ty)
|
||||
return;
|
||||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
/* transform to image coordinates */
|
||||
ratiox = ((gdouble) preview->width / (gdouble) gimage->width);
|
||||
ratioy = ((gdouble) preview->height / (gdouble) gimage->height);
|
||||
|
||||
x = RINT (tx / ratiox);
|
||||
y = RINT (ty / ratioy);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[MARKER_CHANGED],
|
||||
x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_grab_pointer (GimpNavigationPreview *nav_preview)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GdkCursor *cursor;
|
||||
|
||||
widget = GTK_WIDGET (nav_preview);
|
||||
|
||||
nav_preview->has_grab = TRUE;
|
||||
|
||||
gtk_grab_add (widget);
|
||||
|
||||
cursor = gdk_cursor_new (GDK_CROSSHAIR);
|
||||
|
||||
gdk_pointer_grab (widget->window, TRUE,
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK |
|
||||
GDK_BUTTON_MOTION_MASK |
|
||||
GDK_EXTENSION_EVENTS_ALL,
|
||||
widget->window, cursor, 0);
|
||||
|
||||
gdk_cursor_destroy (cursor);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_navigation_preview_button_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
gint tx, ty;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (widget);
|
||||
|
||||
tx = bevent->x;
|
||||
ty = bevent->y;
|
||||
|
||||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
if (! (tx > nav_preview->p_x &&
|
||||
tx < (nav_preview->p_x + nav_preview->p_width) &&
|
||||
ty > nav_preview->p_y &&
|
||||
ty < (nav_preview->p_y + nav_preview->p_height)))
|
||||
{
|
||||
nav_preview->motion_offset_x = nav_preview->p_width / 2;
|
||||
nav_preview->motion_offset_y = nav_preview->p_height / 2;
|
||||
|
||||
tx -= nav_preview->motion_offset_x;
|
||||
ty -= nav_preview->motion_offset_y;
|
||||
|
||||
gimp_navigation_preview_move_to (nav_preview, tx, ty);
|
||||
}
|
||||
else
|
||||
{
|
||||
nav_preview->motion_offset_x = tx - nav_preview->p_x;
|
||||
nav_preview->motion_offset_y = ty - nav_preview->p_y;
|
||||
}
|
||||
|
||||
gimp_navigation_preview_grab_pointer (nav_preview);
|
||||
break;
|
||||
|
||||
/* wheelmouse support */
|
||||
case 4:
|
||||
if (bevent->state & GDK_SHIFT_MASK)
|
||||
{
|
||||
// change_scale (gdisp, GIMP_ZOOM_IN);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
GtkAdjustment *adj =
|
||||
(bevent->state & GDK_CONTROL_MASK) ?
|
||||
gdisp->hsbdata : gdisp->vsbdata;
|
||||
gfloat new_value = adj->value - adj->page_increment / 2;
|
||||
new_value =
|
||||
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
|
||||
gtk_adjustment_set_value (adj, new_value);
|
||||
*/
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (bevent->state & GDK_SHIFT_MASK)
|
||||
{
|
||||
// change_scale (gdisp, GIMP_ZOOM_OUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
GtkAdjustment *adj =
|
||||
(bevent->state & GDK_CONTROL_MASK) ?
|
||||
gdisp->hsbdata : gdisp->vsbdata;
|
||||
gfloat new_value = adj->value + adj->page_increment / 2;
|
||||
new_value = CLAMP (new_value,
|
||||
adj->lower, adj->upper - adj->page_size);
|
||||
gtk_adjustment_set_value (adj, new_value);
|
||||
*/
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_navigation_preview_button_release (GtkWidget *widget,
|
||||
GdkEventButton *bevent)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (widget);
|
||||
|
||||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
nav_preview->has_grab = FALSE;
|
||||
|
||||
gtk_grab_remove (widget);
|
||||
gdk_pointer_ungrab (0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_navigation_preview_motion_notify (GtkWidget *widget,
|
||||
GdkEventMotion *mevent)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
gint tx, ty;
|
||||
GdkModifierType mask;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (widget);
|
||||
|
||||
if (! nav_preview->has_grab)
|
||||
return FALSE;
|
||||
|
||||
gdk_window_get_pointer (widget->window, &tx, &ty, &mask);
|
||||
|
||||
tx -= nav_preview->motion_offset_x;
|
||||
ty -= nav_preview->motion_offset_y;
|
||||
|
||||
gimp_navigation_preview_move_to (nav_preview, tx, ty);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_navigation_preview_key_press (GtkWidget *widget,
|
||||
GdkEventKey *kevent)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
gint scroll_x = 0;
|
||||
gint scroll_y = 0;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (widget);
|
||||
|
||||
switch (kevent->keyval)
|
||||
{
|
||||
case GDK_Up:
|
||||
scroll_y = -1;
|
||||
break;
|
||||
|
||||
case GDK_Left:
|
||||
scroll_x = -1;
|
||||
break;
|
||||
|
||||
case GDK_Right:
|
||||
scroll_x = 1;
|
||||
break;
|
||||
|
||||
case GDK_Down:
|
||||
scroll_y = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (scroll_x || scroll_y)
|
||||
{
|
||||
gimp_navigation_preview_move_to (nav_preview,
|
||||
nav_preview->p_x + scroll_x,
|
||||
nav_preview->p_y + scroll_y);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_render (GimpPreview *preview)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (preview);
|
||||
|
||||
if (GIMP_PREVIEW_CLASS (parent_class)->render)
|
||||
GIMP_PREVIEW_CLASS (parent_class)->render (preview);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||
GdkRectangle *area)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
|
||||
preview = GIMP_PREVIEW (nav_preview);
|
||||
|
||||
if (preview->viewable &&
|
||||
nav_preview->width &&
|
||||
nav_preview->height)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
if (nav_preview->x > 0 ||
|
||||
nav_preview->y > 0 ||
|
||||
nav_preview->width < gimage->width ||
|
||||
nav_preview->height < gimage->height)
|
||||
{
|
||||
if (area)
|
||||
gdk_gc_set_clip_rectangle (nav_preview->gc, area);
|
||||
|
||||
gdk_draw_rectangle (GTK_WIDGET (preview)->window, nav_preview->gc,
|
||||
FALSE,
|
||||
nav_preview->p_x,
|
||||
nav_preview->p_y,
|
||||
nav_preview->p_width - BORDER_PEN_WIDTH + 1,
|
||||
nav_preview->p_height - BORDER_PEN_WIDTH + 1);
|
||||
|
||||
if (area)
|
||||
gdk_gc_set_clip_rectangle (nav_preview->gc, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_navigation_preview_new (GimpImage *gimage,
|
||||
gint size)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
|
||||
g_return_val_if_fail (gimage != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (size > 0 && size <= 256, NULL);
|
||||
|
||||
preview = gtk_type_new (GIMP_TYPE_NAVIGATION_PREVIEW);
|
||||
|
||||
preview->is_popup = TRUE;
|
||||
|
||||
gimp_preview_set_viewable (preview, GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_preview_set_size (preview, size, 0);
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_navigation_preview_set_marker (GimpNavigationPreview *nav_preview,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
GimpImage *gimage;
|
||||
gdouble ratiox, ratioy;
|
||||
|
||||
g_return_if_fail (nav_preview != NULL);
|
||||
g_return_if_fail (GIMP_IS_NAVIGATION_PREVIEW (nav_preview));
|
||||
|
||||
preview = GIMP_PREVIEW (nav_preview);
|
||||
|
||||
g_return_if_fail (preview->viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
/* remove old marker */
|
||||
if (GTK_WIDGET_DRAWABLE (preview))
|
||||
gimp_navigation_preview_draw_marker (nav_preview, NULL);
|
||||
|
||||
nav_preview->x = CLAMP (x, 0, gimage->width - 1);
|
||||
nav_preview->y = CLAMP (y, 0, gimage->height - 1);
|
||||
|
||||
if (width == -1)
|
||||
width = gimage->width;
|
||||
|
||||
if (height == -1)
|
||||
height = gimage->height;
|
||||
|
||||
nav_preview->width = CLAMP (width, 1, gimage->width - nav_preview->x);
|
||||
nav_preview->height = CLAMP (height, 1, gimage->height - nav_preview->y);
|
||||
|
||||
/* transform to preview coordinates */
|
||||
ratiox = ((gdouble) preview->width / (gdouble) gimage->width);
|
||||
ratioy = ((gdouble) preview->height / (gdouble) gimage->height);
|
||||
|
||||
nav_preview->p_x = RINT (nav_preview->x * ratiox);
|
||||
nav_preview->p_y = RINT (nav_preview->y * ratioy);
|
||||
|
||||
nav_preview->p_width = RINT (nav_preview->width * ratiox);
|
||||
nav_preview->p_height = RINT (nav_preview->height * ratioy);
|
||||
|
||||
/* draw new marker */
|
||||
if (GTK_WIDGET_DRAWABLE (preview))
|
||||
gimp_navigation_preview_draw_marker (nav_preview, NULL);
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* GimpNavigationPreview Widget
|
||||
* Copyright (C) 2001 Michael Natterer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_NAVIGATION_PREVIEW_H__
|
||||
#define __GIMP_NAVIGATION_PREVIEW_H__
|
||||
|
||||
|
||||
#include "gimpimagepreview.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#define GIMP_TYPE_NAVIGATION_PREVIEW (gimp_navigation_preview_get_type ())
|
||||
#define GIMP_NAVIGATION_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_NAVIGATION_PREVIEW, GimpNavigationPreview))
|
||||
#define GIMP_NAVIGATION_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NAVIGATION_PREVIEW, GimpNavigationPreviewClass))
|
||||
#define GIMP_IS_NAVIGATION_PREVIEW(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_NAVIGATION_PREVIEW))
|
||||
#define GIMP_IS_NAVIGATION_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NAVIGATION_PREVIEW))
|
||||
|
||||
|
||||
typedef struct _GimpNavigationPreviewClass GimpNavigationPreviewClass;
|
||||
|
||||
struct _GimpNavigationPreview
|
||||
{
|
||||
GimpImagePreview parent_instance;
|
||||
|
||||
/* values in image coordinates */
|
||||
gint x;
|
||||
gint y;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
/* values in preview coordinates */
|
||||
gint p_x;
|
||||
gint p_y;
|
||||
gint p_width;
|
||||
gint p_height;
|
||||
|
||||
gint motion_offset_x;
|
||||
gint motion_offset_y;
|
||||
gboolean has_grab;
|
||||
|
||||
GdkGC *gc;
|
||||
};
|
||||
|
||||
struct _GimpNavigationPreviewClass
|
||||
{
|
||||
GimpPreviewClass parent_class;
|
||||
|
||||
void (* marker_changed) (GimpNavigationPreview *preview,
|
||||
gint x,
|
||||
gint y);
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_navigation_preview_get_type (void);
|
||||
|
||||
GtkWidget * gimp_navigation_preview_new (GimpImage *gimage,
|
||||
gint size);
|
||||
void gimp_navigation_preview_set_marker (GimpNavigationPreview *preview,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GIMP_NAVIGATION_PREVIEW_H__ */
|
|
@ -0,0 +1,565 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* GimpNavigationPreview Widget
|
||||
* Copyright (C) 2001 Michael Natterer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "base/temp-buf.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gimpnavigationpreview.h"
|
||||
|
||||
|
||||
#define BORDER_PEN_WIDTH 3
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
MARKER_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
static void gimp_navigation_preview_class_init (GimpNavigationPreviewClass *klass);
|
||||
static void gimp_navigation_preview_init (GimpNavigationPreview *preview);
|
||||
|
||||
static void gimp_navigation_preview_destroy (GtkObject *object);
|
||||
static void gimp_navigation_preview_realize (GtkWidget *widget);
|
||||
static gboolean gimp_navigation_preview_expose (GtkWidget *widget,
|
||||
GdkEventExpose *eevent);
|
||||
static gboolean gimp_navigation_preview_button_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent);
|
||||
static gboolean gimp_navigation_preview_button_release (GtkWidget *widget,
|
||||
GdkEventButton *bevent);
|
||||
static gboolean gimp_navigation_preview_motion_notify (GtkWidget *widget,
|
||||
GdkEventMotion *mevent);
|
||||
static gboolean gimp_navigation_preview_key_press (GtkWidget *widget,
|
||||
GdkEventKey *kevent);
|
||||
static void gimp_navigation_preview_render (GimpPreview *preview);
|
||||
static void gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||
GdkRectangle *area);
|
||||
|
||||
|
||||
static guint preview_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GimpImagePreviewClass *parent_class = NULL;
|
||||
|
||||
|
||||
GtkType
|
||||
gimp_navigation_preview_get_type (void)
|
||||
{
|
||||
static GtkType preview_type = 0;
|
||||
|
||||
if (! preview_type)
|
||||
{
|
||||
GtkTypeInfo preview_info =
|
||||
{
|
||||
"GimpNavigationPreview",
|
||||
sizeof (GimpNavigationPreview),
|
||||
sizeof (GimpNavigationPreviewClass),
|
||||
(GtkClassInitFunc) gimp_navigation_preview_class_init,
|
||||
(GtkObjectInitFunc) gimp_navigation_preview_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
preview_type = gtk_type_unique (GIMP_TYPE_IMAGE_PREVIEW, &preview_info);
|
||||
}
|
||||
|
||||
return preview_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_class_init (GimpNavigationPreviewClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GimpPreviewClass *preview_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
widget_class = (GtkWidgetClass *) klass;
|
||||
preview_class = (GimpPreviewClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_IMAGE_PREVIEW);
|
||||
|
||||
preview_signals[MARKER_CHANGED] =
|
||||
gtk_signal_new ("marker_changed",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpNavigationPreviewClass,
|
||||
marker_changed),
|
||||
gtk_marshal_NONE__INT_INT,
|
||||
GTK_TYPE_NONE, 2,
|
||||
GTK_TYPE_INT,
|
||||
GTK_TYPE_INT);
|
||||
|
||||
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_navigation_preview_destroy;
|
||||
|
||||
widget_class->realize = gimp_navigation_preview_realize;
|
||||
widget_class->expose_event = gimp_navigation_preview_expose;
|
||||
widget_class->button_press_event = gimp_navigation_preview_button_press;
|
||||
widget_class->button_release_event = gimp_navigation_preview_button_release;
|
||||
widget_class->motion_notify_event = gimp_navigation_preview_motion_notify;
|
||||
widget_class->key_press_event = gimp_navigation_preview_key_press;
|
||||
|
||||
preview_class->render = gimp_navigation_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_init (GimpNavigationPreview *preview)
|
||||
{
|
||||
GTK_WIDGET_SET_FLAGS (preview, GTK_CAN_FOCUS);
|
||||
|
||||
preview->x = 0;
|
||||
preview->y = 0;
|
||||
preview->width = 0;
|
||||
preview->height = 0;
|
||||
|
||||
preview->p_x = 0;
|
||||
preview->p_y = 0;
|
||||
preview->p_width = 0;
|
||||
preview->p_height = 0;
|
||||
|
||||
preview->motion_offset_x = 0;
|
||||
preview->motion_offset_y = 0;
|
||||
preview->has_grab = FALSE;
|
||||
|
||||
preview->gc = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_destroy (GtkObject *object)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (object);
|
||||
|
||||
if (nav_preview->gc)
|
||||
{
|
||||
gdk_gc_unref (nav_preview->gc);
|
||||
nav_preview->gc = NULL;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_realize (GtkWidget *widget)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (widget);
|
||||
|
||||
if (GTK_WIDGET_CLASS (parent_class)->realize)
|
||||
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
||||
|
||||
nav_preview->gc = gdk_gc_new (widget->window);
|
||||
|
||||
gdk_gc_set_function (nav_preview->gc, GDK_INVERT);
|
||||
gdk_gc_set_line_attributes (nav_preview->gc,
|
||||
BORDER_PEN_WIDTH,
|
||||
GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_ROUND);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_navigation_preview_expose (GtkWidget *widget,
|
||||
GdkEventExpose *eevent)
|
||||
{
|
||||
if (GTK_WIDGET_DRAWABLE (widget))
|
||||
{
|
||||
if (GTK_WIDGET_CLASS (parent_class)->expose_event)
|
||||
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, eevent);
|
||||
|
||||
gimp_navigation_preview_draw_marker (GIMP_NAVIGATION_PREVIEW (widget),
|
||||
&eevent->area);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_move_to (GimpNavigationPreview *nav_preview,
|
||||
gint tx,
|
||||
gint ty)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
GimpImage *gimage;
|
||||
gdouble ratiox, ratioy;
|
||||
gint x, y;
|
||||
|
||||
preview = GIMP_PREVIEW (nav_preview);
|
||||
|
||||
tx = CLAMP (tx, 0, preview->width);
|
||||
ty = CLAMP (ty, 0, preview->height);
|
||||
|
||||
if ((tx + nav_preview->p_width) >= preview->width)
|
||||
{
|
||||
tx = preview->width - nav_preview->p_width;
|
||||
}
|
||||
|
||||
if ((ty + nav_preview->p_height) >= preview->height)
|
||||
{
|
||||
ty = preview->height - nav_preview->p_height;
|
||||
}
|
||||
|
||||
if (nav_preview->p_x == tx && nav_preview->p_y == ty)
|
||||
return;
|
||||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
/* transform to image coordinates */
|
||||
ratiox = ((gdouble) preview->width / (gdouble) gimage->width);
|
||||
ratioy = ((gdouble) preview->height / (gdouble) gimage->height);
|
||||
|
||||
x = RINT (tx / ratiox);
|
||||
y = RINT (ty / ratioy);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[MARKER_CHANGED],
|
||||
x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_grab_pointer (GimpNavigationPreview *nav_preview)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GdkCursor *cursor;
|
||||
|
||||
widget = GTK_WIDGET (nav_preview);
|
||||
|
||||
nav_preview->has_grab = TRUE;
|
||||
|
||||
gtk_grab_add (widget);
|
||||
|
||||
cursor = gdk_cursor_new (GDK_CROSSHAIR);
|
||||
|
||||
gdk_pointer_grab (widget->window, TRUE,
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK |
|
||||
GDK_BUTTON_MOTION_MASK |
|
||||
GDK_EXTENSION_EVENTS_ALL,
|
||||
widget->window, cursor, 0);
|
||||
|
||||
gdk_cursor_destroy (cursor);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_navigation_preview_button_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
gint tx, ty;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (widget);
|
||||
|
||||
tx = bevent->x;
|
||||
ty = bevent->y;
|
||||
|
||||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
if (! (tx > nav_preview->p_x &&
|
||||
tx < (nav_preview->p_x + nav_preview->p_width) &&
|
||||
ty > nav_preview->p_y &&
|
||||
ty < (nav_preview->p_y + nav_preview->p_height)))
|
||||
{
|
||||
nav_preview->motion_offset_x = nav_preview->p_width / 2;
|
||||
nav_preview->motion_offset_y = nav_preview->p_height / 2;
|
||||
|
||||
tx -= nav_preview->motion_offset_x;
|
||||
ty -= nav_preview->motion_offset_y;
|
||||
|
||||
gimp_navigation_preview_move_to (nav_preview, tx, ty);
|
||||
}
|
||||
else
|
||||
{
|
||||
nav_preview->motion_offset_x = tx - nav_preview->p_x;
|
||||
nav_preview->motion_offset_y = ty - nav_preview->p_y;
|
||||
}
|
||||
|
||||
gimp_navigation_preview_grab_pointer (nav_preview);
|
||||
break;
|
||||
|
||||
/* wheelmouse support */
|
||||
case 4:
|
||||
if (bevent->state & GDK_SHIFT_MASK)
|
||||
{
|
||||
// change_scale (gdisp, GIMP_ZOOM_IN);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
GtkAdjustment *adj =
|
||||
(bevent->state & GDK_CONTROL_MASK) ?
|
||||
gdisp->hsbdata : gdisp->vsbdata;
|
||||
gfloat new_value = adj->value - adj->page_increment / 2;
|
||||
new_value =
|
||||
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
|
||||
gtk_adjustment_set_value (adj, new_value);
|
||||
*/
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (bevent->state & GDK_SHIFT_MASK)
|
||||
{
|
||||
// change_scale (gdisp, GIMP_ZOOM_OUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
GtkAdjustment *adj =
|
||||
(bevent->state & GDK_CONTROL_MASK) ?
|
||||
gdisp->hsbdata : gdisp->vsbdata;
|
||||
gfloat new_value = adj->value + adj->page_increment / 2;
|
||||
new_value = CLAMP (new_value,
|
||||
adj->lower, adj->upper - adj->page_size);
|
||||
gtk_adjustment_set_value (adj, new_value);
|
||||
*/
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_navigation_preview_button_release (GtkWidget *widget,
|
||||
GdkEventButton *bevent)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (widget);
|
||||
|
||||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
nav_preview->has_grab = FALSE;
|
||||
|
||||
gtk_grab_remove (widget);
|
||||
gdk_pointer_ungrab (0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_navigation_preview_motion_notify (GtkWidget *widget,
|
||||
GdkEventMotion *mevent)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
gint tx, ty;
|
||||
GdkModifierType mask;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (widget);
|
||||
|
||||
if (! nav_preview->has_grab)
|
||||
return FALSE;
|
||||
|
||||
gdk_window_get_pointer (widget->window, &tx, &ty, &mask);
|
||||
|
||||
tx -= nav_preview->motion_offset_x;
|
||||
ty -= nav_preview->motion_offset_y;
|
||||
|
||||
gimp_navigation_preview_move_to (nav_preview, tx, ty);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_navigation_preview_key_press (GtkWidget *widget,
|
||||
GdkEventKey *kevent)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
gint scroll_x = 0;
|
||||
gint scroll_y = 0;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (widget);
|
||||
|
||||
switch (kevent->keyval)
|
||||
{
|
||||
case GDK_Up:
|
||||
scroll_y = -1;
|
||||
break;
|
||||
|
||||
case GDK_Left:
|
||||
scroll_x = -1;
|
||||
break;
|
||||
|
||||
case GDK_Right:
|
||||
scroll_x = 1;
|
||||
break;
|
||||
|
||||
case GDK_Down:
|
||||
scroll_y = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (scroll_x || scroll_y)
|
||||
{
|
||||
gimp_navigation_preview_move_to (nav_preview,
|
||||
nav_preview->p_x + scroll_x,
|
||||
nav_preview->p_y + scroll_y);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_render (GimpPreview *preview)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (preview);
|
||||
|
||||
if (GIMP_PREVIEW_CLASS (parent_class)->render)
|
||||
GIMP_PREVIEW_CLASS (parent_class)->render (preview);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||
GdkRectangle *area)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
|
||||
preview = GIMP_PREVIEW (nav_preview);
|
||||
|
||||
if (preview->viewable &&
|
||||
nav_preview->width &&
|
||||
nav_preview->height)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
if (nav_preview->x > 0 ||
|
||||
nav_preview->y > 0 ||
|
||||
nav_preview->width < gimage->width ||
|
||||
nav_preview->height < gimage->height)
|
||||
{
|
||||
if (area)
|
||||
gdk_gc_set_clip_rectangle (nav_preview->gc, area);
|
||||
|
||||
gdk_draw_rectangle (GTK_WIDGET (preview)->window, nav_preview->gc,
|
||||
FALSE,
|
||||
nav_preview->p_x,
|
||||
nav_preview->p_y,
|
||||
nav_preview->p_width - BORDER_PEN_WIDTH + 1,
|
||||
nav_preview->p_height - BORDER_PEN_WIDTH + 1);
|
||||
|
||||
if (area)
|
||||
gdk_gc_set_clip_rectangle (nav_preview->gc, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_navigation_preview_new (GimpImage *gimage,
|
||||
gint size)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
|
||||
g_return_val_if_fail (gimage != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (size > 0 && size <= 256, NULL);
|
||||
|
||||
preview = gtk_type_new (GIMP_TYPE_NAVIGATION_PREVIEW);
|
||||
|
||||
preview->is_popup = TRUE;
|
||||
|
||||
gimp_preview_set_viewable (preview, GIMP_VIEWABLE (gimage));
|
||||
|
||||
gimp_preview_set_size (preview, size, 0);
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_navigation_preview_set_marker (GimpNavigationPreview *nav_preview,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
GimpImage *gimage;
|
||||
gdouble ratiox, ratioy;
|
||||
|
||||
g_return_if_fail (nav_preview != NULL);
|
||||
g_return_if_fail (GIMP_IS_NAVIGATION_PREVIEW (nav_preview));
|
||||
|
||||
preview = GIMP_PREVIEW (nav_preview);
|
||||
|
||||
g_return_if_fail (preview->viewable);
|
||||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
/* remove old marker */
|
||||
if (GTK_WIDGET_DRAWABLE (preview))
|
||||
gimp_navigation_preview_draw_marker (nav_preview, NULL);
|
||||
|
||||
nav_preview->x = CLAMP (x, 0, gimage->width - 1);
|
||||
nav_preview->y = CLAMP (y, 0, gimage->height - 1);
|
||||
|
||||
if (width == -1)
|
||||
width = gimage->width;
|
||||
|
||||
if (height == -1)
|
||||
height = gimage->height;
|
||||
|
||||
nav_preview->width = CLAMP (width, 1, gimage->width - nav_preview->x);
|
||||
nav_preview->height = CLAMP (height, 1, gimage->height - nav_preview->y);
|
||||
|
||||
/* transform to preview coordinates */
|
||||
ratiox = ((gdouble) preview->width / (gdouble) gimage->width);
|
||||
ratioy = ((gdouble) preview->height / (gdouble) gimage->height);
|
||||
|
||||
nav_preview->p_x = RINT (nav_preview->x * ratiox);
|
||||
nav_preview->p_y = RINT (nav_preview->y * ratioy);
|
||||
|
||||
nav_preview->p_width = RINT (nav_preview->width * ratiox);
|
||||
nav_preview->p_height = RINT (nav_preview->height * ratioy);
|
||||
|
||||
/* draw new marker */
|
||||
if (GTK_WIDGET_DRAWABLE (preview))
|
||||
gimp_navigation_preview_draw_marker (nav_preview, NULL);
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* GimpNavigationPreview Widget
|
||||
* Copyright (C) 2001 Michael Natterer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_NAVIGATION_PREVIEW_H__
|
||||
#define __GIMP_NAVIGATION_PREVIEW_H__
|
||||
|
||||
|
||||
#include "gimpimagepreview.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#define GIMP_TYPE_NAVIGATION_PREVIEW (gimp_navigation_preview_get_type ())
|
||||
#define GIMP_NAVIGATION_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_NAVIGATION_PREVIEW, GimpNavigationPreview))
|
||||
#define GIMP_NAVIGATION_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NAVIGATION_PREVIEW, GimpNavigationPreviewClass))
|
||||
#define GIMP_IS_NAVIGATION_PREVIEW(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_NAVIGATION_PREVIEW))
|
||||
#define GIMP_IS_NAVIGATION_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NAVIGATION_PREVIEW))
|
||||
|
||||
|
||||
typedef struct _GimpNavigationPreviewClass GimpNavigationPreviewClass;
|
||||
|
||||
struct _GimpNavigationPreview
|
||||
{
|
||||
GimpImagePreview parent_instance;
|
||||
|
||||
/* values in image coordinates */
|
||||
gint x;
|
||||
gint y;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
/* values in preview coordinates */
|
||||
gint p_x;
|
||||
gint p_y;
|
||||
gint p_width;
|
||||
gint p_height;
|
||||
|
||||
gint motion_offset_x;
|
||||
gint motion_offset_y;
|
||||
gboolean has_grab;
|
||||
|
||||
GdkGC *gc;
|
||||
};
|
||||
|
||||
struct _GimpNavigationPreviewClass
|
||||
{
|
||||
GimpPreviewClass parent_class;
|
||||
|
||||
void (* marker_changed) (GimpNavigationPreview *preview,
|
||||
gint x,
|
||||
gint y);
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_navigation_preview_get_type (void);
|
||||
|
||||
GtkWidget * gimp_navigation_preview_new (GimpImage *gimage,
|
||||
gint size);
|
||||
void gimp_navigation_preview_set_marker (GimpNavigationPreview *preview,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GIMP_NAVIGATION_PREVIEW_H__ */
|
|
@ -108,6 +108,8 @@ static void gimp_preview_popup_show (GimpPreview *preview,
|
|||
gint x,
|
||||
gint y);
|
||||
static void gimp_preview_popup_hide (GimpPreview *preview);
|
||||
static void gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable);
|
||||
static void gimp_preview_paint (GimpPreview *preview);
|
||||
static gboolean gimp_preview_idle_paint (GimpPreview *preview);
|
||||
static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget,
|
||||
|
@ -224,7 +226,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
|
||||
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
|
||||
widget_class->size_allocate = gimp_preview_size_allocate;
|
||||
widget_class->button_press_event = gimp_preview_button_press_event;
|
||||
|
@ -232,13 +234,13 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
widget_class->enter_notify_event = gimp_preview_enter_notify_event;
|
||||
widget_class->leave_notify_event = gimp_preview_leave_notify_event;
|
||||
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -249,6 +251,7 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->width = 8;
|
||||
preview->height = 8;
|
||||
preview->border_width = 0;
|
||||
preview->dot_for_dot = TRUE;
|
||||
|
||||
gimp_rgba_set (&preview->border_color, 0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
|
@ -256,6 +259,7 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->clickable = FALSE;
|
||||
preview->show_popup = FALSE;
|
||||
|
||||
preview->size = -1;
|
||||
preview->in_button = FALSE;
|
||||
preview->idle_id = 0;
|
||||
preview->popup_id = 0;
|
||||
|
@ -290,19 +294,10 @@ gimp_preview_destroy (GtkObject *object)
|
|||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_preview_new (GimpViewable *viewable,
|
||||
gint size,
|
||||
gint border_width,
|
||||
gboolean is_popup)
|
||||
static GimpPreview *
|
||||
gimp_preview_new_by_type (GimpViewable *viewable)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
gint width, height;
|
||||
|
||||
g_return_val_if_fail (viewable != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
||||
g_return_val_if_fail (size > 0 && size <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
if (GIMP_IS_BRUSH (viewable))
|
||||
{
|
||||
|
@ -337,19 +332,29 @@ gimp_preview_new (GimpViewable *viewable,
|
|||
preview = gtk_type_new (GIMP_TYPE_PREVIEW);
|
||||
}
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
preview->border_width = border_width;
|
||||
return preview;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_preview_new (GimpViewable *viewable,
|
||||
gint size,
|
||||
gint border_width,
|
||||
gboolean is_popup)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
|
||||
g_return_val_if_fail (viewable != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
||||
g_return_val_if_fail (size > 0 && size <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
preview = gimp_preview_new_by_type (viewable);
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
|
||||
gimp_preview_set_viewable (preview, viewable);
|
||||
|
||||
gimp_preview_get_size (preview, size, &width, &height);
|
||||
|
||||
preview->width = width;
|
||||
preview->height = height;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * border_width,
|
||||
height + 2 * border_width);
|
||||
gimp_preview_set_size (preview, size, border_width);
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
@ -371,53 +376,15 @@ gimp_preview_new_full (GimpViewable *viewable,
|
|||
g_return_val_if_fail (height > 0 && height <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
if (GIMP_IS_BRUSH (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_BRUSH_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_DRAWABLE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_DRAWABLE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_IMAGE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_IMAGE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_PATTERN (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PATTERN_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_GRADIENT (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_GRADIENT_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_PALETTE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PALETTE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_TOOL_INFO (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_TOOL_INFO_PREVIEW);
|
||||
}
|
||||
else
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PREVIEW);
|
||||
}
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
|
||||
preview->width = width;
|
||||
preview->height = height;
|
||||
preview->border_width = border_width;
|
||||
preview = gimp_preview_new_by_type (viewable);
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
preview->clickable = clickable;
|
||||
preview->show_popup = show_popup;
|
||||
|
||||
gimp_preview_set_viewable (preview, viewable);
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * border_width,
|
||||
height + 2 * border_width);
|
||||
gimp_preview_set_size_full (preview, width, height, border_width);
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
@ -443,12 +410,17 @@ gimp_preview_set_viewable (GimpPreview *preview,
|
|||
}
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
gimp_preview_paint,
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
GTK_SIGNAL_FUNC (gimp_preview_paint),
|
||||
preview);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
gtk_widget_destroyed,
|
||||
&preview->viewable);
|
||||
GTK_SIGNAL_FUNC (gimp_preview_size_changed),
|
||||
preview);
|
||||
|
||||
}
|
||||
|
||||
preview->viewable = viewable;
|
||||
|
@ -471,16 +443,28 @@ gimp_preview_set_viewable (GimpPreview *preview,
|
|||
NULL);
|
||||
}
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (preview->viewable), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (preview->viewable),
|
||||
"invalidate_preview",
|
||||
GTK_SIGNAL_FUNC (gimp_preview_paint),
|
||||
GTK_OBJECT (preview));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (preview->viewable), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
gtk_signal_connect_object (GTK_OBJECT (preview->viewable),
|
||||
"size_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_preview_size_changed),
|
||||
GTK_OBJECT (preview));
|
||||
|
||||
gimp_preview_render (preview);
|
||||
if (preview->size != -1)
|
||||
{
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,6 +480,8 @@ gimp_preview_set_size (GimpPreview *preview,
|
|||
g_return_if_fail (preview_size > 0 && preview_size <= 256);
|
||||
g_return_if_fail (border_width >= 0 && border_width <= 16);
|
||||
|
||||
preview->size = preview_size;
|
||||
|
||||
gimp_preview_get_size (preview, preview_size, &width, &height);
|
||||
|
||||
gimp_preview_set_size_full (preview,
|
||||
|
@ -523,6 +509,31 @@ gimp_preview_set_size_full (GimpPreview *preview,
|
|||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * preview->border_width,
|
||||
height + 2 * preview->border_width);
|
||||
|
||||
gtk_widget_hide (GTK_WIDGET (preview));
|
||||
gtk_widget_show (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||
gboolean dot_for_dot)
|
||||
{
|
||||
g_return_if_fail (preview != NULL);
|
||||
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
||||
|
||||
if (dot_for_dot != preview->dot_for_dot)
|
||||
{
|
||||
preview->dot_for_dot = dot_for_dot ? TRUE: FALSE;
|
||||
|
||||
if (preview->size != -1)
|
||||
{
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -537,7 +548,7 @@ gimp_preview_set_border_color (GimpPreview *preview,
|
|||
{
|
||||
preview->border_color = *color;
|
||||
|
||||
gimp_preview_render (preview);
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -686,9 +697,12 @@ gimp_preview_real_render (GimpPreview *preview)
|
|||
preview->height);
|
||||
|
||||
if (temp_buf)
|
||||
gimp_preview_render_and_flush (preview,
|
||||
temp_buf,
|
||||
-1);
|
||||
{
|
||||
gimp_preview_render_and_flush (preview,
|
||||
temp_buf,
|
||||
-1);
|
||||
temp_buf_free (temp_buf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -857,6 +871,20 @@ gimp_preview_size_allocate (GtkWidget *widget,
|
|||
gimp_preview_paint (GIMP_PREVIEW (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
if (preview->size != -1)
|
||||
{
|
||||
g_print ("size_changed (%d)\n", preview->size);
|
||||
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_paint (GimpPreview *preview)
|
||||
{
|
||||
|
@ -885,34 +913,50 @@ gimp_preview_idle_paint (GimpPreview *preview)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_preview_calc_size (gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up)
|
||||
gimp_preview_calc_size (GimpPreview *preview,
|
||||
gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up)
|
||||
{
|
||||
gdouble ratio;
|
||||
gdouble xratio;
|
||||
gdouble yratio;
|
||||
|
||||
if (aspect_width > aspect_height)
|
||||
{
|
||||
ratio = (gdouble) width / (gdouble) aspect_width;
|
||||
xratio = yratio = (gdouble) width / (gdouble) aspect_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
ratio = (gdouble) height / (gdouble) aspect_height;
|
||||
xratio = yratio = (gdouble) height / (gdouble) aspect_height;
|
||||
}
|
||||
|
||||
width = RINT (ratio * (gdouble) aspect_width);
|
||||
height = RINT (ratio * (gdouble) aspect_height);
|
||||
if (! preview->dot_for_dot && xresolution != yresolution)
|
||||
{
|
||||
if (xresolution < yresolution)
|
||||
{
|
||||
yratio *= xresolution / yresolution;
|
||||
}
|
||||
else
|
||||
{
|
||||
yratio *= yresolution / xresolution;
|
||||
}
|
||||
}
|
||||
|
||||
width = RINT (xratio * (gdouble) aspect_width);
|
||||
height = RINT (yratio * (gdouble) aspect_height);
|
||||
|
||||
if (width < 1) width = 1;
|
||||
if (height < 1) height = 1;
|
||||
|
||||
*return_width = width;
|
||||
*return_height = height;
|
||||
*scaling_up = (ratio > 1.0);
|
||||
*scaling_up = (xratio > 1.0) || (yratio > 1.0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -49,6 +49,7 @@ struct _GimpPreview
|
|||
gint width;
|
||||
gint height;
|
||||
gint border_width;
|
||||
gboolean dot_for_dot;
|
||||
|
||||
GimpRGB border_color;
|
||||
|
||||
|
@ -57,6 +58,7 @@ struct _GimpPreview
|
|||
gboolean show_popup;
|
||||
|
||||
/*< private >*/
|
||||
gint size;
|
||||
gboolean in_button;
|
||||
guint press_state;
|
||||
guint idle_id;
|
||||
|
@ -108,6 +110,9 @@ void gimp_preview_set_size_full (GimpPreview *preview,
|
|||
gint height,
|
||||
gint border_width);
|
||||
|
||||
void gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||
gboolean dot_for_dot);
|
||||
|
||||
void gimp_preview_set_border_color (GimpPreview *preview,
|
||||
const GimpRGB *border_color);
|
||||
|
||||
|
@ -116,10 +121,13 @@ void gimp_preview_render (GimpPreview *preview);
|
|||
|
||||
/* protected */
|
||||
|
||||
void gimp_preview_calc_size (gint aspect_width,
|
||||
void gimp_preview_calc_size (GimpPreview *preview,
|
||||
gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up);
|
||||
|
|
|
@ -108,6 +108,8 @@ static void gimp_preview_popup_show (GimpPreview *preview,
|
|||
gint x,
|
||||
gint y);
|
||||
static void gimp_preview_popup_hide (GimpPreview *preview);
|
||||
static void gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable);
|
||||
static void gimp_preview_paint (GimpPreview *preview);
|
||||
static gboolean gimp_preview_idle_paint (GimpPreview *preview);
|
||||
static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget,
|
||||
|
@ -224,7 +226,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
|
||||
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
|
||||
widget_class->size_allocate = gimp_preview_size_allocate;
|
||||
widget_class->button_press_event = gimp_preview_button_press_event;
|
||||
|
@ -232,13 +234,13 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
widget_class->enter_notify_event = gimp_preview_enter_notify_event;
|
||||
widget_class->leave_notify_event = gimp_preview_leave_notify_event;
|
||||
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -249,6 +251,7 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->width = 8;
|
||||
preview->height = 8;
|
||||
preview->border_width = 0;
|
||||
preview->dot_for_dot = TRUE;
|
||||
|
||||
gimp_rgba_set (&preview->border_color, 0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
|
@ -256,6 +259,7 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->clickable = FALSE;
|
||||
preview->show_popup = FALSE;
|
||||
|
||||
preview->size = -1;
|
||||
preview->in_button = FALSE;
|
||||
preview->idle_id = 0;
|
||||
preview->popup_id = 0;
|
||||
|
@ -290,19 +294,10 @@ gimp_preview_destroy (GtkObject *object)
|
|||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_preview_new (GimpViewable *viewable,
|
||||
gint size,
|
||||
gint border_width,
|
||||
gboolean is_popup)
|
||||
static GimpPreview *
|
||||
gimp_preview_new_by_type (GimpViewable *viewable)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
gint width, height;
|
||||
|
||||
g_return_val_if_fail (viewable != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
||||
g_return_val_if_fail (size > 0 && size <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
if (GIMP_IS_BRUSH (viewable))
|
||||
{
|
||||
|
@ -337,19 +332,29 @@ gimp_preview_new (GimpViewable *viewable,
|
|||
preview = gtk_type_new (GIMP_TYPE_PREVIEW);
|
||||
}
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
preview->border_width = border_width;
|
||||
return preview;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_preview_new (GimpViewable *viewable,
|
||||
gint size,
|
||||
gint border_width,
|
||||
gboolean is_popup)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
|
||||
g_return_val_if_fail (viewable != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
||||
g_return_val_if_fail (size > 0 && size <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
preview = gimp_preview_new_by_type (viewable);
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
|
||||
gimp_preview_set_viewable (preview, viewable);
|
||||
|
||||
gimp_preview_get_size (preview, size, &width, &height);
|
||||
|
||||
preview->width = width;
|
||||
preview->height = height;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * border_width,
|
||||
height + 2 * border_width);
|
||||
gimp_preview_set_size (preview, size, border_width);
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
@ -371,53 +376,15 @@ gimp_preview_new_full (GimpViewable *viewable,
|
|||
g_return_val_if_fail (height > 0 && height <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
if (GIMP_IS_BRUSH (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_BRUSH_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_DRAWABLE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_DRAWABLE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_IMAGE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_IMAGE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_PATTERN (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PATTERN_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_GRADIENT (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_GRADIENT_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_PALETTE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PALETTE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_TOOL_INFO (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_TOOL_INFO_PREVIEW);
|
||||
}
|
||||
else
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PREVIEW);
|
||||
}
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
|
||||
preview->width = width;
|
||||
preview->height = height;
|
||||
preview->border_width = border_width;
|
||||
preview = gimp_preview_new_by_type (viewable);
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
preview->clickable = clickable;
|
||||
preview->show_popup = show_popup;
|
||||
|
||||
gimp_preview_set_viewable (preview, viewable);
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * border_width,
|
||||
height + 2 * border_width);
|
||||
gimp_preview_set_size_full (preview, width, height, border_width);
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
@ -443,12 +410,17 @@ gimp_preview_set_viewable (GimpPreview *preview,
|
|||
}
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
gimp_preview_paint,
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
GTK_SIGNAL_FUNC (gimp_preview_paint),
|
||||
preview);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
gtk_widget_destroyed,
|
||||
&preview->viewable);
|
||||
GTK_SIGNAL_FUNC (gimp_preview_size_changed),
|
||||
preview);
|
||||
|
||||
}
|
||||
|
||||
preview->viewable = viewable;
|
||||
|
@ -471,16 +443,28 @@ gimp_preview_set_viewable (GimpPreview *preview,
|
|||
NULL);
|
||||
}
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (preview->viewable), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (preview->viewable),
|
||||
"invalidate_preview",
|
||||
GTK_SIGNAL_FUNC (gimp_preview_paint),
|
||||
GTK_OBJECT (preview));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (preview->viewable), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
gtk_signal_connect_object (GTK_OBJECT (preview->viewable),
|
||||
"size_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_preview_size_changed),
|
||||
GTK_OBJECT (preview));
|
||||
|
||||
gimp_preview_render (preview);
|
||||
if (preview->size != -1)
|
||||
{
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,6 +480,8 @@ gimp_preview_set_size (GimpPreview *preview,
|
|||
g_return_if_fail (preview_size > 0 && preview_size <= 256);
|
||||
g_return_if_fail (border_width >= 0 && border_width <= 16);
|
||||
|
||||
preview->size = preview_size;
|
||||
|
||||
gimp_preview_get_size (preview, preview_size, &width, &height);
|
||||
|
||||
gimp_preview_set_size_full (preview,
|
||||
|
@ -523,6 +509,31 @@ gimp_preview_set_size_full (GimpPreview *preview,
|
|||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * preview->border_width,
|
||||
height + 2 * preview->border_width);
|
||||
|
||||
gtk_widget_hide (GTK_WIDGET (preview));
|
||||
gtk_widget_show (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||
gboolean dot_for_dot)
|
||||
{
|
||||
g_return_if_fail (preview != NULL);
|
||||
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
||||
|
||||
if (dot_for_dot != preview->dot_for_dot)
|
||||
{
|
||||
preview->dot_for_dot = dot_for_dot ? TRUE: FALSE;
|
||||
|
||||
if (preview->size != -1)
|
||||
{
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -537,7 +548,7 @@ gimp_preview_set_border_color (GimpPreview *preview,
|
|||
{
|
||||
preview->border_color = *color;
|
||||
|
||||
gimp_preview_render (preview);
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -686,9 +697,12 @@ gimp_preview_real_render (GimpPreview *preview)
|
|||
preview->height);
|
||||
|
||||
if (temp_buf)
|
||||
gimp_preview_render_and_flush (preview,
|
||||
temp_buf,
|
||||
-1);
|
||||
{
|
||||
gimp_preview_render_and_flush (preview,
|
||||
temp_buf,
|
||||
-1);
|
||||
temp_buf_free (temp_buf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -857,6 +871,20 @@ gimp_preview_size_allocate (GtkWidget *widget,
|
|||
gimp_preview_paint (GIMP_PREVIEW (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
if (preview->size != -1)
|
||||
{
|
||||
g_print ("size_changed (%d)\n", preview->size);
|
||||
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_paint (GimpPreview *preview)
|
||||
{
|
||||
|
@ -885,34 +913,50 @@ gimp_preview_idle_paint (GimpPreview *preview)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_preview_calc_size (gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up)
|
||||
gimp_preview_calc_size (GimpPreview *preview,
|
||||
gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up)
|
||||
{
|
||||
gdouble ratio;
|
||||
gdouble xratio;
|
||||
gdouble yratio;
|
||||
|
||||
if (aspect_width > aspect_height)
|
||||
{
|
||||
ratio = (gdouble) width / (gdouble) aspect_width;
|
||||
xratio = yratio = (gdouble) width / (gdouble) aspect_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
ratio = (gdouble) height / (gdouble) aspect_height;
|
||||
xratio = yratio = (gdouble) height / (gdouble) aspect_height;
|
||||
}
|
||||
|
||||
width = RINT (ratio * (gdouble) aspect_width);
|
||||
height = RINT (ratio * (gdouble) aspect_height);
|
||||
if (! preview->dot_for_dot && xresolution != yresolution)
|
||||
{
|
||||
if (xresolution < yresolution)
|
||||
{
|
||||
yratio *= xresolution / yresolution;
|
||||
}
|
||||
else
|
||||
{
|
||||
yratio *= yresolution / xresolution;
|
||||
}
|
||||
}
|
||||
|
||||
width = RINT (xratio * (gdouble) aspect_width);
|
||||
height = RINT (yratio * (gdouble) aspect_height);
|
||||
|
||||
if (width < 1) width = 1;
|
||||
if (height < 1) height = 1;
|
||||
|
||||
*return_width = width;
|
||||
*return_height = height;
|
||||
*scaling_up = (ratio > 1.0);
|
||||
*scaling_up = (xratio > 1.0) || (yratio > 1.0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -49,6 +49,7 @@ struct _GimpPreview
|
|||
gint width;
|
||||
gint height;
|
||||
gint border_width;
|
||||
gboolean dot_for_dot;
|
||||
|
||||
GimpRGB border_color;
|
||||
|
||||
|
@ -57,6 +58,7 @@ struct _GimpPreview
|
|||
gboolean show_popup;
|
||||
|
||||
/*< private >*/
|
||||
gint size;
|
||||
gboolean in_button;
|
||||
guint press_state;
|
||||
guint idle_id;
|
||||
|
@ -108,6 +110,9 @@ void gimp_preview_set_size_full (GimpPreview *preview,
|
|||
gint height,
|
||||
gint border_width);
|
||||
|
||||
void gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||
gboolean dot_for_dot);
|
||||
|
||||
void gimp_preview_set_border_color (GimpPreview *preview,
|
||||
const GimpRGB *border_color);
|
||||
|
||||
|
@ -116,10 +121,13 @@ void gimp_preview_render (GimpPreview *preview);
|
|||
|
||||
/* protected */
|
||||
|
||||
void gimp_preview_calc_size (gint aspect_width,
|
||||
void gimp_preview_calc_size (GimpPreview *preview,
|
||||
gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up);
|
||||
|
|
|
@ -106,24 +106,30 @@ gimp_drawable_preview_get_size (GimpPreview *preview,
|
|||
gboolean scaling_up;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = drawable->gimage;
|
||||
gimage = gimp_drawable_gimage (drawable);
|
||||
|
||||
if (gimage)
|
||||
{
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
size,
|
||||
size,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
width,
|
||||
height,
|
||||
&scaling_up);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
size,
|
||||
size,
|
||||
1.0,
|
||||
1.0,
|
||||
width,
|
||||
height,
|
||||
&scaling_up);
|
||||
|
@ -143,7 +149,7 @@ gimp_drawable_preview_render (GimpPreview *preview)
|
|||
TempBuf *render_buf;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = drawable->gimage;
|
||||
gimage = gimp_drawable_gimage (drawable);
|
||||
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
|
@ -155,20 +161,26 @@ gimp_drawable_preview_render (GimpPreview *preview)
|
|||
height = MAX (1, ROUND ((((gdouble) height / (gdouble) gimage->height) *
|
||||
(gdouble) drawable->height)));
|
||||
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
width,
|
||||
height,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&preview_width,
|
||||
&preview_height,
|
||||
&scaling_up);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
width,
|
||||
height,
|
||||
gimage ? gimage->xresolution : 1.0,
|
||||
gimage ? gimage->yresolution : 1.0,
|
||||
&preview_width,
|
||||
&preview_height,
|
||||
&scaling_up);
|
||||
|
@ -252,16 +264,21 @@ static GtkWidget *
|
|||
gimp_drawable_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
GimpImage *gimage;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean scaling_up;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = gimp_drawable_gimage (drawable);
|
||||
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
MIN (preview->width * 2, 256),
|
||||
MIN (preview->height * 2, 256),
|
||||
gimage ? gimage->xresolution : 1.0,
|
||||
gimage ? gimage->yresolution : 1.0,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
|
|
@ -104,10 +104,13 @@ gimp_image_preview_get_size (GimpPreview *preview,
|
|||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
size,
|
||||
size,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
width,
|
||||
height,
|
||||
&scaling_up);
|
||||
|
@ -129,10 +132,13 @@ gimp_image_preview_render (GimpPreview *preview)
|
|||
width = preview->width;
|
||||
height = preview->height;
|
||||
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
width,
|
||||
height,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&preview_width,
|
||||
&preview_height,
|
||||
&scaling_up);
|
||||
|
@ -203,10 +209,13 @@ gimp_image_preview_create_popup (GimpPreview *preview)
|
|||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
MIN (preview->width * 2, 256),
|
||||
MIN (preview->height * 2, 256),
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
|
|
@ -108,6 +108,8 @@ static void gimp_preview_popup_show (GimpPreview *preview,
|
|||
gint x,
|
||||
gint y);
|
||||
static void gimp_preview_popup_hide (GimpPreview *preview);
|
||||
static void gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable);
|
||||
static void gimp_preview_paint (GimpPreview *preview);
|
||||
static gboolean gimp_preview_idle_paint (GimpPreview *preview);
|
||||
static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget,
|
||||
|
@ -224,7 +226,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
|
||||
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
|
||||
widget_class->size_allocate = gimp_preview_size_allocate;
|
||||
widget_class->button_press_event = gimp_preview_button_press_event;
|
||||
|
@ -232,13 +234,13 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
widget_class->enter_notify_event = gimp_preview_enter_notify_event;
|
||||
widget_class->leave_notify_event = gimp_preview_leave_notify_event;
|
||||
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -249,6 +251,7 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->width = 8;
|
||||
preview->height = 8;
|
||||
preview->border_width = 0;
|
||||
preview->dot_for_dot = TRUE;
|
||||
|
||||
gimp_rgba_set (&preview->border_color, 0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
|
@ -256,6 +259,7 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->clickable = FALSE;
|
||||
preview->show_popup = FALSE;
|
||||
|
||||
preview->size = -1;
|
||||
preview->in_button = FALSE;
|
||||
preview->idle_id = 0;
|
||||
preview->popup_id = 0;
|
||||
|
@ -290,19 +294,10 @@ gimp_preview_destroy (GtkObject *object)
|
|||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_preview_new (GimpViewable *viewable,
|
||||
gint size,
|
||||
gint border_width,
|
||||
gboolean is_popup)
|
||||
static GimpPreview *
|
||||
gimp_preview_new_by_type (GimpViewable *viewable)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
gint width, height;
|
||||
|
||||
g_return_val_if_fail (viewable != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
||||
g_return_val_if_fail (size > 0 && size <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
if (GIMP_IS_BRUSH (viewable))
|
||||
{
|
||||
|
@ -337,19 +332,29 @@ gimp_preview_new (GimpViewable *viewable,
|
|||
preview = gtk_type_new (GIMP_TYPE_PREVIEW);
|
||||
}
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
preview->border_width = border_width;
|
||||
return preview;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_preview_new (GimpViewable *viewable,
|
||||
gint size,
|
||||
gint border_width,
|
||||
gboolean is_popup)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
|
||||
g_return_val_if_fail (viewable != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
||||
g_return_val_if_fail (size > 0 && size <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
preview = gimp_preview_new_by_type (viewable);
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
|
||||
gimp_preview_set_viewable (preview, viewable);
|
||||
|
||||
gimp_preview_get_size (preview, size, &width, &height);
|
||||
|
||||
preview->width = width;
|
||||
preview->height = height;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * border_width,
|
||||
height + 2 * border_width);
|
||||
gimp_preview_set_size (preview, size, border_width);
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
@ -371,53 +376,15 @@ gimp_preview_new_full (GimpViewable *viewable,
|
|||
g_return_val_if_fail (height > 0 && height <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
if (GIMP_IS_BRUSH (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_BRUSH_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_DRAWABLE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_DRAWABLE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_IMAGE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_IMAGE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_PATTERN (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PATTERN_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_GRADIENT (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_GRADIENT_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_PALETTE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PALETTE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_TOOL_INFO (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_TOOL_INFO_PREVIEW);
|
||||
}
|
||||
else
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PREVIEW);
|
||||
}
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
|
||||
preview->width = width;
|
||||
preview->height = height;
|
||||
preview->border_width = border_width;
|
||||
preview = gimp_preview_new_by_type (viewable);
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
preview->clickable = clickable;
|
||||
preview->show_popup = show_popup;
|
||||
|
||||
gimp_preview_set_viewable (preview, viewable);
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * border_width,
|
||||
height + 2 * border_width);
|
||||
gimp_preview_set_size_full (preview, width, height, border_width);
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
@ -443,12 +410,17 @@ gimp_preview_set_viewable (GimpPreview *preview,
|
|||
}
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
gimp_preview_paint,
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
GTK_SIGNAL_FUNC (gimp_preview_paint),
|
||||
preview);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
gtk_widget_destroyed,
|
||||
&preview->viewable);
|
||||
GTK_SIGNAL_FUNC (gimp_preview_size_changed),
|
||||
preview);
|
||||
|
||||
}
|
||||
|
||||
preview->viewable = viewable;
|
||||
|
@ -471,16 +443,28 @@ gimp_preview_set_viewable (GimpPreview *preview,
|
|||
NULL);
|
||||
}
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (preview->viewable), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (preview->viewable),
|
||||
"invalidate_preview",
|
||||
GTK_SIGNAL_FUNC (gimp_preview_paint),
|
||||
GTK_OBJECT (preview));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (preview->viewable), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
gtk_signal_connect_object (GTK_OBJECT (preview->viewable),
|
||||
"size_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_preview_size_changed),
|
||||
GTK_OBJECT (preview));
|
||||
|
||||
gimp_preview_render (preview);
|
||||
if (preview->size != -1)
|
||||
{
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,6 +480,8 @@ gimp_preview_set_size (GimpPreview *preview,
|
|||
g_return_if_fail (preview_size > 0 && preview_size <= 256);
|
||||
g_return_if_fail (border_width >= 0 && border_width <= 16);
|
||||
|
||||
preview->size = preview_size;
|
||||
|
||||
gimp_preview_get_size (preview, preview_size, &width, &height);
|
||||
|
||||
gimp_preview_set_size_full (preview,
|
||||
|
@ -523,6 +509,31 @@ gimp_preview_set_size_full (GimpPreview *preview,
|
|||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * preview->border_width,
|
||||
height + 2 * preview->border_width);
|
||||
|
||||
gtk_widget_hide (GTK_WIDGET (preview));
|
||||
gtk_widget_show (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||
gboolean dot_for_dot)
|
||||
{
|
||||
g_return_if_fail (preview != NULL);
|
||||
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
||||
|
||||
if (dot_for_dot != preview->dot_for_dot)
|
||||
{
|
||||
preview->dot_for_dot = dot_for_dot ? TRUE: FALSE;
|
||||
|
||||
if (preview->size != -1)
|
||||
{
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -537,7 +548,7 @@ gimp_preview_set_border_color (GimpPreview *preview,
|
|||
{
|
||||
preview->border_color = *color;
|
||||
|
||||
gimp_preview_render (preview);
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -686,9 +697,12 @@ gimp_preview_real_render (GimpPreview *preview)
|
|||
preview->height);
|
||||
|
||||
if (temp_buf)
|
||||
gimp_preview_render_and_flush (preview,
|
||||
temp_buf,
|
||||
-1);
|
||||
{
|
||||
gimp_preview_render_and_flush (preview,
|
||||
temp_buf,
|
||||
-1);
|
||||
temp_buf_free (temp_buf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -857,6 +871,20 @@ gimp_preview_size_allocate (GtkWidget *widget,
|
|||
gimp_preview_paint (GIMP_PREVIEW (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
if (preview->size != -1)
|
||||
{
|
||||
g_print ("size_changed (%d)\n", preview->size);
|
||||
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_paint (GimpPreview *preview)
|
||||
{
|
||||
|
@ -885,34 +913,50 @@ gimp_preview_idle_paint (GimpPreview *preview)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_preview_calc_size (gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up)
|
||||
gimp_preview_calc_size (GimpPreview *preview,
|
||||
gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up)
|
||||
{
|
||||
gdouble ratio;
|
||||
gdouble xratio;
|
||||
gdouble yratio;
|
||||
|
||||
if (aspect_width > aspect_height)
|
||||
{
|
||||
ratio = (gdouble) width / (gdouble) aspect_width;
|
||||
xratio = yratio = (gdouble) width / (gdouble) aspect_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
ratio = (gdouble) height / (gdouble) aspect_height;
|
||||
xratio = yratio = (gdouble) height / (gdouble) aspect_height;
|
||||
}
|
||||
|
||||
width = RINT (ratio * (gdouble) aspect_width);
|
||||
height = RINT (ratio * (gdouble) aspect_height);
|
||||
if (! preview->dot_for_dot && xresolution != yresolution)
|
||||
{
|
||||
if (xresolution < yresolution)
|
||||
{
|
||||
yratio *= xresolution / yresolution;
|
||||
}
|
||||
else
|
||||
{
|
||||
yratio *= yresolution / xresolution;
|
||||
}
|
||||
}
|
||||
|
||||
width = RINT (xratio * (gdouble) aspect_width);
|
||||
height = RINT (yratio * (gdouble) aspect_height);
|
||||
|
||||
if (width < 1) width = 1;
|
||||
if (height < 1) height = 1;
|
||||
|
||||
*return_width = width;
|
||||
*return_height = height;
|
||||
*scaling_up = (ratio > 1.0);
|
||||
*scaling_up = (xratio > 1.0) || (yratio > 1.0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -49,6 +49,7 @@ struct _GimpPreview
|
|||
gint width;
|
||||
gint height;
|
||||
gint border_width;
|
||||
gboolean dot_for_dot;
|
||||
|
||||
GimpRGB border_color;
|
||||
|
||||
|
@ -57,6 +58,7 @@ struct _GimpPreview
|
|||
gboolean show_popup;
|
||||
|
||||
/*< private >*/
|
||||
gint size;
|
||||
gboolean in_button;
|
||||
guint press_state;
|
||||
guint idle_id;
|
||||
|
@ -108,6 +110,9 @@ void gimp_preview_set_size_full (GimpPreview *preview,
|
|||
gint height,
|
||||
gint border_width);
|
||||
|
||||
void gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||
gboolean dot_for_dot);
|
||||
|
||||
void gimp_preview_set_border_color (GimpPreview *preview,
|
||||
const GimpRGB *border_color);
|
||||
|
||||
|
@ -116,10 +121,13 @@ void gimp_preview_render (GimpPreview *preview);
|
|||
|
||||
/* protected */
|
||||
|
||||
void gimp_preview_calc_size (gint aspect_width,
|
||||
void gimp_preview_calc_size (GimpPreview *preview,
|
||||
gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up);
|
||||
|
|
|
@ -108,6 +108,8 @@ static void gimp_preview_popup_show (GimpPreview *preview,
|
|||
gint x,
|
||||
gint y);
|
||||
static void gimp_preview_popup_hide (GimpPreview *preview);
|
||||
static void gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable);
|
||||
static void gimp_preview_paint (GimpPreview *preview);
|
||||
static gboolean gimp_preview_idle_paint (GimpPreview *preview);
|
||||
static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget,
|
||||
|
@ -224,7 +226,7 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
|
||||
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
object_class->destroy = gimp_preview_destroy;
|
||||
|
||||
widget_class->size_allocate = gimp_preview_size_allocate;
|
||||
widget_class->button_press_event = gimp_preview_button_press_event;
|
||||
|
@ -232,13 +234,13 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
widget_class->enter_notify_event = gimp_preview_enter_notify_event;
|
||||
widget_class->leave_notify_event = gimp_preview_leave_notify_event;
|
||||
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
klass->clicked = NULL;
|
||||
klass->double_clicked = NULL;
|
||||
klass->extended_clicked = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->get_size = gimp_preview_real_get_size;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -249,6 +251,7 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->width = 8;
|
||||
preview->height = 8;
|
||||
preview->border_width = 0;
|
||||
preview->dot_for_dot = TRUE;
|
||||
|
||||
gimp_rgba_set (&preview->border_color, 0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
|
@ -256,6 +259,7 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->clickable = FALSE;
|
||||
preview->show_popup = FALSE;
|
||||
|
||||
preview->size = -1;
|
||||
preview->in_button = FALSE;
|
||||
preview->idle_id = 0;
|
||||
preview->popup_id = 0;
|
||||
|
@ -290,19 +294,10 @@ gimp_preview_destroy (GtkObject *object)
|
|||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_preview_new (GimpViewable *viewable,
|
||||
gint size,
|
||||
gint border_width,
|
||||
gboolean is_popup)
|
||||
static GimpPreview *
|
||||
gimp_preview_new_by_type (GimpViewable *viewable)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
gint width, height;
|
||||
|
||||
g_return_val_if_fail (viewable != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
||||
g_return_val_if_fail (size > 0 && size <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
if (GIMP_IS_BRUSH (viewable))
|
||||
{
|
||||
|
@ -337,19 +332,29 @@ gimp_preview_new (GimpViewable *viewable,
|
|||
preview = gtk_type_new (GIMP_TYPE_PREVIEW);
|
||||
}
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
preview->border_width = border_width;
|
||||
return preview;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_preview_new (GimpViewable *viewable,
|
||||
gint size,
|
||||
gint border_width,
|
||||
gboolean is_popup)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
|
||||
g_return_val_if_fail (viewable != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
||||
g_return_val_if_fail (size > 0 && size <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
preview = gimp_preview_new_by_type (viewable);
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
|
||||
gimp_preview_set_viewable (preview, viewable);
|
||||
|
||||
gimp_preview_get_size (preview, size, &width, &height);
|
||||
|
||||
preview->width = width;
|
||||
preview->height = height;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * border_width,
|
||||
height + 2 * border_width);
|
||||
gimp_preview_set_size (preview, size, border_width);
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
@ -371,53 +376,15 @@ gimp_preview_new_full (GimpViewable *viewable,
|
|||
g_return_val_if_fail (height > 0 && height <= 256, NULL);
|
||||
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
||||
|
||||
if (GIMP_IS_BRUSH (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_BRUSH_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_DRAWABLE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_DRAWABLE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_IMAGE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_IMAGE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_PATTERN (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PATTERN_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_GRADIENT (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_GRADIENT_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_PALETTE (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PALETTE_PREVIEW);
|
||||
}
|
||||
else if (GIMP_IS_TOOL_INFO (viewable))
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_TOOL_INFO_PREVIEW);
|
||||
}
|
||||
else
|
||||
{
|
||||
preview = gtk_type_new (GIMP_TYPE_PREVIEW);
|
||||
}
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
|
||||
preview->width = width;
|
||||
preview->height = height;
|
||||
preview->border_width = border_width;
|
||||
preview = gimp_preview_new_by_type (viewable);
|
||||
|
||||
preview->is_popup = is_popup;
|
||||
preview->clickable = clickable;
|
||||
preview->show_popup = show_popup;
|
||||
|
||||
gimp_preview_set_viewable (preview, viewable);
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * border_width,
|
||||
height + 2 * border_width);
|
||||
gimp_preview_set_size_full (preview, width, height, border_width);
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
@ -443,12 +410,17 @@ gimp_preview_set_viewable (GimpPreview *preview,
|
|||
}
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
gimp_preview_paint,
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
GTK_SIGNAL_FUNC (gimp_preview_paint),
|
||||
preview);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
||||
gtk_widget_destroyed,
|
||||
&preview->viewable);
|
||||
GTK_SIGNAL_FUNC (gimp_preview_size_changed),
|
||||
preview);
|
||||
|
||||
}
|
||||
|
||||
preview->viewable = viewable;
|
||||
|
@ -471,16 +443,28 @@ gimp_preview_set_viewable (GimpPreview *preview,
|
|||
NULL);
|
||||
}
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (preview->viewable), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (preview->viewable),
|
||||
"invalidate_preview",
|
||||
GTK_SIGNAL_FUNC (gimp_preview_paint),
|
||||
GTK_OBJECT (preview));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (preview->viewable), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&preview->viewable);
|
||||
gtk_signal_connect_object (GTK_OBJECT (preview->viewable),
|
||||
"size_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_preview_size_changed),
|
||||
GTK_OBJECT (preview));
|
||||
|
||||
gimp_preview_render (preview);
|
||||
if (preview->size != -1)
|
||||
{
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,6 +480,8 @@ gimp_preview_set_size (GimpPreview *preview,
|
|||
g_return_if_fail (preview_size > 0 && preview_size <= 256);
|
||||
g_return_if_fail (border_width >= 0 && border_width <= 16);
|
||||
|
||||
preview->size = preview_size;
|
||||
|
||||
gimp_preview_get_size (preview, preview_size, &width, &height);
|
||||
|
||||
gimp_preview_set_size_full (preview,
|
||||
|
@ -523,6 +509,31 @@ gimp_preview_set_size_full (GimpPreview *preview,
|
|||
gtk_preview_size (GTK_PREVIEW (preview),
|
||||
width + 2 * preview->border_width,
|
||||
height + 2 * preview->border_width);
|
||||
|
||||
gtk_widget_hide (GTK_WIDGET (preview));
|
||||
gtk_widget_show (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||
gboolean dot_for_dot)
|
||||
{
|
||||
g_return_if_fail (preview != NULL);
|
||||
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
||||
|
||||
if (dot_for_dot != preview->dot_for_dot)
|
||||
{
|
||||
preview->dot_for_dot = dot_for_dot ? TRUE: FALSE;
|
||||
|
||||
if (preview->size != -1)
|
||||
{
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -537,7 +548,7 @@ gimp_preview_set_border_color (GimpPreview *preview,
|
|||
{
|
||||
preview->border_color = *color;
|
||||
|
||||
gimp_preview_render (preview);
|
||||
gimp_preview_paint (preview);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -686,9 +697,12 @@ gimp_preview_real_render (GimpPreview *preview)
|
|||
preview->height);
|
||||
|
||||
if (temp_buf)
|
||||
gimp_preview_render_and_flush (preview,
|
||||
temp_buf,
|
||||
-1);
|
||||
{
|
||||
gimp_preview_render_and_flush (preview,
|
||||
temp_buf,
|
||||
-1);
|
||||
temp_buf_free (temp_buf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -857,6 +871,20 @@ gimp_preview_size_allocate (GtkWidget *widget,
|
|||
gimp_preview_paint (GIMP_PREVIEW (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
if (preview->size != -1)
|
||||
{
|
||||
g_print ("size_changed (%d)\n", preview->size);
|
||||
|
||||
gimp_preview_set_size (preview,
|
||||
preview->size,
|
||||
preview->border_width);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_paint (GimpPreview *preview)
|
||||
{
|
||||
|
@ -885,34 +913,50 @@ gimp_preview_idle_paint (GimpPreview *preview)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_preview_calc_size (gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up)
|
||||
gimp_preview_calc_size (GimpPreview *preview,
|
||||
gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up)
|
||||
{
|
||||
gdouble ratio;
|
||||
gdouble xratio;
|
||||
gdouble yratio;
|
||||
|
||||
if (aspect_width > aspect_height)
|
||||
{
|
||||
ratio = (gdouble) width / (gdouble) aspect_width;
|
||||
xratio = yratio = (gdouble) width / (gdouble) aspect_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
ratio = (gdouble) height / (gdouble) aspect_height;
|
||||
xratio = yratio = (gdouble) height / (gdouble) aspect_height;
|
||||
}
|
||||
|
||||
width = RINT (ratio * (gdouble) aspect_width);
|
||||
height = RINT (ratio * (gdouble) aspect_height);
|
||||
if (! preview->dot_for_dot && xresolution != yresolution)
|
||||
{
|
||||
if (xresolution < yresolution)
|
||||
{
|
||||
yratio *= xresolution / yresolution;
|
||||
}
|
||||
else
|
||||
{
|
||||
yratio *= yresolution / xresolution;
|
||||
}
|
||||
}
|
||||
|
||||
width = RINT (xratio * (gdouble) aspect_width);
|
||||
height = RINT (yratio * (gdouble) aspect_height);
|
||||
|
||||
if (width < 1) width = 1;
|
||||
if (height < 1) height = 1;
|
||||
|
||||
*return_width = width;
|
||||
*return_height = height;
|
||||
*scaling_up = (ratio > 1.0);
|
||||
*scaling_up = (xratio > 1.0) || (yratio > 1.0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -49,6 +49,7 @@ struct _GimpPreview
|
|||
gint width;
|
||||
gint height;
|
||||
gint border_width;
|
||||
gboolean dot_for_dot;
|
||||
|
||||
GimpRGB border_color;
|
||||
|
||||
|
@ -57,6 +58,7 @@ struct _GimpPreview
|
|||
gboolean show_popup;
|
||||
|
||||
/*< private >*/
|
||||
gint size;
|
||||
gboolean in_button;
|
||||
guint press_state;
|
||||
guint idle_id;
|
||||
|
@ -108,6 +110,9 @@ void gimp_preview_set_size_full (GimpPreview *preview,
|
|||
gint height,
|
||||
gint border_width);
|
||||
|
||||
void gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
||||
gboolean dot_for_dot);
|
||||
|
||||
void gimp_preview_set_border_color (GimpPreview *preview,
|
||||
const GimpRGB *border_color);
|
||||
|
||||
|
@ -116,10 +121,13 @@ void gimp_preview_render (GimpPreview *preview);
|
|||
|
||||
/* protected */
|
||||
|
||||
void gimp_preview_calc_size (gint aspect_width,
|
||||
void gimp_preview_calc_size (GimpPreview *preview,
|
||||
gint aspect_width,
|
||||
gint aspect_height,
|
||||
gint width,
|
||||
gint height,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
gint *return_width,
|
||||
gint *return_height,
|
||||
gboolean *scaling_up);
|
||||
|
|
|
@ -106,24 +106,30 @@ gimp_drawable_preview_get_size (GimpPreview *preview,
|
|||
gboolean scaling_up;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = drawable->gimage;
|
||||
gimage = gimp_drawable_gimage (drawable);
|
||||
|
||||
if (gimage)
|
||||
{
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
size,
|
||||
size,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
width,
|
||||
height,
|
||||
&scaling_up);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
size,
|
||||
size,
|
||||
1.0,
|
||||
1.0,
|
||||
width,
|
||||
height,
|
||||
&scaling_up);
|
||||
|
@ -143,7 +149,7 @@ gimp_drawable_preview_render (GimpPreview *preview)
|
|||
TempBuf *render_buf;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = drawable->gimage;
|
||||
gimage = gimp_drawable_gimage (drawable);
|
||||
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
|
@ -155,20 +161,26 @@ gimp_drawable_preview_render (GimpPreview *preview)
|
|||
height = MAX (1, ROUND ((((gdouble) height / (gdouble) gimage->height) *
|
||||
(gdouble) drawable->height)));
|
||||
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
width,
|
||||
height,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&preview_width,
|
||||
&preview_height,
|
||||
&scaling_up);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
width,
|
||||
height,
|
||||
gimage ? gimage->xresolution : 1.0,
|
||||
gimage ? gimage->yresolution : 1.0,
|
||||
&preview_width,
|
||||
&preview_height,
|
||||
&scaling_up);
|
||||
|
@ -252,16 +264,21 @@ static GtkWidget *
|
|||
gimp_drawable_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
GimpImage *gimage;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean scaling_up;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = gimp_drawable_gimage (drawable);
|
||||
|
||||
gimp_preview_calc_size (drawable->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
MIN (preview->width * 2, 256),
|
||||
MIN (preview->height * 2, 256),
|
||||
gimage ? gimage->xresolution : 1.0,
|
||||
gimage ? gimage->yresolution : 1.0,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
|
|
@ -104,10 +104,13 @@ gimp_image_preview_get_size (GimpPreview *preview,
|
|||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
size,
|
||||
size,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
width,
|
||||
height,
|
||||
&scaling_up);
|
||||
|
@ -129,10 +132,13 @@ gimp_image_preview_render (GimpPreview *preview)
|
|||
width = preview->width;
|
||||
height = preview->height;
|
||||
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
width,
|
||||
height,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&preview_width,
|
||||
&preview_height,
|
||||
&scaling_up);
|
||||
|
@ -203,10 +209,13 @@ gimp_image_preview_create_popup (GimpPreview *preview)
|
|||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
gimp_preview_calc_size (gimage->width,
|
||||
gimp_preview_calc_size (preview,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
MIN (preview->width * 2, 256),
|
||||
MIN (preview->height * 2, 256),
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
|
|
@ -110,6 +110,7 @@ typedef struct _GimpPreview GimpPreview;
|
|||
typedef struct _GimpImagePreview GimpImagePreview;
|
||||
typedef struct _GimpDrawablePreview GimpDrawablePreview;
|
||||
typedef struct _GimpBrushPreview GimpBrushPreview;
|
||||
typedef struct _GimpNavigationPreview GimpNavigationPreview;
|
||||
typedef struct _GimpPatternPreview GimpPatternPreview;
|
||||
typedef struct _GimpPalettePreview GimpPalettePreview;
|
||||
typedef struct _GimpGradientPreview GimpGradientPreview;
|
||||
|
|
Loading…
Reference in New Issue