Commit 112dd804 authored by Michael Natterer's avatar Michael Natterer 😴

app: add a "split preview" feature to GEGL ops that can be dragged around

We also commonly call this "preview curtain".
parent 8984df02
......@@ -63,6 +63,7 @@ struct _GimpImageMap
gchar *icon_name;
GimpImageMapRegion region;
gboolean preview_enabled;
GimpOrientationType preview_orientation;
gdouble preview_percent;
gdouble opacity;
......@@ -85,6 +86,7 @@ static void gimp_image_map_finalize (GObject *object);
static void gimp_image_map_sync_region (GimpImageMap *image_map);
static void gimp_image_map_sync_preview (GimpImageMap *image_map,
gboolean old_enabled,
GimpOrientationType old_orientation,
gdouble old_percent);
static void gimp_image_map_sync_mode (GimpImageMap *image_map);
......@@ -238,6 +240,7 @@ gimp_image_map_set_region (GimpImageMap *image_map,
void
gimp_image_map_set_preview (GimpImageMap *image_map,
gboolean enabled,
GimpOrientationType orientation,
gdouble percent)
{
......@@ -245,16 +248,20 @@ gimp_image_map_set_preview (GimpImageMap *image_map,
percent = CLAMP (percent, 0.0, 1.0);
if (orientation != image_map->preview_orientation ||
if (enabled != image_map->preview_enabled ||
orientation != image_map->preview_orientation ||
percent != image_map->preview_percent)
{
gboolean old_enabled = image_map->preview_enabled;
GimpOrientationType old_orientation = image_map->preview_orientation;
gdouble old_percent = image_map->preview_percent;
image_map->preview_enabled = enabled;
image_map->preview_orientation = orientation;
image_map->preview_percent = percent;
gimp_image_map_sync_preview (image_map, old_orientation, old_percent);
gimp_image_map_sync_preview (image_map,
old_enabled, old_orientation, old_percent);
}
}
......@@ -375,6 +382,7 @@ gimp_image_map_apply (GimpImageMap *image_map,
gimp_image_map_sync_region (image_map);
gimp_image_map_sync_preview (image_map,
image_map->preview_enabled,
image_map->preview_orientation,
image_map->preview_percent);
gimp_image_map_sync_mode (image_map);
......@@ -511,23 +519,28 @@ gimp_image_map_sync_region (GimpImageMap *image_map)
static void
gimp_image_map_get_preview_rect (GimpImageMap *image_map,
gboolean enabled,
GimpOrientationType orientation,
gdouble percent,
GeglRectangle *rect)
{
rect->x = 0;
rect->y = 0;
rect->x = 0;
rect->y = 0;
rect->width = gimp_item_get_width (GIMP_ITEM (image_map->drawable));
rect->height = gimp_item_get_height (GIMP_ITEM (image_map->drawable));
if (orientation == GIMP_ORIENTATION_HORIZONTAL)
rect->width *= percent;
else
rect->height *= percent;
}
if (enabled)
{
if (orientation == GIMP_ORIENTATION_HORIZONTAL)
rect->width *= percent;
else
rect->height *= percent;
}
}
static void
gimp_image_map_sync_preview (GimpImageMap *image_map,
gboolean old_enabled,
GimpOrientationType old_orientation,
gdouble old_percent)
{
......@@ -537,16 +550,20 @@ gimp_image_map_sync_preview (GimpImageMap *image_map,
GeglRectangle new_rect;
gimp_image_map_get_preview_rect (image_map,
old_enabled,
old_orientation,
old_percent,
&old_rect);
gimp_image_map_get_preview_rect (image_map,
image_map->preview_enabled,
image_map->preview_orientation,
image_map->preview_percent,
&new_rect);
gimp_applicator_set_preview (image_map->applicator, TRUE, &new_rect);
gimp_applicator_set_preview (image_map->applicator,
image_map->preview_enabled,
&new_rect);
if (old_rect.width != new_rect.width ||
old_rect.height != new_rect.height)
......
......@@ -57,6 +57,7 @@ GimpImageMap * gimp_image_map_new (GimpDrawable *drawable,
void gimp_image_map_set_region (GimpImageMap *image_map,
GimpImageMapRegion region);
void gimp_image_map_set_preview (GimpImageMap *image_map,
gboolean enabled,
GimpOrientationType orientation,
gdouble percent_visible);
void gimp_image_map_set_mode (GimpImageMap *image_map,
......
......@@ -33,6 +33,8 @@ enum
{
PROP_0,
PROP_PREVIEW,
PROP_PREVIEW_SPLIT,
PROP_PREVIEW_PERCENT,
PROP_REGION,
PROP_SETTINGS
};
......@@ -71,6 +73,21 @@ gimp_image_map_options_class_init (GimpImageMapOptionsClass *klass)
TRUE,
GIMP_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_PREVIEW_SPLIT,
g_param_spec_boolean ("preview-split",
_("_Split view"),
NULL,
FALSE,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_PREVIEW_PERCENT,
g_param_spec_double ("preview-percent",
NULL, NULL,
0.0, 1.0, 0.5,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_REGION,
g_param_spec_enum ("region",
NULL, NULL,
......@@ -120,6 +137,14 @@ gimp_image_map_options_set_property (GObject *object,
options->preview = g_value_get_boolean (value);
break;
case PROP_PREVIEW_SPLIT:
options->preview_split = g_value_get_boolean (value);
break;
case PROP_PREVIEW_PERCENT:
options->preview_percent = g_value_get_double (value);
break;
case PROP_REGION:
options->region = g_value_get_enum (value);
break;
......@@ -150,6 +175,14 @@ gimp_image_map_options_get_property (GObject *object,
g_value_set_boolean (value, options->preview);
break;
case PROP_PREVIEW_SPLIT:
g_value_set_boolean (value, options->preview_split);
break;
case PROP_PREVIEW_PERCENT:
g_value_set_double (value, options->preview_percent);
break;
case PROP_REGION:
g_value_set_enum (value, options->region);
break;
......
......@@ -37,6 +37,8 @@ struct _GimpImageMapOptions
GimpToolOptions parent_instance;
gboolean preview;
gboolean preview_split;
gdouble preview_percent;
GimpImageMapRegion region;
GFile *settings;
};
......
This diff is collapsed.
......@@ -52,6 +52,8 @@ struct _GimpImageMapTool
GimpImageMap *image_map;
GimpGuide *percent_guide;
/* dialog */
gboolean overlay;
GimpToolGui *gui;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment