Commit 2f26016a authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

app: move the code to update scrollbars and rulers to their own files

so they are gone from the "scale" and "scroll" namespaces because they
belong to neither and both. And because the files are way too large.
parent a27179de
......@@ -119,12 +119,16 @@ libappdisplay_a_sources = \
gimpdisplayshell-rotate.h \
gimpdisplayshell-rotate-dialog.c \
gimpdisplayshell-rotate-dialog.h \
gimpdisplayshell-rulers.c \
gimpdisplayshell-rulers.h \
gimpdisplayshell-scale.c \
gimpdisplayshell-scale.h \
gimpdisplayshell-scale-dialog.c \
gimpdisplayshell-scale-dialog.h \
gimpdisplayshell-scroll.c \
gimpdisplayshell-scroll.h \
gimpdisplayshell-scrollbars.c \
gimpdisplayshell-scrollbars.h \
gimpdisplayshell-selection.c \
gimpdisplayshell-selection.h \
gimpdisplayshell-title.c \
......
......@@ -40,6 +40,7 @@
#include "gimpdisplayshell-draw.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpdisplayshell-scrollbars.h"
#include "gimpdisplayshell-selection.h"
#include "gimpdisplayshell-title.h"
#include "gimpdisplayxfer.h"
......@@ -374,7 +375,7 @@ gimp_display_shell_hscrollbar_change_value (GtkRange *range,
g_object_freeze_notify (G_OBJECT (shell->hsbdata));
gimp_display_shell_scroll_setup_hscrollbar (shell, value);
gimp_display_shell_scrollbars_setup_horizontal (shell, value);
g_object_thaw_notify (G_OBJECT (shell->hsbdata)); /* emits "changed" */
......@@ -397,7 +398,7 @@ gimp_display_shell_vscrollbar_change_value (GtkRange *range,
g_object_freeze_notify (G_OBJECT (shell->vsbdata));
gimp_display_shell_scroll_setup_vscrollbar (shell, value);
gimp_display_shell_scrollbars_setup_vertical (shell, value);
g_object_thaw_notify (G_OBJECT (shell->vsbdata)); /* emits "changed" */
......
......@@ -59,6 +59,7 @@
#include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-icon.h"
#include "gimpdisplayshell-profile.h"
#include "gimpdisplayshell-rulers.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpdisplayshell-selection.h"
......@@ -568,7 +569,7 @@ gimp_display_shell_resolution_changed_handler (GimpImage *image,
{
if (shell->unit != GIMP_UNIT_PIXEL)
{
gimp_display_shell_scale_update_rulers (shell);
gimp_display_shell_rulers_update (shell);
}
gimp_display_shell_scaled (shell);
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display-types.h"
#include "core/gimpimage.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-rulers.h"
/**
* gimp_display_shell_rulers_update:
* @shell:
*
**/
void
gimp_display_shell_rulers_update (GimpDisplayShell *shell)
{
GimpImage *image;
gint image_width;
gint image_height;
gdouble resolution_x = 1.0;
gdouble resolution_y = 1.0;
gdouble horizontal_lower;
gdouble horizontal_upper;
gdouble horizontal_max_size;
gdouble vertical_lower;
gdouble vertical_upper;
gdouble vertical_max_size;
if (! shell->display)
return;
image = gimp_display_get_image (shell->display);
if (image)
{
image_width = gimp_image_get_width (image);
image_height = gimp_image_get_height (image);
gimp_image_get_resolution (image, &resolution_x, &resolution_y);
}
else
{
image_width = shell->disp_width;
image_height = shell->disp_height;
}
/* Initialize values */
horizontal_lower = 0;
vertical_lower = 0;
if (image)
{
horizontal_upper = gimp_pixels_to_units (FUNSCALEX (shell,
shell->disp_width),
shell->unit,
resolution_x);
horizontal_max_size = gimp_pixels_to_units (MAX (image_width,
image_height),
shell->unit,
resolution_x);
vertical_upper = gimp_pixels_to_units (FUNSCALEY (shell,
shell->disp_height),
shell->unit,
resolution_y);
vertical_max_size = gimp_pixels_to_units (MAX (image_width,
image_height),
shell->unit,
resolution_y);
}
else
{
horizontal_upper = image_width;
horizontal_max_size = MAX (image_width, image_height);
vertical_upper = image_height;
vertical_max_size = MAX (image_width, image_height);
}
/* Adjust due to scrolling */
if (image)
{
gdouble offset_x;
gdouble offset_y;
offset_x = gimp_pixels_to_units (FUNSCALEX (shell,
(gdouble) shell->offset_x),
shell->unit,
resolution_x);
offset_y = gimp_pixels_to_units (FUNSCALEX (shell,
(gdouble) shell->offset_y),
shell->unit,
resolution_y);
horizontal_lower += offset_x;
horizontal_upper += offset_x;
vertical_lower += offset_y;
vertical_upper += offset_y;
}
/* Finally setup the actual rulers */
gimp_ruler_set_range (GIMP_RULER (shell->hrule),
horizontal_lower,
horizontal_upper,
horizontal_max_size);
gimp_ruler_set_unit (GIMP_RULER (shell->hrule),
shell->unit);
gimp_ruler_set_range (GIMP_RULER (shell->vrule),
vertical_lower,
vertical_upper,
vertical_max_size);
gimp_ruler_set_unit (GIMP_RULER (shell->vrule),
shell->unit);
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_DISPLAY_SHELL_RULERS_H__
#define __GIMP_DISPLAY_SHELL_RULERS_H__
void gimp_display_shell_rulers_update (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_RULERS_H__ */
......@@ -83,168 +83,6 @@ static void gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shel
/* public functions */
/**
* gimp_display_shell_scale_update_scrollbars:
* @shell:
*
**/
void
gimp_display_shell_scale_update_scrollbars (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (! shell->display)
return;
/* Horizontal scrollbar */
g_object_freeze_notify (G_OBJECT (shell->hsbdata));
/* Update upper and lower value before we set the new value */
gimp_display_shell_scroll_setup_hscrollbar (shell, shell->offset_x);
g_object_set (shell->hsbdata,
"value", (gdouble) shell->offset_x,
"page-size", (gdouble) shell->disp_width,
"page-increment", (gdouble) shell->disp_width / 2,
NULL);
g_object_thaw_notify (G_OBJECT (shell->hsbdata)); /* emits "changed" */
/* Vertcal scrollbar */
g_object_freeze_notify (G_OBJECT (shell->vsbdata));
/* Update upper and lower value before we set the new value */
gimp_display_shell_scroll_setup_vscrollbar (shell, shell->offset_y);
g_object_set (shell->vsbdata,
"value", (gdouble) shell->offset_y,
"page-size", (gdouble) shell->disp_height,
"page-increment", (gdouble) shell->disp_height / 2,
NULL);
g_object_thaw_notify (G_OBJECT (shell->vsbdata)); /* emits "changed" */
}
/**
* gimp_display_shell_scale_update_rulers:
* @shell:
*
**/
void
gimp_display_shell_scale_update_rulers (GimpDisplayShell *shell)
{
GimpImage *image;
gint image_width;
gint image_height;
gdouble resolution_x = 1.0;
gdouble resolution_y = 1.0;
gdouble horizontal_lower;
gdouble horizontal_upper;
gdouble horizontal_max_size;
gdouble vertical_lower;
gdouble vertical_upper;
gdouble vertical_max_size;
if (! shell->display)
return;
image = gimp_display_get_image (shell->display);
if (image)
{
image_width = gimp_image_get_width (image);
image_height = gimp_image_get_height (image);
gimp_image_get_resolution (image, &resolution_x, &resolution_y);
}
else
{
image_width = shell->disp_width;
image_height = shell->disp_height;
}
/* Initialize values */
horizontal_lower = 0;
vertical_lower = 0;
if (image)
{
horizontal_upper = gimp_pixels_to_units (FUNSCALEX (shell,
shell->disp_width),
shell->unit,
resolution_x);
horizontal_max_size = gimp_pixels_to_units (MAX (image_width,
image_height),
shell->unit,
resolution_x);
vertical_upper = gimp_pixels_to_units (FUNSCALEY (shell,
shell->disp_height),
shell->unit,
resolution_y);
vertical_max_size = gimp_pixels_to_units (MAX (image_width,
image_height),
shell->unit,
resolution_y);
}
else
{
horizontal_upper = image_width;
horizontal_max_size = MAX (image_width, image_height);
vertical_upper = image_height;
vertical_max_size = MAX (image_width, image_height);
}
/* Adjust due to scrolling */
if (image)
{
gdouble offset_x;
gdouble offset_y;
offset_x = gimp_pixels_to_units (FUNSCALEX (shell,
(gdouble) shell->offset_x),
shell->unit,
resolution_x);
offset_y = gimp_pixels_to_units (FUNSCALEX (shell,
(gdouble) shell->offset_y),
shell->unit,
resolution_y);
horizontal_lower += offset_x;
horizontal_upper += offset_x;
vertical_lower += offset_y;
vertical_upper += offset_y;
}
/* Finally setup the actual rulers */
gimp_ruler_set_range (GIMP_RULER (shell->hrule),
horizontal_lower,
horizontal_upper,
horizontal_max_size);
gimp_ruler_set_unit (GIMP_RULER (shell->hrule),
shell->unit);
gimp_ruler_set_range (GIMP_RULER (shell->vrule),
vertical_lower,
vertical_upper,
vertical_max_size);
gimp_ruler_set_unit (GIMP_RULER (shell->vrule),
shell->unit);
}
/**
* gimp_display_shell_scale_revert:
* @shell: the #GimpDisplayShell
......
......@@ -19,9 +19,6 @@
#define __GIMP_DISPLAY_SHELL_SCALE_H__
void gimp_display_shell_scale_update_scrollbars (GimpDisplayShell *shell);
void gimp_display_shell_scale_update_rulers (GimpDisplayShell *shell);
gboolean gimp_display_shell_scale_revert (GimpDisplayShell *shell);
gboolean gimp_display_shell_scale_can_revert (GimpDisplayShell *shell);
......
......@@ -36,13 +36,14 @@
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-expose.h"
#include "gimpdisplayshell-rotate.h"
#include "gimpdisplayshell-rulers.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpdisplayshell-scrollbars.h"
#include "gimpdisplayshell-transform.h"
#define OVERPAN_FACTOR 0.5
#define MINIMUM_STEP_AMOUNT 1.0
#define OVERPAN_FACTOR 0.5
/**
......@@ -231,8 +232,8 @@ gimp_display_shell_scroll_clamp_and_update (GimpDisplayShell *shell)
shell->offset_y = 0;
}
gimp_display_shell_scale_update_scrollbars (shell);
gimp_display_shell_scale_update_rulers (shell);
gimp_display_shell_scrollbars_update (shell);
gimp_display_shell_rulers_update (shell);
}
/**
......@@ -466,89 +467,3 @@ gimp_display_shell_scroll_get_viewport (GimpDisplayShell *shell,
*w = shell->disp_width / shell->scale_x;
*h = shell->disp_height / shell->scale_y;
}
/**
* gimp_display_shell_scroll_setup_hscrollbar:
* @shell:
* @value:
*
* Setup the limits of the horizontal scrollbar
**/
void
gimp_display_shell_scroll_setup_hscrollbar (GimpDisplayShell *shell,
gdouble value)
{
gint sw;
gdouble lower;
gdouble upper;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (! shell->display ||
! gimp_display_get_image (shell->display))
return;
gimp_display_shell_scale_get_image_size (shell, &sw, NULL);
if (shell->disp_width < sw)
{
lower = MIN (value, 0);
upper = MAX (value + shell->disp_width, sw);
}
else
{
lower = MIN (value, -(shell->disp_width - sw) / 2);
upper = MAX (value + shell->disp_width,
sw + (shell->disp_width - sw) / 2);
}
g_object_set (shell->hsbdata,
"lower", lower,
"upper", upper,
"step-increment", (gdouble) MAX (shell->scale_x,
MINIMUM_STEP_AMOUNT),
NULL);
}
/**
* gimp_display_shell_scroll_setup_vscrollbar:
* @shell:
* @value:
*
* Setup the limits of the vertical scrollbar
**/
void
gimp_display_shell_scroll_setup_vscrollbar (GimpDisplayShell *shell,
gdouble value)
{
gint sh;
gdouble lower;
gdouble upper;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (! shell->display ||
! gimp_display_get_image (shell->display))
return;
gimp_display_shell_scale_get_image_size (shell, NULL, &sh);
if (shell->disp_height < sh)
{
lower = MIN (value, 0);
upper = MAX (value + shell->disp_height, sh);
}
else
{
lower = MIN (value, -(shell->disp_height - sh) / 2);
upper = MAX (value + shell->disp_height,
sh + (shell->disp_height - sh) / 2);
}
g_object_set (shell->vsbdata,
"lower", lower,
"upper", upper,
"step-increment", (gdouble) MAX (shell->scale_y,
MINIMUM_STEP_AMOUNT),
NULL);
}
......@@ -56,10 +56,5 @@ void gimp_display_shell_scroll_get_viewport (GimpDisplayShell *shell,
gdouble *w,
gdouble *h);
void gimp_display_shell_scroll_setup_hscrollbar (GimpDisplayShell *shell,
gdouble value);
void gimp_display_shell_scroll_setup_vscrollbar (GimpDisplayShell *shell,
gdouble value);
#endif /* __GIMP_DISPLAY_SHELL_SCROLL_H__ */
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "display-types.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scrollbars.h"
#define MINIMUM_STEP_AMOUNT 1.0
/**
* gimp_display_shell_scrollbars_update:
* @shell:
*
**/
void
gimp_display_shell_scrollbars_update (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (! shell->display)
return;
/* Horizontal scrollbar */
g_object_freeze_notify (G_OBJECT (shell->hsbdata));
/* Update upper and lower value before we set the new value */
gimp_display_shell_scrollbars_setup_horizontal (shell, shell->offset_x);
g_object_set (shell->hsbdata,
"value", (gdouble) shell->offset_x,
"page-size", (gdouble) shell->disp_width,
"page-increment", (gdouble) shell->disp_width / 2,
NULL);
g_object_thaw_notify (G_OBJECT (shell->hsbdata)); /* emits "changed" */
/* Vertcal scrollbar */
g_object_freeze_notify (G_OBJECT (shell->vsbdata));
/* Update upper and lower value before we set the new value */
gimp_display_shell_scrollbars_setup_vertical (shell, shell->offset_y);
g_object_set (shell->vsbdata,
"value", (gdouble) shell->offset_y,
"page-size", (gdouble) shell->disp_height,