diff --git a/app/actions/view-actions.c b/app/actions/view-actions.c index 363707b4ad..3943eec056 100644 --- a/app/actions/view-actions.c +++ b/app/actions/view-actions.c @@ -813,6 +813,12 @@ view_actions_setup (GimpActionGroup *group) g_signal_connect_object (group->gimp->config, "notify::check-type", G_CALLBACK (view_actions_check_type_notify), group, 0); + g_signal_connect_object (group->gimp->config, "notify::check-custom-color1", + G_CALLBACK (view_actions_check_type_notify), + group, 0); + g_signal_connect_object (group->gimp->config, "notify::check-custom-color2", + G_CALLBACK (view_actions_check_type_notify), + group, 0); view_actions_check_type_notify (GIMP_DISPLAY_CONFIG (group->gimp->config), NULL, group); @@ -1207,9 +1213,9 @@ view_actions_check_type_notify (GimpDisplayConfig *config, GimpActionGroup *group) { gimp_action_group_set_action_color (group, "view-padding-color-light-check", - gimp_render_light_check_color (), + gimp_render_check_color1 (), FALSE); gimp_action_group_set_action_color (group, "view-padding-color-dark-check", - gimp_render_dark_check_color (), + gimp_render_check_color2 (), FALSE); } diff --git a/app/config/gimpdisplayconfig.c b/app/config/gimpdisplayconfig.c index d77f021335..89ecaa3a23 100644 --- a/app/config/gimpdisplayconfig.c +++ b/app/config/gimpdisplayconfig.c @@ -47,6 +47,8 @@ enum PROP_0, PROP_TRANSPARENCY_SIZE, PROP_TRANSPARENCY_TYPE, + PROP_TRANSPARENCY_CUSTOM_COLOR1, + PROP_TRANSPARENCY_CUSTOM_COLOR2, PROP_SNAP_DISTANCE, PROP_MARCHING_ANTS_SPEED, PROP_RESIZE_WINDOWS_ON_ZOOM, @@ -134,6 +136,20 @@ gimp_display_config_class_init (GimpDisplayConfigClass *klass) GIMP_CHECK_TYPE_GRAY_CHECKS, GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_PROP_RGB (object_class, PROP_TRANSPARENCY_CUSTOM_COLOR1, + "transparency-custom-color1", + "Transparency custom color 1", + TRANSPARENCY_CUSTOM_COLOR1_BLURB, + FALSE, &GIMP_CHECKS_CUSTOM_COLOR1, + GIMP_PARAM_STATIC_STRINGS); + + GIMP_CONFIG_PROP_RGB (object_class, PROP_TRANSPARENCY_CUSTOM_COLOR2, + "transparency-custom-color2", + "Transparency custom color 2", + TRANSPARENCY_CUSTOM_COLOR2_BLURB, + FALSE, &GIMP_CHECKS_CUSTOM_COLOR2, + GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_PROP_INT (object_class, PROP_SNAP_DISTANCE, "snap-distance", "Snap distance", @@ -422,6 +438,12 @@ gimp_display_config_set_property (GObject *object, case PROP_TRANSPARENCY_TYPE: display_config->transparency_type = g_value_get_enum (value); break; + case PROP_TRANSPARENCY_CUSTOM_COLOR1: + display_config->transparency_custom_color1 = *(GimpRGB *) g_value_get_boxed (value); + break; + case PROP_TRANSPARENCY_CUSTOM_COLOR2: + display_config->transparency_custom_color2 = *(GimpRGB *) g_value_get_boxed (value); + break; case PROP_SNAP_DISTANCE: display_config->snap_distance = g_value_get_int (value); break; @@ -540,6 +562,12 @@ gimp_display_config_get_property (GObject *object, case PROP_TRANSPARENCY_TYPE: g_value_set_enum (value, display_config->transparency_type); break; + case PROP_TRANSPARENCY_CUSTOM_COLOR1: + g_value_set_boxed (value, &display_config->transparency_custom_color1); + break; + case PROP_TRANSPARENCY_CUSTOM_COLOR2: + g_value_set_boxed (value, &display_config->transparency_custom_color2); + break; case PROP_SNAP_DISTANCE: g_value_set_int (value, display_config->snap_distance); break; diff --git a/app/config/gimpdisplayconfig.h b/app/config/gimpdisplayconfig.h index 0deab5f08b..008b009a1a 100644 --- a/app/config/gimpdisplayconfig.h +++ b/app/config/gimpdisplayconfig.h @@ -43,6 +43,8 @@ struct _GimpDisplayConfig GimpCheckSize transparency_size; GimpCheckType transparency_type; + GimpRGB transparency_custom_color1; + GimpRGB transparency_custom_color2; gint snap_distance; gint marching_ants_speed; gboolean resize_windows_on_zoom; diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h index 73487fa0d7..e522601d82 100644 --- a/app/config/gimprc-blurbs.h +++ b/app/config/gimprc-blurbs.h @@ -716,6 +716,14 @@ _("Show the currently active image in the toolbox.") #define TOOLBOX_WILBER_BLURB \ _("Show the GIMP mascot at the top of the toolbox.") +#define TRANSPARENCY_CUSTOM_COLOR1_BLURB \ +_("The first color to use in the transparency checkerboard, " \ + "when Transparency Type is set to Custom colors.") + +#define TRANSPARENCY_CUSTOM_COLOR2_BLURB \ +_("The second color to use in the transparency checkerboard, " \ + "when Transparency Type is set to Custom colors.") + #define TRANSPARENCY_TYPE_BLURB \ _("Sets the manner in which transparency is displayed in images.") diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 22d1dfd04f..a249e3dc4d 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -928,6 +928,12 @@ gimp_image_constructed (GObject *object) g_signal_connect_object (config, "notify::transparency-size", G_CALLBACK (gimp_item_stack_invalidate_previews), private->layers->container, G_CONNECT_SWAPPED); + g_signal_connect_object (config, "notify::transparency-custom-color1", + G_CALLBACK (gimp_item_stack_invalidate_previews), + private->layers->container, G_CONNECT_SWAPPED); + g_signal_connect_object (config, "notify::transparency-custom-color2", + G_CALLBACK (gimp_item_stack_invalidate_previews), + private->layers->container, G_CONNECT_SWAPPED); g_signal_connect_object (config, "notify::layer-previews", G_CALLBACK (gimp_viewable_size_changed), image, G_CONNECT_SWAPPED); diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 67581ffc4e..4965ba4914 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -2726,9 +2726,34 @@ prefs_dialog_new (Gimp *gimp, prefs_enum_combo_box_add (object, "transparency-type", 0, 0, _("_Check style:"), GTK_GRID (grid), 0, size_group); + + button = gimp_prop_color_button_new (object, + "transparency-custom-color1", + _("Transparency Custom Color 1"), + PREFS_COLOR_BUTTON_WIDTH, + PREFS_COLOR_BUTTON_HEIGHT, + GIMP_COLOR_AREA_FLAT); + gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1, + _("_Custom color 1:"), 0.0, 0.5, + button, 1); + gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), + gimp_get_user_context (gimp)); + + button = gimp_prop_color_button_new (object, + "transparency-custom-color2", + _("Transparency Custom Color 2"), + PREFS_COLOR_BUTTON_WIDTH, + PREFS_COLOR_BUTTON_HEIGHT, + GIMP_COLOR_AREA_FLAT); + gimp_grid_attach_aligned (GTK_GRID (grid), 0, 2, + _("_Custom color 2:"), 0.0, 0.5, + button, 1); + gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), + gimp_get_user_context (gimp)); + prefs_enum_combo_box_add (object, "transparency-size", 0, 0, _("Check _size:"), - GTK_GRID (grid), 1, size_group); + GTK_GRID (grid), 3, size_group); /* Zoom Quality */ vbox2 = prefs_frame_new (_("Zoom Quality"), GTK_CONTAINER (vbox), FALSE); diff --git a/app/display/gimpdisplayshell-appearance.c b/app/display/gimpdisplayshell-appearance.c index 958540d959..221263a763 100644 --- a/app/display/gimpdisplayshell-appearance.c +++ b/app/display/gimpdisplayshell-appearance.c @@ -484,11 +484,11 @@ gimp_display_shell_set_padding (GimpDisplayShell *shell, break; case GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK: - color = *gimp_render_light_check_color (); + color = *gimp_render_check_color1 (); break; case GIMP_CANVAS_PADDING_MODE_DARK_CHECK: - color = *gimp_render_dark_check_color (); + color = *gimp_render_check_color2 (); break; case GIMP_CANVAS_PADDING_MODE_CUSTOM: diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c index a6de49e20a..16e591ad6b 100644 --- a/app/display/gimpdisplayshell-draw.c +++ b/app/display/gimpdisplayshell-draw.c @@ -38,6 +38,8 @@ #include "gimpdisplayshell-draw.h" #include "gimpdisplayshell-render.h" +#include "widgets/gimprender.h" + /* public functions */ @@ -106,24 +108,16 @@ gimp_display_shell_draw_checkerboard (GimpDisplayShell *shell, if (G_UNLIKELY (! shell->checkerboard)) { GimpCheckSize check_size; - GimpCheckType check_type; - guchar check_light; - guchar check_dark; - GimpRGB light; - GimpRGB dark; g_object_get (shell->display->config, "transparency-size", &check_size, - "transparency-type", &check_type, NULL); - gimp_checks_get_shades (check_type, &check_light, &check_dark); - gimp_rgb_set_uchar (&light, check_light, check_light, check_light); - gimp_rgb_set_uchar (&dark, check_dark, check_dark, check_dark); - shell->checkerboard = gimp_cairo_checkerboard_create (cr, - 1 << (check_size + 2), &light, &dark); + 1 << (check_size + 2), + gimp_render_check_color1 (), + gimp_render_check_color2 ()); } cairo_translate (cr, - shell->offset_x, - shell->offset_y); diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c index 1932839907..0cc0915456 100644 --- a/app/display/gimpdisplayshell-handlers.c +++ b/app/display/gimpdisplayshell-handlers.c @@ -327,6 +327,14 @@ gimp_display_shell_connect (GimpDisplayShell *shell) "notify::transparency-type", G_CALLBACK (gimp_display_shell_check_notify_handler), shell); + g_signal_connect (config, + "notify::transparency-custom-color1", + G_CALLBACK (gimp_display_shell_check_notify_handler), + shell); + g_signal_connect (config, + "notify::transparency-custom-color2", + G_CALLBACK (gimp_display_shell_check_notify_handler), + shell); g_signal_connect (config, "notify::image-title-format", diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c index a90dcfb014..e653d9f1f4 100644 --- a/app/plug-in/gimppluginmanager-call.c +++ b/app/plug-in/gimppluginmanager-call.c @@ -210,6 +210,8 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager, -1); config.check_size = display_config->transparency_size; config.check_type = display_config->transparency_type; + config.check_custom_color1 = display_config->transparency_custom_color1; + config.check_custom_color2 = display_config->transparency_custom_color2; config.show_help_button = (gui_config->use_help && gui_config->show_help_button); config.use_cpu_accel = manager->gimp->use_cpu_accel; diff --git a/app/widgets/gimprender.c b/app/widgets/gimprender.c index 549ed025d4..f332702d2d 100644 --- a/app/widgets/gimprender.c +++ b/app/widgets/gimprender.c @@ -37,8 +37,8 @@ static void gimp_render_setup_notify (gpointer config, Gimp *gimp); -static GimpRGB light; -static GimpRGB dark; +static GimpRGB color1; +static GimpRGB color2; void @@ -50,6 +50,14 @@ gimp_render_init (Gimp *gimp) G_CALLBACK (gimp_render_setup_notify), gimp); + g_signal_connect (gimp->config, "notify::transparency-custom-color1", + G_CALLBACK (gimp_render_setup_notify), + gimp); + + g_signal_connect (gimp->config, "notify::transparency-custom-color2", + G_CALLBACK (gimp_render_setup_notify), + gimp); + gimp_render_setup_notify (gimp->config, NULL, gimp); } @@ -64,15 +72,15 @@ gimp_render_exit (Gimp *gimp) } const GimpRGB * -gimp_render_light_check_color (void) +gimp_render_check_color1 (void) { - return &light; + return &color1; } const GimpRGB * -gimp_render_dark_check_color (void) +gimp_render_check_color2 (void) { - return &dark; + return &color2; } static void @@ -81,15 +89,17 @@ gimp_render_setup_notify (gpointer config, Gimp *gimp) { GimpCheckType check_type; - guchar dark_check; - guchar light_check; + GimpRGB *color1_custom; + GimpRGB *color2_custom; g_object_get (config, "transparency-type", &check_type, + "transparency-custom-color1", &color1_custom, + "transparency-custom-color2", &color2_custom, NULL); - gimp_checks_get_shades (check_type, &light_check, &dark_check); + gimp_checks_get_colors (check_type, &color1, &color2, *color1_custom, *color2_custom); - gimp_rgba_set_uchar (&light, light_check, light_check, light_check, 255); - gimp_rgba_set_uchar (&dark, dark_check, dark_check, dark_check, 255); + g_free (color1_custom); + g_free (color2_custom); } diff --git a/app/widgets/gimprender.h b/app/widgets/gimprender.h index c1ecdb31db..c4964302f3 100644 --- a/app/widgets/gimprender.h +++ b/app/widgets/gimprender.h @@ -22,8 +22,8 @@ void gimp_render_init (Gimp *gimp); void gimp_render_exit (Gimp *gimp); -const GimpRGB * gimp_render_light_check_color (void); -const GimpRGB * gimp_render_dark_check_color (void); +const GimpRGB * gimp_render_check_color1 (void); +const GimpRGB * gimp_render_check_color2 (void); #endif /* __GIMP_RENDER_H__ */ diff --git a/app/widgets/gimpviewrenderer.c b/app/widgets/gimpviewrenderer.c index 53e91e7d4e..a5061f90b8 100644 --- a/app/widgets/gimpviewrenderer.c +++ b/app/widgets/gimpviewrenderer.c @@ -775,8 +775,8 @@ gimp_view_renderer_real_draw (GimpViewRenderer *renderer, if (! renderer->priv->pattern) renderer->priv->pattern = gimp_cairo_checkerboard_create (cr, GIMP_CHECK_SIZE_SM, - gimp_render_light_check_color (), - gimp_render_dark_check_color ()); + gimp_render_check_color1 (), + gimp_render_check_color2 ()); cairo_set_source (cr, renderer->priv->pattern); cairo_fill_preserve (cr); @@ -1129,8 +1129,8 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer, if (! renderer->priv->pattern) renderer->priv->pattern = gimp_cairo_checkerboard_create (cr, GIMP_CHECK_SIZE_SM, - gimp_render_light_check_color (), - gimp_render_dark_check_color ()); + gimp_render_check_color1 (), + gimp_render_check_color2 ()); } switch (outside_bg) diff --git a/libgimp/gimp.c b/libgimp/gimp.c index adfc2a4af4..71df47b478 100644 --- a/libgimp/gimp.c +++ b/libgimp/gimp.c @@ -141,6 +141,8 @@ static gboolean _export_thumbnail = TRUE; static gint32 _num_processors = 1; static GimpCheckSize _check_size = GIMP_CHECK_SIZE_MEDIUM_CHECKS; static GimpCheckType _check_type = GIMP_CHECK_TYPE_GRAY_CHECKS; +static GimpRGB _check_custom_color1 = GIMP_CHECKS_CUSTOM_COLOR1; +static GimpRGB _check_custom_color2 = GIMP_CHECKS_CUSTOM_COLOR2; static gint _default_display_id = -1; static gchar *_wm_class = NULL; static gchar *_display_name = NULL; @@ -795,6 +797,38 @@ gimp_check_type (void) return _check_type; } +/** + * gimp_check_custom_color1: + * + * Returns the first checkerboard custom color that can + * be used in previews. + * + * This is a constant value given at plug-in configuration time. + * + * Return value: the _check_custom_color1 value + **/ +const GimpRGB * +gimp_check_custom_color1 (void) +{ + return &_check_custom_color1; +} + +/** + * gimp_check_custom_color2: + * + * Returns the second checkerboard custom color that can + * be used in previews. + * + * This is a constant value given at plug-in configuration time. + * + * Return value: the _check_custom_color2 value + **/ +const GimpRGB * +gimp_check_custom_color2 (void) +{ + return &_check_custom_color2; +} + /** * gimp_default_display: * @@ -1037,6 +1071,8 @@ _gimp_config (GPConfig *config) _tile_height = config->tile_height; _check_size = config->check_size; _check_type = config->check_type; + _check_custom_color1 = config->check_custom_color1; + _check_custom_color2 = config->check_custom_color2; _show_help_button = config->show_help_button ? TRUE : FALSE; _export_color_profile = config->export_color_profile ? TRUE : FALSE; _export_exif = config->export_exif ? TRUE : FALSE; diff --git a/libgimp/gimp.h b/libgimp/gimp.h index 42e0fc5632..a449c68a0a 100644 --- a/libgimp/gimp.h +++ b/libgimp/gimp.h @@ -183,6 +183,8 @@ gboolean gimp_export_thumbnail (void) G_GNUC_CONST; gint gimp_get_num_processors (void) G_GNUC_CONST; GimpCheckSize gimp_check_size (void) G_GNUC_CONST; GimpCheckType gimp_check_type (void) G_GNUC_CONST; +const GimpRGB * gimp_check_custom_color1 (void) G_GNUC_CONST; +const GimpRGB * gimp_check_custom_color2 (void) G_GNUC_CONST; GimpDisplay * gimp_default_display (void) G_GNUC_CONST; const gchar * gimp_wm_class (void) G_GNUC_CONST; const gchar * gimp_display_name (void) G_GNUC_CONST; diff --git a/libgimp/gimpaspectpreview.c b/libgimp/gimpaspectpreview.c index 1312a1c698..0fabf205c7 100644 --- a/libgimp/gimpaspectpreview.c +++ b/libgimp/gimpaspectpreview.c @@ -144,6 +144,8 @@ gimp_aspect_preview_init (GimpAspectPreview *preview) g_object_set (gimp_preview_get_area (GIMP_PREVIEW (preview)), "check-size", gimp_check_size (), "check-type", gimp_check_type (), + "check-custom-color1", gimp_check_custom_color1 (), + "check-custom-color2", gimp_check_custom_color2 (), NULL); } diff --git a/libgimp/gimpdrawablepreview.c b/libgimp/gimpdrawablepreview.c index 0e34964f0c..63be488939 100644 --- a/libgimp/gimpdrawablepreview.c +++ b/libgimp/gimpdrawablepreview.c @@ -142,6 +142,8 @@ gimp_drawable_preview_init (GimpDrawablePreview *preview) g_object_set (gimp_preview_get_area (GIMP_PREVIEW (preview)), "check-size", gimp_check_size (), "check-type", gimp_check_type (), + "check-custom-color1", gimp_check_custom_color1 (), + "check-custom-color2", gimp_check_custom_color2 (), NULL); } diff --git a/libgimp/gimpzoompreview.c b/libgimp/gimpzoompreview.c index d2aba484f9..cab700ade2 100644 --- a/libgimp/gimpzoompreview.c +++ b/libgimp/gimpzoompreview.c @@ -198,6 +198,8 @@ gimp_zoom_preview_init (GimpZoomPreview *preview) g_object_set (area, "check-size", gimp_check_size (), "check-type", gimp_check_type (), + "check-custom-color1", gimp_check_custom_color1 (), + "check-custom-color2", gimp_check_custom_color2 (), NULL); gimp_scrolled_preview_set_policy (GIMP_SCROLLED_PREVIEW (preview), diff --git a/libgimpbase/gimpbaseenums.c b/libgimpbase/gimpbaseenums.c index 50e03fe560..dc0968c618 100644 --- a/libgimpbase/gimpbaseenums.c +++ b/libgimpbase/gimpbaseenums.c @@ -227,6 +227,7 @@ gimp_check_type_get_type (void) { GIMP_CHECK_TYPE_WHITE_ONLY, "GIMP_CHECK_TYPE_WHITE_ONLY", "white-only" }, { GIMP_CHECK_TYPE_GRAY_ONLY, "GIMP_CHECK_TYPE_GRAY_ONLY", "gray-only" }, { GIMP_CHECK_TYPE_BLACK_ONLY, "GIMP_CHECK_TYPE_BLACK_ONLY", "black-only" }, + { GIMP_CHECK_TYPE_CUSTOM_CHECKS, "GIMP_CHECK_TYPE_CUSTOM_CHECKS", "custom-checks" }, { 0, NULL, NULL } }; @@ -238,6 +239,7 @@ gimp_check_type_get_type (void) { GIMP_CHECK_TYPE_WHITE_ONLY, NC_("check-type", "White only"), NULL }, { GIMP_CHECK_TYPE_GRAY_ONLY, NC_("check-type", "Gray only"), NULL }, { GIMP_CHECK_TYPE_BLACK_ONLY, NC_("check-type", "Black only"), NULL }, + { GIMP_CHECK_TYPE_CUSTOM_CHECKS, NC_("check-type", "Custom checks"), NULL }, { 0, NULL, NULL } }; diff --git a/libgimpbase/gimpbaseenums.h b/libgimpbase/gimpbaseenums.h index bb6686cb32..a147933fcc 100644 --- a/libgimpbase/gimpbaseenums.h +++ b/libgimpbase/gimpbaseenums.h @@ -178,6 +178,7 @@ typedef enum /*< pdb-skip >*/ * @GIMP_CHECK_TYPE_WHITE_ONLY: White only * @GIMP_CHECK_TYPE_GRAY_ONLY: Gray only * @GIMP_CHECK_TYPE_BLACK_ONLY: Black only + * @GIMP_CHECK_TYPE_CUSTOM_CHECKS: Custom checks * * Color/Brightness of the checkerboard indicating transparency. **/ @@ -192,7 +193,8 @@ typedef enum /*< pdb-skip >*/ GIMP_CHECK_TYPE_DARK_CHECKS = 2, /*< desc="Dark checks" >*/ GIMP_CHECK_TYPE_WHITE_ONLY = 3, /*< desc="White only" >*/ GIMP_CHECK_TYPE_GRAY_ONLY = 4, /*< desc="Gray only" >*/ - GIMP_CHECK_TYPE_BLACK_ONLY = 5 /*< desc="Black only" >*/ + GIMP_CHECK_TYPE_BLACK_ONLY = 5, /*< desc="Black only" >*/ + GIMP_CHECK_TYPE_CUSTOM_CHECKS = 6 /*< desc="Custom checks" >*/ } GimpCheckType; diff --git a/libgimpbase/gimpchecks.c b/libgimpbase/gimpchecks.c index a393b23164..faf13f28d8 100644 --- a/libgimpbase/gimpchecks.c +++ b/libgimpbase/gimpchecks.c @@ -44,6 +44,8 @@ * @light: (out) (optional): return location for the light shade * @dark: (out) (optional): return location for the dark shade * + * Deprecated: use gimp_checks_get_colors() instead. + * * Retrieves the actual shades of gray to use when drawing a * checkerboard for a certain #GimpCheckType. * @@ -71,3 +73,77 @@ gimp_checks_get_shades (GimpCheckType type, if (dark) *dark = shades[type][0]; } + +/** + * gimp_checks_get_colors: + * @type: the checkerboard type + * @color1: return location for the first color, + * usually the light color + * @color2: return location for the second color, + * usually the dark color + * @color1_custom: the first color to return if type is custom + * @color2_custom: the second color to return if type is custom + **/ +void +gimp_checks_get_colors (GimpCheckType type, + GimpRGB *color1, + GimpRGB *color2, + GimpRGB color1_custom, + GimpRGB color2_custom) +{ + if (color1) + { + switch (type) + { + case GIMP_CHECK_TYPE_LIGHT_CHECKS: + *color1 = GIMP_CHECKS_LIGHT_COLOR_LIGHT; + break; + case GIMP_CHECK_TYPE_DARK_CHECKS: + *color1 = GIMP_CHECKS_DARK_COLOR_LIGHT; + break; + case GIMP_CHECK_TYPE_WHITE_ONLY: + *color1 = GIMP_CHECKS_WHITE_COLOR; + break; + case GIMP_CHECK_TYPE_GRAY_ONLY: + *color1 = GIMP_CHECKS_GRAY_COLOR; + break; + case GIMP_CHECK_TYPE_BLACK_ONLY: + *color1 = GIMP_CHECKS_BLACK_COLOR; + break; + case GIMP_CHECK_TYPE_CUSTOM_CHECKS: + *color1 = color1_custom; + break; + default: + *color1 = GIMP_CHECKS_GRAY_COLOR_LIGHT; + break; + } + } + + if (color2) + { + switch (type) + { + case GIMP_CHECK_TYPE_LIGHT_CHECKS: + *color2 = GIMP_CHECKS_LIGHT_COLOR_DARK; + break; + case GIMP_CHECK_TYPE_DARK_CHECKS: + *color2 = GIMP_CHECKS_DARK_COLOR_DARK; + break; + case GIMP_CHECK_TYPE_WHITE_ONLY: + *color2 = GIMP_CHECKS_WHITE_COLOR; + break; + case GIMP_CHECK_TYPE_GRAY_ONLY: + *color2 = GIMP_CHECKS_GRAY_COLOR; + break; + case GIMP_CHECK_TYPE_BLACK_ONLY: + *color2 = GIMP_CHECKS_BLACK_COLOR; + break; + case GIMP_CHECK_TYPE_CUSTOM_CHECKS: + *color2 = color2_custom; + break; + default: + *color2 = GIMP_CHECKS_GRAY_COLOR_DARK; + break; + } + } +} diff --git a/libgimpbase/gimpchecks.h b/libgimpbase/gimpchecks.h index c41a4d6667..672786f22e 100644 --- a/libgimpbase/gimpchecks.h +++ b/libgimpbase/gimpchecks.h @@ -57,11 +57,94 @@ G_BEGIN_DECLS **/ #define GIMP_CHECK_LIGHT 0.6 +/** + * GIMP_CHECKS_CUSTOM_COLOR1: + * + * The default color 1 for the custom checkerboard type. + **/ +#define GIMP_CHECKS_CUSTOM_COLOR1 ((GimpRGB) { 1.0, 0.0, 0.0, 1.0 }) +/** + * GIMP_CHECKS_CUSTOM_COLOR2: + * + * The default color 2 for the custom checkerboard type. + **/ +#define GIMP_CHECKS_CUSTOM_COLOR2 ((GimpRGB) { 0.0, 1.0, 0.0, 1.0 }) + +/** + * GIMP_CHECKS_LIGHT_COLOR_DARK: + * + * The dark color for the light checkerboard type. + **/ +#define GIMP_CHECKS_LIGHT_COLOR_DARK ((GimpRGB) { 0.8, 0.8, 0.8, 1.0 }) + +/** + * GIMP_CHECKS_LIGHT_COLOR_LIGHT: + * + * The light color for the light checkerboard type. + **/ +#define GIMP_CHECKS_LIGHT_COLOR_LIGHT ((GimpRGB) { 1.0, 1.0, 1.0, 1.0 }) + +/** + * GIMP_CHECKS_GRAY_COLOR_DARK: + * + * The dark color for the gray checkerboard type. + **/ +#define GIMP_CHECKS_GRAY_COLOR_DARK ((GimpRGB) { 0.4, 0.4, 0.4, 1.0 }) + +/** + * GIMP_CHECKS_GRAY_COLOR_LIGHT: + * + * The light color for the gray checkerboard type. + **/ +#define GIMP_CHECKS_GRAY_COLOR_LIGHT ((GimpRGB) { 0.6, 0.6, 0.6, 1.0 }) + +/** + * GIMP_CHECKS_DARK_COLOR_DARK: + * + * The dark color for the dark checkerboard type. + **/ +#define GIMP_CHECKS_DARK_COLOR_DARK ((GimpRGB) { 0.0, 0.0, 0.0, 1.0 }) + +/** + * GIMP_CHECKS_DARK_COLOR_LIGHT: + * + * The light color for the dark checkerboard type. + **/ +#define GIMP_CHECKS_DARK_COLOR_LIGHT ((GimpRGB) { 0.2, 0.2, 0.2, 1.0 }) + +/** + * GIMP_CHECKS_WHITE_COLOR: + * + * The light/dark color for the white checkerboard type. + **/ +#define GIMP_CHECKS_WHITE_COLOR ((GimpRGB) { 1.0, 1.0, 1.0, 1.0 }) + +/** + * GIMP_CHECKS_GRAY_COLOR: + * + * The light/dark color for the gray checkerboard type. + **/ +#define GIMP_CHECKS_GRAY_COLOR ((GimpRGB) { 0.5, 0.5, 0.5, 1.0 }) + +/** + * GIMP_CHECKS_BLACK_COLOR: + * + * The light/dark color for the black checkerboard type. + **/ +#define GIMP_CHECKS_BLACK_COLOR ((GimpRGB) { 0.0, 0.0, 0.0, 1.0 }) + +GIMP_DEPRECATED_FOR(gimp_checks_get_colors) void gimp_checks_get_shades (GimpCheckType type, guchar *light, guchar *dark); +void gimp_checks_get_colors (GimpCheckType type, + GimpRGB *color1, + GimpRGB *color2, + GimpRGB color1_custom, + GimpRGB color2_custom); + G_END_DECLS diff --git a/libgimpbase/gimpprotocol.c b/libgimpbase/gimpprotocol.c index 97b13b0fc4..ee13e90ab0 100644 --- a/libgimpbase/gimpprotocol.c +++ b/libgimpbase/gimpprotocol.c @@ -493,6 +493,12 @@ _gp_config_read (GIOChannel *channel, if (! _gimp_wire_read_int8 (channel, (guint8 *) &config->check_type, 1, user_data)) goto cleanup; + if (! _gimp_wire_read_color (channel, &config->check_custom_color1, + 1, user_data)) + goto cleanup; + if (! _gimp_wire_read_color (channel, &config->check_custom_color2, + 1, user_data)) + goto cleanup; if (! _gimp_wire_read_int8 (channel, (guint8 *) &config->show_help_button, 1, user_data)) @@ -601,6 +607,12 @@ _gp_config_write (GIOChannel *channel, (const guint8 *) &config->check_type, 1, user_data)) return; + if (! _gimp_wire_write_color (channel, &config->check_custom_color1, + 1, user_data)) + return; + if (! _gimp_wire_write_color (channel, &config->check_custom_color2, + 1, user_data)) + return; if (! _gimp_wire_write_int8 (channel, (const guint8 *) &config->show_help_button, 1, user_data)) diff --git a/libgimpbase/gimpprotocol.h b/libgimpbase/gimpprotocol.h index 91e907f354..88147e5318 100644 --- a/libgimpbase/gimpprotocol.h +++ b/libgimpbase/gimpprotocol.h @@ -106,6 +106,8 @@ struct _GPConfig gint32 shm_id; gint8 check_size; gint8 check_type; + GimpRGB check_custom_color1; + GimpRGB check_custom_color2; gint8 show_help_button; gint8 use_cpu_accel; gint8 use_opencl; diff --git a/libgimpwidgets/gimppreview.c b/libgimpwidgets/gimppreview.c index 9a16e5fc6a..dbef1d282b 100644 --- a/libgimpwidgets/gimppreview.c +++ b/libgimpwidgets/gimppreview.c @@ -241,6 +241,12 @@ gimp_preview_init (GimpPreview *preview) g_signal_connect_swapped (priv->area, "notify::check-type", G_CALLBACK (gimp_preview_notify_checks), preview); + g_signal_connect_swapped (priv->area, "notify::check-custom-color1", + G_CALLBACK (gimp_preview_notify_checks), + preview); + g_signal_connect_swapped (priv->area, "notify::check-custom-color2", + G_CALLBACK (gimp_preview_notify_checks), + preview); gtk_widget_add_events (priv->area, GDK_BUTTON_PRESS_MASK | diff --git a/libgimpwidgets/gimppreviewarea.c b/libgimpwidgets/gimppreviewarea.c index 51436f5f02..8e2875b7f3 100644 --- a/libgimpwidgets/gimppreviewarea.c +++ b/libgimpwidgets/gimppreviewarea.c @@ -49,22 +49,34 @@ enum { PROP_0, PROP_CHECK_SIZE, - PROP_CHECK_TYPE + PROP_CHECK_TYPE, + PROP_CHECK_CUSTOM_COLOR1, + PROP_CHECK_CUSTOM_COLOR2 }; #define DEFAULT_CHECK_SIZE GIMP_CHECK_SIZE_MEDIUM_CHECKS #define DEFAULT_CHECK_TYPE GIMP_CHECK_TYPE_GRAY_CHECKS -#define CHECK_COLOR(priv, row, col) \ +#define CHECK_R(priv, row, col) \ (((((priv)->offset_y + (row)) & size) ^ \ - (((priv)->offset_x + (col)) & size)) ? dark : light) + (((priv)->offset_x + (col)) & size)) ? r1 : r2) + +#define CHECK_G(priv, row, col) \ + (((((priv)->offset_y + (row)) & size) ^ \ + (((priv)->offset_x + (col)) & size)) ? g1 : g2) + +#define CHECK_B(priv, row, col) \ + (((((priv)->offset_y + (row)) & size) ^ \ + (((priv)->offset_x + (col)) & size)) ? b1 : b2) struct _GimpPreviewAreaPrivate { GimpCheckSize check_size; GimpCheckType check_type; + GimpRGB check_custom_color1; + GimpRGB check_custom_color2; gint width; gint height; gint rowstride; @@ -144,6 +156,20 @@ gimp_preview_area_class_init (GimpPreviewAreaClass *klass) GIMP_TYPE_CHECK_TYPE, DEFAULT_CHECK_TYPE, GIMP_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_CHECK_CUSTOM_COLOR1, + g_param_spec_boxed ("check-custom-color1", + _("Custom Checks Color 1"), + "The first color of the checkerboard pattern indicating transparency", + GIMP_TYPE_RGB, + GIMP_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_CHECK_CUSTOM_COLOR2, + g_param_spec_boxed ("check-custom-color2", + _("Custom Checks Color 2"), + "The second color of the checkerboard pattern indicating transparency", + GIMP_TYPE_RGB, + GIMP_PARAM_READWRITE)); } static void @@ -157,6 +183,8 @@ gimp_preview_area_init (GimpPreviewArea *area) priv->check_size = DEFAULT_CHECK_SIZE; priv->check_type = DEFAULT_CHECK_TYPE; + priv->check_custom_color1 = GIMP_CHECKS_CUSTOM_COLOR1; + priv->check_custom_color2 = GIMP_CHECKS_CUSTOM_COLOR2; priv->max_width = -1; priv->max_height = -1; @@ -202,6 +230,12 @@ gimp_preview_area_set_property (GObject *object, case PROP_CHECK_TYPE: priv->check_type = g_value_get_enum (value); break; + case PROP_CHECK_CUSTOM_COLOR1: + priv->check_custom_color1 = *(GimpRGB *) g_value_get_boxed (value); + break; + case PROP_CHECK_CUSTOM_COLOR2: + priv->check_custom_color2 = *(GimpRGB *) g_value_get_boxed (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -225,6 +259,12 @@ gimp_preview_area_get_property (GObject *object, case PROP_CHECK_TYPE: g_value_set_enum (value, priv->check_type); break; + case PROP_CHECK_CUSTOM_COLOR1: + g_value_set_boxed (value, &priv->check_custom_color1); + break; + case PROP_CHECK_CUSTOM_COLOR2: + g_value_set_boxed (value, &priv->check_custom_color2); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -460,8 +500,14 @@ gimp_preview_area_draw (GimpPreviewArea *area, const guchar *src; guchar *dest; guint size; - guchar light; - guchar dark; + GimpRGB color1; + GimpRGB color2; + guchar r1; + guchar g1; + guchar b1; + guchar r2; + guchar g2; + guchar b2; gint row; gint col; @@ -513,7 +559,13 @@ gimp_preview_area_draw (GimpPreviewArea *area, } size = 1 << (2 + priv->check_size); - gimp_checks_get_shades (priv->check_type, &light, &dark); + gimp_checks_get_colors (priv->check_type, + &color1, + &color2, + priv->check_custom_color1, + priv->check_custom_color2); + gimp_rgb_get_uchar (&color1, &r1, &g1, &b1); + gimp_rgb_get_uchar (&color2, &r2, &g2, &b2); src = buf; dest = priv->buf + x * 3 + y * priv->rowstride; @@ -541,7 +593,9 @@ gimp_preview_area_draw (GimpPreviewArea *area, switch (s[3]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -552,12 +606,14 @@ gimp_preview_area_draw (GimpPreviewArea *area, default: { - register guint alpha = s[3] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = s[3] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = ((check << 8) + (s[0] - check) * alpha) >> 8; - d[1] = ((check << 8) + (s[1] - check) * alpha) >> 8; - d[2] = ((check << 8) + (s[2] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (s[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (s[1] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (s[2] - check_b) * alpha) >> 8; } break; } @@ -595,7 +651,9 @@ gimp_preview_area_draw (GimpPreviewArea *area, switch (s[1]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -604,11 +662,14 @@ gimp_preview_area_draw (GimpPreviewArea *area, default: { - register guint alpha = s[1] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = s[1] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = d[1] = d[2] = - ((check << 8) + (s[0] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (s[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (s[0] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (s[0] - check_b) * alpha) >> 8; } break; } @@ -654,7 +715,9 @@ gimp_preview_area_draw (GimpPreviewArea *area, switch (s[1]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -665,12 +728,14 @@ gimp_preview_area_draw (GimpPreviewArea *area, default: { - register guint alpha = s[3] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = s[3] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = ((check << 8) + (colormap[0] - check) * alpha) >> 8; - d[1] = ((check << 8) + (colormap[1] - check) * alpha) >> 8; - d[2] = ((check << 8) + (colormap[2] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (colormap[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (colormap[1] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (colormap[2] - check_b) * alpha) >> 8; } break; } @@ -724,8 +789,14 @@ gimp_preview_area_blend (GimpPreviewArea *area, const guchar *src2; guchar *dest; guint size; - guchar light; - guchar dark; + GimpRGB color1; + GimpRGB color2; + guchar r1; + guchar g1; + guchar b1; + guchar r2; + guchar g2; + guchar b2; gint row; gint col; gint i; @@ -798,7 +869,13 @@ gimp_preview_area_blend (GimpPreviewArea *area, } size = 1 << (2 + priv->check_size); - gimp_checks_get_shades (priv->check_type, &light, &dark); + gimp_checks_get_colors (priv->check_type, + &color1, + &color2, + priv->check_custom_color1, + priv->check_custom_color2); + gimp_rgb_get_uchar (&color1, &r1, &g1, &b1); + gimp_rgb_get_uchar (&color2, &r2, &g2, &b2); src1 = buf1; src2 = buf2; @@ -864,7 +941,9 @@ gimp_preview_area_blend (GimpPreviewArea *area, switch (inter[3]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -875,12 +954,14 @@ gimp_preview_area_blend (GimpPreviewArea *area, default: { - register guint alpha = inter[3] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = inter[3] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = ((check << 8) + (inter[0] - check) * alpha) >> 8; - d[1] = ((check << 8) + (inter[1] - check) * alpha) >> 8; - d[2] = ((check << 8) + (inter[2] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (inter[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (inter[1] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (inter[2] - check_b) * alpha) >> 8; } break; } @@ -944,7 +1025,9 @@ gimp_preview_area_blend (GimpPreviewArea *area, switch (inter[1]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -953,11 +1036,14 @@ gimp_preview_area_blend (GimpPreviewArea *area, default: { - register guint alpha = inter[1] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = inter[1] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = d[1] = d[2] = - ((check << 8) + (inter[0] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (inter[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (inter[0] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (inter[0] - check_b) * alpha) >> 8; } break; } @@ -1037,7 +1123,9 @@ gimp_preview_area_blend (GimpPreviewArea *area, switch (inter[3]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -1048,12 +1136,14 @@ gimp_preview_area_blend (GimpPreviewArea *area, default: { - register guint alpha = inter[3] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = inter[3] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = ((check << 8) + (inter[0] - check) * alpha) >> 8; - d[1] = ((check << 8) + (inter[1] - check) * alpha) >> 8; - d[2] = ((check << 8) + (inter[2] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (inter[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (inter[1] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (inter[2] - check_b) * alpha) >> 8; } break; } @@ -1112,8 +1202,14 @@ gimp_preview_area_mask (GimpPreviewArea *area, const guchar *src_mask; guchar *dest; guint size; - guchar light; - guchar dark; + GimpRGB color1; + GimpRGB color2; + guchar r1; + guchar g1; + guchar b1; + guchar r2; + guchar g2; + guchar b2; gint row; gint col; gint i; @@ -1174,7 +1270,13 @@ gimp_preview_area_mask (GimpPreviewArea *area, } size = 1 << (2 + priv->check_size); - gimp_checks_get_shades (priv->check_type, &light, &dark); + gimp_checks_get_colors (priv->check_type, + &color1, + &color2, + priv->check_custom_color1, + priv->check_custom_color2); + gimp_rgb_get_uchar (&color1, &r1, &g1, &b1); + gimp_rgb_get_uchar (&color2, &r2, &g2, &b2); src1 = buf1; src2 = buf2; @@ -1221,7 +1323,9 @@ gimp_preview_area_mask (GimpPreviewArea *area, switch (s1[3]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -1232,12 +1336,14 @@ gimp_preview_area_mask (GimpPreviewArea *area, default: { - register guint alpha = s1[3] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = s1[3] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = ((check << 8) + (s1[0] - check) * alpha) >> 8; - d[1] = ((check << 8) + (s1[1] - check) * alpha) >> 8; - d[2] = ((check << 8) + (s1[2] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (s1[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (s1[1] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (s1[2] - check_b) * alpha) >> 8; } break; } @@ -1247,7 +1353,9 @@ gimp_preview_area_mask (GimpPreviewArea *area, switch (s2[3]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -1258,12 +1366,14 @@ gimp_preview_area_mask (GimpPreviewArea *area, default: { - register guint alpha = s2[3] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = s2[3] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = ((check << 8) + (s2[0] - check) * alpha) >> 8; - d[1] = ((check << 8) + (s2[1] - check) * alpha) >> 8; - d[2] = ((check << 8) + (s2[2] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (s2[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (s2[1] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (s2[2] - check_b) * alpha) >> 8; } break; } @@ -1300,7 +1410,9 @@ gimp_preview_area_mask (GimpPreviewArea *area, switch (inter[3]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -1311,15 +1423,17 @@ gimp_preview_area_mask (GimpPreviewArea *area, default: { - register guint alpha = inter[3] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = inter[3] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = (((check << 8) + - (inter[0] - check) * alpha) >> 8); - d[1] = (((check << 8) + - (inter[1] - check) * alpha) >> 8); - d[2] = (((check << 8) + - (inter[2] - check) * alpha) >> 8); + d[0] = (((check_r << 8) + + (inter[0] - check_r) * alpha) >> 8); + d[1] = (((check_g << 8) + + (inter[1] - check_g) * alpha) >> 8); + d[2] = (((check_b << 8) + + (inter[2] - check_b) * alpha) >> 8); } break; } @@ -1369,7 +1483,9 @@ gimp_preview_area_mask (GimpPreviewArea *area, switch (s1[1]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -1378,11 +1494,14 @@ gimp_preview_area_mask (GimpPreviewArea *area, default: { - register guint alpha = s1[1] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = s1[1] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = d[1] = d[2] = - ((check << 8) + (s1[0] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (s1[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (s1[0] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (s1[0] - check_b) * alpha) >> 8; } break; } @@ -1392,7 +1511,9 @@ gimp_preview_area_mask (GimpPreviewArea *area, switch (s2[1]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -1401,11 +1522,14 @@ gimp_preview_area_mask (GimpPreviewArea *area, default: { - register guint alpha = s2[1] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = s2[1] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = d[1] = d[2] = - ((check << 8) + (s2[0] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (s2[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (s2[0] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (s2[0] - check_b) * alpha) >> 8; } break; } @@ -1437,7 +1561,9 @@ gimp_preview_area_mask (GimpPreviewArea *area, switch (inter[1]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -1446,11 +1572,14 @@ gimp_preview_area_mask (GimpPreviewArea *area, default: { - register guint alpha = inter[1] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = inter[1] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = d[1] = d[2] = - ((check << 8) + (inter[0] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (inter[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (inter[0] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (inter[0] - check_b) * alpha) >> 8; } break; } @@ -1512,7 +1641,9 @@ gimp_preview_area_mask (GimpPreviewArea *area, switch (s1[1]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -1523,12 +1654,14 @@ gimp_preview_area_mask (GimpPreviewArea *area, default: { - register guint alpha = s1[1] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = s1[1] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = ((check << 8) + (cmap1[0] - check) * alpha) >> 8; - d[1] = ((check << 8) + (cmap1[1] - check) * alpha) >> 8; - d[2] = ((check << 8) + (cmap1[2] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (cmap1[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (cmap1[1] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (cmap1[2] - check_b) * alpha) >> 8; } break; } @@ -1538,7 +1671,9 @@ gimp_preview_area_mask (GimpPreviewArea *area, switch (s2[1]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -1549,12 +1684,14 @@ gimp_preview_area_mask (GimpPreviewArea *area, default: { - register guint alpha = s2[1] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = s2[1] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); - d[0] = ((check << 8) + (cmap2[0] - check) * alpha) >> 8; - d[1] = ((check << 8) + (cmap2[1] - check) * alpha) >> 8; - d[2] = ((check << 8) + (cmap2[2] - check) * alpha) >> 8; + d[0] = ((check_r << 8) + (cmap2[0] - check_r) * alpha) >> 8; + d[1] = ((check_g << 8) + (cmap2[1] - check_g) * alpha) >> 8; + d[2] = ((check_b << 8) + (cmap2[2] - check_b) * alpha) >> 8; } break; } @@ -1594,7 +1731,9 @@ gimp_preview_area_mask (GimpPreviewArea *area, switch (inter[3]) { case 0: - d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col); + d[0] = CHECK_R (priv, row, col); + d[1] = CHECK_G (priv, row, col); + d[2] = CHECK_B (priv, row, col); break; case 255: @@ -1605,15 +1744,17 @@ gimp_preview_area_mask (GimpPreviewArea *area, default: { - register guint alpha = inter[3] + 1; - register guint check = CHECK_COLOR (priv, row, col); + register guint alpha = inter[3] + 1; + register guint check_r = CHECK_R (priv, row, col); + register guint check_g = CHECK_G (priv, row, col); + register guint check_b = CHECK_B (priv, row, col); d[0] = - ((check << 8) + (inter[0] - check) * alpha) >> 8; + ((check_r << 8) + (inter[0] - check_r) * alpha) >> 8; d[1] = - ((check << 8) + (inter[1] - check) * alpha) >> 8; + ((check_g << 8) + (inter[1] - check_g) * alpha) >> 8; d[2] = - ((check << 8) + (inter[2] - check) * alpha) >> 8; + ((check_b << 8) + (inter[2] - check_b) * alpha) >> 8; } break; } @@ -1995,6 +2136,10 @@ gimp_preview_area_menu_popup (GimpPreviewArea *area, gimp_preview_area_menu_new (area, "check-type")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), gimp_preview_area_menu_new (area, "check-size")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), + gimp_preview_area_menu_new (area, "check-custom-color1")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), + gimp_preview_area_menu_new (area, "check-custom-color2")); gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *) event); } diff --git a/libgimpwidgets/gimpscrolledpreview.c b/libgimpwidgets/gimpscrolledpreview.c index 8c166801da..1fdecf1a7a 100644 --- a/libgimpwidgets/gimpscrolledpreview.c +++ b/libgimpwidgets/gimpscrolledpreview.c @@ -546,6 +546,8 @@ gimp_scrolled_preview_nav_button_press (GtkWidget *widget, GdkCursor *cursor; GtkBorder border; GimpCheckType check_type; + GimpRGB check_custom_color1; + GimpRGB check_custom_color2; gint area_width; gint area_height; gint x, y; @@ -575,11 +577,15 @@ gimp_scrolled_preview_nav_button_press (GtkWidget *widget, g_object_get (gimp_preview_get_area (gimp_preview), "check-type", &check_type, + "check-custom-color1", &check_custom_color1, + "check-custom-color2", &check_custom_color2, NULL); area = g_object_new (GIMP_TYPE_PREVIEW_AREA, "check-size", GIMP_CHECK_SIZE_SMALL_CHECKS, "check-type", check_type, + "check-custom-color1", check_custom_color1, + "check-custom-color2", check_custom_color2, NULL); gtk_container_add (GTK_CONTAINER (inner), area);