diff --git a/app/display/Makefile.am b/app/display/Makefile.am index 240ae3e2bd..031ec421ea 100644 --- a/app/display/Makefile.am +++ b/app/display/Makefile.am @@ -47,6 +47,8 @@ libappdisplay_a_sources = \ gimpdisplayshell-dnd.h \ gimpdisplayshell-draw.c \ gimpdisplayshell-draw.h \ + gimpdisplayshell-expose.c \ + gimpdisplayshell-expose.h \ gimpdisplayshell-handlers.c \ gimpdisplayshell-handlers.h \ gimpdisplayshell-filter.c \ diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index 465b5a63df..9c23b34d9a 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -40,6 +40,7 @@ #include "gimpdisplay.h" #include "gimpdisplay-handlers.h" #include "gimpdisplayshell.h" +#include "gimpdisplayshell-expose.h" #include "gimpdisplayshell-handlers.h" #include "gimpdisplayshell-icon.h" #include "gimpdisplayshell-transform.h" diff --git a/app/display/gimpdisplayshell-appearance.c b/app/display/gimpdisplayshell-appearance.c index 2960b4095e..1ac3fde88c 100644 --- a/app/display/gimpdisplayshell-appearance.c +++ b/app/display/gimpdisplayshell-appearance.c @@ -42,6 +42,7 @@ #include "gimpdisplayoptions.h" #include "gimpdisplayshell.h" #include "gimpdisplayshell-appearance.h" +#include "gimpdisplayshell-expose.h" #include "gimpdisplayshell-selection.h" #include "gimpimagewindow.h" #include "gimpstatusbar.h" diff --git a/app/display/gimpdisplayshell-cursor.c b/app/display/gimpdisplayshell-cursor.c index ffdb3a680a..cb00e79644 100644 --- a/app/display/gimpdisplayshell-cursor.c +++ b/app/display/gimpdisplayshell-cursor.c @@ -35,6 +35,7 @@ #include "gimpcursorview.h" #include "gimpdisplayshell.h" #include "gimpdisplayshell-cursor.h" +#include "gimpdisplayshell-expose.h" #include "gimpdisplayshell-transform.h" #include "gimpimagewindow.h" #include "gimpstatusbar.h" diff --git a/app/display/gimpdisplayshell-expose.c b/app/display/gimpdisplayshell-expose.c new file mode 100644 index 0000000000..560079be44 --- /dev/null +++ b/app/display/gimpdisplayshell-expose.c @@ -0,0 +1,116 @@ +/* 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 . + */ + +#include "config.h" + +#include +#include + +#include "libgimpmath/gimpmath.h" + +#include "display-types.h" + +#include "core/gimpguide.h" +#include "core/gimpsamplepoint.h" + +#include "gimpdisplayshell.h" +#include "gimpdisplayshell-expose.h" +#include "gimpdisplayshell-transform.h" + + +void +gimp_display_shell_expose_area (GimpDisplayShell *shell, + gint x, + gint y, + gint w, + gint h) +{ + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + gtk_widget_queue_draw_area (shell->canvas, x, y, w, h); +} + +void +gimp_display_shell_expose_guide (GimpDisplayShell *shell, + GimpGuide *guide) +{ + gint position; + gint x, y; + + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + g_return_if_fail (GIMP_IS_GUIDE (guide)); + + position = gimp_guide_get_position (guide); + + if (position < 0) + return; + + gimp_display_shell_transform_xy (shell, + position, position, + &x, &y, + FALSE); + + switch (gimp_guide_get_orientation (guide)) + { + case GIMP_ORIENTATION_HORIZONTAL: + gimp_display_shell_expose_area (shell, 0, y, shell->disp_width, 1); + break; + + case GIMP_ORIENTATION_VERTICAL: + gimp_display_shell_expose_area (shell, x, 0, 1, shell->disp_height); + break; + + default: + break; + } +} + +void +gimp_display_shell_expose_sample_point (GimpDisplayShell *shell, + GimpSamplePoint *sample_point) +{ + gdouble x, y; + gint x1, y1, x2, y2; + + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + g_return_if_fail (sample_point != NULL); + + if (sample_point->x < 0) + return; + + gimp_display_shell_transform_xy_f (shell, + sample_point->x + 0.5, + sample_point->y + 0.5, + &x, &y, + FALSE); + + x1 = MAX (0, floor (x - GIMP_SAMPLE_POINT_DRAW_SIZE)); + y1 = MAX (0, floor (y - GIMP_SAMPLE_POINT_DRAW_SIZE)); + x2 = MIN (shell->disp_width, ceil (x + GIMP_SAMPLE_POINT_DRAW_SIZE)); + y2 = MIN (shell->disp_height, ceil (y + GIMP_SAMPLE_POINT_DRAW_SIZE)); + + /* HACK: add 3 instead of 1 so the number gets cleared too */ + gimp_display_shell_expose_area (shell, x1, y1, x2 - x1 + 3, y2 - y1 + 3); +} + +void +gimp_display_shell_expose_full (GimpDisplayShell *shell) +{ + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + gtk_widget_queue_draw (shell->canvas); +} diff --git a/app/display/gimpdisplayshell-expose.h b/app/display/gimpdisplayshell-expose.h new file mode 100644 index 0000000000..110a865bc9 --- /dev/null +++ b/app/display/gimpdisplayshell-expose.h @@ -0,0 +1,34 @@ +/* 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 . + */ + +#ifndef __GIMP_DISPLAY_SHELL_EXPOSE_H__ +#define __GIMP_DISPLAY_SHELL_EXPOSE_H__ + + +void gimp_display_shell_expose_area (GimpDisplayShell *shell, + gint x, + gint y, + gint w, + gint h); +void gimp_display_shell_expose_guide (GimpDisplayShell *shell, + GimpGuide *guide); +void gimp_display_shell_expose_sample_point (GimpDisplayShell *shell, + GimpSamplePoint *sample_point); +void gimp_display_shell_expose_full (GimpDisplayShell *shell); + + +#endif /* __GIMP_DISPLAY_SHELL_EXPOSE_H__ */ diff --git a/app/display/gimpdisplayshell-filter.c b/app/display/gimpdisplayshell-filter.c index 6ba9a4a83d..a491ba6035 100644 --- a/app/display/gimpdisplayshell-filter.c +++ b/app/display/gimpdisplayshell-filter.c @@ -27,6 +27,7 @@ #include "config/gimpcoreconfig.h" #include "gimpdisplayshell.h" +#include "gimpdisplayshell-expose.h" #include "gimpdisplayshell-filter.h" diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c index 16be205dbf..6882c06e93 100644 --- a/app/display/gimpdisplayshell-handlers.c +++ b/app/display/gimpdisplayshell-handlers.c @@ -44,6 +44,7 @@ #include "gimpdisplayshell-appearance.h" #include "gimpdisplayshell-callbacks.h" #include "gimpdisplayshell-draw.h" +#include "gimpdisplayshell-expose.h" #include "gimpdisplayshell-handlers.h" #include "gimpdisplayshell-icon.h" #include "gimpdisplayshell-scale.h" diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c index e53158fe96..dce3583620 100644 --- a/app/display/gimpdisplayshell-scale.c +++ b/app/display/gimpdisplayshell-scale.c @@ -34,6 +34,7 @@ #include "gimpdisplay.h" #include "gimpdisplayshell.h" #include "gimpdisplayshell-draw.h" +#include "gimpdisplayshell-expose.h" #include "gimpdisplayshell-scale.h" #include "gimpdisplayshell-scroll.h" #include "gimpdisplayshell-title.h" diff --git a/app/display/gimpdisplayshell-scroll.c b/app/display/gimpdisplayshell-scroll.c index c937c40923..0bbba2183b 100644 --- a/app/display/gimpdisplayshell-scroll.c +++ b/app/display/gimpdisplayshell-scroll.c @@ -38,6 +38,7 @@ #include "gimpdisplay-foreach.h" #include "gimpdisplayshell.h" #include "gimpdisplayshell-draw.h" +#include "gimpdisplayshell-expose.h" #include "gimpdisplayshell-scale.h" #include "gimpdisplayshell-scroll.h" diff --git a/app/display/gimpdisplayshell-selection.c b/app/display/gimpdisplayshell-selection.c index 73d8526662..51a8beddc3 100644 --- a/app/display/gimpdisplayshell-selection.c +++ b/app/display/gimpdisplayshell-selection.c @@ -35,6 +35,7 @@ #include "gimpdisplay.h" #include "gimpdisplayshell.h" #include "gimpdisplayshell-appearance.h" +#include "gimpdisplayshell-expose.h" #include "gimpdisplayshell-selection.h" #include "gimpdisplayshell-transform.h" diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 6b7c7825d2..b8704f4ebf 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -37,14 +37,12 @@ #include "core/gimp.h" #include "core/gimpchannel.h" #include "core/gimpcontext.h" -#include "core/gimpguide.h" #include "core/gimpimage.h" #include "core/gimpimage-grid.h" #include "core/gimpimage-guides.h" #include "core/gimpimage-snap.h" #include "core/gimpprojection.h" #include "core/gimpmarshal.h" -#include "core/gimpsamplepoint.h" #include "core/gimptemplate.h" #include "widgets/gimpactiongroup.h" @@ -65,7 +63,7 @@ #include "gimpdisplayshell-cursor.h" #include "gimpdisplayshell-dnd.h" #include "gimpdisplayshell-draw.h" -#include "gimpdisplayshell-draw.h" +#include "gimpdisplayshell-expose.h" #include "gimpdisplayshell-filter.h" #include "gimpdisplayshell-handlers.h" #include "gimpdisplayshell-progress.h" @@ -1497,89 +1495,6 @@ gimp_display_shell_mask_bounds (GimpDisplayShell *shell, return ((*x2 - *x1) > 0) && ((*y2 - *y1) > 0); } -void -gimp_display_shell_expose_area (GimpDisplayShell *shell, - gint x, - gint y, - gint w, - gint h) -{ - g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - - gtk_widget_queue_draw_area (shell->canvas, x, y, w, h); -} - -void -gimp_display_shell_expose_guide (GimpDisplayShell *shell, - GimpGuide *guide) -{ - gint position; - gint x, y; - - g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - g_return_if_fail (GIMP_IS_GUIDE (guide)); - - position = gimp_guide_get_position (guide); - - if (position < 0) - return; - - gimp_display_shell_transform_xy (shell, - position, position, - &x, &y, - FALSE); - - switch (gimp_guide_get_orientation (guide)) - { - case GIMP_ORIENTATION_HORIZONTAL: - gimp_display_shell_expose_area (shell, 0, y, shell->disp_width, 1); - break; - - case GIMP_ORIENTATION_VERTICAL: - gimp_display_shell_expose_area (shell, x, 0, 1, shell->disp_height); - break; - - default: - break; - } -} - -void -gimp_display_shell_expose_sample_point (GimpDisplayShell *shell, - GimpSamplePoint *sample_point) -{ - gdouble x, y; - gint x1, y1, x2, y2; - - g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - g_return_if_fail (sample_point != NULL); - - if (sample_point->x < 0) - return; - - gimp_display_shell_transform_xy_f (shell, - sample_point->x + 0.5, - sample_point->y + 0.5, - &x, &y, - FALSE); - - x1 = MAX (0, floor (x - GIMP_SAMPLE_POINT_DRAW_SIZE)); - y1 = MAX (0, floor (y - GIMP_SAMPLE_POINT_DRAW_SIZE)); - x2 = MIN (shell->disp_width, ceil (x + GIMP_SAMPLE_POINT_DRAW_SIZE)); - y2 = MIN (shell->disp_height, ceil (y + GIMP_SAMPLE_POINT_DRAW_SIZE)); - - /* HACK: add 3 instead of 1 so the number gets cleared too */ - gimp_display_shell_expose_area (shell, x1, y1, x2 - x1 + 3, y2 - y1 + 3); -} - -void -gimp_display_shell_expose_full (GimpDisplayShell *shell) -{ - g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - - gtk_widget_queue_draw (shell->canvas); -} - void gimp_display_shell_flush (GimpDisplayShell *shell, gboolean now) diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index 33d008c410..af10e9cf38 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -257,17 +257,6 @@ gboolean gimp_display_shell_mask_bounds (GimpDisplayShell *shell, gint *x2, gint *y2); -void gimp_display_shell_expose_area (GimpDisplayShell *shell, - gint x, - gint y, - gint w, - gint h); -void gimp_display_shell_expose_guide (GimpDisplayShell *shell, - GimpGuide *guide); -void gimp_display_shell_expose_sample_point (GimpDisplayShell *shell, - GimpSamplePoint *sample_point); -void gimp_display_shell_expose_full (GimpDisplayShell *shell); - void gimp_display_shell_flush (GimpDisplayShell *shell, gboolean now); diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c index fe980d8452..64181420c4 100644 --- a/app/tools/gimptransformtool.c +++ b/app/tools/gimptransformtool.c @@ -55,6 +55,7 @@ #include "display/gimpdisplay.h" #include "display/gimpdisplayshell.h" #include "display/gimpdisplayshell-appearance.h" +#include "display/gimpdisplayshell-expose.h" #include "display/gimpdisplayshell-transform.h" #include "gimptoolcontrol.h"