[SCM] calf/master: + GUI: initial work on list view control (tabular editor)
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:39:29 UTC 2013
The following commit has been merged in the master branch:
commit a4fd68579866d89b3e1e248def2f008ea5233bb8
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Tue Apr 7 00:05:07 2009 +0100
+ GUI: initial work on list view control (tabular editor)
diff --git a/src/calf/gui.h b/src/calf/gui.h
index e35600d..26bca22 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -80,6 +80,9 @@ struct param_control: public control_base
virtual ~param_control();
};
+/////////////////////////////////////////////////////////////////////////////////////////////
+// containers
+
struct control_container: public control_base
{
GtkContainer *container;
@@ -132,6 +135,9 @@ struct scrolled_container: public control_container
virtual GtkWidget *create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes);
};
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// controls
+
/// Display-only control: static text
struct label_param_control: public param_control
{
@@ -195,6 +201,7 @@ struct spin_param_control: public param_control
static void value_changed(GtkSpinButton *widget, gpointer value);
};
+/// Check box
struct toggle_param_control: public param_control
{
virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
@@ -203,6 +210,7 @@ struct toggle_param_control: public param_control
static void toggle_value_changed(GtkCheckButton *widget, gpointer value);
};
+/// Push button
struct button_param_control: public param_control
{
virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
@@ -211,6 +219,7 @@ struct button_param_control: public param_control
static void button_clicked(GtkButton *widget, gpointer value);
};
+/// Combo list box
struct combo_box_param_control: public param_control
{
virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
@@ -219,6 +228,7 @@ struct combo_box_param_control: public param_control
static void combo_value_changed(GtkComboBox *widget, gpointer value);
};
+/// Line graph
struct line_graph_param_control: public param_control
{
int last_generation;
@@ -230,6 +240,7 @@ struct line_graph_param_control: public param_control
virtual ~line_graph_param_control();
};
+/// Knob
struct knob_param_control: public param_control
{
virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
@@ -238,6 +249,7 @@ struct knob_param_control: public param_control
static void knob_value_changed(GtkWidget *widget, gpointer value);
};
+/// Static keyboard image
struct keyboard_param_control: public param_control
{
CalfKeyboard *kb;
@@ -247,6 +259,7 @@ struct keyboard_param_control: public param_control
virtual void set() {}
};
+/// Curve editor
struct curve_param_control: public param_control, public send_configure_iface
{
CalfCurve *curve;
@@ -257,6 +270,7 @@ struct curve_param_control: public param_control, public send_configure_iface
virtual void send_configure(const char *key, const char *value);
};
+/// Text entry
struct entry_param_control: public param_control, public send_configure_iface
{
GtkEntry *entry;
@@ -268,6 +282,7 @@ struct entry_param_control: public param_control, public send_configure_iface
static void entry_value_changed(GtkWidget *widget, gpointer value);
};
+/// File chooser button
struct filechooser_param_control: public param_control, public send_configure_iface
{
GtkFileChooserButton *filechooser;
@@ -279,6 +294,20 @@ struct filechooser_param_control: public param_control, public send_configure_if
static void filechooser_value_changed(GtkWidget *widget, gpointer value);
};
+/// List view used for variable-length tabular data
+struct listview_param_control: public param_control, public send_configure_iface
+{
+ GtkTreeView *tree;
+ GtkListStore *lstore;
+ calf_plugins::table_edit_iface *teif;
+
+ 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);
+};
+
class plugin_gui_window;
class plugin_gui: public send_configure_iface, public send_updates_iface
diff --git a/src/gui.cpp b/src/gui.cpp
index 746de21..a276db9 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -624,6 +624,55 @@ line_graph_param_control::~line_graph_param_control()
{
}
+// list view
+
+GtkWidget *listview_param_control::create(plugin_gui *_gui, int _param_no)
+{
+ gui = _gui;
+ param_no = _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;
+ while (tci[cols].name != NULL)
+ cols++;
+
+ GType *p = new GType[cols];
+ for (int i = 0; i < cols; i++)
+ p[i] = G_TYPE_STRING;
+ lstore = gtk_list_store_newv(cols, p);
+ update_store("");
+ widget = gtk_tree_view_new_with_model(GTK_TREE_MODEL(lstore));
+ delete []p;
+ tree = GTK_TREE_VIEW(widget);
+ assert(teif);
+
+ for (int i = 0; i < cols; i++)
+ {
+ GtkCellRenderer *cr = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes(tree, i, tci[i].name, cr, "text", i, NULL);
+ }
+ gtk_tree_view_set_headers_visible(tree, TRUE);
+
+ return widget;
+}
+
+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);
+}
+
+void listview_param_control::send_configure(const char *key, const char *value)
+{
+ if (attribs["key"] == key)
+ {
+ update_store(value);
+ }
+}
+
/******************************** GUI proper ********************************/
plugin_gui::plugin_gui(plugin_gui_window *_window)
@@ -828,6 +877,8 @@ param_control *plugin_gui::create_control_from_xml(const char *element, const ch
return new entry_param_control;
if (!strcmp(element, "filechooser"))
return new filechooser_param_control;
+ if (!strcmp(element, "listview"))
+ return new listview_param_control;
return NULL;
}
@@ -912,6 +963,8 @@ void plugin_gui::xml_element_start(const char *element, const char *attributes[]
else
param_no = it->second;
}
+ if (param_no != -1)
+ current_control->param_variable = plugin->get_param_props(param_no)->short_name;
current_control->create(this, param_no);
current_control->init_xml(element);
current_control->set();
@@ -1090,16 +1143,13 @@ static const char *general_preset_pre_xml =
" <menu action=\"PresetMenuAction\">\n";
static const char *builtin_preset_pre_xml =
-// " <menu action=\"BuiltinPresetMenuAction\">\n"
" <placeholder name=\"builtin_presets\">\n";
static const char *user_preset_pre_xml =
-// " <menu action=\"UserPresetMenuAction\">\n"
" <placeholder name=\"user_presets\">\n";
static const char *preset_post_xml =
" </placeholder>\n"
-// " </menu>\n"
" </menu>\n"
" </menubar>\n"
"</ui>\n"
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list