Bug 658904 - Wrong behaviour in hidding layers with shift + left mouse click
Fix "exclusive visible" for layer trees. Doesn't touch the visibility of any non-toplevel items that is not in the exclusive item's ancestry.
This commit is contained in:
@ -36,6 +36,7 @@
|
|||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
static GList * gimp_item_exclusive_get_ancestry (GimpItem *item);
|
||||||
static void gimp_item_exclusive_get_lists (GimpItem *item,
|
static void gimp_item_exclusive_get_lists (GimpItem *item,
|
||||||
const gchar *property,
|
const gchar *property,
|
||||||
GList **on,
|
GList **on,
|
||||||
@ -48,6 +49,7 @@ void
|
|||||||
gimp_item_toggle_exclusive_visible (GimpItem *item,
|
gimp_item_toggle_exclusive_visible (GimpItem *item,
|
||||||
GimpContext *context)
|
GimpContext *context)
|
||||||
{
|
{
|
||||||
|
GList *ancestry;
|
||||||
GList *on;
|
GList *on;
|
||||||
GList *off;
|
GList *off;
|
||||||
GList *list;
|
GList *list;
|
||||||
@ -56,13 +58,13 @@ gimp_item_toggle_exclusive_visible (GimpItem *item,
|
|||||||
g_return_if_fail (gimp_item_is_attached (item));
|
g_return_if_fail (gimp_item_is_attached (item));
|
||||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||||
|
|
||||||
|
ancestry = gimp_item_exclusive_get_ancestry (item);
|
||||||
gimp_item_exclusive_get_lists (item, "visible", &on, &off);
|
gimp_item_exclusive_get_lists (item, "visible", &on, &off);
|
||||||
|
|
||||||
if (on || off || ! gimp_item_get_visible (item))
|
if (on || off || ! gimp_item_is_visible (item))
|
||||||
{
|
{
|
||||||
GimpImage *image = gimp_item_get_image (item);
|
GimpImage *image = gimp_item_get_image (item);
|
||||||
GimpUndo *undo;
|
GimpUndo *undo;
|
||||||
|
|
||||||
gboolean push_undo = TRUE;
|
gboolean push_undo = TRUE;
|
||||||
|
|
||||||
undo = gimp_image_undo_can_compress (image, GIMP_TYPE_UNDO_STACK,
|
undo = gimp_image_undo_can_compress (image, GIMP_TYPE_UNDO_STACK,
|
||||||
@ -86,7 +88,8 @@ gimp_item_toggle_exclusive_visible (GimpItem *item,
|
|||||||
(gpointer) item);
|
(gpointer) item);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_image_undo_push_item_visibility (image, NULL, item);
|
for (list = ancestry; list; list = g_list_next (list))
|
||||||
|
gimp_image_undo_push_item_visibility (image, NULL, list->data);
|
||||||
|
|
||||||
for (list = on; list; list = g_list_next (list))
|
for (list = on; list; list = g_list_next (list))
|
||||||
gimp_image_undo_push_item_visibility (image, NULL, list->data);
|
gimp_image_undo_push_item_visibility (image, NULL, list->data);
|
||||||
@ -101,7 +104,8 @@ gimp_item_toggle_exclusive_visible (GimpItem *item,
|
|||||||
gimp_undo_refresh_preview (undo, context);
|
gimp_undo_refresh_preview (undo, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_item_set_visible (item, TRUE, FALSE);
|
for (list = ancestry; list; list = g_list_next (list))
|
||||||
|
gimp_item_set_visible (list->data, TRUE, FALSE);
|
||||||
|
|
||||||
if (on)
|
if (on)
|
||||||
{
|
{
|
||||||
@ -122,6 +126,22 @@ gimp_item_toggle_exclusive_visible (GimpItem *item,
|
|||||||
|
|
||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
|
static GList *
|
||||||
|
gimp_item_exclusive_get_ancestry (GimpItem *item)
|
||||||
|
{
|
||||||
|
GimpViewable *parent;
|
||||||
|
GList *ancestry = NULL;
|
||||||
|
|
||||||
|
for (parent = GIMP_VIEWABLE (item);
|
||||||
|
parent;
|
||||||
|
parent = gimp_viewable_get_parent (parent))
|
||||||
|
{
|
||||||
|
ancestry = g_list_prepend (ancestry, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ancestry;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_item_exclusive_get_lists (GimpItem *item,
|
gimp_item_exclusive_get_lists (GimpItem *item,
|
||||||
const gchar *property,
|
const gchar *property,
|
||||||
@ -144,6 +164,13 @@ gimp_item_exclusive_get_lists (GimpItem *item,
|
|||||||
GimpItem *other = list->data;
|
GimpItem *other = list->data;
|
||||||
|
|
||||||
if (other != item)
|
if (other != item)
|
||||||
|
{
|
||||||
|
/* we are only interested in toplevel items that are not
|
||||||
|
* item's ancestor
|
||||||
|
*/
|
||||||
|
if (! gimp_viewable_get_parent (GIMP_VIEWABLE (other)) &&
|
||||||
|
! gimp_viewable_is_ancestor (GIMP_VIEWABLE (other),
|
||||||
|
GIMP_VIEWABLE (item)))
|
||||||
{
|
{
|
||||||
gboolean value;
|
gboolean value;
|
||||||
|
|
||||||
@ -155,6 +182,7 @@ gimp_item_exclusive_get_lists (GimpItem *item,
|
|||||||
*off = g_list_prepend (*off, other);
|
*off = g_list_prepend (*off, other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_list_free (items);
|
g_list_free (items);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user