From 4d93809fec282a59fdaa41eca19ace4fb34fd210 Mon Sep 17 00:00:00 2001 From: GMT 1999 Austin Donnelly Date: Sun, 7 Nov 1999 19:03:43 +0000 Subject: [PATCH] delay the showing of the full-size pattern, brush or gradient by 150ms as Sun Nov 7 18:59:22 GMT 1999 Austin Donnelly * app/gimpcontextpreview.c: delay the showing of the full-size pattern, brush or gradient by 150ms as the brush and pattern selector dialogs currently do. Also, only generate a "click" event if the user has clicked quickly, ie, the mouse up event came before the timeout caused the popup to be displayed). * app/gimprc.c: default image size now 983x857, in an attempt to flush out problems to do with large images, images with incomplete tiles around the edges, and images with width != height. Non-square pixels and other resolution stuff will come in at a later stage when we've got the first round of problems fixed. * app/gradient.c: don't allow two gradients with the same name - replace the first. Mainly this stops us having two "Default" gradients if you start up with --no-data. * app/interface.c: can now create an indicator panel in the toolbox even if we have --no-data, since we have built-in defaults now. --- ChangeLog | 23 ++++++++ app/display/gimpdisplayshell-draw.c | 2 +- app/display/gimpdisplayshell.c | 2 +- app/gimpcontextpreview.c | 89 ++++++++++++++++++++++++----- app/gimprc.c | 5 +- app/gradient.c | 11 ++++ app/gradient_editor.c | 11 ++++ app/gui/gradient-editor.c | 11 ++++ app/interface.c | 2 +- app/widgets/gimpgradienteditor.c | 11 ++++ 10 files changed, 147 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d552949b2..7616735cba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +Sun Nov 7 18:59:22 GMT 1999 Austin Donnelly + + * app/gimpcontextpreview.c: delay the showing of the full-size + pattern, brush or gradient by 150ms as the brush and pattern + selector dialogs currently do. Also, only generate a "click" + event if the user has clicked quickly, ie, the mouse up event + came before the timeout caused the popup to be displayed). + + * app/gimprc.c: default image size now 983x857, in an attempt to + flush out problems to do with large images, images with + incomplete tiles around the edges, and images with + width != height. Non-square pixels and other resolution stuff + will come in at a later stage when we've got the first round + of problems fixed. + + * app/gradient.c: don't allow two gradients with the same name - + replace the first. Mainly this stops us having two "Default" + gradients if you start up with --no-data. + + * app/interface.c: can now create an indicator panel in the + toolbox even if we have --no-data, since we have built-in + defaults now. + Sun Nov 7 15:41:07 GMT 1999 Austin Donnelly * app/module_db.c: fix button resize behaviour. Closes Bug#3350. diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c index d9fe781a3b..f9100dba89 100644 --- a/app/display/gimpdisplayshell-draw.c +++ b/app/display/gimpdisplayshell-draw.c @@ -600,7 +600,7 @@ create_toolbox (void) create_tools (wbox); create_color_area (wbox); - if (show_indicators && (!no_data) ) + if (show_indicators) create_indicator_area (wbox); gtk_widget_show (window); toolbox_set_drag_dest (window); diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index d9fe781a3b..f9100dba89 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -600,7 +600,7 @@ create_toolbox (void) create_tools (wbox); create_color_area (wbox); - if (show_indicators && (!no_data) ) + if (show_indicators) create_indicator_area (wbox); gtk_widget_show (window); toolbox_set_drag_dest (window); diff --git a/app/gimpcontextpreview.c b/app/gimpcontextpreview.c index 1d50539540..00b974ce69 100644 --- a/app/gimpcontextpreview.c +++ b/app/gimpcontextpreview.c @@ -77,6 +77,9 @@ static unsigned char scale_pipe_indicator_bits[7][7][3] = }; +/* how long to wait after mouse-down before showing popup */ +#define POPUP_DELAY_MS 150 + /* size of the gradient popup */ #define GRADIENT_POPUP_WIDTH 128 #define GRADIENT_POPUP_HEIGHT 32 @@ -90,10 +93,13 @@ static unsigned char scale_pipe_indicator_bits[7][7][3] = GDK_LEAVE_NOTIFY_MASK) /* shared widgets for the popups */ +/* XXX: It is pretty dangerous making these variables statics, + * I'd feel safer if they were per-instance and private. -- austin */ static GtkWidget *gcp_popup = NULL; static GtkWidget *gcp_popup_preview = NULL; static guint gcp_pipe_timer = 0; static guint gcp_pipe_index = 0; +static guint gcp_popup_timer = 0; /* dnd stuff */ static GtkTargetEntry context_preview_target_table[3][1] = @@ -398,7 +404,6 @@ gimp_context_preview_button_press_event (GtkWidget *widget, gimp_context_preview_popup_open (GIMP_CONTEXT_PREVIEW (widget), bevent->x, bevent->y); } - gtk_signal_emit_by_name (GTK_OBJECT (widget), "clicked"); } return FALSE; } @@ -407,25 +412,54 @@ static gint gimp_context_preview_button_release_event (GtkWidget *widget, GdkEventButton *bevent) { - if (bevent->button == 1 && GIMP_CONTEXT_PREVIEW (widget)->show_popup) + gboolean fast_click = TRUE; + + if (bevent->button == 1) { - gdk_pointer_ungrab (bevent->time); - gimp_context_preview_popup_close (); + if (GIMP_CONTEXT_PREVIEW (widget)->show_popup) + { + gdk_pointer_ungrab (bevent->time); + + /* user clicked quickly if the timeout is still running */ + fast_click = gcp_popup_timer; + + gimp_context_preview_popup_close (); + } + + if (fast_click) + gtk_signal_emit_by_name (GTK_OBJECT (widget), "clicked"); } return FALSE; } -static void -gimp_context_preview_popup_open (GimpContextPreview *gcp, - gint x, - gint y) + +typedef struct { + GimpContextPreview *gcp; + gint x; + gint y; +} popup_timeout_args_t; + + +static gboolean +gimp_context_preview_popup_timeout (gpointer data) { + popup_timeout_args_t *popup_timeout_args = data; + GimpContextPreview *gcp; + gint x, y; gint x_org, y_org; gint scr_w, scr_h; - g_return_if_fail (gcp != NULL); + gcp_popup_timer = 0; + + g_return_val_if_fail (popup_timeout_args != NULL, FALSE); + + gcp = popup_timeout_args->gcp; + x = popup_timeout_args->x; + y = popup_timeout_args->y; + + g_return_val_if_fail (gcp != NULL, FALSE); if (!gcp->data) - return; + return FALSE; switch (gcp->type) { @@ -448,7 +482,7 @@ gimp_context_preview_popup_open (GimpContextPreview *gcp, } } else if (gcp->popup_width <= gcp->width && gcp->popup_height <= gcp->height) - return; + return FALSE; } break; case GCP_PATTERN: @@ -457,17 +491,17 @@ gimp_context_preview_popup_open (GimpContextPreview *gcp, gcp->popup_width = pattern->mask->width; gcp->popup_height = pattern->mask->height; if (gcp->popup_width <= gcp->width && gcp->popup_height <= gcp->height) - return; + return FALSE; } break; case GCP_GRADIENT: gcp->popup_width = GRADIENT_POPUP_WIDTH; gcp->popup_height = GRADIENT_POPUP_HEIGHT; if (gcp->popup_width <= gcp->width && gcp->popup_height <= gcp->height) - return; + return FALSE; break; default: - return; + return FALSE; } /* make sure the popup exists and is not visible */ @@ -527,7 +561,28 @@ gimp_context_preview_popup_open (GimpContextPreview *gcp, break; } gtk_widget_queue_draw (gcp_popup_preview); + + return FALSE; } + + +static void +gimp_context_preview_popup_open (GimpContextPreview *gcp, + gint x, + gint y) +{ + static popup_timeout_args_t popup_timeout_args; + + g_return_if_fail (gcp_popup_timer == 0); + + popup_timeout_args.gcp = gcp; + popup_timeout_args.x = x; + popup_timeout_args.y = y; + gcp_popup_timer = gtk_timeout_add (POPUP_DELAY_MS, + gimp_context_preview_popup_timeout, + &popup_timeout_args); +} + static void gimp_context_preview_popup_close (void) @@ -535,7 +590,11 @@ gimp_context_preview_popup_close (void) if (gcp_pipe_timer > 0) gtk_timeout_remove (gcp_pipe_timer); gcp_pipe_timer = 0; - + + if (gcp_popup_timer) + gtk_timeout_remove (gcp_popup_timer); + gcp_popup_timer = 0; + if (gcp_popup != NULL) gtk_widget_hide (gcp_popup); } diff --git a/app/gimprc.c b/app/gimprc.c index 233412a97c..4e47759140 100644 --- a/app/gimprc.c +++ b/app/gimprc.c @@ -138,8 +138,9 @@ int confirm_on_close = TRUE; int save_session_info = TRUE; int save_device_status = FALSE; int always_restore_session = FALSE; -int default_width = 256; -int default_height = 256; +int default_width = 983; +int default_height = 857; +/* temporary default size increase to stress test stuff. -- austin 7/11/99 */ int default_type = RGB; double default_xresolution = 72.0; double default_yresolution = 72.0; diff --git a/app/gradient.c b/app/gradient.c index 74d1c4e5ee..679a4a7e4f 100644 --- a/app/gradient.c +++ b/app/gradient.c @@ -5980,6 +5980,7 @@ grad_insert_in_gradients_list (gradient_t *grad) n = 0; tmp = gradients_list; + g = NULL; while (tmp) { @@ -5992,6 +5993,16 @@ grad_insert_in_gradients_list (gradient_t *grad) tmp = g_slist_next (tmp); } + /* is there a gradient with this name already? */ + if (g && strcmp (grad->name, g->name) == 0) + { + gradients_list = g_slist_remove (gradients_list, g); + grad_free_gradient (g); + num_gradients--; + /* force refresh in case anyone had the gradient selected */ + gimp_context_refresh_gradients (); + } + num_gradients++; gradients_list = g_slist_insert (gradients_list, grad, n); diff --git a/app/gradient_editor.c b/app/gradient_editor.c index 74d1c4e5ee..679a4a7e4f 100644 --- a/app/gradient_editor.c +++ b/app/gradient_editor.c @@ -5980,6 +5980,7 @@ grad_insert_in_gradients_list (gradient_t *grad) n = 0; tmp = gradients_list; + g = NULL; while (tmp) { @@ -5992,6 +5993,16 @@ grad_insert_in_gradients_list (gradient_t *grad) tmp = g_slist_next (tmp); } + /* is there a gradient with this name already? */ + if (g && strcmp (grad->name, g->name) == 0) + { + gradients_list = g_slist_remove (gradients_list, g); + grad_free_gradient (g); + num_gradients--; + /* force refresh in case anyone had the gradient selected */ + gimp_context_refresh_gradients (); + } + num_gradients++; gradients_list = g_slist_insert (gradients_list, grad, n); diff --git a/app/gui/gradient-editor.c b/app/gui/gradient-editor.c index 74d1c4e5ee..679a4a7e4f 100644 --- a/app/gui/gradient-editor.c +++ b/app/gui/gradient-editor.c @@ -5980,6 +5980,7 @@ grad_insert_in_gradients_list (gradient_t *grad) n = 0; tmp = gradients_list; + g = NULL; while (tmp) { @@ -5992,6 +5993,16 @@ grad_insert_in_gradients_list (gradient_t *grad) tmp = g_slist_next (tmp); } + /* is there a gradient with this name already? */ + if (g && strcmp (grad->name, g->name) == 0) + { + gradients_list = g_slist_remove (gradients_list, g); + grad_free_gradient (g); + num_gradients--; + /* force refresh in case anyone had the gradient selected */ + gimp_context_refresh_gradients (); + } + num_gradients++; gradients_list = g_slist_insert (gradients_list, grad, n); diff --git a/app/interface.c b/app/interface.c index d9fe781a3b..f9100dba89 100644 --- a/app/interface.c +++ b/app/interface.c @@ -600,7 +600,7 @@ create_toolbox (void) create_tools (wbox); create_color_area (wbox); - if (show_indicators && (!no_data) ) + if (show_indicators) create_indicator_area (wbox); gtk_widget_show (window); toolbox_set_drag_dest (window); diff --git a/app/widgets/gimpgradienteditor.c b/app/widgets/gimpgradienteditor.c index 74d1c4e5ee..679a4a7e4f 100644 --- a/app/widgets/gimpgradienteditor.c +++ b/app/widgets/gimpgradienteditor.c @@ -5980,6 +5980,7 @@ grad_insert_in_gradients_list (gradient_t *grad) n = 0; tmp = gradients_list; + g = NULL; while (tmp) { @@ -5992,6 +5993,16 @@ grad_insert_in_gradients_list (gradient_t *grad) tmp = g_slist_next (tmp); } + /* is there a gradient with this name already? */ + if (g && strcmp (grad->name, g->name) == 0) + { + gradients_list = g_slist_remove (gradients_list, g); + grad_free_gradient (g); + num_gradients--; + /* force refresh in case anyone had the gradient selected */ + gimp_context_refresh_gradients (); + } + num_gradients++; gradients_list = g_slist_insert (gradients_list, grad, n);