[gimp/soc-2012-unified-transformation: 28/52] transformtool: Add the five options instead of just two
- From: Mikael Magnusson <mikachu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2012-unified-transformation: 28/52] transformtool: Add the five options instead of just two
- Date: Sat, 18 Aug 2012 17:29:56 +0000 (UTC)
commit b77b612103ef647f552d02ccbaa79301d1dd9412
Author: Mikael Magnusson <mikachu src gnome org>
Date: Wed Jul 18 14:06:38 2012 +0200
transformtool: Add the five options instead of just two
app/tools/gimptransformoptions.c | 105 +++++++++++++++++++++++++---------
app/tools/gimptransformoptions.h | 5 +-
app/tools/gimptransformtool.c | 25 ++++++--
app/tools/gimpunifiedtransformtool.c | 16 +++--
4 files changed, 110 insertions(+), 41 deletions(-)
---
diff --git a/app/tools/gimptransformoptions.c b/app/tools/gimptransformoptions.c
index b7a2e85..111749a 100644
--- a/app/tools/gimptransformoptions.c
+++ b/app/tools/gimptransformoptions.c
@@ -54,7 +54,10 @@ enum
PROP_GRID_TYPE,
PROP_GRID_SIZE,
PROP_CONSTRAIN,
- PROP_ALTERNATE,
+ PROP_KEEPASPECT,
+ PROP_FROMPIVOT,
+ PROP_FREESHEAR,
+ PROP_CORNERSNAP,
};
@@ -141,10 +144,25 @@ gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
- GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ALTERNATE,
- "alternate",
- N_("Use alternate set of controls"),
- TRUE,
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_KEEPASPECT,
+ "keepaspect",
+ NULL,
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FROMPIVOT,
+ "frompivot",
+ NULL,
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FREESHEAR,
+ "freeshear",
+ NULL,
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CORNERSNAP,
+ "cornersnap",
+ NULL,
+ FALSE,
GIMP_PARAM_STATIC_STRINGS);
}
@@ -191,8 +209,17 @@ gimp_transform_options_set_property (GObject *object,
case PROP_CONSTRAIN:
options->constrain = g_value_get_boolean (value);
break;
- case PROP_ALTERNATE:
- options->alternate = g_value_get_boolean (value);
+ case PROP_KEEPASPECT:
+ options->keepaspect = g_value_get_boolean (value);
+ break;
+ case PROP_FROMPIVOT:
+ options->frompivot = g_value_get_boolean (value);
+ break;
+ case PROP_FREESHEAR:
+ options->freeshear = g_value_get_boolean (value);
+ break;
+ case PROP_CORNERSNAP:
+ options->cornersnap = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -237,8 +264,17 @@ gimp_transform_options_get_property (GObject *object,
case PROP_CONSTRAIN:
g_value_set_boolean (value, options->constrain);
break;
- case PROP_ALTERNATE:
- g_value_set_boolean (value, options->alternate);
+ case PROP_KEEPASPECT:
+ g_value_set_boolean (value, options->keepaspect);
+ break;
+ case PROP_FROMPIVOT:
+ g_value_set_boolean (value, options->frompivot);
+ break;
+ case PROP_FREESHEAR:
+ g_value_set_boolean (value, options->freeshear);
+ break;
+ case PROP_CORNERSNAP:
+ g_value_set_boolean (value, options->cornersnap);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -283,7 +319,6 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
GtkWidget *grid_box;
const gchar *constrain_label = NULL;
const gchar *constrain_tip = NULL;
- const gchar *alternate = NULL;
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
@@ -366,37 +401,51 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
constrain_label = _("Keep aspect (%s)");
constrain_tip = _("Keep the original aspect ratio");
}
- else if (tool_options->tool_info->tool_type == GIMP_TYPE_UNIFIED_TRANSFORM_TOOL)
- {
- alternate = (_("From center (%s)"));
- constrain_label = constrain_tip = (_("Constrain/snap movement (%s)"));
- }
/* The constrain behaviour is not what is in the spec, it would make the help labels essays */
/* spec:
* constrain move,rotate,perspective = ctrl
- * keep aspect scale = shift
* from centre scale,shear = ctrl
- * free shear = shift
* centre/corner rotate = ctrl
+ * keep aspect scale = shift
+ * free shear = shift
* real life:
* constrain move,rotate,perspective,scale(aspect),shear,rotation axis = ctrl
* from centre scale, shear = shift
*/
- /* TODO: should we just hardcode ctrl and shift here instead of using the not really applicably named functions? */
- if (alternate)
+ //TODO: check that the selection tools use the gimp_get_*_mask() functions for constrain/etc or change to what they use
+ else if (tool_options->tool_info->tool_type == GIMP_TYPE_UNIFIED_TRANSFORM_TOOL)
{
+ struct {
+ gboolean shift;
+ gchar *name;
+ gchar *desc;
+ } opt_list[] = {
+ { TRUE, "keepaspect", "Keep aspect (%s)" },
+ { TRUE, "freeshear", "Move edge freely in shearing (%s)" },
+ { FALSE, "frompivot", "Scale from pivot / Symmetric shearing (%s)" },
+ { FALSE, "cornersnap", "Snap pivot point to corners/center (%s)" },
+ { FALSE, "constrain", "Constrain movement (%s)" },
+ };
+
GtkWidget *button;
gchar *label;
-
- label = g_strdup_printf (alternate,
- gimp_get_mod_string (gimp_get_extend_selection_mask ()));
-
- button = gimp_prop_check_button_new (config, "alternate", label);
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
-
- g_free (label);
+ gint i;
+
+ for (i = 0; i < 5; i++)
+ {
+ label = g_strdup_printf (opt_list[i].desc,
+ gimp_get_mod_string (
+ opt_list[i].shift
+ ? gimp_get_extend_selection_mask ()
+ : gimp_get_constrain_behavior_mask ()));
+
+ button = gimp_prop_check_button_new (config, opt_list[i].name, label);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
+
+ g_free (label);
+ }
}
if (constrain_label)
diff --git a/app/tools/gimptransformoptions.h b/app/tools/gimptransformoptions.h
index e9d2698..f483ed8 100644
--- a/app/tools/gimptransformoptions.h
+++ b/app/tools/gimptransformoptions.h
@@ -47,7 +47,10 @@ struct _GimpTransformOptions
GimpGuidesType grid_type;
gint grid_size;
gboolean constrain;
- gboolean alternate;
+ gboolean keepaspect;
+ gboolean frompivot;
+ gboolean freeshear;
+ gboolean cornersnap;
};
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index c198178..9ded675 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -490,14 +490,27 @@ gimp_transform_tool_modifier_key (GimpTool *tool,
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool);
if (key == gimp_get_constrain_behavior_mask ())
- g_object_set (options,
- "constrain", ! options->constrain,
- NULL);
+ {
+ g_object_set (options,
+ "frompivot", ! options->frompivot,
+ NULL);
+ g_object_set (options,
+ "cornersnap", ! options->cornersnap,
+ NULL);
+ g_object_set (options,
+ "constrain", ! options->constrain,
+ NULL);
+ }
if (key == gimp_get_extend_selection_mask ())
- g_object_set (options,
- "alternate", ! options->alternate,
- NULL);
+ {
+ g_object_set (options,
+ "keepaspect", ! options->keepaspect,
+ NULL);
+ g_object_set (options,
+ "freeshear", ! options->freeshear,
+ NULL);
+ }
}
static void
diff --git a/app/tools/gimpunifiedtransformtool.c b/app/tools/gimpunifiedtransformtool.c
index 289e81d..f47e610 100644
--- a/app/tools/gimpunifiedtransformtool.c
+++ b/app/tools/gimpunifiedtransformtool.c
@@ -759,7 +759,11 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
gint i;
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (transform_tool);
gboolean constrain = options->constrain;
- gboolean frompivot = options->alternate;
+ gboolean keepaspect = options->keepaspect;
+ gboolean frompivot = options->frompivot;
+ gboolean freeshear = options->freeshear;
+ gboolean cornersnap = options->cornersnap;
+
TransformAction function = transform_tool->function;
x[0] = &transform_tool->trans_info[X0];
@@ -852,7 +856,7 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
{
gint screenx, screeny;
- if (constrain)
+ if (cornersnap)
{
/* snap to corner points and center */
gint closest = 0;
@@ -913,7 +917,7 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
/* when the keep aspect transformation constraint is enabled, the
* translation shall only be along the diagonal that runs trough
* this corner point. */
- if (constrain)
+ if (keepaspect)
{
/* restrict to movement along the diagonal */
GimpVector2 diag = vectorsubtract (tp, op);
@@ -1062,7 +1066,7 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
/* restrict to movement along the midline */
p = vectorproject (p, midline);
- if (constrain)
+ if (keepaspect)
//TODO this scales about the center, not the opposite edge
{
/* when the keep aspect transformation constraint is enabled, all
@@ -1148,7 +1152,7 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
dxo = dyo = 0;
}
- if (constrain)
+ if (!freeshear)
{
/* restrict to movement along the side */
GimpVector2 lp = { .x = px[left], .y = py[left] },
@@ -1162,7 +1166,7 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
dy = p.y;
}
- if (constrain && frompivot)
+ if (!freeshear && frompivot)
{
/* restrict to movement along the opposite side */
GimpVector2 lp = { .x = px[lefto], .y = py[lefto] },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]