added VOID__DOUBLE_DOUBLE marshaller.
* libgimpwidgets/gimpwidgetsmarshal.list: added VOID__DOUBLE_DOUBLE marshaller. * libgimpwidgets/gimpzoommodel.[ch]: new signal: "zoomed", emitted when the zoom factor changes. This signal have the old factor and the new factor as argument. * libgimp/gimpzoompreview.c: use the "zoomed" signal instead of the "notify::value" one. This allow to use the old and new factors to keep the preview centered on the same point.
This commit is contained in:
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
2005-10-01 DindinX <dindinx@gimp.org>
|
||||||
|
|
||||||
|
* libgimpwidgets/gimpwidgetsmarshal.list: added VOID__DOUBLE_DOUBLE
|
||||||
|
marshaller.
|
||||||
|
|
||||||
|
* libgimpwidgets/gimpzoommodel.[ch]: new signal: "zoomed", emitted
|
||||||
|
when the zoom factor changes. This signal have the old factor and the
|
||||||
|
new factor as argument.
|
||||||
|
|
||||||
|
* libgimp/gimpzoompreview.c: use the "zoomed" signal instead of the
|
||||||
|
"notify::value" one. This allow to use the old and new factors to keep
|
||||||
|
the preview centered on the same point.
|
||||||
|
|
||||||
2005-10-01 DindinX <dindinx@gimp.org>
|
2005-10-01 DindinX <dindinx@gimp.org>
|
||||||
|
|
||||||
* libgimp/gimpzoompreview.c: call gtk_adjustment_value_changed in
|
* libgimp/gimpzoompreview.c: call gtk_adjustment_value_changed in
|
||||||
|
@ -23,6 +23,15 @@ GimpZoomModel
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### SIGNAL GimpZoomModel::zoomed ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@gimpzoommodel: the object which received the signal.
|
||||||
|
@arg1:
|
||||||
|
@arg2:
|
||||||
|
|
||||||
<!-- ##### ARG GimpZoomModel:fraction ##### -->
|
<!-- ##### ARG GimpZoomModel:fraction ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
|
@ -47,25 +47,27 @@ struct _GimpZoomPreviewPrivate
|
|||||||
|
|
||||||
#define GIMP_ZOOM_PREVIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIMP_TYPE_ZOOM_PREVIEW, GimpZoomPreviewPrivate))
|
#define GIMP_ZOOM_PREVIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIMP_TYPE_ZOOM_PREVIEW, GimpZoomPreviewPrivate))
|
||||||
|
|
||||||
static void gimp_zoom_preview_set_adjustments (GimpZoomPreview *preview);
|
static void gimp_zoom_preview_set_adjustments (GimpZoomPreview *preview,
|
||||||
static void gimp_zoom_preview_size_allocate (GtkWidget *widget,
|
gdouble old_factor,
|
||||||
GtkAllocation *allocation,
|
gdouble new_factor);
|
||||||
GimpZoomPreview *preview);
|
static void gimp_zoom_preview_size_allocate (GtkWidget *widget,
|
||||||
static void gimp_zoom_preview_style_set (GtkWidget *widget,
|
GtkAllocation *allocation,
|
||||||
GtkStyle *prev_style);
|
GimpZoomPreview *preview);
|
||||||
static void gimp_zoom_preview_draw (GimpPreview *preview);
|
static void gimp_zoom_preview_style_set (GtkWidget *widget,
|
||||||
static void gimp_zoom_preview_draw_buffer (GimpPreview *preview,
|
GtkStyle *prev_style);
|
||||||
const guchar *buffer,
|
static void gimp_zoom_preview_draw (GimpPreview *preview);
|
||||||
gint rowstride);
|
static void gimp_zoom_preview_draw_buffer (GimpPreview *preview,
|
||||||
static void gimp_zoom_preview_draw_thumb (GimpPreview *preview,
|
const guchar *buffer,
|
||||||
GimpPreviewArea *area,
|
gint rowstride);
|
||||||
gint width,
|
static void gimp_zoom_preview_draw_thumb (GimpPreview *preview,
|
||||||
gint height);
|
GimpPreviewArea *area,
|
||||||
static gboolean gimp_zoom_preview_get_bounds (GimpDrawable *drawable,
|
gint width,
|
||||||
gint *xmin,
|
gint height);
|
||||||
gint *ymin,
|
static gboolean gimp_zoom_preview_get_bounds (GimpDrawable *drawable,
|
||||||
gint *xmax,
|
gint *xmin,
|
||||||
gint *ymax);
|
gint *ymin,
|
||||||
|
gint *xmax,
|
||||||
|
gint *ymax);
|
||||||
|
|
||||||
G_DEFINE_TYPE (GimpZoomPreview, gimp_zoom_preview,
|
G_DEFINE_TYPE (GimpZoomPreview, gimp_zoom_preview,
|
||||||
GIMP_TYPE_SCROLLED_PREVIEW)
|
GIMP_TYPE_SCROLLED_PREVIEW)
|
||||||
@ -99,7 +101,7 @@ gimp_zoom_preview_init (GimpZoomPreview *preview)
|
|||||||
|
|
||||||
priv->zoom = gimp_zoom_model_new ();
|
priv->zoom = gimp_zoom_model_new ();
|
||||||
gimp_zoom_model_set_range (GIMP_ZOOM_MODEL (priv->zoom), 1.0, 256.0);
|
gimp_zoom_model_set_range (GIMP_ZOOM_MODEL (priv->zoom), 1.0, 256.0);
|
||||||
g_signal_connect_swapped (priv->zoom, "notify::value",
|
g_signal_connect_swapped (priv->zoom, "zoomed",
|
||||||
G_CALLBACK (gimp_zoom_preview_set_adjustments),
|
G_CALLBACK (gimp_zoom_preview_set_adjustments),
|
||||||
preview);
|
preview);
|
||||||
|
|
||||||
@ -148,37 +150,41 @@ gimp_zoom_preview_init (GimpZoomPreview *preview)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_zoom_preview_set_adjustments (GimpZoomPreview *preview)
|
gimp_zoom_preview_set_adjustments (GimpZoomPreview *preview,
|
||||||
|
gdouble old_factor,
|
||||||
|
gdouble new_factor)
|
||||||
{
|
{
|
||||||
GimpScrolledPreview *scrolled_preview;
|
GimpScrolledPreview *scrolled_preview = GIMP_SCROLLED_PREVIEW (preview);
|
||||||
GtkAdjustment *adj;
|
GtkAdjustment *adj;
|
||||||
gdouble zoom_factor;
|
gdouble width;
|
||||||
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
|
gdouble height;
|
||||||
|
gdouble ratio;
|
||||||
|
|
||||||
scrolled_preview = GIMP_SCROLLED_PREVIEW (preview);
|
width = GIMP_PREVIEW (preview)->width;
|
||||||
zoom_factor = gimp_zoom_model_get_factor (priv->zoom);
|
height = GIMP_PREVIEW (preview)->height;
|
||||||
|
ratio = new_factor / old_factor;
|
||||||
|
|
||||||
adj = gtk_range_get_adjustment (GTK_RANGE (scrolled_preview->hscr));
|
adj = gtk_range_get_adjustment (GTK_RANGE (scrolled_preview->hscr));
|
||||||
adj->lower = 0;
|
adj->lower = 0;
|
||||||
adj->page_size = GIMP_PREVIEW (preview)->width;
|
adj->page_size = width;
|
||||||
adj->upper = GIMP_PREVIEW (preview)->width * zoom_factor;
|
adj->upper = width * new_factor;
|
||||||
adj->step_increment = 1.0;
|
adj->step_increment = new_factor;
|
||||||
adj->page_increment = MAX (adj->page_size / 2.0, adj->step_increment);
|
adj->page_increment = MAX (width / 2.0, adj->step_increment);
|
||||||
adj->value = CLAMP (adj->value,
|
adj->value = CLAMP ((adj->value + width / 2.0) * ratio - width / 2.0,
|
||||||
adj->lower,
|
adj->lower,
|
||||||
adj->upper - adj->page_size);
|
adj->upper - width);
|
||||||
gtk_adjustment_changed (adj);
|
gtk_adjustment_changed (adj);
|
||||||
gtk_adjustment_value_changed (adj);
|
gtk_adjustment_value_changed (adj);
|
||||||
|
|
||||||
adj = gtk_range_get_adjustment (GTK_RANGE (scrolled_preview->vscr));
|
adj = gtk_range_get_adjustment (GTK_RANGE (scrolled_preview->vscr));
|
||||||
adj->lower = 0;
|
adj->lower = 0;
|
||||||
adj->page_size = GIMP_PREVIEW (preview)->height;
|
adj->page_size = height;
|
||||||
adj->upper = GIMP_PREVIEW (preview)->height * zoom_factor;
|
adj->upper = height * new_factor;
|
||||||
adj->step_increment = 1.0;
|
adj->step_increment = new_factor;
|
||||||
adj->page_increment = MAX (adj->page_size / 2.0, adj->step_increment);
|
adj->page_increment = MAX (height / 2.0, adj->step_increment);
|
||||||
adj->value = CLAMP (adj->value,
|
adj->value = CLAMP ((adj->value + height / 2.0) *ratio - height / 2.0,
|
||||||
adj->lower,
|
adj->lower,
|
||||||
adj->upper - adj->page_size);
|
adj->upper - height);
|
||||||
gtk_adjustment_changed (adj);
|
gtk_adjustment_changed (adj);
|
||||||
gtk_adjustment_value_changed (adj);
|
gtk_adjustment_value_changed (adj);
|
||||||
|
|
||||||
@ -190,13 +196,16 @@ gimp_zoom_preview_size_allocate (GtkWidget *widget,
|
|||||||
GtkAllocation *allocation,
|
GtkAllocation *allocation,
|
||||||
GimpZoomPreview *preview)
|
GimpZoomPreview *preview)
|
||||||
{
|
{
|
||||||
|
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
|
||||||
|
gdouble zoom_factor;
|
||||||
gint width = GIMP_PREVIEW (preview)->xmax - GIMP_PREVIEW (preview)->xmin;
|
gint width = GIMP_PREVIEW (preview)->xmax - GIMP_PREVIEW (preview)->xmin;
|
||||||
gint height = GIMP_PREVIEW (preview)->ymax - GIMP_PREVIEW (preview)->ymin;
|
gint height = GIMP_PREVIEW (preview)->ymax - GIMP_PREVIEW (preview)->ymin;
|
||||||
|
|
||||||
GIMP_PREVIEW (preview)->width = MIN (width, allocation->width);
|
GIMP_PREVIEW (preview)->width = MIN (width, allocation->width);
|
||||||
GIMP_PREVIEW (preview)->height = MIN (height, allocation->height);
|
GIMP_PREVIEW (preview)->height = MIN (height, allocation->height);
|
||||||
|
|
||||||
gimp_zoom_preview_set_adjustments (preview);
|
zoom_factor = gimp_zoom_model_get_factor (priv->zoom);
|
||||||
|
gimp_zoom_preview_set_adjustments (preview, zoom_factor, zoom_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -483,7 +492,7 @@ gimp_zoom_preview_new (GimpDrawable *drawable)
|
|||||||
"ratio", (gdouble) width / (gdouble) height,
|
"ratio", (gdouble) width / (gdouble) height,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gimp_zoom_preview_set_adjustments (preview);
|
gimp_zoom_preview_set_adjustments (preview, 1.0, 1.0);
|
||||||
|
|
||||||
return GTK_WIDGET (preview);
|
return GTK_WIDGET (preview);
|
||||||
}
|
}
|
||||||
|
@ -29,5 +29,6 @@ VOID: OBJECT, INT
|
|||||||
VOID: POINTER, POINTER
|
VOID: POINTER, POINTER
|
||||||
VOID: STRING, FLAGS
|
VOID: STRING, FLAGS
|
||||||
VOID: STRING, INT
|
VOID: STRING, INT
|
||||||
|
VOID: DOUBLE, DOUBLE
|
||||||
|
|
||||||
BOOLEAN: POINTER
|
BOOLEAN: POINTER
|
||||||
|
@ -30,12 +30,19 @@
|
|||||||
#include "libgimpmath/gimpmath.h"
|
#include "libgimpmath/gimpmath.h"
|
||||||
|
|
||||||
#include "gimphelpui.h"
|
#include "gimphelpui.h"
|
||||||
|
#include "gimpwidgetsmarshal.h"
|
||||||
#include "gimpzoommodel.h"
|
#include "gimpzoommodel.h"
|
||||||
|
|
||||||
|
|
||||||
#define ZOOM_MIN (1.0 / 256.0)
|
#define ZOOM_MIN (1.0 / 256.0)
|
||||||
#define ZOOM_MAX (256.0)
|
#define ZOOM_MAX (256.0)
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ZOOMED,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@ -66,15 +73,34 @@ static void gimp_zoom_model_get_property (GObject *object,
|
|||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
|
|
||||||
|
static guint zoom_model_signals[LAST_SIGNAL] = { 0, };
|
||||||
|
|
||||||
G_DEFINE_TYPE (GimpZoomModel, gimp_zoom_model, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (GimpZoomModel, gimp_zoom_model, G_TYPE_OBJECT);
|
||||||
#define parent_class gimp_zoom_model_parent_class
|
#define parent_class gimp_zoom_model_parent_class
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_zoom_model_class_init (GimpZoomModelClass *klass)
|
gimp_zoom_model_class_init (GimpZoomModelClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
/**
|
||||||
|
* GimpZoomModel::zoomed:
|
||||||
|
* @model: the object that received the signal
|
||||||
|
* @old_factor: the zoom factor before it changes
|
||||||
|
* @new_factor: the zoom factor after it has changed.
|
||||||
|
*
|
||||||
|
* Emitted the zoom factor of the zoom model changes.
|
||||||
|
*/
|
||||||
|
zoom_model_signals[ZOOMED] =
|
||||||
|
g_signal_new ("zoomed",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (GimpZoomModelClass,
|
||||||
|
zoomed),
|
||||||
|
NULL, NULL,
|
||||||
|
_gimp_widgets_marshal_VOID__DOUBLE_DOUBLE,
|
||||||
|
G_TYPE_NONE, 2,
|
||||||
|
G_TYPE_DOUBLE, G_TYPE_DOUBLE);
|
||||||
|
|
||||||
object_class->set_property = gimp_zoom_model_set_property;
|
object_class->set_property = gimp_zoom_model_set_property;
|
||||||
object_class->get_property = gimp_zoom_model_get_property;
|
object_class->get_property = gimp_zoom_model_get_property;
|
||||||
@ -129,7 +155,9 @@ gimp_zoom_model_set_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
GimpZoomModelPrivate *priv = GIMP_ZOOM_MODEL_GET_PRIVATE (object);
|
GimpZoomModelPrivate *priv = GIMP_ZOOM_MODEL_GET_PRIVATE (object);
|
||||||
|
gdouble previous_value;
|
||||||
|
|
||||||
|
previous_value = priv->value;
|
||||||
g_object_freeze_notify (object);
|
g_object_freeze_notify (object);
|
||||||
|
|
||||||
switch (property_id)
|
switch (property_id)
|
||||||
@ -137,6 +165,7 @@ gimp_zoom_model_set_property (GObject *object,
|
|||||||
case PROP_VALUE:
|
case PROP_VALUE:
|
||||||
priv->value = g_value_get_double (value);
|
priv->value = g_value_get_double (value);
|
||||||
|
|
||||||
|
g_object_notify (object, "value");
|
||||||
g_object_notify (object, "fraction");
|
g_object_notify (object, "fraction");
|
||||||
g_object_notify (object, "percentage");
|
g_object_notify (object, "percentage");
|
||||||
break;
|
break;
|
||||||
@ -164,6 +193,11 @@ gimp_zoom_model_set_property (GObject *object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_object_thaw_notify (object);
|
g_object_thaw_notify (object);
|
||||||
|
if (priv->value != previous_value)
|
||||||
|
{
|
||||||
|
g_signal_emit (object, zoom_model_signals[ZOOMED],
|
||||||
|
0, previous_value, priv->value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -45,6 +45,10 @@ struct _GimpZoomModelClass
|
|||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
void (* zoomed) (GimpZoomModel *model,
|
||||||
|
gdouble old_factor,
|
||||||
|
gdouble new_factor);
|
||||||
|
|
||||||
/* Padding for future expansion */
|
/* Padding for future expansion */
|
||||||
void (* _gimp_reserved1) (void);
|
void (* _gimp_reserved1) (void);
|
||||||
void (* _gimp_reserved2) (void);
|
void (* _gimp_reserved2) (void);
|
||||||
|
Reference in New Issue
Block a user