mirror of https://github.com/GNOME/gimp.git
app/Makefile.am removed.
2001-11-10 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/qmask.[ch]: removed. * app/core/gimpimage.[ch]: added "qmask_changed" signal and gimp_image_[set|get]_qmask_state(). * app/display/Makefile.am * app/display/gimpdisplayshell-qmask.[ch]: put the stuff here. * app/display/gimpdisplayshell-handlers.[ch]: new files: handlers for GimpImage signals handled by GimpDisplayShell. * app/display/gimpdisplay-handlers.c: removed some of them here. Don't include any GimpDisplayShell stuff any more. * app/display/gimpdisplay.c: no need to update the qmask buttons in gimp_display_flush_whenever(). * app/display/gimpdisplayshell.c: call gimp_display_shell_connect() and disconnect().
This commit is contained in:
parent
7125fdbc43
commit
360f8321f5
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
2001-11-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/Makefile.am
|
||||
* app/qmask.[ch]: removed.
|
||||
|
||||
* app/core/gimpimage.[ch]: added "qmask_changed" signal and
|
||||
gimp_image_[set|get]_qmask_state().
|
||||
|
||||
* app/display/Makefile.am
|
||||
* app/display/gimpdisplayshell-qmask.[ch]: put the stuff here.
|
||||
|
||||
* app/display/gimpdisplayshell-handlers.[ch]: new files: handlers
|
||||
for GimpImage signals handled by GimpDisplayShell.
|
||||
|
||||
* app/display/gimpdisplay-handlers.c: removed some of them here.
|
||||
Don't include any GimpDisplayShell stuff any more.
|
||||
|
||||
* app/display/gimpdisplay.c: no need to update the qmask buttons
|
||||
in gimp_display_flush_whenever().
|
||||
|
||||
* app/display/gimpdisplayshell.c: call gimp_display_shell_connect()
|
||||
and disconnect().
|
||||
|
||||
2001-11-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/qmask.c: fixed qmask callbacks to check if the toggle is
|
||||
|
|
|
@ -20,8 +20,6 @@ gimp_SOURCES = @STRIP_BEGIN@ \
|
|||
nav_window.h \
|
||||
ops_buttons.c \
|
||||
ops_buttons.h \
|
||||
qmask.c \
|
||||
qmask.h \
|
||||
undo_history.c \
|
||||
undo_history.h \
|
||||
##
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
#include "display-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpchannel.h"
|
||||
|
@ -35,15 +33,14 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-mask.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplay-foreach.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "widgets/gimpcolorpanel.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplay-foreach.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-qmask.h"
|
||||
|
||||
#include "floating_sel.h"
|
||||
#include "qmask.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -61,7 +58,8 @@ struct _EditQmaskOptions
|
|||
};
|
||||
|
||||
|
||||
/* Prototypes */
|
||||
/* local function prototypes */
|
||||
|
||||
static void edit_qmask_channel_query (GimpDisplay *gdisp);
|
||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
|
@ -74,93 +72,18 @@ static void qmask_color_changed (GimpColorButton *button,
|
|||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
/* Actual code */
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
|
||||
qmask_buttons_update (gdisp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qmask_buttons_update (GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
g_assert (gdisp);
|
||||
g_assert (gdisp->gimage);
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (shell->qmaskon)->active)
|
||||
{
|
||||
/* Disable toggle from doing anything */
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
|
||||
/* Change the state of the buttons */
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskon),
|
||||
gdisp->gimage->qmask_state);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff),
|
||||
! gdisp->gimage->qmask_state);
|
||||
|
||||
/* Enable toggle again */
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
/* public functions */
|
||||
|
||||
gboolean
|
||||
qmask_button_press_callback (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
gimp_display_shell_qmask_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = (GimpDisplay *) data;
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
(event->button == 1))
|
||||
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
|
||||
{
|
||||
edit_qmask_channel_query (gdisp);
|
||||
|
||||
|
@ -171,65 +94,74 @@ qmask_button_press_callback (GtkWidget *widget,
|
|||
}
|
||||
|
||||
void
|
||||
qmask_deactivate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (!gdisp->gimage->qmask_state)
|
||||
if (! gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set do nothing */
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
undo_push_group_start (gimage, QMASK_UNDO);
|
||||
/* push the undo here since removing the mask will
|
||||
call the qmask_removed_callback() which will set
|
||||
the qmask_state to FALSE */
|
||||
* call the qmask_removed_callback() which will set
|
||||
* the qmask_state to FALSE
|
||||
*/
|
||||
undo_push_qmask (gimage);
|
||||
gimage_mask_load (gimage, gmask);
|
||||
gimp_image_remove_channel (gimage, gmask);
|
||||
gimage_mask_load (gimage, mask);
|
||||
gimp_image_remove_channel (gimage, mask);
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
qmask_activate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
GimpLayer *layer;
|
||||
GimpRGB color;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gdisp->gimage->qmask_state)
|
||||
if (gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
color = gimage->qmask_color;
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
gimage->qmask_state = TRUE;
|
||||
/* if the user was clever and created his own */
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -244,38 +176,43 @@ qmask_activate_callback (GtkWidget *widget,
|
|||
floating_sel_to_layer (layer);
|
||||
}
|
||||
|
||||
gmask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
mask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (gmask),
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
|
||||
gimp_get_user_context (gimage->gimp),
|
||||
TRANSPARENT_FILL);
|
||||
}
|
||||
else /* if selection */
|
||||
{
|
||||
gmask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
gimp_channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
gimp_channel_set_color (mask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
|
||||
gimage_mask_none (gimage); /* Clear the selection */
|
||||
}
|
||||
|
||||
undo_push_qmask (gimage);
|
||||
undo_push_group_end (gimage);
|
||||
gdisp->gimage->qmask_state = TRUE;
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
gdisplays_flush ();
|
||||
|
||||
/* connect to the removed signal, so the buttons get updated */
|
||||
g_signal_connect (G_OBJECT (gmask), "removed",
|
||||
g_signal_connect (G_OBJECT (mask), "removed",
|
||||
G_CALLBACK (qmask_removed_callback),
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
edit_qmask_channel_query (GimpDisplay *gdisp)
|
||||
{
|
||||
|
@ -399,3 +336,37 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
}
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
#include "display-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpchannel.h"
|
||||
|
@ -35,15 +33,14 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-mask.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplay-foreach.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "widgets/gimpcolorpanel.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplay-foreach.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-qmask.h"
|
||||
|
||||
#include "floating_sel.h"
|
||||
#include "qmask.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -61,7 +58,8 @@ struct _EditQmaskOptions
|
|||
};
|
||||
|
||||
|
||||
/* Prototypes */
|
||||
/* local function prototypes */
|
||||
|
||||
static void edit_qmask_channel_query (GimpDisplay *gdisp);
|
||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
|
@ -74,93 +72,18 @@ static void qmask_color_changed (GimpColorButton *button,
|
|||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
/* Actual code */
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
|
||||
qmask_buttons_update (gdisp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qmask_buttons_update (GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
g_assert (gdisp);
|
||||
g_assert (gdisp->gimage);
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (shell->qmaskon)->active)
|
||||
{
|
||||
/* Disable toggle from doing anything */
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
|
||||
/* Change the state of the buttons */
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskon),
|
||||
gdisp->gimage->qmask_state);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff),
|
||||
! gdisp->gimage->qmask_state);
|
||||
|
||||
/* Enable toggle again */
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
/* public functions */
|
||||
|
||||
gboolean
|
||||
qmask_button_press_callback (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
gimp_display_shell_qmask_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = (GimpDisplay *) data;
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
(event->button == 1))
|
||||
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
|
||||
{
|
||||
edit_qmask_channel_query (gdisp);
|
||||
|
||||
|
@ -171,65 +94,74 @@ qmask_button_press_callback (GtkWidget *widget,
|
|||
}
|
||||
|
||||
void
|
||||
qmask_deactivate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (!gdisp->gimage->qmask_state)
|
||||
if (! gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set do nothing */
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
undo_push_group_start (gimage, QMASK_UNDO);
|
||||
/* push the undo here since removing the mask will
|
||||
call the qmask_removed_callback() which will set
|
||||
the qmask_state to FALSE */
|
||||
* call the qmask_removed_callback() which will set
|
||||
* the qmask_state to FALSE
|
||||
*/
|
||||
undo_push_qmask (gimage);
|
||||
gimage_mask_load (gimage, gmask);
|
||||
gimp_image_remove_channel (gimage, gmask);
|
||||
gimage_mask_load (gimage, mask);
|
||||
gimp_image_remove_channel (gimage, mask);
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
qmask_activate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
GimpLayer *layer;
|
||||
GimpRGB color;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gdisp->gimage->qmask_state)
|
||||
if (gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
color = gimage->qmask_color;
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
gimage->qmask_state = TRUE;
|
||||
/* if the user was clever and created his own */
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -244,38 +176,43 @@ qmask_activate_callback (GtkWidget *widget,
|
|||
floating_sel_to_layer (layer);
|
||||
}
|
||||
|
||||
gmask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
mask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (gmask),
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
|
||||
gimp_get_user_context (gimage->gimp),
|
||||
TRANSPARENT_FILL);
|
||||
}
|
||||
else /* if selection */
|
||||
{
|
||||
gmask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
gimp_channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
gimp_channel_set_color (mask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
|
||||
gimage_mask_none (gimage); /* Clear the selection */
|
||||
}
|
||||
|
||||
undo_push_qmask (gimage);
|
||||
undo_push_group_end (gimage);
|
||||
gdisp->gimage->qmask_state = TRUE;
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
gdisplays_flush ();
|
||||
|
||||
/* connect to the removed signal, so the buttons get updated */
|
||||
g_signal_connect (G_OBJECT (gmask), "removed",
|
||||
g_signal_connect (G_OBJECT (mask), "removed",
|
||||
G_CALLBACK (qmask_removed_callback),
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
edit_qmask_channel_query (GimpDisplay *gdisp)
|
||||
{
|
||||
|
@ -399,3 +336,37 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
}
|
||||
|
|
|
@ -175,6 +175,7 @@ enum
|
|||
MASK_CHANGED,
|
||||
RESOLUTION_CHANGED,
|
||||
UNIT_CHANGED,
|
||||
QMASK_CHANGED,
|
||||
SELECTION_CONTROL,
|
||||
|
||||
CLEAN,
|
||||
|
@ -324,6 +325,15 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[QMASK_CHANGED] =
|
||||
g_signal_new ("qmask_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, qmask_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SELECTION_CONTROL] =
|
||||
g_signal_new ("selection_control",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -839,6 +849,28 @@ gimp_image_get_unit (const GimpImage *gimage)
|
|||
return gimage->unit;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
if (qmask_state != gimage->qmask_state)
|
||||
{
|
||||
gimage->qmask_state = qmask_state ? TRUE : FALSE;
|
||||
|
||||
gimp_image_qmask_changed (gimage);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_get_qmask_state (const GimpImage *gimage)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
return gimage->qmask_state;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc)
|
||||
|
@ -2024,6 +2056,14 @@ gimp_image_unit_changed (GimpImage *gimage)
|
|||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[UNIT_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_qmask_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[QMASK_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_alpha_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -141,6 +141,7 @@ struct _GimpImageClass
|
|||
void (* mask_changed) (GimpImage *gimage);
|
||||
void (* resolution_changed) (GimpImage *gimage);
|
||||
void (* unit_changed) (GimpImage *gimage);
|
||||
void (* qmask_changed) (GimpImage *gimage);
|
||||
void (* selection_control) (GimpImage *gimage,
|
||||
GimpSelectionControl control);
|
||||
|
||||
|
@ -185,11 +186,18 @@ void gimp_image_get_resolution (const GimpImage *gimage,
|
|||
void gimp_image_set_unit (GimpImage *gimage,
|
||||
GimpUnit unit);
|
||||
GimpUnit gimp_image_get_unit (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state);
|
||||
gboolean gimp_image_get_qmask_state (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc);
|
||||
PlugInProcDef * gimp_image_get_save_proc (const GimpImage *gimage);
|
||||
|
||||
gint gimp_image_get_width (const GimpImage *gimage);
|
||||
gint gimp_image_get_height (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_resize (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
|
@ -201,11 +209,13 @@ void gimp_image_scale (GimpImage *gimage,
|
|||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bpp);
|
||||
void gimp_image_free_shadow (GimpImage *gimage);
|
||||
|
||||
void gimp_image_apply_image (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *src2PR,
|
||||
|
@ -223,6 +233,7 @@ void gimp_image_replace_image (GimpImage *gimage,
|
|||
PixelRegion *maskPR,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
void gimp_image_get_foreground (const GimpImage *gimage,
|
||||
const GimpDrawable *drawable,
|
||||
guchar *fg);
|
||||
|
@ -241,6 +252,7 @@ void gimp_image_transform_color (const GimpImage *gimage,
|
|||
guchar *src,
|
||||
guchar *dest,
|
||||
GimpImageBaseType type);
|
||||
|
||||
GimpGuide * gimp_image_add_hguide (GimpImage *gimage);
|
||||
GimpGuide * gimp_image_add_vguide (GimpImage *gimage);
|
||||
void gimp_image_add_guide (GimpImage *gimage,
|
||||
|
@ -298,6 +310,7 @@ void gimp_image_floating_selection_changed (GimpImage *gimage);
|
|||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
void gimp_image_resolution_changed (GimpImage *gimage);
|
||||
void gimp_image_unit_changed (GimpImage *gimage);
|
||||
void gimp_image_qmask_changed (GimpImage *gimage);
|
||||
void gimp_image_update (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
|
|
|
@ -175,6 +175,7 @@ enum
|
|||
MASK_CHANGED,
|
||||
RESOLUTION_CHANGED,
|
||||
UNIT_CHANGED,
|
||||
QMASK_CHANGED,
|
||||
SELECTION_CONTROL,
|
||||
|
||||
CLEAN,
|
||||
|
@ -324,6 +325,15 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[QMASK_CHANGED] =
|
||||
g_signal_new ("qmask_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, qmask_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SELECTION_CONTROL] =
|
||||
g_signal_new ("selection_control",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -839,6 +849,28 @@ gimp_image_get_unit (const GimpImage *gimage)
|
|||
return gimage->unit;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
if (qmask_state != gimage->qmask_state)
|
||||
{
|
||||
gimage->qmask_state = qmask_state ? TRUE : FALSE;
|
||||
|
||||
gimp_image_qmask_changed (gimage);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_get_qmask_state (const GimpImage *gimage)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
return gimage->qmask_state;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc)
|
||||
|
@ -2024,6 +2056,14 @@ gimp_image_unit_changed (GimpImage *gimage)
|
|||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[UNIT_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_qmask_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[QMASK_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_alpha_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -141,6 +141,7 @@ struct _GimpImageClass
|
|||
void (* mask_changed) (GimpImage *gimage);
|
||||
void (* resolution_changed) (GimpImage *gimage);
|
||||
void (* unit_changed) (GimpImage *gimage);
|
||||
void (* qmask_changed) (GimpImage *gimage);
|
||||
void (* selection_control) (GimpImage *gimage,
|
||||
GimpSelectionControl control);
|
||||
|
||||
|
@ -185,11 +186,18 @@ void gimp_image_get_resolution (const GimpImage *gimage,
|
|||
void gimp_image_set_unit (GimpImage *gimage,
|
||||
GimpUnit unit);
|
||||
GimpUnit gimp_image_get_unit (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state);
|
||||
gboolean gimp_image_get_qmask_state (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc);
|
||||
PlugInProcDef * gimp_image_get_save_proc (const GimpImage *gimage);
|
||||
|
||||
gint gimp_image_get_width (const GimpImage *gimage);
|
||||
gint gimp_image_get_height (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_resize (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
|
@ -201,11 +209,13 @@ void gimp_image_scale (GimpImage *gimage,
|
|||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bpp);
|
||||
void gimp_image_free_shadow (GimpImage *gimage);
|
||||
|
||||
void gimp_image_apply_image (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *src2PR,
|
||||
|
@ -223,6 +233,7 @@ void gimp_image_replace_image (GimpImage *gimage,
|
|||
PixelRegion *maskPR,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
void gimp_image_get_foreground (const GimpImage *gimage,
|
||||
const GimpDrawable *drawable,
|
||||
guchar *fg);
|
||||
|
@ -241,6 +252,7 @@ void gimp_image_transform_color (const GimpImage *gimage,
|
|||
guchar *src,
|
||||
guchar *dest,
|
||||
GimpImageBaseType type);
|
||||
|
||||
GimpGuide * gimp_image_add_hguide (GimpImage *gimage);
|
||||
GimpGuide * gimp_image_add_vguide (GimpImage *gimage);
|
||||
void gimp_image_add_guide (GimpImage *gimage,
|
||||
|
@ -298,6 +310,7 @@ void gimp_image_floating_selection_changed (GimpImage *gimage);
|
|||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
void gimp_image_resolution_changed (GimpImage *gimage);
|
||||
void gimp_image_unit_changed (GimpImage *gimage);
|
||||
void gimp_image_qmask_changed (GimpImage *gimage);
|
||||
void gimp_image_update (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
|
|
|
@ -175,6 +175,7 @@ enum
|
|||
MASK_CHANGED,
|
||||
RESOLUTION_CHANGED,
|
||||
UNIT_CHANGED,
|
||||
QMASK_CHANGED,
|
||||
SELECTION_CONTROL,
|
||||
|
||||
CLEAN,
|
||||
|
@ -324,6 +325,15 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[QMASK_CHANGED] =
|
||||
g_signal_new ("qmask_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, qmask_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SELECTION_CONTROL] =
|
||||
g_signal_new ("selection_control",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -839,6 +849,28 @@ gimp_image_get_unit (const GimpImage *gimage)
|
|||
return gimage->unit;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
if (qmask_state != gimage->qmask_state)
|
||||
{
|
||||
gimage->qmask_state = qmask_state ? TRUE : FALSE;
|
||||
|
||||
gimp_image_qmask_changed (gimage);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_get_qmask_state (const GimpImage *gimage)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
return gimage->qmask_state;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc)
|
||||
|
@ -2024,6 +2056,14 @@ gimp_image_unit_changed (GimpImage *gimage)
|
|||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[UNIT_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_qmask_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[QMASK_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_alpha_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -141,6 +141,7 @@ struct _GimpImageClass
|
|||
void (* mask_changed) (GimpImage *gimage);
|
||||
void (* resolution_changed) (GimpImage *gimage);
|
||||
void (* unit_changed) (GimpImage *gimage);
|
||||
void (* qmask_changed) (GimpImage *gimage);
|
||||
void (* selection_control) (GimpImage *gimage,
|
||||
GimpSelectionControl control);
|
||||
|
||||
|
@ -185,11 +186,18 @@ void gimp_image_get_resolution (const GimpImage *gimage,
|
|||
void gimp_image_set_unit (GimpImage *gimage,
|
||||
GimpUnit unit);
|
||||
GimpUnit gimp_image_get_unit (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state);
|
||||
gboolean gimp_image_get_qmask_state (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc);
|
||||
PlugInProcDef * gimp_image_get_save_proc (const GimpImage *gimage);
|
||||
|
||||
gint gimp_image_get_width (const GimpImage *gimage);
|
||||
gint gimp_image_get_height (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_resize (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
|
@ -201,11 +209,13 @@ void gimp_image_scale (GimpImage *gimage,
|
|||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bpp);
|
||||
void gimp_image_free_shadow (GimpImage *gimage);
|
||||
|
||||
void gimp_image_apply_image (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *src2PR,
|
||||
|
@ -223,6 +233,7 @@ void gimp_image_replace_image (GimpImage *gimage,
|
|||
PixelRegion *maskPR,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
void gimp_image_get_foreground (const GimpImage *gimage,
|
||||
const GimpDrawable *drawable,
|
||||
guchar *fg);
|
||||
|
@ -241,6 +252,7 @@ void gimp_image_transform_color (const GimpImage *gimage,
|
|||
guchar *src,
|
||||
guchar *dest,
|
||||
GimpImageBaseType type);
|
||||
|
||||
GimpGuide * gimp_image_add_hguide (GimpImage *gimage);
|
||||
GimpGuide * gimp_image_add_vguide (GimpImage *gimage);
|
||||
void gimp_image_add_guide (GimpImage *gimage,
|
||||
|
@ -298,6 +310,7 @@ void gimp_image_floating_selection_changed (GimpImage *gimage);
|
|||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
void gimp_image_resolution_changed (GimpImage *gimage);
|
||||
void gimp_image_unit_changed (GimpImage *gimage);
|
||||
void gimp_image_qmask_changed (GimpImage *gimage);
|
||||
void gimp_image_update (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
#include "display-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpchannel.h"
|
||||
|
@ -35,15 +33,14 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-mask.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplay-foreach.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "widgets/gimpcolorpanel.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplay-foreach.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-qmask.h"
|
||||
|
||||
#include "floating_sel.h"
|
||||
#include "qmask.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -61,7 +58,8 @@ struct _EditQmaskOptions
|
|||
};
|
||||
|
||||
|
||||
/* Prototypes */
|
||||
/* local function prototypes */
|
||||
|
||||
static void edit_qmask_channel_query (GimpDisplay *gdisp);
|
||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
|
@ -74,93 +72,18 @@ static void qmask_color_changed (GimpColorButton *button,
|
|||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
/* Actual code */
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
|
||||
qmask_buttons_update (gdisp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qmask_buttons_update (GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
g_assert (gdisp);
|
||||
g_assert (gdisp->gimage);
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (shell->qmaskon)->active)
|
||||
{
|
||||
/* Disable toggle from doing anything */
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
|
||||
/* Change the state of the buttons */
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskon),
|
||||
gdisp->gimage->qmask_state);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff),
|
||||
! gdisp->gimage->qmask_state);
|
||||
|
||||
/* Enable toggle again */
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
/* public functions */
|
||||
|
||||
gboolean
|
||||
qmask_button_press_callback (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
gimp_display_shell_qmask_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = (GimpDisplay *) data;
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
(event->button == 1))
|
||||
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
|
||||
{
|
||||
edit_qmask_channel_query (gdisp);
|
||||
|
||||
|
@ -171,65 +94,74 @@ qmask_button_press_callback (GtkWidget *widget,
|
|||
}
|
||||
|
||||
void
|
||||
qmask_deactivate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (!gdisp->gimage->qmask_state)
|
||||
if (! gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set do nothing */
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
undo_push_group_start (gimage, QMASK_UNDO);
|
||||
/* push the undo here since removing the mask will
|
||||
call the qmask_removed_callback() which will set
|
||||
the qmask_state to FALSE */
|
||||
* call the qmask_removed_callback() which will set
|
||||
* the qmask_state to FALSE
|
||||
*/
|
||||
undo_push_qmask (gimage);
|
||||
gimage_mask_load (gimage, gmask);
|
||||
gimp_image_remove_channel (gimage, gmask);
|
||||
gimage_mask_load (gimage, mask);
|
||||
gimp_image_remove_channel (gimage, mask);
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
qmask_activate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
GimpLayer *layer;
|
||||
GimpRGB color;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gdisp->gimage->qmask_state)
|
||||
if (gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
color = gimage->qmask_color;
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
gimage->qmask_state = TRUE;
|
||||
/* if the user was clever and created his own */
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -244,38 +176,43 @@ qmask_activate_callback (GtkWidget *widget,
|
|||
floating_sel_to_layer (layer);
|
||||
}
|
||||
|
||||
gmask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
mask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (gmask),
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
|
||||
gimp_get_user_context (gimage->gimp),
|
||||
TRANSPARENT_FILL);
|
||||
}
|
||||
else /* if selection */
|
||||
{
|
||||
gmask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
gimp_channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
gimp_channel_set_color (mask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
|
||||
gimage_mask_none (gimage); /* Clear the selection */
|
||||
}
|
||||
|
||||
undo_push_qmask (gimage);
|
||||
undo_push_group_end (gimage);
|
||||
gdisp->gimage->qmask_state = TRUE;
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
gdisplays_flush ();
|
||||
|
||||
/* connect to the removed signal, so the buttons get updated */
|
||||
g_signal_connect (G_OBJECT (gmask), "removed",
|
||||
g_signal_connect (G_OBJECT (mask), "removed",
|
||||
G_CALLBACK (qmask_removed_callback),
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
edit_qmask_channel_query (GimpDisplay *gdisp)
|
||||
{
|
||||
|
@ -399,3 +336,37 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
}
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
#include "display-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpchannel.h"
|
||||
|
@ -35,15 +33,14 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-mask.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplay-foreach.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "widgets/gimpcolorpanel.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplay-foreach.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-qmask.h"
|
||||
|
||||
#include "floating_sel.h"
|
||||
#include "qmask.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -61,7 +58,8 @@ struct _EditQmaskOptions
|
|||
};
|
||||
|
||||
|
||||
/* Prototypes */
|
||||
/* local function prototypes */
|
||||
|
||||
static void edit_qmask_channel_query (GimpDisplay *gdisp);
|
||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
|
@ -74,93 +72,18 @@ static void qmask_color_changed (GimpColorButton *button,
|
|||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
/* Actual code */
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
|
||||
qmask_buttons_update (gdisp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qmask_buttons_update (GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
g_assert (gdisp);
|
||||
g_assert (gdisp->gimage);
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (shell->qmaskon)->active)
|
||||
{
|
||||
/* Disable toggle from doing anything */
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
|
||||
/* Change the state of the buttons */
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskon),
|
||||
gdisp->gimage->qmask_state);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff),
|
||||
! gdisp->gimage->qmask_state);
|
||||
|
||||
/* Enable toggle again */
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
/* public functions */
|
||||
|
||||
gboolean
|
||||
qmask_button_press_callback (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
gimp_display_shell_qmask_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = (GimpDisplay *) data;
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
(event->button == 1))
|
||||
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
|
||||
{
|
||||
edit_qmask_channel_query (gdisp);
|
||||
|
||||
|
@ -171,65 +94,74 @@ qmask_button_press_callback (GtkWidget *widget,
|
|||
}
|
||||
|
||||
void
|
||||
qmask_deactivate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (!gdisp->gimage->qmask_state)
|
||||
if (! gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set do nothing */
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
undo_push_group_start (gimage, QMASK_UNDO);
|
||||
/* push the undo here since removing the mask will
|
||||
call the qmask_removed_callback() which will set
|
||||
the qmask_state to FALSE */
|
||||
* call the qmask_removed_callback() which will set
|
||||
* the qmask_state to FALSE
|
||||
*/
|
||||
undo_push_qmask (gimage);
|
||||
gimage_mask_load (gimage, gmask);
|
||||
gimp_image_remove_channel (gimage, gmask);
|
||||
gimage_mask_load (gimage, mask);
|
||||
gimp_image_remove_channel (gimage, mask);
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
qmask_activate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
GimpLayer *layer;
|
||||
GimpRGB color;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gdisp->gimage->qmask_state)
|
||||
if (gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
color = gimage->qmask_color;
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
gimage->qmask_state = TRUE;
|
||||
/* if the user was clever and created his own */
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -244,38 +176,43 @@ qmask_activate_callback (GtkWidget *widget,
|
|||
floating_sel_to_layer (layer);
|
||||
}
|
||||
|
||||
gmask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
mask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (gmask),
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
|
||||
gimp_get_user_context (gimage->gimp),
|
||||
TRANSPARENT_FILL);
|
||||
}
|
||||
else /* if selection */
|
||||
{
|
||||
gmask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
gimp_channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
gimp_channel_set_color (mask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
|
||||
gimage_mask_none (gimage); /* Clear the selection */
|
||||
}
|
||||
|
||||
undo_push_qmask (gimage);
|
||||
undo_push_group_end (gimage);
|
||||
gdisp->gimage->qmask_state = TRUE;
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
gdisplays_flush ();
|
||||
|
||||
/* connect to the removed signal, so the buttons get updated */
|
||||
g_signal_connect (G_OBJECT (gmask), "removed",
|
||||
g_signal_connect (G_OBJECT (mask), "removed",
|
||||
G_CALLBACK (qmask_removed_callback),
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
edit_qmask_channel_query (GimpDisplay *gdisp)
|
||||
{
|
||||
|
@ -399,3 +336,37 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
}
|
||||
|
|
|
@ -175,6 +175,7 @@ enum
|
|||
MASK_CHANGED,
|
||||
RESOLUTION_CHANGED,
|
||||
UNIT_CHANGED,
|
||||
QMASK_CHANGED,
|
||||
SELECTION_CONTROL,
|
||||
|
||||
CLEAN,
|
||||
|
@ -324,6 +325,15 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[QMASK_CHANGED] =
|
||||
g_signal_new ("qmask_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, qmask_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SELECTION_CONTROL] =
|
||||
g_signal_new ("selection_control",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -839,6 +849,28 @@ gimp_image_get_unit (const GimpImage *gimage)
|
|||
return gimage->unit;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
if (qmask_state != gimage->qmask_state)
|
||||
{
|
||||
gimage->qmask_state = qmask_state ? TRUE : FALSE;
|
||||
|
||||
gimp_image_qmask_changed (gimage);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_get_qmask_state (const GimpImage *gimage)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
return gimage->qmask_state;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc)
|
||||
|
@ -2024,6 +2056,14 @@ gimp_image_unit_changed (GimpImage *gimage)
|
|||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[UNIT_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_qmask_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[QMASK_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_alpha_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -141,6 +141,7 @@ struct _GimpImageClass
|
|||
void (* mask_changed) (GimpImage *gimage);
|
||||
void (* resolution_changed) (GimpImage *gimage);
|
||||
void (* unit_changed) (GimpImage *gimage);
|
||||
void (* qmask_changed) (GimpImage *gimage);
|
||||
void (* selection_control) (GimpImage *gimage,
|
||||
GimpSelectionControl control);
|
||||
|
||||
|
@ -185,11 +186,18 @@ void gimp_image_get_resolution (const GimpImage *gimage,
|
|||
void gimp_image_set_unit (GimpImage *gimage,
|
||||
GimpUnit unit);
|
||||
GimpUnit gimp_image_get_unit (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state);
|
||||
gboolean gimp_image_get_qmask_state (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc);
|
||||
PlugInProcDef * gimp_image_get_save_proc (const GimpImage *gimage);
|
||||
|
||||
gint gimp_image_get_width (const GimpImage *gimage);
|
||||
gint gimp_image_get_height (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_resize (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
|
@ -201,11 +209,13 @@ void gimp_image_scale (GimpImage *gimage,
|
|||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bpp);
|
||||
void gimp_image_free_shadow (GimpImage *gimage);
|
||||
|
||||
void gimp_image_apply_image (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *src2PR,
|
||||
|
@ -223,6 +233,7 @@ void gimp_image_replace_image (GimpImage *gimage,
|
|||
PixelRegion *maskPR,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
void gimp_image_get_foreground (const GimpImage *gimage,
|
||||
const GimpDrawable *drawable,
|
||||
guchar *fg);
|
||||
|
@ -241,6 +252,7 @@ void gimp_image_transform_color (const GimpImage *gimage,
|
|||
guchar *src,
|
||||
guchar *dest,
|
||||
GimpImageBaseType type);
|
||||
|
||||
GimpGuide * gimp_image_add_hguide (GimpImage *gimage);
|
||||
GimpGuide * gimp_image_add_vguide (GimpImage *gimage);
|
||||
void gimp_image_add_guide (GimpImage *gimage,
|
||||
|
@ -298,6 +310,7 @@ void gimp_image_floating_selection_changed (GimpImage *gimage);
|
|||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
void gimp_image_resolution_changed (GimpImage *gimage);
|
||||
void gimp_image_unit_changed (GimpImage *gimage);
|
||||
void gimp_image_qmask_changed (GimpImage *gimage);
|
||||
void gimp_image_update (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
|
|
|
@ -175,6 +175,7 @@ enum
|
|||
MASK_CHANGED,
|
||||
RESOLUTION_CHANGED,
|
||||
UNIT_CHANGED,
|
||||
QMASK_CHANGED,
|
||||
SELECTION_CONTROL,
|
||||
|
||||
CLEAN,
|
||||
|
@ -324,6 +325,15 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[QMASK_CHANGED] =
|
||||
g_signal_new ("qmask_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, qmask_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SELECTION_CONTROL] =
|
||||
g_signal_new ("selection_control",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -839,6 +849,28 @@ gimp_image_get_unit (const GimpImage *gimage)
|
|||
return gimage->unit;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
if (qmask_state != gimage->qmask_state)
|
||||
{
|
||||
gimage->qmask_state = qmask_state ? TRUE : FALSE;
|
||||
|
||||
gimp_image_qmask_changed (gimage);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_get_qmask_state (const GimpImage *gimage)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
return gimage->qmask_state;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc)
|
||||
|
@ -2024,6 +2056,14 @@ gimp_image_unit_changed (GimpImage *gimage)
|
|||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[UNIT_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_qmask_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[QMASK_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_alpha_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -141,6 +141,7 @@ struct _GimpImageClass
|
|||
void (* mask_changed) (GimpImage *gimage);
|
||||
void (* resolution_changed) (GimpImage *gimage);
|
||||
void (* unit_changed) (GimpImage *gimage);
|
||||
void (* qmask_changed) (GimpImage *gimage);
|
||||
void (* selection_control) (GimpImage *gimage,
|
||||
GimpSelectionControl control);
|
||||
|
||||
|
@ -185,11 +186,18 @@ void gimp_image_get_resolution (const GimpImage *gimage,
|
|||
void gimp_image_set_unit (GimpImage *gimage,
|
||||
GimpUnit unit);
|
||||
GimpUnit gimp_image_get_unit (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state);
|
||||
gboolean gimp_image_get_qmask_state (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc);
|
||||
PlugInProcDef * gimp_image_get_save_proc (const GimpImage *gimage);
|
||||
|
||||
gint gimp_image_get_width (const GimpImage *gimage);
|
||||
gint gimp_image_get_height (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_resize (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
|
@ -201,11 +209,13 @@ void gimp_image_scale (GimpImage *gimage,
|
|||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bpp);
|
||||
void gimp_image_free_shadow (GimpImage *gimage);
|
||||
|
||||
void gimp_image_apply_image (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *src2PR,
|
||||
|
@ -223,6 +233,7 @@ void gimp_image_replace_image (GimpImage *gimage,
|
|||
PixelRegion *maskPR,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
void gimp_image_get_foreground (const GimpImage *gimage,
|
||||
const GimpDrawable *drawable,
|
||||
guchar *fg);
|
||||
|
@ -241,6 +252,7 @@ void gimp_image_transform_color (const GimpImage *gimage,
|
|||
guchar *src,
|
||||
guchar *dest,
|
||||
GimpImageBaseType type);
|
||||
|
||||
GimpGuide * gimp_image_add_hguide (GimpImage *gimage);
|
||||
GimpGuide * gimp_image_add_vguide (GimpImage *gimage);
|
||||
void gimp_image_add_guide (GimpImage *gimage,
|
||||
|
@ -298,6 +310,7 @@ void gimp_image_floating_selection_changed (GimpImage *gimage);
|
|||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
void gimp_image_resolution_changed (GimpImage *gimage);
|
||||
void gimp_image_unit_changed (GimpImage *gimage);
|
||||
void gimp_image_qmask_changed (GimpImage *gimage);
|
||||
void gimp_image_update (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
|
|
|
@ -175,6 +175,7 @@ enum
|
|||
MASK_CHANGED,
|
||||
RESOLUTION_CHANGED,
|
||||
UNIT_CHANGED,
|
||||
QMASK_CHANGED,
|
||||
SELECTION_CONTROL,
|
||||
|
||||
CLEAN,
|
||||
|
@ -324,6 +325,15 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[QMASK_CHANGED] =
|
||||
g_signal_new ("qmask_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, qmask_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SELECTION_CONTROL] =
|
||||
g_signal_new ("selection_control",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -839,6 +849,28 @@ gimp_image_get_unit (const GimpImage *gimage)
|
|||
return gimage->unit;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
if (qmask_state != gimage->qmask_state)
|
||||
{
|
||||
gimage->qmask_state = qmask_state ? TRUE : FALSE;
|
||||
|
||||
gimp_image_qmask_changed (gimage);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_get_qmask_state (const GimpImage *gimage)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
return gimage->qmask_state;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc)
|
||||
|
@ -2024,6 +2056,14 @@ gimp_image_unit_changed (GimpImage *gimage)
|
|||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[UNIT_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_qmask_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[QMASK_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_alpha_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -141,6 +141,7 @@ struct _GimpImageClass
|
|||
void (* mask_changed) (GimpImage *gimage);
|
||||
void (* resolution_changed) (GimpImage *gimage);
|
||||
void (* unit_changed) (GimpImage *gimage);
|
||||
void (* qmask_changed) (GimpImage *gimage);
|
||||
void (* selection_control) (GimpImage *gimage,
|
||||
GimpSelectionControl control);
|
||||
|
||||
|
@ -185,11 +186,18 @@ void gimp_image_get_resolution (const GimpImage *gimage,
|
|||
void gimp_image_set_unit (GimpImage *gimage,
|
||||
GimpUnit unit);
|
||||
GimpUnit gimp_image_get_unit (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state);
|
||||
gboolean gimp_image_get_qmask_state (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc);
|
||||
PlugInProcDef * gimp_image_get_save_proc (const GimpImage *gimage);
|
||||
|
||||
gint gimp_image_get_width (const GimpImage *gimage);
|
||||
gint gimp_image_get_height (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_resize (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
|
@ -201,11 +209,13 @@ void gimp_image_scale (GimpImage *gimage,
|
|||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bpp);
|
||||
void gimp_image_free_shadow (GimpImage *gimage);
|
||||
|
||||
void gimp_image_apply_image (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *src2PR,
|
||||
|
@ -223,6 +233,7 @@ void gimp_image_replace_image (GimpImage *gimage,
|
|||
PixelRegion *maskPR,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
void gimp_image_get_foreground (const GimpImage *gimage,
|
||||
const GimpDrawable *drawable,
|
||||
guchar *fg);
|
||||
|
@ -241,6 +252,7 @@ void gimp_image_transform_color (const GimpImage *gimage,
|
|||
guchar *src,
|
||||
guchar *dest,
|
||||
GimpImageBaseType type);
|
||||
|
||||
GimpGuide * gimp_image_add_hguide (GimpImage *gimage);
|
||||
GimpGuide * gimp_image_add_vguide (GimpImage *gimage);
|
||||
void gimp_image_add_guide (GimpImage *gimage,
|
||||
|
@ -298,6 +310,7 @@ void gimp_image_floating_selection_changed (GimpImage *gimage);
|
|||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
void gimp_image_resolution_changed (GimpImage *gimage);
|
||||
void gimp_image_unit_changed (GimpImage *gimage);
|
||||
void gimp_image_qmask_changed (GimpImage *gimage);
|
||||
void gimp_image_update (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
|
|
|
@ -175,6 +175,7 @@ enum
|
|||
MASK_CHANGED,
|
||||
RESOLUTION_CHANGED,
|
||||
UNIT_CHANGED,
|
||||
QMASK_CHANGED,
|
||||
SELECTION_CONTROL,
|
||||
|
||||
CLEAN,
|
||||
|
@ -324,6 +325,15 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[QMASK_CHANGED] =
|
||||
g_signal_new ("qmask_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, qmask_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gimp_image_signals[SELECTION_CONTROL] =
|
||||
g_signal_new ("selection_control",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -839,6 +849,28 @@ gimp_image_get_unit (const GimpImage *gimage)
|
|||
return gimage->unit;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
if (qmask_state != gimage->qmask_state)
|
||||
{
|
||||
gimage->qmask_state = qmask_state ? TRUE : FALSE;
|
||||
|
||||
gimp_image_qmask_changed (gimage);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_get_qmask_state (const GimpImage *gimage)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
|
||||
return gimage->qmask_state;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc)
|
||||
|
@ -2024,6 +2056,14 @@ gimp_image_unit_changed (GimpImage *gimage)
|
|||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[UNIT_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_qmask_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[QMASK_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_alpha_changed (GimpImage *gimage)
|
||||
{
|
||||
|
|
|
@ -141,6 +141,7 @@ struct _GimpImageClass
|
|||
void (* mask_changed) (GimpImage *gimage);
|
||||
void (* resolution_changed) (GimpImage *gimage);
|
||||
void (* unit_changed) (GimpImage *gimage);
|
||||
void (* qmask_changed) (GimpImage *gimage);
|
||||
void (* selection_control) (GimpImage *gimage,
|
||||
GimpSelectionControl control);
|
||||
|
||||
|
@ -185,11 +186,18 @@ void gimp_image_get_resolution (const GimpImage *gimage,
|
|||
void gimp_image_set_unit (GimpImage *gimage,
|
||||
GimpUnit unit);
|
||||
GimpUnit gimp_image_get_unit (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_qmask_state (GimpImage *gimage,
|
||||
gboolean qmask_state);
|
||||
gboolean gimp_image_get_qmask_state (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_set_save_proc (GimpImage *gimage,
|
||||
PlugInProcDef *proc);
|
||||
PlugInProcDef * gimp_image_get_save_proc (const GimpImage *gimage);
|
||||
|
||||
gint gimp_image_get_width (const GimpImage *gimage);
|
||||
gint gimp_image_get_height (const GimpImage *gimage);
|
||||
|
||||
void gimp_image_resize (GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height,
|
||||
|
@ -201,11 +209,13 @@ void gimp_image_scale (GimpImage *gimage,
|
|||
gboolean gimp_image_check_scaling (const GimpImage *gimage,
|
||||
gint new_width,
|
||||
gint new_height);
|
||||
|
||||
TileManager * gimp_image_shadow (GimpImage *gimage,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bpp);
|
||||
void gimp_image_free_shadow (GimpImage *gimage);
|
||||
|
||||
void gimp_image_apply_image (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *src2PR,
|
||||
|
@ -223,6 +233,7 @@ void gimp_image_replace_image (GimpImage *gimage,
|
|||
PixelRegion *maskPR,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
void gimp_image_get_foreground (const GimpImage *gimage,
|
||||
const GimpDrawable *drawable,
|
||||
guchar *fg);
|
||||
|
@ -241,6 +252,7 @@ void gimp_image_transform_color (const GimpImage *gimage,
|
|||
guchar *src,
|
||||
guchar *dest,
|
||||
GimpImageBaseType type);
|
||||
|
||||
GimpGuide * gimp_image_add_hguide (GimpImage *gimage);
|
||||
GimpGuide * gimp_image_add_vguide (GimpImage *gimage);
|
||||
void gimp_image_add_guide (GimpImage *gimage,
|
||||
|
@ -298,6 +310,7 @@ void gimp_image_floating_selection_changed (GimpImage *gimage);
|
|||
void gimp_image_mask_changed (GimpImage *gimage);
|
||||
void gimp_image_resolution_changed (GimpImage *gimage);
|
||||
void gimp_image_unit_changed (GimpImage *gimage);
|
||||
void gimp_image_qmask_changed (GimpImage *gimage);
|
||||
void gimp_image_update (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "gimprc.h"
|
||||
#include "nav_window.h"
|
||||
#include "plug_in.h"
|
||||
#include "qmask.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
@ -475,9 +474,6 @@ gimp_display_flush_whenever (GimpDisplay *gdisp,
|
|||
/* update the gdisplay's info dialog */
|
||||
info_window_update (gdisp);
|
||||
|
||||
/* update the gdisplay's qmask buttons */
|
||||
qmask_buttons_update (gdisp);
|
||||
|
||||
/* ensure the consistency of the tear-off menus */
|
||||
if (! now && gimp_context_get_display (gimp_get_user_context
|
||||
(gdisp->gimage->gimp)) == gdisp)
|
||||
|
|
|
@ -21,8 +21,12 @@ libappdisplay_a_SOURCES = @STRIP_BEGIN@ \
|
|||
gimpdisplayshell-callbacks.h \
|
||||
gimpdisplayshell-dnd.c \
|
||||
gimpdisplayshell-dnd.h \
|
||||
gimpdisplayshell-handlers.c \
|
||||
gimpdisplayshell-handlers.h \
|
||||
gimpdisplayshell-layer-select.c \
|
||||
gimpdisplayshell-layer-select.h \
|
||||
gimpdisplayshell-qmask.c \
|
||||
gimpdisplayshell-qmask.h \
|
||||
gimpdisplayshell-render.c \
|
||||
gimpdisplayshell-render.h \
|
||||
gimpdisplayshell-scale.c \
|
||||
|
|
|
@ -26,36 +26,26 @@
|
|||
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplay-handlers.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-scale.h"
|
||||
|
||||
#include "gimprc.h"
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_display_update_title_handler (GimpImage *gimage,
|
||||
gpointer data);
|
||||
static void gimp_display_update_handler (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h,
|
||||
gpointer data);
|
||||
static void gimp_display_selection_control_handler (GimpImage *gimage,
|
||||
GimpSelectionControl control,
|
||||
gpointer data);
|
||||
static void gimp_display_mode_changed_handler (GimpImage *gimage,
|
||||
gpointer data);
|
||||
static void gimp_display_colormap_changed_handler (GimpImage *gimage,
|
||||
gint ncol,
|
||||
gpointer data);
|
||||
static void gimp_display_size_changed_handler (GimpImage *gimage,
|
||||
gpointer data);
|
||||
static void gimp_display_resolution_changed_handler (GimpImage *gimage,
|
||||
gpointer data);
|
||||
static void gimp_display_unit_changed_handler (GimpImage *gimage,
|
||||
gpointer data);
|
||||
static void gimp_display_update_handler (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_display_selection_control_handler (GimpImage *gimage,
|
||||
GimpSelectionControl control,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_display_mode_changed_handler (GimpImage *gimage,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_display_colormap_changed_handler (GimpImage *gimage,
|
||||
gint ncol,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_display_size_changed_handler (GimpImage *gimage,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -76,16 +66,6 @@ gimp_display_connect (GimpDisplay *gdisp,
|
|||
|
||||
g_object_ref (G_OBJECT (gimage));
|
||||
|
||||
g_signal_connect (G_OBJECT (gimage), "dirty",
|
||||
G_CALLBACK (gimp_display_update_title_handler),
|
||||
gdisp);
|
||||
g_signal_connect (G_OBJECT (gimage), "clean",
|
||||
G_CALLBACK (gimp_display_update_title_handler),
|
||||
gdisp);
|
||||
g_signal_connect (G_OBJECT (gimage), "name_changed",
|
||||
G_CALLBACK (gimp_display_update_title_handler),
|
||||
gdisp);
|
||||
|
||||
g_signal_connect (G_OBJECT (gimage), "update",
|
||||
G_CALLBACK (gimp_display_update_handler),
|
||||
gdisp);
|
||||
|
@ -101,12 +81,6 @@ gimp_display_connect (GimpDisplay *gdisp,
|
|||
g_signal_connect (G_OBJECT (gimage), "size_changed",
|
||||
G_CALLBACK (gimp_display_size_changed_handler),
|
||||
gdisp);
|
||||
g_signal_connect (G_OBJECT (gimage), "resolution_changed",
|
||||
G_CALLBACK (gimp_display_resolution_changed_handler),
|
||||
gdisp);
|
||||
g_signal_connect (G_OBJECT (gimage), "unit_changed",
|
||||
G_CALLBACK (gimp_display_unit_changed_handler),
|
||||
gdisp);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -115,12 +89,6 @@ gimp_display_disconnect (GimpDisplay *gdisp)
|
|||
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gdisp->gimage));
|
||||
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (gdisp->gimage),
|
||||
gimp_display_unit_changed_handler,
|
||||
gdisp);
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (gdisp->gimage),
|
||||
gimp_display_resolution_changed_handler,
|
||||
gdisp);
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (gdisp->gimage),
|
||||
gimp_display_size_changed_handler,
|
||||
gdisp);
|
||||
|
@ -137,10 +105,6 @@ gimp_display_disconnect (GimpDisplay *gdisp)
|
|||
gimp_display_update_handler,
|
||||
gdisp);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (gdisp->gimage),
|
||||
gimp_display_update_title_handler,
|
||||
gdisp);
|
||||
|
||||
gdisp->gimage->disp_count--;
|
||||
|
||||
g_object_unref (G_OBJECT (gdisp->gimage));
|
||||
|
@ -151,51 +115,28 @@ gimp_display_disconnect (GimpDisplay *gdisp)
|
|||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_display_update_title_handler (GimpImage *gimage,
|
||||
gpointer data)
|
||||
gimp_display_update_handler (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = GIMP_DISPLAY (data);
|
||||
|
||||
gimp_display_shell_update_title (GIMP_DISPLAY_SHELL (gdisp->shell));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_update_handler (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = GIMP_DISPLAY (data);
|
||||
|
||||
gdisplay_add_update_area (gdisp, x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_selection_control_handler (GimpImage *gimage,
|
||||
GimpSelectionControl control,
|
||||
gpointer data)
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = GIMP_DISPLAY (data);
|
||||
|
||||
gdisplay_selection_visibility (gdisp, control);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_mode_changed_handler (GimpImage *gimage,
|
||||
gpointer data)
|
||||
gimp_display_mode_changed_handler (GimpImage *gimage,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = GIMP_DISPLAY (data);
|
||||
|
||||
gdisplay_add_update_area (gdisp,
|
||||
0, 0,
|
||||
gdisp->gimage->width,
|
||||
|
@ -203,14 +144,10 @@ gimp_display_mode_changed_handler (GimpImage *gimage,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_display_colormap_changed_handler (GimpImage *gimage,
|
||||
gint ncol,
|
||||
gpointer data)
|
||||
gimp_display_colormap_changed_handler (GimpImage *gimage,
|
||||
gint ncol,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = GIMP_DISPLAY (data);
|
||||
|
||||
if (gimp_image_base_type (gdisp->gimage) == INDEXED)
|
||||
gdisplay_add_update_area (gdisp,
|
||||
0, 0,
|
||||
|
@ -219,44 +156,11 @@ gimp_display_colormap_changed_handler (GimpImage *gimage,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_display_size_changed_handler (GimpImage *gimage,
|
||||
gpointer data)
|
||||
gimp_display_size_changed_handler (GimpImage *gimage,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = GIMP_DISPLAY (data);
|
||||
|
||||
gdisplay_add_update_area (gdisp,
|
||||
0, 0,
|
||||
gdisp->gimage->width,
|
||||
gdisp->gimage->height);
|
||||
|
||||
gimp_display_shell_resize_cursor_label (GIMP_DISPLAY_SHELL (gdisp->shell));
|
||||
|
||||
gimp_display_shell_scale_resize (GIMP_DISPLAY_SHELL (gdisp->shell),
|
||||
gimprc.allow_resize_windows, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_resolution_changed_handler (GimpImage *gimage,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = GIMP_DISPLAY (data);
|
||||
|
||||
gimp_display_shell_scale_setup (GIMP_DISPLAY_SHELL (gdisp->shell));
|
||||
gimp_display_shell_resize_cursor_label (GIMP_DISPLAY_SHELL (gdisp->shell));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_unit_changed_handler (GimpImage *gimage,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = GIMP_DISPLAY (data);
|
||||
|
||||
gimp_display_shell_scale_setup (GIMP_DISPLAY_SHELL (gdisp->shell));
|
||||
gimp_display_shell_resize_cursor_label (GIMP_DISPLAY_SHELL (gdisp->shell));
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "gimprc.h"
|
||||
#include "nav_window.h"
|
||||
#include "plug_in.h"
|
||||
#include "qmask.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
@ -475,9 +474,6 @@ gimp_display_flush_whenever (GimpDisplay *gdisp,
|
|||
/* update the gdisplay's info dialog */
|
||||
info_window_update (gdisp);
|
||||
|
||||
/* update the gdisplay's qmask buttons */
|
||||
qmask_buttons_update (gdisp);
|
||||
|
||||
/* ensure the consistency of the tear-off menus */
|
||||
if (! now && gimp_context_get_display (gimp_get_user_context
|
||||
(gdisp->gimage->gimp)) == gdisp)
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-callbacks.h"
|
||||
#include "gimpdisplayshell-dnd.h"
|
||||
#include "gimpdisplayshell-handlers.h"
|
||||
#include "gimpdisplayshell-qmask.h"
|
||||
#include "gimpdisplayshell-render.h"
|
||||
#include "gximage.h"
|
||||
|
||||
|
@ -59,7 +61,6 @@
|
|||
#include "gimprc.h"
|
||||
#include "nav_window.h"
|
||||
#include "plug_in.h"
|
||||
#include "qmask.h"
|
||||
#include "undo.h"
|
||||
|
||||
#ifdef DISPLAY_FILTERS
|
||||
|
@ -243,6 +244,11 @@ gimp_display_shell_destroy (GtkObject *object)
|
|||
|
||||
shell = GIMP_DISPLAY_SHELL (object);
|
||||
|
||||
if (shell->gdisp)
|
||||
{
|
||||
gimp_display_shell_disconnect (shell);
|
||||
}
|
||||
|
||||
shell->display_areas = gimp_display_area_list_free (shell->display_areas);
|
||||
|
||||
#ifdef DISPLAY_FILTERS
|
||||
|
@ -298,6 +304,8 @@ gimp_display_shell_destroy (GtkObject *object)
|
|||
shell->nav_popup = NULL;
|
||||
}
|
||||
|
||||
shell->gdisp = NULL;
|
||||
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
|
@ -624,18 +632,18 @@ gimp_display_shell_new (GimpDisplay *gdisp)
|
|||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff), TRUE);
|
||||
|
||||
g_signal_connect (G_OBJECT (shell->qmaskoff), "toggled",
|
||||
G_CALLBACK (qmask_deactivate_callback),
|
||||
gdisp);
|
||||
G_CALLBACK (gimp_display_shell_qmask_off_toggled),
|
||||
shell);
|
||||
g_signal_connect (G_OBJECT (shell->qmaskoff), "button_press_event",
|
||||
G_CALLBACK (qmask_button_press_callback),
|
||||
gdisp);
|
||||
G_CALLBACK (gimp_display_shell_qmask_button_press),
|
||||
shell);
|
||||
|
||||
g_signal_connect (G_OBJECT (shell->qmaskon), "toggled",
|
||||
G_CALLBACK (qmask_activate_callback),
|
||||
gdisp);
|
||||
G_CALLBACK (gimp_display_shell_qmask_on_toggled),
|
||||
shell);
|
||||
g_signal_connect (G_OBJECT (shell->qmaskon), "button_press_event",
|
||||
G_CALLBACK (qmask_button_press_callback),
|
||||
gdisp);
|
||||
G_CALLBACK (gimp_display_shell_qmask_button_press),
|
||||
shell);
|
||||
|
||||
gimp_help_set_help_data (shell->qmaskon, NULL, "#qmask_on_button");
|
||||
|
||||
|
@ -744,6 +752,8 @@ gimp_display_shell_new (GimpDisplay *gdisp)
|
|||
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
gimp_display_shell_connect (shell);
|
||||
|
||||
return GTK_WIDGET (shell);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
/* 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 "core/gimpimage.h"
|
||||
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-handlers.h"
|
||||
#include "gimpdisplayshell-qmask.h"
|
||||
#include "gimpdisplayshell-scale.h"
|
||||
|
||||
#include "gimprc.h"
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_display_shell_update_title_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_size_changed_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_resolution_changed_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_unit_changed_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_qmask_changed_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
gimp_display_shell_connect (GimpDisplayShell *shell)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
g_return_if_fail (GIMP_IS_DISPLAY (shell->gdisp));
|
||||
g_return_if_fail (GIMP_IS_IMAGE (shell->gdisp->gimage));
|
||||
|
||||
gimage = shell->gdisp->gimage;
|
||||
|
||||
g_signal_connect (G_OBJECT (gimage), "dirty",
|
||||
G_CALLBACK (gimp_display_shell_update_title_handler),
|
||||
shell);
|
||||
g_signal_connect (G_OBJECT (gimage), "clean",
|
||||
G_CALLBACK (gimp_display_shell_update_title_handler),
|
||||
shell);
|
||||
g_signal_connect (G_OBJECT (gimage), "name_changed",
|
||||
G_CALLBACK (gimp_display_shell_update_title_handler),
|
||||
shell);
|
||||
|
||||
g_signal_connect (G_OBJECT (gimage), "size_changed",
|
||||
G_CALLBACK (gimp_display_shell_size_changed_handler),
|
||||
shell);
|
||||
g_signal_connect (G_OBJECT (gimage), "resolution_changed",
|
||||
G_CALLBACK (gimp_display_shell_resolution_changed_handler),
|
||||
shell);
|
||||
g_signal_connect (G_OBJECT (gimage), "unit_changed",
|
||||
G_CALLBACK (gimp_display_shell_unit_changed_handler),
|
||||
shell);
|
||||
g_signal_connect (G_OBJECT (gimage), "qmask_changed",
|
||||
G_CALLBACK (gimp_display_shell_qmask_changed_handler),
|
||||
shell);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_disconnect (GimpDisplayShell *shell)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
g_return_if_fail (GIMP_IS_DISPLAY (shell->gdisp));
|
||||
g_return_if_fail (GIMP_IS_IMAGE (shell->gdisp->gimage));
|
||||
|
||||
gimage = shell->gdisp->gimage;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (gimage),
|
||||
gimp_display_shell_qmask_changed_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (gimage),
|
||||
gimp_display_shell_unit_changed_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (gimage),
|
||||
gimp_display_shell_resolution_changed_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (gimage),
|
||||
gimp_display_shell_size_changed_handler,
|
||||
shell);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (gimage),
|
||||
gimp_display_shell_update_title,
|
||||
shell);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_display_shell_update_title_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
gimp_display_shell_update_title (shell);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_size_changed_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
gimp_display_shell_resize_cursor_label (shell);
|
||||
gimp_display_shell_scale_resize (shell, gimprc.allow_resize_windows, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_resolution_changed_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
gimp_display_shell_scale_setup (shell);
|
||||
gimp_display_shell_resize_cursor_label (shell);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_unit_changed_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
gimp_display_shell_scale_setup (shell);
|
||||
gimp_display_shell_resize_cursor_label (shell);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_qmask_changed_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
if (shell->gdisp->gimage->qmask_state !=
|
||||
GTK_TOGGLE_BUTTON (shell->qmaskon)->active)
|
||||
{
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskon),
|
||||
gimp_display_shell_qmask_on_toggled,
|
||||
shell);
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskoff),
|
||||
gimp_display_shell_qmask_off_toggled,
|
||||
shell);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskon),
|
||||
shell->gdisp->gimage->qmask_state);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff),
|
||||
! shell->gdisp->gimage->qmask_state);
|
||||
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskon),
|
||||
gimp_display_shell_qmask_on_toggled,
|
||||
shell);
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskoff),
|
||||
gimp_display_shell_qmask_off_toggled,
|
||||
shell);
|
||||
}
|
||||
}
|
|
@ -16,18 +16,12 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __QMASK_H__
|
||||
#define __QMASK_H__
|
||||
#ifndef __GIMP_DISPLAY_SHELL_HANDLERS_H__
|
||||
#define __GIMP_DISPLAY_SHELL_HANDLERS_H__
|
||||
|
||||
|
||||
gboolean qmask_button_press_callback (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data);
|
||||
void qmask_activate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp);
|
||||
void qmask_deactivate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp);
|
||||
void qmask_buttons_update (GimpDisplay *gdisp);
|
||||
void gimp_display_shell_connect (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_disconnect (GimpDisplayShell *shell);
|
||||
|
||||
|
||||
#endif /* __QMASK_H__ */
|
||||
#endif /* __GIMP_DISPLAY_SHELL_HANDLERS_H__ */
|
|
@ -19,15 +19,13 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
#include "display-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpchannel.h"
|
||||
|
@ -35,15 +33,14 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-mask.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplay-foreach.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "widgets/gimpcolorpanel.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplay-foreach.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-qmask.h"
|
||||
|
||||
#include "floating_sel.h"
|
||||
#include "qmask.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -61,7 +58,8 @@ struct _EditQmaskOptions
|
|||
};
|
||||
|
||||
|
||||
/* Prototypes */
|
||||
/* local function prototypes */
|
||||
|
||||
static void edit_qmask_channel_query (GimpDisplay *gdisp);
|
||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
|
@ -74,93 +72,18 @@ static void qmask_color_changed (GimpColorButton *button,
|
|||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
/* Actual code */
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
|
||||
qmask_buttons_update (gdisp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qmask_buttons_update (GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
g_assert (gdisp);
|
||||
g_assert (gdisp->gimage);
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (shell->qmaskon)->active)
|
||||
{
|
||||
/* Disable toggle from doing anything */
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
|
||||
/* Change the state of the buttons */
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskon),
|
||||
gdisp->gimage->qmask_state);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff),
|
||||
! gdisp->gimage->qmask_state);
|
||||
|
||||
/* Enable toggle again */
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
/* public functions */
|
||||
|
||||
gboolean
|
||||
qmask_button_press_callback (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
gimp_display_shell_qmask_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = (GimpDisplay *) data;
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
(event->button == 1))
|
||||
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
|
||||
{
|
||||
edit_qmask_channel_query (gdisp);
|
||||
|
||||
|
@ -171,65 +94,74 @@ qmask_button_press_callback (GtkWidget *widget,
|
|||
}
|
||||
|
||||
void
|
||||
qmask_deactivate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (!gdisp->gimage->qmask_state)
|
||||
if (! gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set do nothing */
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
undo_push_group_start (gimage, QMASK_UNDO);
|
||||
/* push the undo here since removing the mask will
|
||||
call the qmask_removed_callback() which will set
|
||||
the qmask_state to FALSE */
|
||||
* call the qmask_removed_callback() which will set
|
||||
* the qmask_state to FALSE
|
||||
*/
|
||||
undo_push_qmask (gimage);
|
||||
gimage_mask_load (gimage, gmask);
|
||||
gimp_image_remove_channel (gimage, gmask);
|
||||
gimage_mask_load (gimage, mask);
|
||||
gimp_image_remove_channel (gimage, mask);
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
qmask_activate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
GimpLayer *layer;
|
||||
GimpRGB color;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gdisp->gimage->qmask_state)
|
||||
if (gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
color = gimage->qmask_color;
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
gimage->qmask_state = TRUE;
|
||||
/* if the user was clever and created his own */
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -244,38 +176,43 @@ qmask_activate_callback (GtkWidget *widget,
|
|||
floating_sel_to_layer (layer);
|
||||
}
|
||||
|
||||
gmask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
mask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (gmask),
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
|
||||
gimp_get_user_context (gimage->gimp),
|
||||
TRANSPARENT_FILL);
|
||||
}
|
||||
else /* if selection */
|
||||
{
|
||||
gmask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
gimp_channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
gimp_channel_set_color (mask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
|
||||
gimage_mask_none (gimage); /* Clear the selection */
|
||||
}
|
||||
|
||||
undo_push_qmask (gimage);
|
||||
undo_push_group_end (gimage);
|
||||
gdisp->gimage->qmask_state = TRUE;
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
gdisplays_flush ();
|
||||
|
||||
/* connect to the removed signal, so the buttons get updated */
|
||||
g_signal_connect (G_OBJECT (gmask), "removed",
|
||||
g_signal_connect (G_OBJECT (mask), "removed",
|
||||
G_CALLBACK (qmask_removed_callback),
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
edit_qmask_channel_query (GimpDisplay *gdisp)
|
||||
{
|
||||
|
@ -399,3 +336,37 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
}
|
||||
|
|
|
@ -16,18 +16,17 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __QMASK_H__
|
||||
#define __QMASK_H__
|
||||
#ifndef __GIMP_DISPLAY_SHELL_QMASK_H__
|
||||
#define __GIMP_DISPLAY_SHELL_QMASK_H__
|
||||
|
||||
|
||||
gboolean qmask_button_press_callback (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data);
|
||||
void qmask_activate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp);
|
||||
void qmask_deactivate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp);
|
||||
void qmask_buttons_update (GimpDisplay *gdisp);
|
||||
gboolean gimp_display_shell_qmask_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
GimpDisplayShell *shell);
|
||||
void gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell);
|
||||
void gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell);
|
||||
|
||||
|
||||
#endif /* __QMASK_H__ */
|
||||
#endif /* __GIMP_DISPLAY_SHELL_QMASK_H__ */
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-callbacks.h"
|
||||
#include "gimpdisplayshell-dnd.h"
|
||||
#include "gimpdisplayshell-handlers.h"
|
||||
#include "gimpdisplayshell-qmask.h"
|
||||
#include "gimpdisplayshell-render.h"
|
||||
#include "gximage.h"
|
||||
|
||||
|
@ -59,7 +61,6 @@
|
|||
#include "gimprc.h"
|
||||
#include "nav_window.h"
|
||||
#include "plug_in.h"
|
||||
#include "qmask.h"
|
||||
#include "undo.h"
|
||||
|
||||
#ifdef DISPLAY_FILTERS
|
||||
|
@ -243,6 +244,11 @@ gimp_display_shell_destroy (GtkObject *object)
|
|||
|
||||
shell = GIMP_DISPLAY_SHELL (object);
|
||||
|
||||
if (shell->gdisp)
|
||||
{
|
||||
gimp_display_shell_disconnect (shell);
|
||||
}
|
||||
|
||||
shell->display_areas = gimp_display_area_list_free (shell->display_areas);
|
||||
|
||||
#ifdef DISPLAY_FILTERS
|
||||
|
@ -298,6 +304,8 @@ gimp_display_shell_destroy (GtkObject *object)
|
|||
shell->nav_popup = NULL;
|
||||
}
|
||||
|
||||
shell->gdisp = NULL;
|
||||
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
|
@ -624,18 +632,18 @@ gimp_display_shell_new (GimpDisplay *gdisp)
|
|||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff), TRUE);
|
||||
|
||||
g_signal_connect (G_OBJECT (shell->qmaskoff), "toggled",
|
||||
G_CALLBACK (qmask_deactivate_callback),
|
||||
gdisp);
|
||||
G_CALLBACK (gimp_display_shell_qmask_off_toggled),
|
||||
shell);
|
||||
g_signal_connect (G_OBJECT (shell->qmaskoff), "button_press_event",
|
||||
G_CALLBACK (qmask_button_press_callback),
|
||||
gdisp);
|
||||
G_CALLBACK (gimp_display_shell_qmask_button_press),
|
||||
shell);
|
||||
|
||||
g_signal_connect (G_OBJECT (shell->qmaskon), "toggled",
|
||||
G_CALLBACK (qmask_activate_callback),
|
||||
gdisp);
|
||||
G_CALLBACK (gimp_display_shell_qmask_on_toggled),
|
||||
shell);
|
||||
g_signal_connect (G_OBJECT (shell->qmaskon), "button_press_event",
|
||||
G_CALLBACK (qmask_button_press_callback),
|
||||
gdisp);
|
||||
G_CALLBACK (gimp_display_shell_qmask_button_press),
|
||||
shell);
|
||||
|
||||
gimp_help_set_help_data (shell->qmaskon, NULL, "#qmask_on_button");
|
||||
|
||||
|
@ -744,6 +752,8 @@ gimp_display_shell_new (GimpDisplay *gdisp)
|
|||
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
gimp_display_shell_connect (shell);
|
||||
|
||||
return GTK_WIDGET (shell);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
#include "display-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpchannel.h"
|
||||
|
@ -35,15 +33,14 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-mask.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplay-foreach.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "widgets/gimpcolorpanel.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplay-foreach.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-qmask.h"
|
||||
|
||||
#include "floating_sel.h"
|
||||
#include "qmask.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -61,7 +58,8 @@ struct _EditQmaskOptions
|
|||
};
|
||||
|
||||
|
||||
/* Prototypes */
|
||||
/* local function prototypes */
|
||||
|
||||
static void edit_qmask_channel_query (GimpDisplay *gdisp);
|
||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
|
@ -74,93 +72,18 @@ static void qmask_color_changed (GimpColorButton *button,
|
|||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
/* Actual code */
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
|
||||
qmask_buttons_update (gdisp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qmask_buttons_update (GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
g_assert (gdisp);
|
||||
g_assert (gdisp->gimage);
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (shell->qmaskon)->active)
|
||||
{
|
||||
/* Disable toggle from doing anything */
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
|
||||
/* Change the state of the buttons */
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskon),
|
||||
gdisp->gimage->qmask_state);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff),
|
||||
! gdisp->gimage->qmask_state);
|
||||
|
||||
/* Enable toggle again */
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
/* public functions */
|
||||
|
||||
gboolean
|
||||
qmask_button_press_callback (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
gimp_display_shell_qmask_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = (GimpDisplay *) data;
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
(event->button == 1))
|
||||
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
|
||||
{
|
||||
edit_qmask_channel_query (gdisp);
|
||||
|
||||
|
@ -171,65 +94,74 @@ qmask_button_press_callback (GtkWidget *widget,
|
|||
}
|
||||
|
||||
void
|
||||
qmask_deactivate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (!gdisp->gimage->qmask_state)
|
||||
if (! gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set do nothing */
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
undo_push_group_start (gimage, QMASK_UNDO);
|
||||
/* push the undo here since removing the mask will
|
||||
call the qmask_removed_callback() which will set
|
||||
the qmask_state to FALSE */
|
||||
* call the qmask_removed_callback() which will set
|
||||
* the qmask_state to FALSE
|
||||
*/
|
||||
undo_push_qmask (gimage);
|
||||
gimage_mask_load (gimage, gmask);
|
||||
gimp_image_remove_channel (gimage, gmask);
|
||||
gimage_mask_load (gimage, mask);
|
||||
gimp_image_remove_channel (gimage, mask);
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
qmask_activate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpChannel *mask;
|
||||
GimpLayer *layer;
|
||||
GimpRGB color;
|
||||
|
||||
gdisp = shell->gdisp;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gdisp->gimage->qmask_state)
|
||||
if (gimp_image_get_qmask_state (gimage))
|
||||
return; /* if already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
color = gimage->qmask_color;
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
if (mask)
|
||||
{
|
||||
gimage->qmask_state = TRUE;
|
||||
/* if the user was clever and created his own */
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -244,38 +176,43 @@ qmask_activate_callback (GtkWidget *widget,
|
|||
floating_sel_to_layer (layer);
|
||||
}
|
||||
|
||||
gmask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
mask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (gmask),
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
|
||||
gimp_get_user_context (gimage->gimp),
|
||||
TRANSPARENT_FILL);
|
||||
}
|
||||
else /* if selection */
|
||||
{
|
||||
gmask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
gimp_channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, mask, 0);
|
||||
gimp_channel_set_color (mask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
|
||||
gimage_mask_none (gimage); /* Clear the selection */
|
||||
}
|
||||
|
||||
undo_push_qmask (gimage);
|
||||
undo_push_group_end (gimage);
|
||||
gdisp->gimage->qmask_state = TRUE;
|
||||
|
||||
gimp_image_set_qmask_state (gimage, TRUE);
|
||||
|
||||
gdisplays_flush ();
|
||||
|
||||
/* connect to the removed signal, so the buttons get updated */
|
||||
g_signal_connect (G_OBJECT (gmask), "removed",
|
||||
g_signal_connect (G_OBJECT (mask), "removed",
|
||||
G_CALLBACK (qmask_removed_callback),
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
edit_qmask_channel_query (GimpDisplay *gdisp)
|
||||
{
|
||||
|
@ -399,3 +336,37 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
|
||||
}
|
||||
|
|
401
app/qmask.c
401
app/qmask.c
|
@ -1,401 +0,0 @@
|
|||
/* 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets/widgets-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpchannel.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-mask.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplay-foreach.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "widgets/gimpcolorpanel.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
#include "floating_sel.h"
|
||||
#include "qmask.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
typedef struct _EditQmaskOptions EditQmaskOptions;
|
||||
|
||||
struct _EditQmaskOptions
|
||||
{
|
||||
GtkWidget *query_box;
|
||||
GtkWidget *name_entry;
|
||||
GtkWidget *color_panel;
|
||||
|
||||
GimpImage *gimage;
|
||||
};
|
||||
|
||||
|
||||
/* Prototypes */
|
||||
static void edit_qmask_channel_query (GimpDisplay *gdisp);
|
||||
static void edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||
gpointer client_data);
|
||||
static void qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
static void qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data);
|
||||
static void qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data);
|
||||
|
||||
/* Actual code */
|
||||
|
||||
static void
|
||||
qmask_query_scale_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
qmask_removed_callback (GtkObject *qmask,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp = (GimpDisplay *) data;
|
||||
|
||||
if (!gdisp->gimage)
|
||||
return;
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
|
||||
qmask_buttons_update (gdisp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qmask_buttons_update (GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
g_assert (gdisp);
|
||||
g_assert (gdisp->gimage);
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (shell->qmaskon)->active)
|
||||
{
|
||||
/* Disable toggle from doing anything */
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
|
||||
/* Change the state of the buttons */
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskon),
|
||||
gdisp->gimage->qmask_state);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff),
|
||||
! gdisp->gimage->qmask_state);
|
||||
|
||||
/* Enable toggle again */
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskoff),
|
||||
qmask_deactivate_callback,
|
||||
gdisp);
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskon),
|
||||
qmask_activate_callback,
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
qmask_button_press_callback (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
gdisp = (GimpDisplay *) data;
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) &&
|
||||
(event->button == 1))
|
||||
{
|
||||
edit_qmask_channel_query (gdisp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
qmask_deactivate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (!gdisp->gimage->qmask_state)
|
||||
return; /* if already set do nothing */
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
{
|
||||
undo_push_group_start (gimage, QMASK_UNDO);
|
||||
/* push the undo here since removing the mask will
|
||||
call the qmask_removed_callback() which will set
|
||||
the qmask_state to FALSE */
|
||||
undo_push_qmask (gimage);
|
||||
gimage_mask_load (gimage, gmask);
|
||||
gimp_image_remove_channel (gimage, gmask);
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
gdisp->gimage->qmask_state = FALSE;
|
||||
|
||||
if (gmask)
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
qmask_activate_callback (GtkWidget *widget,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpChannel *gmask;
|
||||
GimpLayer *layer;
|
||||
GimpRGB color;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
if (gdisp->gimage->qmask_state)
|
||||
return; /* if already set, do nothing */
|
||||
|
||||
/* Set the defaults */
|
||||
color = gimage->qmask_color;
|
||||
|
||||
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
|
||||
|
||||
if (gmask)
|
||||
{
|
||||
gimage->qmask_state = TRUE;
|
||||
/* if the user was clever and created his own */
|
||||
return;
|
||||
}
|
||||
|
||||
undo_push_group_start (gimage, QMASK_UNDO);
|
||||
|
||||
if (gimage_mask_is_empty (gimage))
|
||||
{
|
||||
/* if no selection */
|
||||
|
||||
if ((layer = gimp_image_floating_sel (gimage)))
|
||||
{
|
||||
floating_sel_to_layer (layer);
|
||||
}
|
||||
|
||||
gmask = gimp_channel_new (gimage,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
"Qmask",
|
||||
&color);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
|
||||
gimp_drawable_fill_by_type (GIMP_DRAWABLE (gmask),
|
||||
gimp_get_user_context (gimage->gimp),
|
||||
TRANSPARENT_FILL);
|
||||
}
|
||||
else /* if selection */
|
||||
{
|
||||
gmask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
|
||||
gimp_image_add_channel (gimage, gmask, 0);
|
||||
gimp_channel_set_color (gmask, &color);
|
||||
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
|
||||
gimage_mask_none (gimage); /* Clear the selection */
|
||||
}
|
||||
|
||||
undo_push_qmask (gimage);
|
||||
undo_push_group_end (gimage);
|
||||
gdisp->gimage->qmask_state = TRUE;
|
||||
gdisplays_flush ();
|
||||
|
||||
/* connect to the removed signal, so the buttons get updated */
|
||||
g_signal_connect (G_OBJECT (gmask), "removed",
|
||||
G_CALLBACK (qmask_removed_callback),
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
edit_qmask_channel_query (GimpDisplay *gdisp)
|
||||
{
|
||||
EditQmaskOptions *options;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *opacity_scale;
|
||||
GtkObject *opacity_scale_data;
|
||||
|
||||
/* the new options structure */
|
||||
options = g_new0 (EditQmaskOptions, 1);
|
||||
|
||||
options->gimage = gdisp->gimage;
|
||||
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
|
||||
&options->gimage->qmask_color,
|
||||
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||
48, 64);
|
||||
|
||||
/* The dialog */
|
||||
options->query_box =
|
||||
gimp_dialog_new (_("Edit Qmask Attributes"), "edit_qmask_attributes",
|
||||
gimp_standard_help_func,
|
||||
"dialogs/edit_qmask_attributes.html",
|
||||
GTK_WIN_POS_MOUSE,
|
||||
FALSE, TRUE, FALSE,
|
||||
|
||||
GTK_STOCK_OK, edit_qmask_query_ok_callback,
|
||||
options, NULL, NULL, TRUE, FALSE,
|
||||
GTK_STOCK_CANCEL, edit_qmask_query_cancel_callback,
|
||||
options, NULL, NULL, FALSE, TRUE,
|
||||
|
||||
NULL);
|
||||
|
||||
/* The main hbox */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
|
||||
hbox);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
/* The vbox */
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
/* The table */
|
||||
table = gtk_table_new (1, 2, FALSE);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
||||
gtk_widget_show (table);
|
||||
|
||||
/* The opacity scale */
|
||||
opacity_scale_data =
|
||||
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
|
||||
0.0, 100.0, 1.0, 1.0, 0.0);
|
||||
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
|
||||
gtk_widget_set_usize (opacity_scale, 100, -1);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
|
||||
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||
_("Mask Opacity:"), 1.0, 1.0,
|
||||
opacity_scale, 1, FALSE);
|
||||
|
||||
g_signal_connect (G_OBJECT (opacity_scale_data), "value_changed",
|
||||
G_CALLBACK (qmask_query_scale_update),
|
||||
options->color_panel);
|
||||
|
||||
/* The color panel */
|
||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (options->color_panel);
|
||||
|
||||
g_signal_connect (G_OBJECT (options->color_panel), "color_changed",
|
||||
G_CALLBACK (qmask_color_changed),
|
||||
opacity_scale_data);
|
||||
|
||||
gtk_widget_show (options->query_box);
|
||||
}
|
||||
|
||||
static void
|
||||
edit_qmask_query_ok_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
EditQmaskOptions *options;
|
||||
GimpChannel *channel;
|
||||
GimpRGB color;
|
||||
|
||||
options = (EditQmaskOptions *) data;
|
||||
|
||||
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
|
||||
|
||||
if (options->gimage && channel)
|
||||
{
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||
&color);
|
||||
|
||||
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||
{
|
||||
gimp_channel_set_color (channel, &color);
|
||||
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
/* update the qmask color no matter what */
|
||||
options->gimage->qmask_color = color;
|
||||
|
||||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
||||
|
||||
static void
|
||||
edit_qmask_query_cancel_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
EditQmaskOptions *options;
|
||||
|
||||
options = (EditQmaskOptions *) data;
|
||||
|
||||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
}
|
|
@ -1,3 +1,7 @@
|
|||
2001-11-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* POTFILES.in: app/qmask.c -> app/display/gimpdisplayshell-qmask.c
|
||||
|
||||
2001-11-08 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* POTFILES.in: updated.
|
||||
|
|
|
@ -11,7 +11,6 @@ app/gimprc.c
|
|||
app/main.c
|
||||
app/nav_window.c
|
||||
app/plug_in.c
|
||||
app/qmask.c
|
||||
app/undo.c
|
||||
app/undo_history.c
|
||||
app/user_install.c
|
||||
|
@ -39,6 +38,7 @@ app/display/gimpdisplay.c
|
|||
app/display/gimpdisplayshell.c
|
||||
app/display/gimpdisplayshell-callbacks.c
|
||||
app/display/gimpdisplayshell-layer-select.c
|
||||
app/display/gimpdisplayshell-qmask.c
|
||||
|
||||
app/file/file-open.c
|
||||
app/file/file-save.c
|
||||
|
|
Loading…
Reference in New Issue