[SCM] calf/master: + GUI: add spin button widget

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:38:47 UTC 2013


The following commit has been merged in the master branch:
commit 7f4aeb197bf6057cf9d4eb926456b60760416c55
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sun Jan 4 22:06:08 2009 +0000

    + GUI: add spin button widget

diff --git a/src/calf/gui.h b/src/calf/gui.h
index 74e22f3..f92a6b0 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -167,6 +167,7 @@ struct led_param_control: public param_control
     virtual void set();
 };
 
+/// Horizontal slider
 struct hscale_param_control: public param_control
 {
     GtkHScale *scale;
@@ -179,9 +180,10 @@ struct hscale_param_control: public param_control
     static gchar *hscale_format_value(GtkScale *widget, double arg1, gpointer value);
 };
 
+/// Vertical slider
 struct vscale_param_control: public param_control
 {
-    GtkHScale *scale;
+    GtkVScale *scale;
 
     virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
     virtual void get();
@@ -190,6 +192,15 @@ struct vscale_param_control: public param_control
     static void vscale_value_changed(GtkHScale *widget, gpointer value);
 };
 
+/// Spin button
+struct spin_param_control: public param_control
+{
+    virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
+    virtual void get();
+    virtual void set();
+    static void value_changed(GtkSpinButton *widget, gpointer value);
+};
+
 struct toggle_param_control: public param_control
 {
     GtkCheckButton *scale;
diff --git a/src/gui.cpp b/src/gui.cpp
index 296c373..7f6eaf4 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -306,6 +306,43 @@ void toggle_param_control::set()
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), (int)gui->plugin->get_param_value(param_no) - (int)props.min);
 }
 
+// spin button
+
+GtkWidget *spin_param_control::create(plugin_gui *_gui, int _param_no)
+{
+    gui = _gui;
+    param_no = _param_no;
+    
+    const parameter_properties &props = get_props();
+    if (props.step > 1)
+        widget  = gtk_spin_button_new_with_range (props.min, props.max, (props.max - props.min) / (props.step - 1));
+    if (props.step > 0)
+        widget  = gtk_spin_button_new_with_range (props.min, props.max, props.step);
+    else
+        widget  = gtk_spin_button_new_with_range (props.min, props.max, 1);
+    gtk_signal_connect (GTK_OBJECT (widget), "value-changed", G_CALLBACK (value_changed), (gpointer)this);
+    return widget;
+}
+
+void spin_param_control::value_changed(GtkSpinButton *widget, gpointer value)
+{
+    param_control *jhp = (param_control *)value;
+    jhp->get();
+}
+
+void spin_param_control::get()
+{
+    // const parameter_properties &props = get_props();
+    gui->set_param_value(param_no, gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (widget)), this);
+}
+
+void spin_param_control::set()
+{
+    _GUARD_CHANGE_
+    // const parameter_properties &props = get_props();
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), gui->plugin->get_param_value(param_no));
+}
+
 // button
 
 GtkWidget *button_param_control::create(plugin_gui *_gui, int _param_no)
@@ -672,6 +709,8 @@ param_control *plugin_gui::create_control_from_xml(const char *element, const ch
         return new combo_box_param_control;
     if (!strcmp(element, "toggle"))
         return new toggle_param_control;
+    if (!strcmp(element, "spin"))
+        return new spin_param_control;
     if (!strcmp(element, "button"))
         return new button_param_control;
     if (!strcmp(element, "label"))

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list