Some formatting cleanup in the unified transform tool commits

This commit is contained in:
Michael Natterer 2012-08-21 19:50:01 +02:00
parent 2d2756688d
commit b1acd93f5e
5 changed files with 76 additions and 42 deletions

View File

@ -240,7 +240,7 @@ static const GimpDialogFactoryEntry entries[] =
FOREIGN ("gimp-text-tool-dialog", TRUE, TRUE),
FOREIGN ("gimp-threshold-tool-dialog", TRUE, FALSE),
FOREIGN ("gimp-perspective-tool-dialog", TRUE, FALSE),
FOREIGN ("gimp-unified-transform-tool-dialog", TRUE, FALSE),
FOREIGN ("gimp-unified-transform-tool-dialog", TRUE, FALSE),
FOREIGN ("gimp-toolbox-color-dialog", TRUE, FALSE),
FOREIGN ("gimp-gradient-editor-color-dialog", TRUE, FALSE),

View File

@ -194,8 +194,8 @@ libapptools_a_sources = \
gimptransformtool.h \
gimptransformtoolundo.c \
gimptransformtoolundo.h \
gimpunifiedtransformtool.c \
gimpunifiedtransformtool.h \
gimpunifiedtransformtool.c \
gimpunifiedtransformtool.h \
gimpvectoroptions.c \
gimpvectoroptions.h \
gimpvectortool.c \

View File

@ -469,28 +469,44 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
else if (tool_options->tool_info->tool_type == GIMP_TYPE_UNIFIED_TRANSFORM_TOOL)
{
GdkModifierType shift = gimp_get_extend_selection_mask ();
GdkModifierType ctrl = gimp_get_constrain_behavior_mask ();
struct {
GdkModifierType ctrl = gimp_get_constrain_behavior_mask ();
struct
{
GdkModifierType mod;
gchar *name;
gchar *desc;
gchar *tip;
} opt_list[] = {
}
opt_list[] =
{
{ shift, NULL, "Constrain (%s)" },
{ shift, "constrain-move", "Move", "Constrain movement to 45 degree angles from center (%s)" },
{ shift, "constrain-scale", "Scale", "Maintain aspect ratio when scaling (%s)" },
{ shift, "constrain-rotate", "Rotate", "Constrain rotation to 15 degree increments (%s)" },
{ shift, "constrain-shear", "Shear", "Shear along edge direction only (%s)" },
{ shift, "constrain-perspective", "Perspective", "Constrain perspective handles to move along edges and diagonal (%s)" },
{ shift, "constrain-move", "Move",
"Constrain movement to 45 degree angles from center (%s)" },
{ shift, "constrain-scale", "Scale",
"Maintain aspect ratio when scaling (%s)" },
{ shift, "constrain-rotate", "Rotate",
"Constrain rotation to 15 degree increments (%s)" },
{ shift, "constrain-shear", "Shear",
"Shear along edge direction only (%s)" },
{ shift, "constrain-perspective", "Perspective",
"Constrain perspective handles to move along edges and diagonal (%s)" },
{ ctrl, NULL, "From pivot (%s)" },
{ ctrl, "frompivot-scale", "Scale", "Scale from pivot point (%s)" },
{ ctrl, "frompivot-shear", "Shear", "Shear opposite edge by same amount (%s)" },
{ ctrl, "frompivot-perspective", "Perspective", "Maintain position of pivot while changing perspective (%s)" },
{ ctrl, NULL,
"From pivot (%s)" },
{ ctrl, "frompivot-scale", "Scale",
"Scale from pivot point (%s)" },
{ ctrl, "frompivot-shear", "Shear",
"Shear opposite edge by same amount (%s)" },
{ ctrl, "frompivot-perspective", "Perspective",
"Maintain position of pivot while changing perspective (%s)" },
{ 0, NULL, "Pivot" },
{ shift, "cornersnap", "Snap (%s)", "Snap pivot to corners and center (%s)" },
{ 0, "fixedpivot", "Lock", "Lock pivot position to canvas" },
{ 0, NULL,
"Pivot" },
{ shift, "cornersnap", "Snap (%s)",
"Snap pivot to corners and center (%s)" },
{ 0, "fixedpivot", "Lock",
"Lock pivot position to canvas" },
};
GtkWidget *button;
@ -512,9 +528,11 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
if (opt_list[i].name)
{
button = gimp_prop_check_button_new (config, opt_list[i].name, label);
gtk_box_pack_start (GTK_BOX (frame ? grid_box : vbox), button, FALSE, FALSE, 0);
button = gimp_prop_check_button_new (config, opt_list[i].name,
label);
gtk_box_pack_start (GTK_BOX (frame ? grid_box : vbox),
button, FALSE, FALSE, 0);
gtk_widget_show (button);

View File

@ -68,8 +68,8 @@
#define RESPONSE_RESET 1
#define RESPONSE_UNDO 2
#define RESPONSE_REDO 3
#define RESPONSE_UNDO 2
#define RESPONSE_REDO 3
#define MIN_HANDLE_SIZE 6
@ -150,7 +150,8 @@ static void gimp_transform_tool_handles_recalc (GimpTransformTool
static void gimp_transform_tool_response (GtkWidget *widget,
gint response_id,
GimpTransformTool *tr_tool);
static void free_trans (gpointer data);
static void free_trans (gpointer data);
static void update_sensitivity (GimpTransformTool *tr_tool);
@ -288,6 +289,7 @@ gimp_transform_tool_initialize (GimpTool *tool,
tr_tool->old_trans_info = g_list_last (tr_tool->undo_list)->data;
tr_tool->prev_trans_info = g_list_first (tr_tool->undo_list)->data;
update_sensitivity (tr_tool);
/* Save the current transformation info */
for (i = 0; i < TRANS_INFO_SIZE; i++)
{
@ -351,8 +353,9 @@ void gimp_transform_tool_push_internal_undo (GimpTransformTool *tr_tool)
{
gint i;
/* push current state on the undo list and set this
* state as the current state, but avoid doing this if there were no changes */
/* push current state on the undo list and set this state as the
* current state, but avoid doing this if there were no changes
*/
for (i = 0; i < TRANS_INFO_SIZE; i++)
if ((*tr_tool->prev_trans_info)[i] != tr_tool->trans_info[i])
break;
@ -362,10 +365,12 @@ void gimp_transform_tool_push_internal_undo (GimpTransformTool *tr_tool)
tr_tool->prev_trans_info = g_slice_new (TransInfo);
for (i = 0; i < TRANS_INFO_SIZE; i++)
(*tr_tool->prev_trans_info)[i] = tr_tool->trans_info[i];
tr_tool->undo_list = g_list_prepend (tr_tool->undo_list, tr_tool->prev_trans_info);
tr_tool->undo_list = g_list_prepend (tr_tool->undo_list,
tr_tool->prev_trans_info);
/* If we undid anything and started interacting, we have to discard
* the redo history */
/* If we undid anything and started interacting, we have to
* discard the redo history
*/
g_list_free_full (tr_tool->redo_list, free_trans);
tr_tool->redo_list = NULL;
@ -803,7 +808,8 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
tr_tool->y1,
tr_tool->x2,
tr_tool->y2,
GIMP_IS_PERSPECTIVE_TOOL (tr_tool) || GIMP_IS_UNIFIED_TRANSFORM_TOOL (tr_tool),
GIMP_IS_PERSPECTIVE_TOOL (tr_tool) ||
GIMP_IS_UNIFIED_TRANSFORM_TOOL (tr_tool),
options->preview_opacity);
}
@ -1544,8 +1550,8 @@ gimp_transform_tool_response (GtkWidget *widget,
GimpTransformTool *tr_tool)
{
GimpTool *tool = GIMP_TOOL (tr_tool);
GList *it = tr_tool->redo_list;
gint i;
GList *it = tr_tool->redo_list;
gint i;
switch (response_id)
{
@ -1560,24 +1566,32 @@ gimp_transform_tool_response (GtkWidget *widget,
if (response_id == RESPONSE_UNDO)
{
/* Move prev_trans_info from undo_list to redo_list */
tr_tool->redo_list = g_list_prepend (tr_tool->redo_list, tr_tool->prev_trans_info);
tr_tool->undo_list = g_list_remove (tr_tool->undo_list, tr_tool->prev_trans_info);
tr_tool->redo_list = g_list_prepend (tr_tool->redo_list,
tr_tool->prev_trans_info);
tr_tool->undo_list = g_list_remove (tr_tool->undo_list,
tr_tool->prev_trans_info);
tr_tool->prev_trans_info = it->data;
}
else if (response_id == RESPONSE_REDO)
{
/* And the opposite */
tr_tool->prev_trans_info = it->data;
tr_tool->undo_list = g_list_prepend (tr_tool->undo_list, tr_tool->prev_trans_info);
tr_tool->redo_list = g_list_remove (tr_tool->redo_list, tr_tool->prev_trans_info);
tr_tool->undo_list = g_list_prepend (tr_tool->undo_list,
tr_tool->prev_trans_info);
tr_tool->redo_list = g_list_remove (tr_tool->redo_list,
tr_tool->prev_trans_info);
}
else if (response_id == RESPONSE_RESET)
{
/* Move all undo events to redo, and pop off the first one as that's the current one,
* which always sits on the undo_list */
tr_tool->redo_list = g_list_remove (g_list_concat (g_list_reverse (tr_tool->undo_list), tr_tool->redo_list), tr_tool->old_trans_info);
tr_tool->redo_list =
g_list_remove (g_list_concat (g_list_reverse (tr_tool->undo_list),
tr_tool->redo_list),
tr_tool->old_trans_info);
tr_tool->prev_trans_info = tr_tool->old_trans_info;
tr_tool->undo_list = g_list_prepend (NULL, tr_tool->prev_trans_info);
tr_tool->undo_list = g_list_prepend (NULL,
tr_tool->prev_trans_info);
}
update_sensitivity (tr_tool);
@ -1611,12 +1625,14 @@ gimp_transform_tool_response (GtkWidget *widget,
}
}
static void free_trans (gpointer data)
static void
free_trans (gpointer data)
{
g_slice_free (TransInfo, data);
}
static void update_sensitivity (GimpTransformTool *tr_tool)
static void
update_sensitivity (GimpTransformTool *tr_tool)
{
if (!tr_tool->dialog)
return;

View File

@ -347,8 +347,8 @@ STOCK_TOOL_IMAGES = \
tools/stock-tool-text-22.png \
tools/stock-tool-threshold-16.png \
tools/stock-tool-threshold-22.png \
tools/stock-tool-unified-transform-16.png \
tools/stock-tool-unified-transform-22.png \
tools/stock-tool-unified-transform-16.png \
tools/stock-tool-unified-transform-22.png \
tools/stock-tool-zoom-16.png \
tools/stock-tool-zoom-22.png