gimp r26166 - in trunk: . app/display
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26166 - in trunk: . app/display
- Date: Sat, 12 Jul 2008 14:48:10 +0000 (UTC)
Author: martinn
Date: Sat Jul 12 14:48:09 2008
New Revision: 26166
URL: http://svn.gnome.org/viewvc/gimp?rev=26166&view=rev
Log:
2008-07-12 Martin Nordholts <martinn svn gnome org>
The following change is conceptually based on a patch by
Alexia Death and implements the core functionality for
bug #362915.
* app/display/gimpdisplayshell-scroll.[ch]
(gimp_display_shell_scroll_clamp_offsets): Clamp the offsets in
such a way that allows to scroll beyond the image border.
(gimp_display_shell_setup_hscrollbar_with_value)
(gimp_display_shell_setup_vscrollbar_with_value): Put common
scrollbar range setup code here.
* app/display/gimpdisplayshell-scale.c
(gimp_display_shell_scale_setup): Use above helper functions for
setting up scrollbar range.
* app/display/gimpdisplayshell-callbacks.c: Handle adjustment of
the scrollbar range when they are about to change value.
* app/display/gimpdisplayshell.c: Always keep the scrollbar
steppers sensitive to user input.
Modified:
trunk/ChangeLog
trunk/app/display/gimpdisplayshell-callbacks.c
trunk/app/display/gimpdisplayshell-scale.c
trunk/app/display/gimpdisplayshell-scroll.c
trunk/app/display/gimpdisplayshell-scroll.h
trunk/app/display/gimpdisplayshell.c
Modified: trunk/app/display/gimpdisplayshell-callbacks.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-callbacks.c (original)
+++ trunk/app/display/gimpdisplayshell-callbacks.c Sat Jul 12 14:48:09 2008
@@ -85,7 +85,15 @@
GimpDisplayShell *shell);
static void gimp_display_shell_hscrollbar_update (GtkAdjustment *adjustment,
GimpDisplayShell *shell);
+static gboolean gimp_display_shell_vscrollbar_update_range (GtkRange *range,
+ GtkScrollType scroll,
+ gdouble value,
+ GimpDisplayShell *shell);
+static gboolean gimp_display_shell_hscrollbar_update_range (GtkRange *range,
+ GtkScrollType scroll,
+ gdouble value,
+ GimpDisplayShell *shell);
static GdkModifierType
gimp_display_shell_key_to_state (gint key);
@@ -239,6 +247,14 @@
G_CALLBACK (gimp_display_shell_vscrollbar_update),
shell);
+ g_signal_connect (shell->hsb, "change-value",
+ G_CALLBACK (gimp_display_shell_hscrollbar_update_range),
+ shell);
+
+ g_signal_connect (shell->vsb, "change-value",
+ G_CALLBACK (gimp_display_shell_vscrollbar_update_range),
+ shell);
+
/* allow shrinking */
gtk_widget_set_size_request (GTK_WIDGET (shell), 0, 0);
@@ -324,6 +340,52 @@
}
}
+gboolean
+gimp_display_shell_hscrollbar_update_range (GtkRange *range,
+ GtkScrollType scroll,
+ gdouble value,
+ GimpDisplayShell *shell)
+{
+ g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), TRUE);
+
+ if (! shell->display)
+ return TRUE;
+
+ if ((scroll == GTK_SCROLL_JUMP) ||
+ (scroll == GTK_SCROLL_PAGE_BACKWARD) ||
+ (scroll == GTK_SCROLL_PAGE_FORWARD))
+ return FALSE;
+
+ gimp_display_shell_setup_hscrollbar_with_value (shell, value);
+
+ gtk_adjustment_changed (shell->hsbdata);
+
+ return FALSE;
+}
+
+gboolean
+gimp_display_shell_vscrollbar_update_range (GtkRange *range,
+ GtkScrollType scroll,
+ gdouble value,
+ GimpDisplayShell *shell)
+{
+ g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), TRUE);
+
+ if (! shell->display)
+ return TRUE;
+
+ if ((scroll == GTK_SCROLL_JUMP) ||
+ (scroll == GTK_SCROLL_PAGE_BACKWARD) ||
+ (scroll == GTK_SCROLL_PAGE_FORWARD))
+ return FALSE;
+
+ gimp_display_shell_setup_vscrollbar_with_value (shell, value);
+
+ gtk_adjustment_changed (shell->vsbdata);
+
+ return FALSE;
+}
+
static void
gimp_display_shell_check_device_cursor (GimpDisplayShell *shell)
{
Modified: trunk/app/display/gimpdisplayshell-scale.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.c (original)
+++ trunk/app/display/gimpdisplayshell-scale.c Sat Jul 12 14:48:09 2008
@@ -117,21 +117,31 @@
sh = image_height;
}
+
+ /* Horizontal scrollbar */
+
shell->hsbdata->value = shell->offset_x;
- shell->hsbdata->upper = sw;
- shell->hsbdata->page_size = MIN (sw, shell->disp_width);
+ shell->hsbdata->page_size = shell->disp_width;
shell->hsbdata->page_increment = shell->disp_width / 2;
shell->hsbdata->step_increment = shell->scale_x;
+ gimp_display_shell_setup_hscrollbar_with_value (shell, shell->offset_x);
+
+ gtk_adjustment_changed (shell->hsbdata);
+
+
+ /* Vertcal scrollbar */
+
shell->vsbdata->value = shell->offset_y;
- shell->vsbdata->upper = sh;
- shell->vsbdata->page_size = MIN (sh, shell->disp_height);
+ shell->vsbdata->page_size = shell->disp_height;
shell->vsbdata->page_increment = shell->disp_height / 2;
shell->vsbdata->step_increment = shell->scale_y;
- gtk_adjustment_changed (shell->hsbdata);
+ gimp_display_shell_setup_vscrollbar_with_value (shell, shell->offset_y);
+
gtk_adjustment_changed (shell->vsbdata);
+
/* Setup rulers */
{
gdouble horizontal_lower;
Modified: trunk/app/display/gimpdisplayshell-scroll.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scroll.c (original)
+++ trunk/app/display/gimpdisplayshell-scroll.c Sat Jul 12 14:48:09 2008
@@ -36,6 +36,9 @@
#include "gimpdisplayshell-scroll.h"
+#define OVERPAN_FACTOR 0.5
+
+
/**
* gimp_display_shell_center_around_image_coordinate:
* @shell:
@@ -122,33 +125,46 @@
if (shell->display->image)
{
gint sw, sh;
+ gint min_offset_x;
+ gint max_offset_x;
+ gint min_offset_y;
+ gint max_offset_y;
sw = SCALEX (shell, gimp_image_get_width (shell->display->image));
sh = SCALEY (shell, gimp_image_get_height (shell->display->image));
- if (shell->disp_width > sw)
+ if (shell->disp_width < sw)
{
- shell->offset_x = -(shell->disp_width - sw) / 2;
+ min_offset_x = 0 - shell->disp_width * OVERPAN_FACTOR;
+ max_offset_x = sw - shell->disp_width * (1.0 - OVERPAN_FACTOR);
}
else
{
- gint min_offset_x = 0;
- gint max_offset_x = sw - shell->disp_width;
+ gint overpan_amount;
+
+ overpan_amount = shell->disp_width - sw * (1.0 - OVERPAN_FACTOR);
- shell->offset_x = CLAMP (shell->offset_x, min_offset_x, max_offset_x);
+ min_offset_x = 0 - overpan_amount;
+ max_offset_x = sw + overpan_amount - shell->disp_width;
}
- if (shell->disp_height > sh)
+ if (shell->disp_height < sh)
{
- shell->offset_y = -(shell->disp_height - sh) / 2;
+ min_offset_y = 0 - shell->disp_height * OVERPAN_FACTOR;
+ max_offset_y = sh - shell->disp_height * (1.0 - OVERPAN_FACTOR);
}
else
{
- gint min_offset_y = 0;
- gint max_offset_y = sh - shell->disp_height;
+ gint overpan_amount;
- shell->offset_y = CLAMP (shell->offset_y, min_offset_y, max_offset_y);
+ overpan_amount = shell->disp_height - sh * (1.0 - OVERPAN_FACTOR);
+
+ min_offset_y = 0 - overpan_amount;
+ max_offset_y = sh + overpan_amount - shell->disp_height;
}
+
+ shell->offset_x = CLAMP (shell->offset_x, min_offset_x, max_offset_x);
+ shell->offset_y = CLAMP (shell->offset_y, min_offset_y, max_offset_y);
}
else
{
@@ -298,3 +314,83 @@
if (offset_x) *offset_x = MAX (0, shell->offset_x);
if (offset_y) *offset_y = MAX (0, shell->offset_y);
}
+
+/**
+ * gimp_display_shell_setup_hscrollbar_with_value:
+ * @shell:
+ * @value:
+ *
+ * Setup the limits of the horizontal scrollbar
+ *
+ **/
+void
+gimp_display_shell_setup_hscrollbar_with_value (GimpDisplayShell *shell,
+ gdouble value)
+{
+ gint sw;
+
+ g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+ if (! shell->display ||
+ ! shell->display->image)
+ return;
+
+ sw = SCALEX (shell, gimp_image_get_width (shell->display->image));
+
+ if (shell->disp_width < sw)
+ {
+ shell->hsbdata->upper = MAX (value + shell->disp_width,
+ sw);
+
+ shell->hsbdata->lower = MIN (value,
+ 0);
+ }
+ else
+ {
+ shell->hsbdata->lower = MIN (value,
+ -(shell->disp_width - sw) / 2);
+
+ shell->hsbdata->upper = MAX (value + shell->disp_width,
+ sw + (shell->disp_width - sw) / 2);
+ }
+}
+
+/**
+ * gimp_display_shell_setup_vscrollbar_with_value:
+ * @shell:
+ * @value:
+ *
+ * Setup the limits of the vertical scrollbar
+ *
+ **/
+void
+gimp_display_shell_setup_vscrollbar_with_value (GimpDisplayShell *shell,
+ gdouble value)
+{
+ gint sh;
+
+ g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+ if (! shell->display ||
+ ! shell->display->image)
+ return;
+
+ sh = SCALEY (shell, gimp_image_get_height (shell->display->image));
+
+ if (shell->disp_height < sh)
+ {
+ shell->vsbdata->upper = MAX (value + shell->disp_height,
+ sh);
+
+ shell->vsbdata->lower = MIN (value,
+ 0);
+ }
+ else
+ {
+ shell->vsbdata->lower = MIN (value,
+ -(shell->disp_height - sh) / 2);
+
+ shell->vsbdata->upper = MAX (value + shell->disp_height,
+ sh + (shell->disp_height - sh) / 2);
+ }
+}
Modified: trunk/app/display/gimpdisplayshell-scroll.h
==============================================================================
--- trunk/app/display/gimpdisplayshell-scroll.h (original)
+++ trunk/app/display/gimpdisplayshell-scroll.h Sat Jul 12 14:48:09 2008
@@ -50,5 +50,10 @@
gint *offset_x,
gint *offset_y);
+void gimp_display_shell_setup_hscrollbar_with_value (GimpDisplayShell *shell,
+ gdouble value);
+void gimp_display_shell_setup_vscrollbar_with_value (GimpDisplayShell *shell,
+ gdouble value);
+
#endif /* __GIMP_DISPLAY_SHELL_SCROLL_H__ */
Modified: trunk/app/display/gimpdisplayshell.c
==============================================================================
--- trunk/app/display/gimpdisplayshell.c (original)
+++ trunk/app/display/gimpdisplayshell.c Sat Jul 12 14:48:09 2008
@@ -935,12 +935,20 @@
shell->hsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, image_width,
1, 1, image_width));
shell->hsb = gtk_hscrollbar_new (shell->hsbdata);
+
+ gtk_range_set_lower_stepper_sensitivity (GTK_RANGE (shell->hsb), GTK_SENSITIVITY_ON);
+ gtk_range_set_upper_stepper_sensitivity (GTK_RANGE (shell->hsb), GTK_SENSITIVITY_ON);
+
GTK_WIDGET_UNSET_FLAGS (shell->hsb, GTK_CAN_FOCUS);
/* the vertical scrollbar */
shell->vsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, image_height,
1, 1, image_height));
shell->vsb = gtk_vscrollbar_new (shell->vsbdata);
+
+ gtk_range_set_lower_stepper_sensitivity (GTK_RANGE (shell->vsb), GTK_SENSITIVITY_ON);
+ gtk_range_set_upper_stepper_sensitivity (GTK_RANGE (shell->vsb), GTK_SENSITIVITY_ON);
+
GTK_WIDGET_UNSET_FLAGS (shell->vsb, GTK_CAN_FOCUS);
/* create the contents of the inner_table ********************************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]