[pitivi] Make videobalance effect configurable



commit 0df384a23cbea1f9012bd99d8f2565ac3339294f
Author: Thibault Saunier <tsaunier gnome org>
Date:   Sun Jul 4 19:14:12 2010 -0400

    Make videobalance effect configurable

 pitivi/ui/clipproperties.py       |   34 ++++++++++++++-
 pitivi/ui/effectsconfiguration.py |   82 +++++++++++++++++++++++++++++++++++++
 2 files changed, 114 insertions(+), 2 deletions(-)
---
diff --git a/pitivi/ui/clipproperties.py b/pitivi/ui/clipproperties.py
index 94b250f..e670df8 100644
--- a/pitivi/ui/clipproperties.py
+++ b/pitivi/ui/clipproperties.py
@@ -35,6 +35,8 @@ from pitivi.receiver import receiver, handler
 from pitivi.timeline.track import TrackEffect
 from pitivi.stream import AudioStream, VideoStream
 
+from pitivi.ui.effectsconfiguration import EffectUIFactory
+
 (COL_ACTIVATED,
  COL_TYPE,
  COL_NAME_TEXT,
@@ -78,6 +80,8 @@ class EffectProperties(gtk.Expander):
         self.timeline_object = None
         self.app = instance
         self.effectsHandler = self.app.effects
+        self.effectUIFactory = EffectUIFactory()
+        self.effect_config_ui = None
 
         self.VContent = gtk.VBox()
         self.add(self.VContent)
@@ -171,12 +175,13 @@ class EffectProperties(gtk.Expander):
             gtk.gdk.ACTION_COPY)
 
         self.removeEffectBt.connect("clicked", self._removeEffectClicked)
+
         self.treeview.connect("drag-data-received", self._dragDataReceivedCb)
         self.treeview.connect("drag-leave", self._dragLeaveCb)
         self.treeview.connect("drag-drop", self._dragDropCb)
         self.treeview.connect("drag-motion", self._dragMotionCb)
-        self.treeview.connect("query-tooltip",
-                              self._treeViewQueryTooltipCb)
+        self.treeview.connect("query-tooltip", self._treeViewQueryTooltipCb)
+        self.treeview.connect("button-press-event", self._treeViewButtonPressEventCb)
 
         self.connect('notify::expanded', self.expandedcb)
 
@@ -266,6 +271,7 @@ class EffectProperties(gtk.Expander):
             else:
                 self._showExplainLabel()
             self.VContent.show()
+            self._updateEffectConfigUi()
         else:
             self.VContent.hide()
 
@@ -288,3 +294,27 @@ class EffectProperties(gtk.Expander):
         self.table.hide()
         self.explain_box.show()
         self.explain_label.show()
+
+    def _treeViewButtonPressEventCb(self, treeview, event):
+        self._updateEffectConfigUi()
+
+    def _updateEffectConfigUi(self):
+        selection = self.treeview.get_selection().get_selected()
+        if selection[1]:
+            effect = self.storemodel.get_value(selection[1], COL_TRACK_EFFECT)
+            #TODO figure out the name of the element better
+            for element in effect.gnl_object.recurse():
+                if effect.factory.name in element.get_name():
+                    break
+
+            if self.effect_config_ui:
+                self.effect_config_ui.hide()
+
+            self.effect_config_ui = self.effectUIFactory.getEffectConfigurationUI(element)
+            if self.effect_config_ui:
+                self.VContent.pack_start(self.effect_config_ui, expand=False, fill=True)
+                self.effect_config_ui.show_all()
+        else:
+            if self.effect_config_ui:
+                self.effect_config_ui.hide()
+                self.effect_config_ui = None
diff --git a/pitivi/ui/effectsconfiguration.py b/pitivi/ui/effectsconfiguration.py
new file mode 100644
index 0000000..ec3e451
--- /dev/null
+++ b/pitivi/ui/effectsconfiguration.py
@@ -0,0 +1,82 @@
+#
+#       ui/effectsconfiguration.py
+#
+# Copyright (C) 2010 Thibault Saunier <tsaunier gnome org>
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 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 3, or (at your option)
+# any later version.
+
+import gtk
+
+from gettext import gettext as _
+
+from pitivi.ui.common import SPACING
+
+class EffectUIFactory(object):
+    def __init__(self):
+        self.cache_dict = {}
+
+    def getEffectConfigurationUI(self, effect):
+        if "videobalance" in effect.get_name():
+            if effect not in self.cache_dict:
+                video_balance_ui =  VideoBalanceConfig(effect)
+                self.cache_dict[effect] = video_balance_ui
+                return video_balance_ui
+            else:
+                return self.cache_dict[effect]
+        else:
+            return None
+
+
+class VideoBalanceConfig(gtk.HBox):
+    def __init__(self, effect):
+        gtk.HBox.__init__(self, spacing=SPACING)
+
+        self.balance = effect
+        brightness = effect.get_property("brightness")
+        contrast = effect.get_property("contrast")
+        hue = effect.get_property("hue")
+        saturation = effect.get_property("saturation")
+
+        properties = [(_("contrast"), 0, 2, brightness),
+                      (_("brightness"), -1, 1, contrast),
+                      (_("hue"), -1, 1, hue),
+                      (_("saturation"), 0, 2, saturation)]
+
+
+        controls = gtk.VBox()
+        labels = gtk.VBox()
+
+        for prop, lower, upper, default in properties:
+            widget = gtk.HScale()
+            label = gtk.Label("\n  "+ prop + " :")
+            widget.set_update_policy(gtk.UPDATE_CONTINUOUS)
+            widget.set_value(default)
+            widget.set_draw_value(True)
+            widget.set_range(lower, upper)
+            widget.connect("value-changed", self.onValueChangedCb, prop)
+
+            controls.pack_start(widget, True, True)
+            labels.pack_end(label, True, True)
+
+        self.pack_start(labels, expand=False, fill=True)
+        self.pack_end(controls, expand=True, fill=True)
+
+    def onValueChangedCb(self, widget, prop):
+        self.balance.set_property(prop, widget.get_value())



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