[vlmc-devel] commit: Effects: Starting an effect settings widget ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sun Aug 22 22:54:19 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sat Aug 21 22:22:15 2010 +0200| [ff4c641871fd4d54f9ec49562e843da89e1c9fc3] | committer: Hugo Beauzée-Luyssen 

Effects: Starting an effect settings widget

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=ff4c641871fd4d54f9ec49562e843da89e1c9fc3
---

 src/CMakeLists.txt                             |    2 +
 src/EffectsEngine/EffectInstance.cpp           |    6 ++
 src/EffectsEngine/EffectInstance.h             |    1 +
 src/Gui/effectsengine/EffectInstanceWidget.cpp |   88 ++++++++++++++++++++++++
 src/Gui/effectsengine/EffectInstanceWidget.h   |   50 +++++++++++++
 5 files changed, 147 insertions(+), 0 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cb952ba..b9c76d3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -157,6 +157,7 @@ ELSE(NOT WITH_GUI)
         Gui/MainWindow.cpp
         Gui/UndoStack.cpp
         Gui/WorkflowFileRendererDialog.cpp
+        Gui/effectsengine/EffectInstanceWidget.cpp
         Gui/effectsengine/EffectsList.cpp
         Gui/effectsengine/EffectsListView.cpp
         Gui/export/RendererSettings.cpp
@@ -221,6 +222,7 @@ ELSE(NOT WITH_GUI)
         Gui/MainWindow.h
         Gui/UndoStack.h
         Gui/WorkflowFileRendererDialog.h
+        Gui/effectsengine/EffectInstanceWidget.h
         Gui/effectsengine/EffectsList.h
         Gui/effectsengine/EffectsListView.h
         Gui/export/RendererSettings.h
diff --git a/src/EffectsEngine/EffectInstance.cpp b/src/EffectsEngine/EffectInstance.cpp
index 1d38226..0a385e1 100644
--- a/src/EffectsEngine/EffectInstance.cpp
+++ b/src/EffectsEngine/EffectInstance.cpp
@@ -79,3 +79,9 @@ EffectInstance::params() const
 {
     return m_params;
 }
+
+EffectInstance::ParamList&
+EffectInstance::params()
+{
+    return m_params;
+}
diff --git a/src/EffectsEngine/EffectInstance.h b/src/EffectsEngine/EffectInstance.h
index e2227f8..c586a9b 100644
--- a/src/EffectsEngine/EffectInstance.h
+++ b/src/EffectsEngine/EffectInstance.h
@@ -36,6 +36,7 @@ class EffectInstance
         void            init( quint32 width, quint32 height );
         Effect*         effect();
         const ParamList &params() const;
+        ParamList       &params();
     protected:
         EffectInstance( Effect *effect );
         virtual ~EffectInstance();
diff --git a/src/Gui/effectsengine/EffectInstanceWidget.cpp b/src/Gui/effectsengine/EffectInstanceWidget.cpp
new file mode 100644
index 0000000..4051b37
--- /dev/null
+++ b/src/Gui/effectsengine/EffectInstanceWidget.cpp
@@ -0,0 +1,88 @@
+/*****************************************************************************
+ * EffectInstanceWidget.h: Display the settings for an EffectInstance
+ *****************************************************************************
+ * Copyright (C) 2008-2010 VideoLAN
+ *
+ * Authors: Hugo Beauzée-Luyssen <beauze.h at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "EffectInstanceWidget.h"
+
+#include "BoolWidget.h"
+#include "DoubleWidget.h"
+#include "Effect.h"
+#include "EffectInstance.h"
+#include "EffectSettingValue.h"
+
+#include <QFormLayout>
+#include <QLabel>
+
+EffectInstanceWidget::EffectInstanceWidget( EffectInstance *effect, QWidget *parent ) :
+    QDialog( parent )
+{
+    QFormLayout     *layout = new QFormLayout( this );
+
+    layout->setFieldGrowthPolicy( QFormLayout::AllNonFixedFieldsGrow );
+    layout->addRow( tr( "Name" ), new QLabel( effect->effect()->name(), this ) );
+    layout->addRow( tr( "Description" ), new QLabel( effect->effect()->description(), this ) );
+    layout->addRow( tr( "Type" ), new QLabel( nameFromType( effect->effect()->type() ), this ) );
+
+    EffectInstance::ParamList::iterator         it = effect->params().begin();
+    EffectInstance::ParamList::iterator         ite = effect->params().end();
+    while ( it != ite )
+    {
+        EffectSettingValue          *s = it.value();
+        ISettingsCategoryWidget     *widget = widgetFactory( s );
+        QLabel                      *label = new QLabel( tr( s->name() ), this );
+        widget->widget()->setToolTip( s->description() );
+        layout->addRow( label , widget->widget() );
+        m_settings.push_back( s );
+        ++it;
+    }
+}
+
+QString
+EffectInstanceWidget::nameFromType( Effect::Type type )
+{
+    switch ( type )
+    {
+    case Effect::Filter:
+        return tr( "Filter" );
+    case Effect::Source:
+        return tr( "Source" );
+    case Effect::Mixer2:
+        return tr( "Mixer 2" );
+    case Effect::Mixer3:
+        return tr( "Mixer 3" );
+    default:
+        return tr( "Unknown type" );
+    }
+}
+
+ISettingsCategoryWidget*
+EffectInstanceWidget::widgetFactory( EffectSettingValue *s )
+{
+    switch ( s->type() )
+    {
+    case    SettingValue::Bool:
+        return new BoolWidget( s, this );
+    case    SettingValue::Double:
+        return new DoubleWidget( s, this );
+    default:
+        return NULL;
+    }
+}
diff --git a/src/Gui/effectsengine/EffectInstanceWidget.h b/src/Gui/effectsengine/EffectInstanceWidget.h
new file mode 100644
index 0000000..abb1c6b
--- /dev/null
+++ b/src/Gui/effectsengine/EffectInstanceWidget.h
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * EffectInstanceWidget.h: Display the settings for an EffectInstance
+ *****************************************************************************
+ * Copyright (C) 2008-2010 VideoLAN
+ *
+ * Authors: Hugo Beauzée-Luyssen <beauze.h at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef EFFECTINSTANCEWIDGET_H
+#define EFFECTINSTANCEWIDGET_H
+
+#include <QDialog>
+
+class   EffectInstance;
+class   EffectSettingValue;
+
+#include "Effect.h"
+
+class   ISettingsCategoryWidget;
+
+class EffectInstanceWidget : public QDialog
+{
+    Q_OBJECT
+
+    public:
+        explicit EffectInstanceWidget( EffectInstance* effect, QWidget *parent = 0);
+
+    private:
+        static QString                      nameFromType( Effect::Type type );
+        ISettingsCategoryWidget             *widgetFactory( EffectSettingValue *s );
+    private:
+        EffectInstance                      *m_effect;
+        QList<EffectSettingValue*>          m_settings;
+};
+
+#endif // EFFECTINSTANCEWIDGET_H



More information about the Vlmc-devel mailing list