gimp-gap r782 - in trunk: . gap
- From: wolfgangh svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp-gap r782 - in trunk: . gap
- Date: Sun, 12 Oct 2008 12:04:59 +0000 (UTC)
Author: wolfgangh
Date: Sun Oct 12 12:04:58 2008
New Revision: 782
URL: http://svn.gnome.org/viewvc/gimp-gap?rev=782&view=rev
Log:
wrapper for rotate any angle
Modified:
trunk/ChangeLog
trunk/gap/gap_wr_trans.c
Modified: trunk/gap/gap_wr_trans.c
==============================================================================
--- trunk/gap/gap_wr_trans.c (original)
+++ trunk/gap/gap_wr_trans.c Sun Oct 12 12:04:58 2008
@@ -41,6 +41,7 @@
/* Defines */
+#define PLUG_IN_NAME_ANY "plug_in_wr_layer_rotate_any"
#define PLUG_IN_NAME_180 "plug_in_wr_layer_rotate_180"
#define PLUG_IN_NAME_90 "plug_in_wr_layer_rotate_90"
#define PLUG_IN_NAME_270 "plug_in_wr_layer_rotate_270"
@@ -50,6 +51,10 @@
#define PLUG_IN_AUTHOR "Wolfgang Hofer (hof gimp org)"
#define PLUG_IN_COPYRIGHT "Wolfgang Hofer"
+#define PLUG_IN_BINARY "gap_wr_trans"
+
+#define SCALE_WIDTH 200
+
typedef enum
{
GAP_TRANS_UNDEFINED
@@ -58,16 +63,17 @@
,GAP_TRANS_ROT_90
,GAP_TRANS_ROT_180
,GAP_TRANS_ROT_270
+ ,GAP_TRANS_ROT_ANY
} GapTransLayerMode;
typedef struct {
- gint32 dummy;
+ gdouble angle_deg;
} TransValues;
static TransValues glob_vals =
{
- 0 /* dummy */
+ 0.0 /* rotation angle in degree */
};
static void iter_query ();
@@ -78,7 +84,8 @@
gint *nreturn_vals, /* number of out-parameters */
GimpParam ** return_vals); /* out-parameters */
-static gint32 p_transform_layer(gint32 image_id, gint32 drawable_id, GapTransLayerMode trans_mode);
+static gint32 p_transform_layer(gint32 image_id, gint32 drawable_id, GapTransLayerMode trans_mode, TransValues *val_ptr);
+static gboolean p_dialog(GapTransLayerMode trans_mode, TransValues *val_ptr);
/* Global Variables */
@@ -116,12 +123,18 @@
static GimpLastvalDef lastvals[] =
{
- GIMP_LASTVALDEF_GINT32 (GIMP_ITER_FALSE, glob_vals.dummy, "dummy"),
+ GIMP_LASTVALDEF_GINT32 (GIMP_ITER_FALSE, glob_vals.angle_deg, "angle in degree"),
};
gimp_plugin_domain_register (GETTEXT_PACKAGE, LOCALEDIR);
/* registration for last values buffer structure (useful for animated filter apply) */
+ gimp_lastval_desc_register(PLUG_IN_NAME_ANY,
+ &glob_vals,
+ sizeof(glob_vals),
+ G_N_ELEMENTS (lastvals),
+ lastvals);
+
gimp_lastval_desc_register(PLUG_IN_NAME_90,
&glob_vals,
sizeof(glob_vals),
@@ -240,6 +253,23 @@
global_number_out_args,
in_args,
NULL);
+
+ gimp_install_procedure (PLUG_IN_NAME_ANY,
+ "Rotate Layer by specified angle in degree",
+ "This plug-in is a wrapper for gimp rotate functionality, "
+ "and provides the typical PDB interface for calling it as "
+ "filter in animations."
+ "(for the use with GAP Video Frame manipulation)",
+ PLUG_IN_AUTHOR,
+ PLUG_IN_COPYRIGHT,
+ GAP_VERSION_WITH_DATE,
+ N_("Rotate any angle"),
+ PLUG_IN_IMAGE_TYPES,
+ GIMP_PLUGIN,
+ global_number_in_args,
+ global_number_out_args,
+ in_args,
+ NULL);
{
/* Menu names */
const char *menupath_image_video_layer_transform = N_("<Image>/Video/Layer/Transform/");
@@ -253,6 +283,7 @@
gimp_plugin_menu_register (PLUG_IN_NAME_90, menupath_image_video_layer_transform);
gimp_plugin_menu_register (PLUG_IN_NAME_180, menupath_image_video_layer_transform);
gimp_plugin_menu_register (PLUG_IN_NAME_270, menupath_image_video_layer_transform);
+ gimp_plugin_menu_register (PLUG_IN_NAME_ANY, menupath_image_video_layer_transform);
}
} /* end query */
@@ -329,15 +360,59 @@
{
trans_mode = GAP_TRANS_ROT_270;
}
+
+ if (strcmp (name, PLUG_IN_NAME_ANY) == 0)
+ {
+ trans_mode = GAP_TRANS_ROT_ANY;
+ }
if(trans_mode != GAP_TRANS_UNDEFINED)
{
if(gimp_drawable_is_layer(drawable_id))
{
+ gboolean run_flag;
+
+ /* Initial values */
+ glob_vals.angle_deg = 0;
+ run_flag = TRUE;
+
+ /* Possibly retrieve data from a previous run */
+ gimp_get_data (name, &glob_vals);
+
+ switch (run_mode)
+ {
+ case GIMP_RUN_INTERACTIVE:
+
+ /* Get information from the dialog */
+ run_flag = p_dialog(trans_mode, &glob_vals);
+ break;
+
+ case GIMP_RUN_NONINTERACTIVE:
+ /* check to see if invoked with the correct number of parameters */
+ if (nparams >= 4)
+ {
+ glob_vals.angle_deg = param[3].data.d_float;
+ }
+ else
+ {
+ status = GIMP_PDB_CALLING_ERROR;
+ }
+ break;
+
+ case GIMP_RUN_WITH_LAST_VALS:
+ break;
+
+ default:
+ break;
+ }
+
+
+
/* here the action starts, we transform the drawable */
trans_drawable_id = p_transform_layer(image_id
, drawable_id
, trans_mode
+ , &glob_vals
);
if (trans_drawable_id < 0)
{
@@ -394,7 +469,7 @@
* --------------------------
*/
static gint32
-p_transform_layer(gint32 image_id, gint32 drawable_id, GapTransLayerMode trans_mode)
+p_transform_layer(gint32 image_id, gint32 drawable_id, GapTransLayerMode trans_mode, TransValues *val_ptr)
{
gboolean auto_center;
gboolean clip_result;
@@ -414,7 +489,7 @@
center_x = gimp_drawable_width(drawable_id) / 2;
center_y = gimp_drawable_height(drawable_id) / 2;
- if(has_selection)
+ if(non_empty)
{
sav_selection_id = gimp_selection_save(image_id);
}
@@ -477,12 +552,31 @@
,clip_result
);
break;
+ case GAP_TRANS_ROT_ANY:
+ {
+ gdouble l_angle_rad;
+
+ clip_result = FALSE;
+ l_angle_rad = (val_ptr->angle_deg * G_PI) / 180.0;
+
+ trans_drawable_id = gimp_drawable_transform_rotate_default(drawable_id
+ , l_angle_rad
+ , FALSE /* auto_center */
+ , center_x
+ , center_y
+ , TRUE /* interpolation (TRUE use default interpolation) */
+ , clip_result
+ );
+
+
+ } /* end gap_pdb_gimp_rotate_degree */
+ break;
default:
break;
}
- if((has_selection)
+ if((non_empty)
&& (sav_selection_id >= 0))
{
/* if there was a selection, the transform (flip or simple rotate) operation
@@ -500,7 +594,7 @@
gimp_selection_load(sav_selection_id);
gimp_image_remove_channel(image_id, sav_selection_id);
- gimp_drawable_delete(sav_selection_id);
+ //gimp_drawable_delete(sav_selection_id);
}
gimp_image_undo_group_end(image_id);
@@ -508,3 +602,76 @@
return (trans_drawable_id);
} /* end p_transform_layer */
+
+
+
+/* --------------------------
+ * p_dialog
+ * --------------------------
+ */
+static gboolean
+p_dialog (GapTransLayerMode trans_mode, TransValues *val_ptr)
+{
+ GtkWidget *dialog;
+ GtkWidget *main_vbox;
+ GtkWidget *preview;
+ GtkWidget *table;
+ GtkObject *adj;
+ gboolean run;
+
+ if(trans_mode != GAP_TRANS_ROT_ANY)
+ {
+ /* all other modes have no dialog and shall run immediate when invoked */
+ return (TRUE);
+ }
+
+ gimp_ui_init (PLUG_IN_BINARY, TRUE);
+
+ dialog = gimp_dialog_new (_("Rotate any angle"), PLUG_IN_BINARY,
+ NULL, 0,
+ gimp_standard_help_func, PLUG_IN_NAME_ANY,
+
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+
+ NULL);
+
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL,
+ -1);
+
+ gimp_window_set_transient (GTK_WINDOW (dialog));
+
+ main_vbox = gtk_vbox_new (FALSE, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
+ gtk_widget_show (main_vbox);
+
+
+ /* Controls */
+ table = gtk_table_new (3, 3, FALSE);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 6);
+ gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+ gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);
+ gtk_widget_show (table);
+
+ adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
+ _("Rotate angle:"), SCALE_WIDTH, 7,
+ val_ptr->angle_deg, -3600.0, 3600.0, 1.0, 15.0, 2,
+ TRUE, 0, 0,
+ NULL, NULL);
+ g_signal_connect (adj, "value-changed",
+ G_CALLBACK (gimp_double_adjustment_update),
+ &val_ptr->angle_deg);
+
+ /* Done */
+
+ gtk_widget_show (dialog);
+
+ run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
+
+ gtk_widget_destroy (dialog);
+
+ return run;
+} /* end p_dialog */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]