mirror of https://github.com/GNOME/gimp.git
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:
parent
e5caf21bcb
commit
d90b84ba9d
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.")
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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 }
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 |
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue