[gimp/soc-2009-dynamics] Adjust dynamics editor codes and its function call in dialogs-constructor.



commit 1b0c3595c35f29e36eb28eaadc24f6c3a84731a5
Author: zhenfeng zhao <zhzzf_0808 hotmail com>
Date:   Sun Aug 2 15:57:53 2009 -0300

    Adjust dynamics editor codes and its function call in dialogs-constructor.

 app/dialogs/dialogs-constructors.c |    4 +-
 app/widgets/gimpdynamicseditor.c   |  321 ++++--------------------------------
 app/widgets/gimpdynamicseditor.h   |    6 +-
 3 files changed, 41 insertions(+), 290 deletions(-)
---
diff --git a/app/dialogs/dialogs-constructors.c b/app/dialogs/dialogs-constructors.c
index cb9b5f0..6babfbf 100644
--- a/app/dialogs/dialogs-constructors.c
+++ b/app/dialogs/dialogs-constructors.c
@@ -32,7 +32,7 @@
 #include "config/gimpguiconfig.h"
 
 #include "widgets/gimpbrusheditor.h"
-//#include "widgets/gimpdynamicseditor.h"
+#include "widgets/gimpdynamicseditor.h"
 #include "widgets/gimpbrushfactoryview.h"
 #include "widgets/gimpbufferview.h"
 #include "widgets/gimpchanneltreeview.h"
@@ -675,7 +675,7 @@ dialogs_dynamics_editor_get (GimpDialogFactory *factory,
                           GimpContext       *context,
                           gint               view_size)
 {
-  return gimp_brush_editor_new (context,
+  return gimp_dynamics_editor_new (context,
                                 factory->menu_factory);
 }
 
diff --git a/app/widgets/gimpdynamicseditor.c b/app/widgets/gimpdynamicseditor.c
index d2600da..e81d554 100644
--- a/app/widgets/gimpdynamicseditor.c
+++ b/app/widgets/gimpdynamicseditor.c
@@ -74,8 +74,8 @@ static GObject * gimp_dynamics_editor_constructor (GType              type,
                                                    guint              n_params,
                                                    GObjectConstructParam *params);
 
-//static void   gimp_dynamics_editor_set_data       (GimpDataEditor     *editor,
-//                                                   GimpData           *data);
+static void   gimp_dynamics_editor_set_data       (GimpDataEditor     *editor,
+                                                   GimpData           *data);
 
 static void   gimp_dynamics_editor_set_context    (GimpDocked         *docked,
                                                    GimpContext        *context);
@@ -137,7 +137,7 @@ gimp_dynamics_editor_class_init (GimpDynamicsEditorClass *klass)
 
   object_class->constructor = gimp_dynamics_editor_constructor;
 
-  //editor_class->set_data    = gimp_dynamics_editor_set_data;
+  editor_class->set_data    = gimp_dynamics_editor_set_data;
   editor_class->title       = _("Dynamics Editor");
 }
 
@@ -163,291 +163,22 @@ static void
 gimp_dynamics_editor_init (GimpDynamicsEditor *editor)
 {
   GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
-}
-/*  
-  GtkWidget      *frame;
-  GtkWidget      *box;
-  gint            row = 0;
-*/
 
-/*  public functions  */
-
-GtkWidget *
-gimp_paint_options_gui (GimpToolOptions *tool_options)
-{
+  GtkWidget      *frame;
+  //GtkWidget      *box;
+  //gint            row = 0;
+
+  //add a frame
+  frame = gtk_frame_new (NULL);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
+  gtk_box_pack_start (GTK_BOX (editor), frame, TRUE, TRUE, 0);
+  gtk_widget_show (frame);
 	
-  GObject          *config  = G_OBJECT (tool_options);
-  GimpPaintOptions *options = GIMP_PAINT_OPTIONS (tool_options);
-  GtkWidget        *vbox    = gimp_tool_options_gui (tool_options);
-  GtkWidget        *frame;
-  GtkWidget        *table;
-  GtkWidget        *menu;
-  GtkWidget        *label;
-  GtkWidget        *button;
-  GtkWidget        *incremental_toggle = NULL;
-  gint              table_row          = 0;
-  gint              n_dynamics         = 0;
-  GtkWidget        *dynamics_labels[7];
-  GType             tool_type;
-
-  tool_type = tool_options->tool_info->tool_type;
-
-  /*  the main table  */
-  table = gtk_table_new (3, 3, FALSE);
-  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
-  gtk_table_set_row_spacings (GTK_TABLE (table), 2);
-  gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
-  gtk_widget_show (table);
-
-  g_object_set_data (G_OBJECT (vbox), GIMP_PAINT_OPTIONS_TABLE_KEY, table);
-
-  /*  the paint mode menu  */
-  menu  = gimp_prop_paint_mode_menu_new (config, "paint-mode", TRUE, FALSE);
-  label = gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
-                                     _("Mode:"), 0.0, 0.5,
-                                     menu, 2, FALSE);
-
-  if (tool_type == GIMP_TYPE_ERASER_TOOL     ||
-      tool_type == GIMP_TYPE_CONVOLVE_TOOL   ||
-      tool_type == GIMP_TYPE_DODGE_BURN_TOOL ||
-      tool_type == GIMP_TYPE_SMUDGE_TOOL)
-    {
-      gtk_widget_set_sensitive (menu, FALSE);
-      gtk_widget_set_sensitive (label, FALSE);
-    }
-
-  /*  the opacity scale  */
-  gimp_prop_opacity_entry_new (config, "opacity",
-                               GTK_TABLE (table), 0, table_row++,
-                               _("Opacity:"));
-
-  /*  the brush  */
-  if (g_type_is_a (tool_type, GIMP_TYPE_BRUSH_TOOL))
-    {
-      GtkObject *adj_scale;
-      GtkObject *adj_angle;
-      GtkObject *adj_aspect_ratio;
-
-
-      button = gimp_prop_brush_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
-                                        "brush-view-type", "brush-view-size");
-      gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
-                                 _("Brush:"), 0.0, 0.5,
-                                 button, 2, FALSE);
-
-      adj_scale = gimp_prop_scale_entry_new (config, "brush-scale",
-                                             GTK_TABLE (table), 0, table_row++,
-                                             _("Scale:"),
-                                             0.01, 0.1, 2,
-                                             FALSE, 0.0, 0.0);
-      gimp_scale_entry_set_logarithmic (adj_scale, TRUE);
-
-      adj_aspect_ratio = gimp_prop_scale_entry_new (config, "brush-aspect-ratio",
-                                                    GTK_TABLE (table), 0, table_row++,
-                                                    _("Aspect Ratio:"),
-                                                    0.01, 0.1, 2,
-                                                    FALSE, 0.0, 0.0);
-      gimp_scale_entry_set_logarithmic (adj_aspect_ratio, TRUE);
-
-      adj_angle = gimp_prop_scale_entry_new (config, "brush-angle",
-                                             GTK_TABLE (table), 0, table_row++,
-                                             _("Angle:"),
-                                             1.0, 5.0, 2,
-                                             FALSE, 0.0, 0.0);
-    }
-
-  if (tool_has_opacity_dynamics (tool_type))
-    {
-      dynamics_labels[n_dynamics] = gtk_label_new (_("Opacity"));
-      n_dynamics++;
-    }
-
-  if (tool_has_hardness_dynamics (tool_type))
-    {
-      dynamics_labels[n_dynamics] = gtk_label_new (_("Hardness"));
-      n_dynamics++;
-    }
-
-  if (tool_has_rate_dynamics (tool_type))
-    {
-      dynamics_labels[n_dynamics] = gtk_label_new (_("Rate"));
-      n_dynamics++;
-    }
-
-  if (tool_has_size_dynamics (tool_type))
-    {
-      dynamics_labels[n_dynamics] = gtk_label_new (_("Size"));
-      n_dynamics++;
-    }
-
-  if (tool_has_aspect_ratio_dynamics (tool_type))
-    {
-      dynamics_labels[n_dynamics] = gtk_label_new (_("Aspect ratio"));
-      n_dynamics++;
-    }
-
-
-  if (tool_has_angle_dynamics (tool_type))
-    {
-      dynamics_labels[n_dynamics] = gtk_label_new (_("Angle"));
-      n_dynamics++;
-    }
-
-  if (tool_has_color_dynamics (tool_type))
-    {
-      dynamics_labels[n_dynamics] = gtk_label_new (_("Color"));
-      n_dynamics++;
-    }
-
-  /* NB: When adding new dynamics, increase size of the
-   * dynamics_labels[] array
-   */
-
-
-  if (n_dynamics > 0)
-    {
-      GtkWidget *inner_frame;
-      GtkWidget *fixed;
-      gint       i;
-      gboolean   rtl = gtk_widget_get_direction (vbox) == GTK_TEXT_DIR_RTL;
-
-      frame = gimp_prop_expander_new (config, "dynamics-expanded",
-                                      _("Brush Dynamics"));
-      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-      gtk_widget_show (frame);
-
-      inner_frame = gimp_frame_new ("<expander>");
-      gtk_container_add (GTK_CONTAINER (frame), inner_frame);
-      gtk_widget_show (inner_frame);
-
-      table = gtk_table_new (7, n_dynamics + 2, FALSE);
-      gtk_container_add (GTK_CONTAINER (inner_frame), table);
-      gtk_widget_show (table);
-
-      label = gtk_label_new (_("Pressure:"));
-      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
-                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
-      gtk_widget_show (label);
-
-      label = gtk_label_new (_("Velocity:"));
-      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
-                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
-      gtk_widget_show (label);
-
-      label = gtk_label_new (_("Direction:"));
-      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
-                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
-      gtk_widget_show (label);
-
-      label = gtk_label_new (_("Tilt:"));
-      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
-                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
-      gtk_widget_show (label);
-
-      label = gtk_label_new (_("Random:"));
-      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 5, 6,
-                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
-      gtk_widget_show (label);
-
-      label = gtk_label_new (_("Fading - new:"));
-      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 6, 7,
-                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
-      gtk_widget_show (label);
-
-      pressure_options_gui (options, tool_type,
-                            GTK_TABLE (table), 1,
-                            dynamics_labels);
-
-      velocity_options_gui (options, tool_type,
-                            GTK_TABLE (table), 2);
-
-      direction_options_gui (options, tool_type,
-                             GTK_TABLE (table), 3);
-
-      tilt_options_gui (options, tool_type,
-                        GTK_TABLE (table), 4);
-
-      random_options_gui (options, tool_type,
-                          GTK_TABLE (table), 5);
-
-      fading_options_gui (options, tool_type,
-                          GTK_TABLE (table), 6);
+}
 
-      /* EEK: pack the fixed *after* the buttons so the table calls
-       * size-allocates on it *before* it places the toggles. Fixes
-       * label positions in RTL mode.
-       */
-      fixed = gtk_fixed_new ();
-      gtk_table_attach (GTK_TABLE (table), fixed, 0, n_dynamics + 2, 0, 1,
-                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
-      gtk_widget_show (fixed);
 
-      for (i = 0; i < n_dynamics; i++)
-        {
-          gtk_label_set_angle (GTK_LABEL (dynamics_labels[i]),
-                               rtl ? 315 : 45);
-          gtk_misc_set_alignment (GTK_MISC (dynamics_labels[i]), 1.0, 1.0);
-          gtk_fixed_put (GTK_FIXED (fixed), dynamics_labels[i], 0, 0);
-          gtk_widget_show (dynamics_labels[i]);
-        }
-    }
-
-  if (g_type_is_a (tool_type, GIMP_TYPE_BRUSH_TOOL))
-    {
-      frame = fade_options_gui (options, tool_type);
-      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-      gtk_widget_show (frame);
-
-      frame = jitter_options_gui (options, tool_type);
-      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-      gtk_widget_show (frame);
-    }
-
-  /*  the "incremental" toggle  */
-  if (tool_type == GIMP_TYPE_PENCIL_TOOL     ||
-      tool_type == GIMP_TYPE_PAINTBRUSH_TOOL ||
-      tool_type == GIMP_TYPE_ERASER_TOOL)
-    {
-      incremental_toggle =
-        gimp_prop_enum_check_button_new (config,
-                                         "application-mode",
-                                         _("Incremental"),
-                                         GIMP_PAINT_CONSTANT,
-                                         GIMP_PAINT_INCREMENTAL);
-      gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0);
-      gtk_widget_show (incremental_toggle);
-    }
-
-  /* the "hard edge" toggle */
-  if (tool_type == GIMP_TYPE_ERASER_TOOL            ||
-      tool_type == GIMP_TYPE_CLONE_TOOL             ||
-      tool_type == GIMP_TYPE_HEAL_TOOL              ||
-      tool_type == GIMP_TYPE_PERSPECTIVE_CLONE_TOOL ||
-      tool_type == GIMP_TYPE_CONVOLVE_TOOL          ||
-      tool_type == GIMP_TYPE_DODGE_BURN_TOOL        ||
-      tool_type == GIMP_TYPE_SMUDGE_TOOL)
-    {
-      button = gimp_prop_check_button_new (config, "hard", _("Hard edge"));
-      gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
-      gtk_widget_show (button);
-    }
-
-  if (g_type_is_a (tool_type, GIMP_TYPE_PAINTBRUSH_TOOL))
-    {
-      frame = gradient_options_gui (options, tool_type, incremental_toggle);
-      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-      gtk_widget_show (frame);
-    }
-
-  return vbox;
-}
 
+	
 static GObject *
 gimp_dynamics_editor_constructor (GType                  type,
                                   guint                  n_params,
@@ -476,7 +207,7 @@ gimp_dynamics_editor_set_context (GimpDocked  *docked,
 
 /*  public functions  */
 
-/*
+
 GtkWidget *
 gimp_dynamics_editor_new (GimpContext     *context,
                           GimpMenuFactory *menu_factory)
@@ -492,7 +223,7 @@ gimp_dynamics_editor_new (GimpContext     *context,
                        "data",            gimp_context_get_brush (context),
                        NULL);
 }
-*/
+
 
 
 /*  private functions  */
@@ -990,3 +721,23 @@ fading_options_gui (GimpPaintOptions *paint_options,
 }
 
 
+/*
+GtkWidget *
+gimp_paint_options_gui (GimpToolOptions *tool_options)
+{
+	
+  GObject          *config  = G_OBJECT (tool_options);
+  GimpPaintOptions *options = GIMP_PAINT_OPTIONS (tool_options);
+  GtkWidget        *vbox    = gimp_tool_options_gui (tool_options);
+  GtkWidget        *frame;
+  GtkWidget        *table;
+  GtkWidget        *menu;
+  GtkWidget        *label;
+  GtkWidget        *button;
+  GtkWidget        *incremental_toggle = NULL;
+  gint              table_row          = 0;
+  gint              n_dynamics         = 0;
+  GtkWidget        *dynamics_labels[7];
+  GType             tool_type;
+}
+*/
diff --git a/app/widgets/gimpdynamicseditor.h b/app/widgets/gimpdynamicseditor.h
index 7928876..eb0e97c 100644
--- a/app/widgets/gimpdynamicseditor.h
+++ b/app/widgets/gimpdynamicseditor.h
@@ -28,19 +28,19 @@
 #define GIMP_IS_DYNAMICS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DYNAMICS_EDITOR))
 #define GIMP_DYNAMICS_EDITOR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DYNAMICS_EDITOR, GimpDynamicsEditorClass))
 
-
 typedef struct _GimpDynamicsEditorClass GimpDynamicsEditorClass;
 
+
 struct _GimpDynamicsEditor
 {
   GimpDataEditor  parent_instance;
-  //GtkWidget      *options_vbox;
+  GtkWidget      *options_vbox;
 
   //not sure what to add yet.
   
 };
 
-GtkWidget  * gimp_paint_options_gui (GimpToolOptions *tool_options);
+//GtkWidget  * gimp_paint_options_gui (GimpToolOptions *tool_options);
 
 struct _GimpDynamicsEditorClass
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]