traverso-commit
[Top][All Lists]
Advanced

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

[Traverso-commit] traverso/src plugins/LV2/LV2Plugin.cpp plugins/...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src plugins/LV2/LV2Plugin.cpp plugins/...
Date: Thu, 24 May 2007 23:24:03 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/05/24 23:24:03

Modified files:
        src/plugins/LV2: LV2Plugin.cpp LV2Plugin.h 
                         LV2PluginPropertiesDialog.cpp 
                         LV2PluginPropertiesDialog.h 
        src/plugins    : Plugin.h PluginSlider.cpp PluginSlider.h 
        src/traverso/songcanvas: PluginView.cpp 

Log message:
        Some plugin control tweaking, not sure yet how to handle logarithmic 
control ports ?

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/plugins/LV2/LV2Plugin.cpp?cvsroot=traverso&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/traverso/src/plugins/LV2/LV2Plugin.h?cvsroot=traverso&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/traverso/src/plugins/LV2/LV2PluginPropertiesDialog.cpp?cvsroot=traverso&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/traverso/src/plugins/LV2/LV2PluginPropertiesDialog.h?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/plugins/Plugin.h?cvsroot=traverso&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/traverso/src/plugins/PluginSlider.cpp?cvsroot=traverso&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/traverso/src/plugins/PluginSlider.h?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/PluginView.cpp?cvsroot=traverso&r1=1.18&r2=1.19

Patches:
Index: plugins/LV2/LV2Plugin.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/plugins/LV2/LV2Plugin.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- plugins/LV2/LV2Plugin.cpp   24 May 2007 10:56:43 -0000      1.6
+++ plugins/LV2/LV2Plugin.cpp   24 May 2007 23:24:02 -0000      1.7
@@ -323,16 +323,27 @@
        , m_controlValue(value)
 {
        slv2_instance_connect_port(m_lv2plugin->get_instance(), m_index, 
&m_controlValue);
+       init();
 }
 
 LV2ControlPort::LV2ControlPort( LV2Plugin * plugin, const QDomNode node )
        : PluginPort(plugin), m_lv2plugin(plugin)
 {
        set_state(node);
-       
        slv2_instance_connect_port(m_lv2plugin->get_instance(), m_index, 
&m_controlValue);
+       init();
 }
 
+void LV2ControlPort::init()
+{
+       foreach(QString string, get_hints()) {
+               if (string == "http://lv2plug.in/ontology#logarithmic";) {
+                       m_hint = LOG_CONTROL;
+               } else  if (string == "http://lv2plug.in/ontology#integer";) {
+                       m_hint = INT_CONTROL;
+               }
+       }
+}
 
 QDomNode LV2ControlPort::get_state( QDomDocument doc )
 {
@@ -367,12 +378,36 @@
 
 }
 
+float LV2ControlPort::get_default_value()
+{
+       SLV2Port port = 
slv2_plugin_get_port_by_index(m_lv2plugin->get_slv2_plugin(), m_index);
+       return slv2_port_get_default_value (m_lv2plugin->get_slv2_plugin(), 
port);
+}
+
+
 QString LV2ControlPort::get_description()
 {
        SLV2Port port = 
slv2_plugin_get_port_by_index(m_lv2plugin->get_slv2_plugin(), m_index);
+       return QString(slv2_port_get_name(m_lv2plugin->get_slv2_plugin(), 
port));
+}
+
+QString LV2ControlPort::get_symbol()
+{
+       SLV2Port port = 
slv2_plugin_get_port_by_index(m_lv2plugin->get_slv2_plugin(), m_index);
        return QString(slv2_port_get_symbol(m_lv2plugin->get_slv2_plugin(), 
port));
 }
 
+QStringList LV2ControlPort::get_hints()
+{
+       SLV2Port port = 
slv2_plugin_get_port_by_index(m_lv2plugin->get_slv2_plugin(), m_index);
+       SLV2Strings list = slv2_port_get_hints(m_lv2plugin->get_slv2_plugin(), 
port);
+       QStringList qslist;
+       for (unsigned i=0; i < slv2_strings_size(list); ++i) {
+               qslist << QString(slv2_strings_get_at(list, i));
+       }
+       return qslist;
+}
+
 void LV2ControlPort::set_control_value(float value)
 {
        m_controlValue = value;

Index: plugins/LV2/LV2Plugin.h
===================================================================
RCS file: /sources/traverso/traverso/src/plugins/LV2/LV2Plugin.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- plugins/LV2/LV2Plugin.h     24 May 2007 13:32:54 -0000      1.6
+++ plugins/LV2/LV2Plugin.h     24 May 2007 23:24:03 -0000      1.7
@@ -94,15 +94,20 @@
        float get_control_value() {return m_controlValue; }
        float get_min_control_value();
        float get_max_control_value();
+       float get_default_value();
+       
        QDomNode get_state(QDomDocument doc);
 
        QString get_description();
+       QString get_symbol();
 
 private:
        LV2Plugin*      m_lv2plugin;
        float           m_controlValue;
 
        int set_state( const QDomNode & node );
+       void init();
+       QStringList get_hints();
 
 public slots:
        void set_control_value(float value);

Index: plugins/LV2/LV2PluginPropertiesDialog.cpp
===================================================================
RCS file: 
/sources/traverso/traverso/src/plugins/LV2/LV2PluginPropertiesDialog.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- plugins/LV2/LV2PluginPropertiesDialog.cpp   24 May 2007 10:56:43 -0000      
1.6
+++ plugins/LV2/LV2PluginPropertiesDialog.cpp   24 May 2007 23:24:03 -0000      
1.7
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: LV2PluginPropertiesDialog.cpp,v 1.6 2007/05/24 10:56:43 r_sijrier Exp $
+$Id: LV2PluginPropertiesDialog.cpp,v 1.7 2007/05/24 23:24:03 r_sijrier Exp $
 */
 
 
@@ -34,12 +34,10 @@
 #include <PluginSlider.h>
 #include "Command.h"
 
-LV2PluginPropertiesDialog::LV2PluginPropertiesDialog(LV2Plugin* plugin)
-       : QDialog()
+LV2PluginPropertiesDialog::LV2PluginPropertiesDialog(QWidget* parent, 
LV2Plugin* plugin)
+       : QDialog(parent)
        , m_plugin(plugin)
 {
-       setModal(true);
-       
        QWidget* sliderWidget = new QWidget(this);
        QVBoxLayout* sliderWidgetLayout = new QVBoxLayout;
        sliderWidget->setLayout(sliderWidgetLayout);
@@ -63,18 +61,20 @@
 
        foreach(LV2ControlPort* port, m_plugin->get_control_ports()) {
 
+               if (port->get_symbol() == "latency") {
+                       continue;
+               }
+               
                QWidget* widget = new QWidget(sliderWidget);
                QHBoxLayout* lay = new QHBoxLayout();
                lay->setSpacing(12);
                lay->setMargin(3);
 
-               PluginSlider* slider = new PluginSlider();
+               PluginSlider* slider = new PluginSlider(port);
                slider->setFixedWidth(200);
-               slider->set_minimum(port->get_min_control_value());
-               slider->set_maximum(port->get_max_control_value());
-               slider->set_value(port->get_control_value());
-               connect(slider, SIGNAL(sliderValueChanged(float)), port, 
SLOT(set_control_value(float)));
+               slider->update_slider_position();
                
+               connect(slider, SIGNAL(sliderValueChanged(float)), port, 
SLOT(set_control_value(float)));
                // in case the plugin has a slave 'map' the signal to the slave 
port control slot too!
                if (m_plugin->get_slave()) {
                        connect(slider, SIGNAL(sliderValueChanged(float)), 
m_plugin->get_slave()->get_control_port_by_index(port->get_index()), 
SLOT(set_control_value(float)));

Index: plugins/LV2/LV2PluginPropertiesDialog.h
===================================================================
RCS file: 
/sources/traverso/traverso/src/plugins/LV2/LV2PluginPropertiesDialog.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- plugins/LV2/LV2PluginPropertiesDialog.h     24 May 2007 10:56:43 -0000      
1.3
+++ plugins/LV2/LV2PluginPropertiesDialog.h     24 May 2007 23:24:03 -0000      
1.4
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: LV2PluginPropertiesDialog.h,v 1.3 2007/05/24 10:56:43 r_sijrier Exp $
+$Id: LV2PluginPropertiesDialog.h,v 1.4 2007/05/24 23:24:03 r_sijrier Exp $
 */
 
 
@@ -33,7 +33,7 @@
        Q_OBJECT
 
 public:
-       LV2PluginPropertiesDialog(LV2Plugin* plugin);
+       LV2PluginPropertiesDialog(QWidget* parent, LV2Plugin* plugin);
        ~LV2PluginPropertiesDialog(){};
 
 

Index: plugins/Plugin.h
===================================================================
RCS file: /sources/traverso/traverso/src/plugins/Plugin.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- plugins/Plugin.h    22 Jan 2007 20:12:58 -0000      1.5
+++ plugins/Plugin.h    24 May 2007 23:24:03 -0000      1.6
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: Plugin.h,v 1.5 2007/01/22 20:12:58 r_sijrier Exp $
+$Id: Plugin.h,v 1.6 2007/05/24 23:24:03 r_sijrier Exp $
 */
 
 
@@ -66,17 +66,25 @@
 {
 
 public:
-       PluginPort(QObject* parent, int index) : QObject(parent), 
m_index(index) {};
-       PluginPort(QObject* parent) : QObject(parent) {};
+       PluginPort(QObject* parent, int index) : QObject(parent), 
m_index(index), m_hint(FLOAT_CONTROL) {};
+       PluginPort(QObject* parent) : QObject(parent), m_hint(FLOAT_CONTROL) {};
        ~PluginPort(){};
 
        virtual QDomNode get_state(QDomDocument doc);
        virtual int set_state( const QDomNode & node ) = 0;
        
+       enum PortHint {
+               FLOAT_CONTROL,
+               INT_CONTROL,
+               LOG_CONTROL
+       };
+       
        int get_index() const {return m_index;}
+       int get_hint() const {return m_hint;}
 
 protected:
        int     m_index;
+       int     m_hint;
 }; 
 
 

Index: plugins/PluginSlider.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/plugins/PluginSlider.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- plugins/PluginSlider.cpp    21 Apr 2007 15:26:49 -0000      1.4
+++ plugins/PluginSlider.cpp    24 May 2007 23:24:03 -0000      1.5
@@ -17,40 +17,30 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: PluginSlider.cpp,v 1.4 2007/04/21 15:26:49 r_sijrier Exp $
+$Id: PluginSlider.cpp,v 1.5 2007/05/24 23:24:03 r_sijrier Exp $
 */
 
 #include "PluginSlider.h"
 #include <Themer.h>
+#include "LV2Plugin.h"
+#include "Plugin.h"
 
-PluginSlider::PluginSlider()
+PluginSlider::PluginSlider(LV2ControlPort* port)
        : QWidget()
+       , m_port(port)
 {
        setMaximumHeight(18);
        highlight = dragging = false;
-       m_stepvalue = 1;
-}
-
-void PluginSlider::set_minimum(float min)
-{
-       m_min = min;
-}
-
-
-void PluginSlider::set_maximum(float max)
-{
-       m_max = max;
-}
 
-void PluginSlider::set_value(float value)
-{
-       m_value = value;
-       update_slider_position();
-}
+       m_min = m_port->get_min_control_value();
+       m_max = m_port->get_max_control_value();
+       m_value = m_port->get_control_value();
 
-void PluginSlider::set_step_value( float value )
-{
-       m_stepvalue = value;
+       if (m_port->get_hint() == PluginPort::INT_CONTROL) {
+               m_stepvalue = 1;
+       } else {
+               m_stepvalue = (m_max - m_min) / (width() / 25);
+       }
 }
 
 void PluginSlider::paintEvent(QPaintEvent *)
@@ -65,10 +55,17 @@
                background = background.light(105);
        }
        
+       // avoid painting at 0, it looks bad...
+       if (m_xpos <= 1) m_xpos = 2;
+       
        painter.setBrush(background);
-       painter.drawRect(0, 0, width() - 0.5, height()- 0.5);
+       painter.drawRect(0, 0, width() - 0.5, height() - 0.5);
        painter.fillRect(1, 1, m_xpos - 2, height() - 2, QBrush(color));
+       if (m_port->get_hint() == PluginPort::INT_CONTROL) {
+               painter.drawText(0, 0, width(), height(), Qt::AlignCenter, 
QString::number((int)m_value));
+       } else {
        painter.drawText(0, 0, width(), height(), Qt::AlignCenter, 
QString::number(m_value, 'f', 2));
+       }
 }
 
 void PluginSlider::mousePressEvent( QMouseEvent * e )
@@ -97,6 +94,7 @@
                
        m_xpos = mouseX;
        
+       
        float relativePos = ((float) mouseX) / width();
        
        float range = m_max - m_min;

Index: plugins/PluginSlider.h
===================================================================
RCS file: /sources/traverso/traverso/src/plugins/PluginSlider.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- plugins/PluginSlider.h      9 Aug 2006 21:12:45 -0000       1.2
+++ plugins/PluginSlider.h      24 May 2007 23:24:03 -0000      1.3
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: PluginSlider.h,v 1.2 2006/08/09 21:12:45 r_sijrier Exp $
+$Id: PluginSlider.h,v 1.3 2007/05/24 23:24:03 r_sijrier Exp $
 */
 
 
@@ -28,21 +28,18 @@
 #include <QPainter>
 #include <QMouseEvent>
 
+class LV2ControlPort;
 
 class PluginSlider : public QWidget
 {
        Q_OBJECT
        
 public:
-       PluginSlider();
+       PluginSlider(LV2ControlPort* port);
        ~PluginSlider(){};
        
        void paint(QPainter *);
-       
-       void set_maximum(float max);
-       void set_minimum(float min);
-       void set_value(float value);
-       void set_step_value(float value);
+       void update_slider_position();
        
 protected:
        void paintEvent(QPaintEvent *);
@@ -54,6 +51,7 @@
         void wheelEvent(QWheelEvent* e );
        
 private:
+       LV2ControlPort* m_port;
        float   m_max;
        float   m_min;
        float   m_value;
@@ -63,7 +61,6 @@
        bool    dragging;
        
        void calculate_new_value(int mouseX);
-       void update_slider_position();
        
 signals:
        void sliderValueChanged(float value);

Index: traverso/songcanvas/PluginView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/PluginView.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- traverso/songcanvas/PluginView.cpp  24 May 2007 13:13:14 -0000      1.18
+++ traverso/songcanvas/PluginView.cpp  24 May 2007 23:24:03 -0000      1.19
@@ -25,6 +25,7 @@
 
 #include "TrackView.h"
 #include "PluginChainView.h"
+#include "Interface.h"
 
 #include <Themer.h>
 #include <Plugin.h>
@@ -112,7 +113,7 @@
 {
 #if defined (LV2_SUPPORT)
        if (! propertiesDialog) {
-               propertiesDialog = new LV2PluginPropertiesDialog((LV2Plugin*) 
m_plugin);
+               propertiesDialog = new 
LV2PluginPropertiesDialog(Interface::instance(), (LV2Plugin*) m_plugin);
                propertiesDialog->setWindowTitle(m_name);
        } 
        propertiesDialog->show();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]