mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-24 07:11:04 +00:00
4403d58a62
2001-11-16 Michael Natterer <mitch@gimp.org> Wishlist item #57669: * app/gimprc.[ch]: replaced gimprc option "allow-resize-windows" by "resize-windows-on-zoom" and "resize-windows-on-resize". * app/gui/preferences-dialog.c: added a toggle for "resize-windows-on-resize". * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/tools/gimpmagnifytool.c * docs/gimprc.5.in * etc/gimprc.in * etc/gimprc.win32: changed accordingly. * app/display/gimpdisplay-area.[ch]: added gimp_area_new(). * app/display/gimpdisplay.c: cleanup usage of GimpArea. * app/display/gimpdisplayshell.[ch]: added configurable canvas padding color and a small color_panel to change it in the upper right corner of the window. * app/display/gimpdisplayshell-callbacks.[ch]: added a callback for the color_panel, initialize the color in the "realize" callback. Wishlist item #51548. * app/display/gimpdisplayshell-selection.[ch] * app/gui/menus.c * app/gui/view-commands.[ch]: made the layer boundary toggleable separately from the selection. * app/gui/color-notebook.c: #if 0'ed a debugging g_print().
106 lines
2.5 KiB
C
106 lines
2.5 KiB
C
/* The GIMP -- an 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 2 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, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "display-types.h"
|
|
|
|
#include "gimpdisplay-area.h"
|
|
|
|
|
|
#define OVERHEAD 25 /* in units of pixel area */
|
|
|
|
|
|
GimpArea *
|
|
gimp_area_new (gint x1,
|
|
gint y1,
|
|
gint x2,
|
|
gint y2)
|
|
{
|
|
GimpArea *area;
|
|
|
|
area = g_new (GimpArea, 1);
|
|
|
|
area->x1 = x1;
|
|
area->y1 = y1;
|
|
area->x2 = x2;
|
|
area->y2 = y2;
|
|
|
|
return area;
|
|
}
|
|
|
|
/*
|
|
* As far as I can tell, this function takes a GimpArea and unifies it with
|
|
* an existing list of GimpAreas, trying to avoid overdraw. [adam]
|
|
*/
|
|
GSList *
|
|
gimp_display_area_list_process (GSList *list,
|
|
GimpArea *area)
|
|
{
|
|
GSList *new_list;
|
|
GSList *l;
|
|
gint area1, area2, area3;
|
|
GimpArea *ga2;
|
|
|
|
/* start new list off */
|
|
new_list = g_slist_prepend (NULL, area);
|
|
|
|
for (l = list; l; l = g_slist_next (l))
|
|
{
|
|
ga2 = (GimpArea *) l->data;
|
|
|
|
area1 = (area->x2 - area->x1) * (area->y2 - area->y1) + OVERHEAD;
|
|
area2 = (ga2->x2 - ga2->x1) * (ga2->y2 - ga2->y1) + OVERHEAD;
|
|
area3 = (MAX (ga2->x2, area->x2) - MIN (ga2->x1, area->x1)) *
|
|
(MAX (ga2->y2, area->y2) - MIN (ga2->y1, area->y1)) + OVERHEAD;
|
|
|
|
if ((area1 + area2) < area3)
|
|
{
|
|
new_list = g_slist_prepend (new_list, ga2);
|
|
}
|
|
else
|
|
{
|
|
area->x1 = MIN (area->x1, ga2->x1);
|
|
area->y1 = MIN (area->y1, ga2->y1);
|
|
area->x2 = MAX (area->x2, ga2->x2);
|
|
area->y2 = MAX (area->y2, ga2->y2);
|
|
|
|
g_free (ga2);
|
|
}
|
|
}
|
|
|
|
if (list)
|
|
g_slist_free (list);
|
|
|
|
return new_list;
|
|
}
|
|
|
|
GSList *
|
|
gimp_display_area_list_free (GSList *list)
|
|
{
|
|
if (list)
|
|
{
|
|
g_slist_foreach (list, (GFunc) g_free, NULL);
|
|
g_slist_free (list);
|
|
}
|
|
|
|
return NULL;
|
|
}
|