diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index 16e2cdf10e..a99d32a251 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -504,5 +504,5 @@ gimp_display_shell_canvas_draw_drop_zone (GimpDisplayShell *shell, { gimp_display_shell_draw_background (shell, cr); - gimp_cairo_draw_drop_wilber (shell->canvas, cr); + gimp_cairo_draw_drop_wilber (shell->canvas, cr, shell->blink); } diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 2324f1c1b7..4b94b304aa 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -841,6 +841,12 @@ gimp_display_shell_dispose (GObject *object) shell->grid_dialog = NULL; } + if (shell->blink_timeout_id) + { + g_source_remove (shell->blink_timeout_id); + shell->blink_timeout_id = 0; + } + shell->display = NULL; G_OBJECT_CLASS (parent_class)->dispose (object); @@ -1299,6 +1305,28 @@ gimp_display_shell_reconnect (GimpDisplayShell *shell) gimp_display_shell_expose_full (shell); } +static gboolean +gimp_display_shell_blink (GimpDisplayShell *shell) +{ + shell->blink_timeout_id = 0; + + if (shell->blink) + { + shell->blink = FALSE; + } + else + { + shell->blink = TRUE; + + shell->blink_timeout_id = + g_timeout_add (100, (GSourceFunc) gimp_display_shell_blink, shell); + } + + gimp_display_shell_expose_full (shell); + + return FALSE; +} + void gimp_display_shell_empty (GimpDisplayShell *shell) { @@ -1341,6 +1369,9 @@ gimp_display_shell_empty (GimpDisplayShell *shell) if (shell->display == gimp_context_get_display (user_context)) gimp_ui_manager_update (shell->popup_manager, shell->display); + + shell->blink_timeout_id = + g_timeout_add (1403230, (GSourceFunc) gimp_display_shell_blink, shell); } static gboolean @@ -1395,6 +1426,12 @@ gimp_display_shell_fill (GimpDisplayShell *shell, TRUE, TRUE); + if (shell->blink_timeout_id) + { + g_source_remove (shell->blink_timeout_id); + shell->blink_timeout_id = 0; + } + shell->fill_idle_id = g_idle_add_full (GIMP_DISPLAY_SHELL_FILL_IDLE_PRIORITY, (GSourceFunc) gimp_display_shell_fill_idle, shell, diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index 4eb4cd51cf..ffe04bfea9 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -187,6 +187,9 @@ struct _GimpDisplayShell GimpMotionBuffer *motion_buffer; GQueue *zoom_focus_pointer_queue; + + gboolean blink; + guint blink_timeout_id; }; struct _GimpDisplayShellClass diff --git a/app/widgets/gimpcairo-wilber.c b/app/widgets/gimpcairo-wilber.c index 883ccc65ec..45196405f0 100644 --- a/app/widgets/gimpcairo-wilber.c +++ b/app/widgets/gimpcairo-wilber.c @@ -34,6 +34,11 @@ #include "gimpcairo-wilber.h" +static void gimp_cairo_eyes (cairo_t *cr, + gdouble x, + gdouble y); + + void gimp_cairo_draw_toolbox_wilber (GtkWidget *widget, cairo_t *cr) @@ -76,7 +81,8 @@ gimp_cairo_draw_toolbox_wilber (GtkWidget *widget, void gimp_cairo_draw_drop_wilber (GtkWidget *widget, - cairo_t *cr) + cairo_t *cr, + gboolean blink) { GtkStyle *style; GtkStateType state; @@ -126,6 +132,20 @@ gimp_cairo_draw_drop_wilber (GtkWidget *widget, style->fg[state].blue / 65535.0, 0.15); cairo_fill (cr); + + if (blink) + { + gimp_cairo_eyes (cr, + - wilber_width * 0.6, + allocation.height / factor - wilber_height * 1.1); + + cairo_set_source_rgba (cr, + style->fg[state].red / 65535.0, + 0, + 0, + 1.0); + cairo_fill (cr); + } } @@ -137,14 +157,22 @@ gimp_cairo_draw_drop_wilber (GtkWidget *widget, static const gchar wilber_path[] = "M 509.72445,438.68864 C 501.47706,469.77945 464.95038,491.54566 431.85915,497.74874 C 438.5216,503.01688 442.87782,511.227 442.87782,520.37375 C 442.87783,536.24746 429.95607,549.0223 414.08235,549.0223 C 398.20863,549.0223 385.28688,536.24746 385.28688,520.37375 C 385.28688,511.52403 389.27666,503.61286 395.57098,498.3364 C 359.36952,495.90384 343.70976,463.95812 343.70975,463.95814 L 342.68134,509.64891 C 342.68134,514.35021 342.08391,519.96098 340.18378,528.3072 C 339.84664,527.80364 339.51399,527.33515 339.15537,526.83804 C 330.25511,514.5011 317.25269,507.81431 306.39317,508.76741 C 302.77334,509.08511 299.47017,510.33348 296.54982,512.4403 C 284.86847,520.86757 284.97665,540.94721 296.84366,557.3965 C 306.96274,571.42287 322.32232,578.25612 333.8664,574.73254 C 391.94635,615.17624 532.16931,642.41915 509.72445,438.68864 z M 363.24953,501.1278 C 373.83202,501.12778 382.49549,509.79127 382.49549,520.37375 C 382.49549,530.95624 373.83201,539.47279 363.24953,539.47279 C 352.66706,539.47279 344.1505,530.95624 344.1505,520.37375 C 344.15049,509.79129 352.66706,501.1278 363.24953,501.1278 z M 305.80551,516.1132 C 311.68466,516.11318 316.38344,521.83985 316.38344,528.89486 C 316.38345,535.94982 311.68467,541.67652 305.80551,541.67652 C 299.92636,541.67652 295.08067,535.94987 295.08067,528.89486 C 295.08065,521.83985 299.92636,516.1132 305.80551,516.1132 z M 440.821,552.54828 C 440.821,552.54828 448.7504,554.02388 453.8965,559.45332 C 457.41881,563.16951 457.75208,569.15506 456.98172,577.37703 C 456.21143,573.8833 454.89571,571.76659 453.8965,569.29666 C 443.01388,582.47662 413.42981,583.08929 376.0312,569.88433 C 416.63248,578.00493 437.38806,570.56014 449.48903,561.2163 C 446.29383,557.08917 440.821,552.54828 440.821,552.54828 z M 434.64723,524.59684 C 434.64723,532.23974 428.44429,538.44268 420.80139,538.44268 C 413.15849,538.44268 406.95555,532.23974 406.95555,524.59684 C 406.95555,516.95394 413.15849,510.751 420.80139,510.751 C 428.44429,510.751 434.64723,516.95394 434.64723,524.59684 z M 378.00043,522.99931 C 378.00043,527.70264 374.18324,531.51984 369.47991,531.51984 C 364.77658,531.51984 360.95939,527.70264 360.95939,522.99931 C 360.95939,518.29599 364.77658,514.47879 369.47991,514.47879 C 374.18324,514.47879 378.00043,518.29599 378.00043,522.99931 z "; +static const gchar eyes_path[] = + "M 434.64723,524.59684 C 434.64723,532.23974 428.44429,538.44268 420.80139,538.44268 C 413.15849,538.44268 406.95555,532.23974 406.95555,524.59684 C 406.95555,516.95394 413.15849,510.751 420.80139,510.751 C 428.44429,510.751 434.64723,516.95394 434.64723,524.59684 z M 378.00043,522.99931 C 378.00043,527.70264 374.18324,531.51984 369.47991,531.51984 C 364.77658,531.51984 360.95939,527.70264 360.95939,522.99931 C 360.95939,518.29599 364.77658,514.47879 369.47991,514.47879 C 374.18324,514.47879 378.00043,518.29599 378.00043,522.99931 z "; + static cairo_path_t *wilber_cairo_path = NULL; static gdouble wilber_x1, wilber_y1; static gdouble wilber_x2, wilber_y2; +static cairo_path_t *eyes_cairo_path = NULL; +static gdouble eyes_x1, eyes_y1; +static gdouble eyes_x2, eyes_y2; -static void wilber_parse_path_data (cairo_t *cr, - const gchar *data); -static void wilber_get_extents (cairo_t *cr); + +static void parse_path_data (cairo_t *cr, + const gchar *data); +static void wilber_get_extents (cairo_t *cr); +static void eyes_get_extents (cairo_t *cr); /** @@ -170,6 +198,22 @@ gimp_cairo_wilber (cairo_t *cr, cairo_restore (cr); } +static void +gimp_cairo_eyes (cairo_t *cr, + gdouble x, + gdouble y) +{ + wilber_get_extents (cr); + eyes_get_extents (cr); + + cairo_save (cr); + + cairo_translate (cr, x - wilber_x1, y - wilber_y1); + cairo_append_path (cr, eyes_cairo_path); + + cairo_restore (cr); +} + void gimp_cairo_wilber_get_size (cairo_t *cr, gdouble *width, @@ -187,10 +231,10 @@ wilber_get_extents (cairo_t *unused) { if (! wilber_cairo_path) { - cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_A8, 1, 1); + cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_A8, 1, 1); cairo_t *cr = cairo_create (s); - wilber_parse_path_data (cr, wilber_path); + parse_path_data (cr, wilber_path); cairo_fill_extents (cr, &wilber_x1, &wilber_y1, &wilber_x2, &wilber_y2); wilber_cairo_path = cairo_copy_path (cr); @@ -200,6 +244,24 @@ wilber_get_extents (cairo_t *unused) } } +static void +eyes_get_extents (cairo_t *unused) +{ + if (! eyes_cairo_path) + { + cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_A8, 1, 1); + cairo_t *cr = cairo_create (s); + + parse_path_data (cr, eyes_path); + cairo_fill_extents (cr, &eyes_x1, &eyes_y1, &eyes_x2, &eyes_y2); + + eyes_cairo_path = cairo_copy_path (cr); + + cairo_destroy (cr); + cairo_surface_destroy (s); + } +} + /**********************************************************/ /* Below is the code that parses the actual path data. */ /* */ @@ -226,8 +288,8 @@ static void parse_path_do_cmd (ParsePathContext *ctx, static void -wilber_parse_path_data (cairo_t *cr, - const gchar *data) +parse_path_data (cairo_t *cr, + const gchar *data) { ParsePathContext ctx; diff --git a/app/widgets/gimpcairo-wilber.h b/app/widgets/gimpcairo-wilber.h index 44d3d249b8..72dd5923f9 100644 --- a/app/widgets/gimpcairo-wilber.h +++ b/app/widgets/gimpcairo-wilber.h @@ -28,7 +28,8 @@ void gimp_cairo_draw_toolbox_wilber (GtkWidget *widget, cairo_t *cr); void gimp_cairo_draw_drop_wilber (GtkWidget *widget, - cairo_t *cr); + cairo_t *cr, + gboolean blink); void gimp_cairo_wilber (cairo_t *cr, gdouble x,