implement GtkWidget::drag_motion() and set the FG/BG depending on where

2004-07-01  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpfgbgarea.[ch]: implement GtkWidget::drag_motion()
	and set the FG/BG depending on where the color was dropped. Also
	set the drag status accordingly so the cursor indicates whether
	dropping will have an effect or not. Fixes bug #145219.
This commit is contained in:
Michael Natterer 2004-07-01 10:42:00 +00:00 committed by Michael Natterer
parent d5fb658079
commit 6679dc7183
3 changed files with 44 additions and 5 deletions

View File

@ -1,3 +1,10 @@
2004-07-01 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpfgbgarea.[ch]: implement GtkWidget::drag_motion()
and set the FG/BG depending on where the color was dropped. Also
set the drag status accordingly so the cursor indicates whether
dropping will have an effect or not. Fixes bug #145219.
2004-07-01 Sven Neumann <sven@gimp.org>
* app/core/gimptemplate.c: do like Liam taught us and use the

View File

@ -79,6 +79,11 @@ static gboolean gimp_fg_bg_editor_button_press (GtkWidget *widget,
GdkEventButton *bevent);
static gboolean gimp_fg_bg_editor_button_release (GtkWidget *widget,
GdkEventButton *bevent);
static gboolean gimp_fg_bg_editor_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static void gimp_fg_bg_editor_context_changed (GimpContext *context,
const GimpRGB *color,
@ -91,7 +96,6 @@ static void gimp_fg_bg_editor_drop_color (GtkWidget *widget,
gpointer data);
static guint editor_signals[LAST_SIGNAL] = { 0 };
static GtkDrawingAreaClass *parent_class = NULL;
@ -152,6 +156,7 @@ gimp_fg_bg_editor_class_init (GimpFgBgEditorClass *klass)
widget_class->expose_event = gimp_fg_bg_editor_expose;
widget_class->button_press_event = gimp_fg_bg_editor_button_press;
widget_class->button_release_event = gimp_fg_bg_editor_button_release;
widget_class->drag_motion = gimp_fg_bg_editor_drag_motion;
g_object_class_install_property (object_class, PROP_CONTEXT,
g_param_spec_object ("context",
@ -474,7 +479,6 @@ gimp_fg_bg_editor_button_press (GtkWidget *widget,
default:
break;
}
}
return FALSE;
@ -516,6 +520,30 @@ gimp_fg_bg_editor_button_release (GtkWidget *widget,
return FALSE;
}
static gboolean
gimp_fg_bg_editor_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GimpFgBgEditor *editor = GIMP_FG_BG_EDITOR (widget);
editor->dnd_target = gimp_fg_bg_editor_target (editor, x, y);
if (editor->dnd_target == FORE_AREA ||
editor->dnd_target == BACK_AREA)
{
gdk_drag_status (context, GDK_ACTION_COPY, time);
return TRUE;
}
gdk_drag_status (context, 0, time);
return FALSE;
}
/* public functions */
@ -618,15 +646,18 @@ gimp_fg_bg_editor_drop_color (GtkWidget *widget,
if (editor->context)
{
switch (editor->active_color)
switch (editor->dnd_target)
{
case GIMP_ACTIVE_COLOR_FOREGROUND:
case FORE_AREA:
gimp_context_set_foreground (editor->context, color);
break;
case GIMP_ACTIVE_COLOR_BACKGROUND:
case BACK_AREA:
gimp_context_set_background (editor->context, color);
break;
default:
break;
}
}
}

View File

@ -52,6 +52,7 @@ struct _GimpFgBgEditor
gint rect_width;
gint rect_height;
gint click_target;
gint dnd_target;
};
struct _GimpFgBgEditorClass