[gimp] Move "visible" and "active" to GimpImagePrivate
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Move "visible" and "active" to GimpImagePrivate
- Date: Thu, 4 Feb 2010 08:10:11 +0000 (UTC)
commit 02f5931c968ecfb92aef960a623bfe3867ab2f01
Author: Michael Natterer <mitch gimp org>
Date: Thu Feb 4 09:08:50 2010 +0100
Move "visible" and "active" to GimpImagePrivate
and add accessors for the entire arrays (not just their members).
app/core/gimpimage-duplicate.c | 8 +++--
app/core/gimpimage-private.h | 3 ++
app/core/gimpimage.c | 61 +++++++++++++++++++++++++++++++++------
app/core/gimpimage.h | 10 ++++--
app/core/gimplayer-project.c | 7 +++-
app/core/gimplayer.c | 4 +--
6 files changed, 72 insertions(+), 21 deletions(-)
---
diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c
index 6f6a4f7..ccc5fb2 100644
--- a/app/core/gimpimage-duplicate.c
+++ b/app/core/gimpimage-duplicate.c
@@ -359,12 +359,14 @@ static void
gimp_image_duplicate_components (GimpImage *image,
GimpImage *new_image)
{
- gint count;
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+ GimpImagePrivate *new_private = GIMP_IMAGE_GET_PRIVATE (new_image);
+ gint count;
for (count = 0; count < MAX_CHANNELS; count++)
{
- new_image->visible[count] = image->visible[count];
- new_image->active[count] = image->active[count];
+ new_private->visible[count] = private->visible[count];
+ new_private->active[count] = private->active[count];
}
}
diff --git a/app/core/gimpimage-private.h b/app/core/gimpimage-private.h
index af11b00..f41bfe7 100644
--- a/app/core/gimpimage-private.h
+++ b/app/core/gimpimage-private.h
@@ -75,6 +75,9 @@ struct _GimpImagePrivate
GimpChannel *selection_mask; /* the selection mask channel */
GimpParasiteList *parasites; /* Plug-in parasite data */
+
+ gboolean visible[MAX_CHANNELS]; /* visible channels */
+ gboolean active[MAX_CHANNELS]; /* active channels */
};
#define GIMP_IMAGE_GET_PRIVATE(image) \
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 04cc498..f16392d 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -663,8 +663,8 @@ gimp_image_init (GimpImage *image)
for (i = 0; i < MAX_CHANNELS; i++)
{
- image->visible[i] = TRUE;
- image->active[i] = TRUE;
+ private->visible[i] = TRUE;
+ private->active[i] = TRUE;
}
image->quick_mask_state = FALSE;
@@ -1727,6 +1727,9 @@ gimp_image_mask_changed (GimpImage *image)
g_signal_emit (image, gimp_image_signals[MASK_CHANGED], 0);
}
+
+/* image components */
+
gint
gimp_image_get_component_index (const GimpImage *image,
GimpChannelType channel)
@@ -1757,17 +1760,20 @@ gimp_image_set_component_active (GimpImage *image,
GimpChannelType channel,
gboolean active)
{
- gint index = -1;
+ GimpImagePrivate *private;
+ gint index = -1;
g_return_if_fail (GIMP_IS_IMAGE (image));
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
index = gimp_image_get_component_index (image, channel);
- if (index != -1 && active != image->active[index])
+ if (index != -1 && active != private->active[index])
{
GimpLayer *floating_sel = gimp_image_get_floating_selection (image);
- image->active[index] = active ? TRUE : FALSE;
+ private->active[index] = active ? TRUE : FALSE;
if (floating_sel)
gimp_drawable_update (GIMP_DRAWABLE (floating_sel),
@@ -1797,25 +1803,44 @@ gimp_image_get_component_active (const GimpImage *image,
index = gimp_image_get_component_index (image, channel);
if (index != -1)
- return image->active[index];
+ return GIMP_IMAGE_GET_PRIVATE (image)->active[index];
return FALSE;
}
void
+gimp_image_get_active_array (const GimpImage *image,
+ gboolean *components)
+{
+ GimpImagePrivate *private;
+ gint i;
+
+ g_return_if_fail (GIMP_IS_IMAGE (image));
+ g_return_if_fail (components != NULL);
+
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ for (i = 0; i < MAX_CHANNELS; i++)
+ components[i] = private->active[i];
+}
+
+void
gimp_image_set_component_visible (GimpImage *image,
GimpChannelType channel,
gboolean visible)
{
- gint index = -1;
+ GimpImagePrivate *private;
+ gint index = -1;
g_return_if_fail (GIMP_IS_IMAGE (image));
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
index = gimp_image_get_component_index (image, channel);
- if (index != -1 && visible != image->visible[index])
+ if (index != -1 && visible != private->visible[index])
{
- image->visible[index] = visible ? TRUE : FALSE;
+ private->visible[index] = visible ? TRUE : FALSE;
g_signal_emit (image,
gimp_image_signals[COMPONENT_VISIBILITY_CHANGED], 0,
@@ -1839,12 +1864,28 @@ gimp_image_get_component_visible (const GimpImage *image,
index = gimp_image_get_component_index (image, channel);
if (index != -1)
- return image->visible[index];
+ return GIMP_IMAGE_GET_PRIVATE (image)->visible[index];
return FALSE;
}
void
+gimp_image_get_visible_array (const GimpImage *image,
+ gboolean *components)
+{
+ GimpImagePrivate *private;
+ gint i;
+
+ g_return_if_fail (GIMP_IS_IMAGE (image));
+ g_return_if_fail (components != NULL);
+
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ for (i = 0; i < MAX_CHANNELS; i++)
+ components[i] = private->visible[i];
+}
+
+void
gimp_image_mode_changed (GimpImage *image)
{
g_return_if_fail (GIMP_IS_IMAGE (image));
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index 31cdd82..1454e4d 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -105,9 +105,6 @@ struct _GimpImage
Gimp *gimp; /* the GIMP the image belongs to*/
- gboolean visible[MAX_CHANNELS]; /* visible channels */
- gboolean active[MAX_CHANNELS]; /* active channels */
-
gboolean quick_mask_state; /* TRUE if quick mask is on */
gboolean quick_mask_inverted; /* TRUE if quick mask is inverted */
GimpRGB quick_mask_color; /* rgba triplet of the color */
@@ -245,6 +242,9 @@ void gimp_image_floating_selection_changed (GimpImage *image);
GimpChannel * gimp_image_get_mask (const GimpImage *image);
void gimp_image_mask_changed (GimpImage *image);
+
+/* image components */
+
gint gimp_image_get_component_index (const GimpImage *image,
GimpChannelType channel);
@@ -253,12 +253,16 @@ void gimp_image_set_component_active (GimpImage *image,
gboolean active);
gboolean gimp_image_get_component_active (const GimpImage *image,
GimpChannelType type);
+void gimp_image_get_active_array (const GimpImage *image,
+ gboolean *components);
void gimp_image_set_component_visible (GimpImage *image,
GimpChannelType type,
gboolean visible);
gboolean gimp_image_get_component_visible (const GimpImage *image,
GimpChannelType type);
+void gimp_image_get_visible_array (const GimpImage *image,
+ gboolean *components);
void gimp_image_mode_changed (GimpImage *image);
void gimp_image_alpha_changed (GimpImage *image);
diff --git a/app/core/gimplayer-project.c b/app/core/gimplayer-project.c
index 28d09a2..e091450 100644
--- a/app/core/gimplayer-project.c
+++ b/app/core/gimplayer-project.c
@@ -75,6 +75,7 @@ gimp_layer_project_region (GimpDrawable *drawable,
TileManager *temp_layer_tiles = NULL;
InitialMode initial_mode;
CombinationMode combination_mode;
+ gboolean visible[MAX_CHANNELS];
gimp_drawable_init_src_region (drawable, &srcPR,
x, y, width, height,
@@ -122,13 +123,15 @@ gimp_layer_project_region (GimpDrawable *drawable,
break;
}
+ gimp_image_get_visible_array (image, visible);
+
if (combine)
{
combine_regions (projPR, &srcPR, projPR, mask_pr,
colormap,
gimp_layer_get_opacity (layer) * 255.999,
gimp_layer_get_mode (layer),
- image->visible,
+ visible,
combination_mode);
}
else
@@ -137,7 +140,7 @@ gimp_layer_project_region (GimpDrawable *drawable,
colormap,
gimp_layer_get_opacity (layer) * 255.999,
gimp_layer_get_mode (layer),
- image->visible,
+ visible,
initial_mode);
}
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 5c7b10d..04a6d6a 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -847,11 +847,9 @@ gimp_layer_get_active_components (const GimpDrawable *drawable,
{
GimpLayer *layer = GIMP_LAYER (drawable);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
- gint i;
/* first copy the image active channels */
- for (i = 0; i < MAX_CHANNELS; i++)
- active[i] = image->active[i];
+ gimp_image_get_active_array (image, active);
if (gimp_drawable_has_alpha (drawable) && layer->lock_alpha)
active[gimp_drawable_bytes (drawable) - 1] = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]