[SCM] calf/master: + GUI: more work on list control (still not functional)

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:39:30 UTC 2013


The following commit has been merged in the master branch:
commit 62038c7c30f8411f2cdcc1a229e71d003d03f41e
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Tue Apr 21 23:30:13 2009 +0100

    + GUI: more work on list control (still not functional)

diff --git a/src/calf/giface.h b/src/calf/giface.h
index e788b82..2ac7ac4 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -207,6 +207,8 @@ enum table_column_type
     TCT_FLOAT, ///< float value (encoded as C locale string)
     TCT_ENUM, ///< enum value (see: 'values' array in table_column_info) - encoded as string base 10 representation of integer
     TCT_STRING, ///< string value (encoded as C-escaped string)
+    TCT_OBJECT, ///< external object, encoded as string
+    TCT_LABEL, ///< string value (encoded as C-escaped string)
 };
 
 /// parameters of 
@@ -225,16 +227,22 @@ struct table_edit_iface
 {
     /// retrieve the table layout for specific parameter
     virtual const table_column_info *get_table_columns(int param) = 0;
+
+    /// return the current number of rows
+    virtual uint32_t get_table_rows(int param) = 0;
     
-    /// change parsable string to visible string
-    virtual std::string to_string(int param, int column, const std::string &src, std::string &error) { error.clear(); return src; }
+    /// retrieve data item from the plugin
+    virtual std::string get_cell(int param, int column) { return calf_utils::i2s(param)+":"+calf_utils::i2s(column); }
 
-    /// make a parsable string out of user-entered string (including validation)
-    virtual std::string from_string(int param, int column, const std::string &src, std::string &error) { error.clear(); return src; }
+    /// set data item to the plugin
+    virtual void set_cell(int param, int column, const std::string &src, std::string &error) { error.clear(); }
     
-    /// return a line graph interface for a specific parameter/column
+    /// return a line graph interface for a specific parameter/column (unused for now)
     virtual line_graph_iface *get_graph_iface(int param, int column) { return NULL; }
     
+    /// return an editor name for a specific grid cell (unused for now - I don't even know how editors be implemented)
+    virtual const char *get_cell_editor(int param, int column) { return NULL; }
+    
     virtual ~table_edit_iface() {}
 };
 
diff --git a/src/calf/gui.h b/src/calf/gui.h
index 26bca22..e6c5ed8 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -300,12 +300,16 @@ struct listview_param_control: public param_control, public send_configure_iface
     GtkTreeView *tree;
     GtkListStore *lstore;
     calf_plugins::table_edit_iface *teif;
+    int cols;
+    std::vector<GtkTreeIter> positions;
     
     virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
     virtual void get() {}
     virtual void set() {}
     virtual void send_configure(const char *key, const char *value);
     void update_store(const std::string &data);
+    static void on_edited(GtkCellRenderer *renderer, gchar *path, gchar *new_text, listview_param_control *pThis);
+    static void on_editing_canceled(GtkCellRenderer *renderer, listview_param_control *pThis);
 };
 
 class plugin_gui_window;
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index cf4c48e..a216e31 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -103,6 +103,28 @@ struct monosynth_metadata: public plugin_metadata<monosynth_metadata>
         param_count };
     enum { in_count = 0, out_count = 2, support_midi = true, require_midi = true, rt_capable = true };
     enum { step_size = 64, step_shift = 6 };
+    enum {
+        modsrc_none,
+        modsrc_velocity,
+        modsrc_pressure,
+        modsrc_modwheel,
+        modsrc_env1,
+        modsrc_lfo1,
+        modsrc_count,
+    };
+    enum {
+        moddest_none,
+        moddest_amplitude,
+        moddest_cutoff,
+        moddest_resonance,
+        moddest_o1detune,
+        moddest_o2detune,
+        moddest_o1pitch,
+        moddest_o2pitch,
+        moddest_o1pw,
+        moddest_o2pw,
+        moddest_count,
+    };
     PLUGIN_NAME_ID_LABEL("monosynth", "monosynth", "Monosynth")
 };
     
diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index 80a7c40..b7d2fd5 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -37,7 +37,7 @@ namespace calf_plugins {
     
 /// Monosynth-in-making. Parameters may change at any point, so don't make songs with it!
 /// It lacks inertia for parameters, even for those that really need it.
-class monosynth_audio_module: public audio_module<monosynth_metadata>, public line_graph_iface
+class monosynth_audio_module: public audio_module<monosynth_metadata>, public line_graph_iface, public table_edit_iface
 {
 public:
     float *ins[in_count]; 
@@ -191,6 +191,9 @@ public:
             
         return 3;
     }
+    
+    virtual const table_column_info *get_table_columns(int param);
+    virtual uint32_t get_table_rows(int param);
 };
 
 struct organ_audio_module: public audio_module<organ_metadata>, public dsp::drawbar_organ, public line_graph_iface
diff --git a/src/gui.cpp b/src/gui.cpp
index a276db9..45ba95e 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -634,7 +634,7 @@ GtkWidget *listview_param_control::create(plugin_gui *_gui, int _param_no)
     teif = gui->plugin->get_table_edit_iface();
     const table_column_info *tci = teif->get_table_columns(param_no);
     assert(tci);
-    int cols = 0;
+    cols = 0;
     while (tci[cols].name != NULL)
         cols++;
     
@@ -650,7 +650,24 @@ GtkWidget *listview_param_control::create(plugin_gui *_gui, int _param_no)
     
     for (int i = 0; i < cols; i++)
     {
-        GtkCellRenderer *cr = gtk_cell_renderer_text_new ();
+        GtkCellRenderer *cr = NULL;
+        
+        if (tci[i].type == TCT_ENUM) {
+            cr = gtk_cell_renderer_combo_new ();
+            GtkListStore *cls = gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING);
+            for (int j = 0; tci[i].values[j]; j++)
+                gtk_list_store_insert_with_values(cls, NULL, j, 0, j, 1, tci[i].values[j], -1);
+            g_object_set(cr, "model", cls, "editable", TRUE, "has-entry", FALSE, "text-column", 1, "mode", GTK_CELL_RENDERER_MODE_EDITABLE, NULL);
+        }
+        else {
+            bool editable = tci[i].type != TCT_LABEL;
+            cr = gtk_cell_renderer_text_new ();
+            if (editable)
+                g_object_set(cr, "editable", TRUE, "mode", GTK_CELL_RENDERER_MODE_EDITABLE, NULL);
+        }
+        g_object_set_data (G_OBJECT(cr), "column", (void *)&tci[i]);
+        gtk_signal_connect (GTK_OBJECT (cr), "edited", G_CALLBACK (on_edited), (gpointer)this);
+        gtk_signal_connect (GTK_OBJECT (cr), "editing-canceled", G_CALLBACK (on_editing_canceled), (gpointer)this);
         gtk_tree_view_insert_column_with_attributes(tree, i, tci[i].name, cr, "text", i, NULL);
     }
     gtk_tree_view_set_headers_visible(tree, TRUE);
@@ -661,8 +678,17 @@ GtkWidget *listview_param_control::create(plugin_gui *_gui, int _param_no)
 void listview_param_control::update_store(const std::string &data)
 {
     gtk_list_store_clear(lstore);
-    gtk_list_store_insert_with_values(lstore, NULL, 0, 0, "Foo", 1, "Bar", -1);
-    gtk_list_store_insert_with_values(lstore, NULL, 1, 0, "Kat", 1, "Dogg", -1);
+    uint32_t rows = teif->get_table_rows(param_no);
+    for (uint32_t i = 0; i < rows; i++)
+    {
+        GtkTreeIter iter;
+        gtk_list_store_insert(lstore, &iter, i);
+        for (int j = 0; j < cols; j++)
+        {
+            gtk_list_store_set(lstore, &iter, j, teif->get_cell(i, j).c_str(), -1);
+        }
+        positions.push_back(iter);
+    }
 }
 
 void listview_param_control::send_configure(const char *key, const char *value)
@@ -673,6 +699,18 @@ void listview_param_control::send_configure(const char *key, const char *value)
     }
 }
 
+void listview_param_control::on_edited(GtkCellRenderer *renderer, gchar *path, gchar *new_text, listview_param_control *pThis)
+{
+    const table_column_info *tci = pThis->teif->get_table_columns(pThis->param_no);
+    gtk_list_store_set(pThis->lstore, &pThis->positions[atoi(path)], ((table_column_info *)g_object_get_data(G_OBJECT(renderer), "column")) - tci, new_text, -1);
+    gtk_widget_grab_focus(pThis->widget);
+}
+
+void listview_param_control::on_editing_canceled(GtkCellRenderer *renderer, listview_param_control *pThis)
+{
+    gtk_widget_grab_focus(pThis->widget);
+}
+
 /******************************** GUI proper ********************************/
 
 plugin_gui::plugin_gui(plugin_gui_window *_window)
diff --git a/src/monosynth.cpp b/src/monosynth.cpp
index b36ab37..21a5136 100644
--- a/src/monosynth.cpp
+++ b/src/monosynth.cpp
@@ -574,3 +574,48 @@ void monosynth_audio_module::deactivate()
     envelope.reset();
     stack.clear();
 }
+
+static const char *monosynth_mod_src_names[] = {
+    "None", 
+    "Velocity",
+    "Pressure",
+    "ModWheel",
+    "Envelope",
+    "LFO",
+    NULL
+};
+
+static const char *monosynth_mod_dest_names[] = {
+    "None",
+    "Amplitude",
+    "Cutoff",
+    "Resonance",
+    "OX: Detune",
+    "O1: Detune",
+    "O2: Detune",
+    "OX: Pitch",
+    "O1: Pitch",
+    "O2: Pitch",
+    "OX: PW",
+    "O1: PW",
+    "O2: PW",
+    NULL
+};
+
+const table_column_info *monosynth_audio_module::get_table_columns(int param)
+{
+
+    static table_column_info tci[] = {
+        { "Source", TCT_ENUM, 0, 0, 0, monosynth_mod_src_names },
+        { "Modulator", TCT_ENUM, 0, 0, 0, monosynth_mod_src_names },
+        { "Amount", TCT_FLOAT, 0, 1, 1, NULL},
+        { "Destination", TCT_ENUM, 0, 0, 0, monosynth_mod_dest_names  },
+        { NULL }
+    };
+    return tci;
+}
+
+uint32_t monosynth_audio_module::get_table_rows(int param)
+{
+    return 2;
+}

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list