Custom transparency checkerboard colors

Reviewer (Jehan) note: cherry picked from MR !274. Still deciding
whether this will be pushed to gimp-2-10 branch too.

Fixed Conflicts from !274:
	app/dialogs/preferences-dialog.c
	app/display/gimpdisplayshell-draw.c
	app/plug-in/gimppluginmanager-call.c
	libgimp/gimp.c
	libgimp/gimp.h
	libgimpwidgets/gimppreviewarea.c
	libgimpwidgets/gimppreviewarea.h
	libgimpwidgets/gimpscrolledpreview.c
This commit is contained in:
Ben Rogalski 2020-05-24 16:26:50 -04:00 committed by Jehan
parent e5caf21bcb
commit d90b84ba9d
27 changed files with 601 additions and 134 deletions

View file

@ -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 }
};

View file

@ -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;

View file

@ -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;
}
}
}

View file

@ -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

View file

@ -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))

View file

@ -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;