gimp r28199 - in trunk: . libgimpwidgets
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r28199 - in trunk: . libgimpwidgets
- Date: Sun, 22 Mar 2009 20:46:49 +0000 (UTC)
Author: mitch
Date: Sun Mar 22 20:46:48 2009
New Revision: 28199
URL: http://svn.gnome.org/viewvc/gimp?rev=28199&view=rev
Log:
2009-03-22 Michael Natterer <mitch gimp org>
* libgimpwidgets/gimpscrolledpreview.c: use GtkAdjustment's
accessors.
Modified:
trunk/ChangeLog
trunk/libgimpwidgets/gimpscrolledpreview.c
Modified: trunk/libgimpwidgets/gimpscrolledpreview.c
==============================================================================
--- trunk/libgimpwidgets/gimpscrolledpreview.c (original)
+++ trunk/libgimpwidgets/gimpscrolledpreview.c Sun Mar 22 20:46:48 2009
@@ -262,15 +262,12 @@
width = GIMP_PREVIEW (preview)->xmax - GIMP_PREVIEW (preview)->xmin;
- adj->lower = 0;
- adj->upper = width;
- adj->page_size = GIMP_PREVIEW (preview)->width;
- adj->step_increment = 1.0;
- adj->page_increment = MAX (adj->page_size / 2.0, adj->step_increment);
- adj->value = CLAMP (adj->value,
- adj->lower, adj->upper - adj->page_size);
-
- gtk_adjustment_changed (adj);
+ gtk_adjustment_configure (adj,
+ gtk_adjustment_get_value (adj),
+ 0, width,
+ 1.0,
+ MAX (GIMP_PREVIEW (preview)->width / 2.0, 1.0),
+ GIMP_PREVIEW (preview)->width);
}
static void
@@ -281,15 +278,12 @@
height = GIMP_PREVIEW (preview)->ymax - GIMP_PREVIEW (preview)->ymin;
- adj->lower = 0;
- adj->upper = height;
- adj->page_size = GIMP_PREVIEW (preview)->height;
- adj->step_increment = 1.0;
- adj->page_increment = MAX (adj->page_size / 2.0, adj->step_increment);
- adj->value = CLAMP (adj->value,
- adj->lower, adj->upper - adj->page_size);
-
- gtk_adjustment_changed (adj);
+ gtk_adjustment_configure (adj,
+ gtk_adjustment_get_value (adj),
+ 0, height,
+ 1.0,
+ MAX (GIMP_PREVIEW (preview)->height / 2.0, 1.0),
+ GIMP_PREVIEW (preview)->height);
}
static void
@@ -432,8 +426,14 @@
x = priv->drag_xoff - (x - priv->drag_x);
y = priv->drag_yoff - (y - priv->drag_y);
- x = CLAMP (x, hadj->lower, hadj->upper - hadj->page_size);
- y = CLAMP (y, vadj->lower, vadj->upper - vadj->page_size);
+ x = CLAMP (x,
+ gtk_adjustment_get_lower (hadj),
+ gtk_adjustment_get_upper (hadj) -
+ gtk_adjustment_get_page_size (hadj));
+ y = CLAMP (y,
+ gtk_adjustment_get_lower (vadj),
+ gtk_adjustment_get_upper (vadj) -
+ gtk_adjustment_get_page_size (vadj));
if (GIMP_PREVIEW (preview)->xoff != x ||
GIMP_PREVIEW (preview)->yoff != y)
@@ -489,18 +489,20 @@
{
case GDK_SCROLL_UP:
case GDK_SCROLL_LEFT:
- value -= adj->page_increment / 2;
+ value -= gtk_adjustment_get_page_increment (adj) / 2;
break;
case GDK_SCROLL_DOWN:
case GDK_SCROLL_RIGHT:
- value += adj->page_increment / 2;
+ value += gtk_adjustment_get_page_increment (adj) / 2;
break;
}
- gtk_adjustment_set_value (adj, CLAMP (value,
- adj->lower,
- adj->upper - adj->page_size));
+ gtk_adjustment_set_value (adj,
+ CLAMP (value,
+ gtk_adjustment_get_lower (adj),
+ gtk_adjustment_get_upper (adj) -
+ gtk_adjustment_get_page_size (adj)));
}
break;
@@ -517,7 +519,7 @@
{
GimpScrolledPreviewPrivate *priv = GIMP_SCROLLED_PREVIEW_GET_PRIVATE (preview);
- preview->xoff = hadj->value;
+ preview->xoff = gtk_adjustment_get_value (hadj);
gimp_preview_area_set_offsets (GIMP_PREVIEW_AREA (preview->area),
preview->xoff, preview->yoff);
@@ -535,7 +537,7 @@
{
GimpScrolledPreviewPrivate *priv = GIMP_SCROLLED_PREVIEW_GET_PRIVATE (preview);
- preview->yoff = vadj->value;
+ preview->yoff = gtk_adjustment_get_value (vadj);
gimp_preview_area_set_offsets (GIMP_PREVIEW_AREA (preview->area),
preview->xoff, preview->yoff);
@@ -606,10 +608,16 @@
gdk_window_get_origin (gtk_widget_get_window (widget), &x, &y);
adj = gtk_range_get_adjustment (GTK_RANGE (preview->hscr));
- h = (adj->value / adj->upper) + (adj->page_size / adj->upper) / 2.0;
+ h = ((gtk_adjustment_get_value (adj) /
+ gtk_adjustment_get_upper (adj)) +
+ (gtk_adjustment_get_page_size (adj) /
+ gtk_adjustment_get_upper (adj)) / 2.0);
adj = gtk_range_get_adjustment (GTK_RANGE (preview->vscr));
- v = (adj->value / adj->upper) + (adj->page_size / adj->upper) / 2.0;
+ v = ((gtk_adjustment_get_value (adj) /
+ gtk_adjustment_get_upper (adj)) +
+ (gtk_adjustment_get_page_size (adj) /
+ gtk_adjustment_get_upper (adj)) / 2.0);
x += event->x - h * (gdouble) GIMP_PREVIEW_AREA (area)->width;
y += event->y - v * (gdouble) GIMP_PREVIEW_AREA (area)->height;
@@ -674,18 +682,26 @@
gtk_widget_get_pointer (widget, &cx, &cy);
- x = cx * (hadj->upper - hadj->lower) / widget->allocation.width;
- y = cy * (vadj->upper - vadj->lower) / widget->allocation.height;
-
- x += hadj->lower - hadj->page_size / 2;
- y += vadj->lower - vadj->page_size / 2;
-
- gtk_adjustment_set_value (hadj, CLAMP (x,
- hadj->lower,
- hadj->upper - hadj->page_size));
- gtk_adjustment_set_value (vadj, CLAMP (y,
- vadj->lower,
- vadj->upper - vadj->page_size));
+ x = cx * (gtk_adjustment_get_upper (hadj) -
+ gtk_adjustment_get_lower (hadj)) / widget->allocation.width;
+ y = cy * (gtk_adjustment_get_upper (vadj) -
+ gtk_adjustment_get_lower (vadj)) / widget->allocation.height;
+
+ x += (gtk_adjustment_get_lower (hadj) -
+ gtk_adjustment_get_page_size (hadj) / 2);
+ y += (gtk_adjustment_get_lower (vadj) -
+ gtk_adjustment_get_page_size (vadj) / 2);
+
+ gtk_adjustment_set_value (hadj,
+ CLAMP (x,
+ gtk_adjustment_get_lower (hadj),
+ gtk_adjustment_get_upper (hadj) -
+ gtk_adjustment_get_page_size (hadj)));
+ gtk_adjustment_set_value (vadj,
+ CLAMP (y,
+ gtk_adjustment_get_lower (vadj),
+ gtk_adjustment_get_upper (vadj) -
+ gtk_adjustment_get_page_size (vadj)));
gtk_widget_queue_draw (widget);
gdk_window_process_updates (gtk_widget_get_window (widget), FALSE);
@@ -713,13 +729,21 @@
adj = gtk_range_get_adjustment (GTK_RANGE (preview->hscr));
- x = adj->value / (adj->upper - adj->lower);
- w = adj->page_size / (adj->upper - adj->lower);
+ x = (gtk_adjustment_get_value (adj) /
+ (gtk_adjustment_get_upper (adj) -
+ gtk_adjustment_get_lower (adj)));
+ w = (gtk_adjustment_get_page_size (adj) /
+ (gtk_adjustment_get_upper (adj) -
+ gtk_adjustment_get_lower (adj)));
adj = gtk_range_get_adjustment (GTK_RANGE (preview->vscr));
- y = adj->value / (adj->upper - adj->lower);
- h = adj->page_size / (adj->upper - adj->lower);
+ y = (gtk_adjustment_get_value (adj) /
+ (gtk_adjustment_get_upper (adj) -
+ gtk_adjustment_get_lower (adj)));
+ h = (gtk_adjustment_get_page_size (adj) /
+ (gtk_adjustment_get_upper (adj) -
+ gtk_adjustment_get_lower (adj)));
if (w >= 1.0 && h >= 1.0)
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]