[pitivi] ProjectSettings: constrain width/height spinbuttons when link button is checked.



commit f61c7487bcf088a1c753c51ec239bed728f3452b
Author: Brandon Lewis <brandon_lewis alum berkeley edu>
Date:   Fri Nov 19 18:20:52 2010 +0000

    ProjectSettings: constrain width/height spinbuttons when link button is checked.

 pitivi/ui/projectsettings.py |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/ui/projectsettings.py b/pitivi/ui/projectsettings.py
index 6070052..c4f88b7 100644
--- a/pitivi/ui/projectsettings.py
+++ b/pitivi/ui/projectsettings.py
@@ -111,7 +111,16 @@ class ProjectSettingsDialog(GladeWindow):
             (self.dar_fraction_widget, None, "value-changed"),
             (self.par_combo, None, "changed"),
             (self.par_fraction_widget, None, "value-changed"),
+            (self.width_spinbutton, None, "value-changed"),
+            (self.height_spinbutton, None, "value-changed"),
         )
+
+        # constrain width and height IFF constrain_sar_button is active
+        self.wg.add_edge(self.width_spinbutton, self.height_spinbutton,
+            self.constrained, self.updateHeight)
+        self.wg.add_edge(self.height_spinbutton, self.width_spinbutton,
+            self.constrained, self.updateWidth)
+
         # keep framereate text field and combo in sync
         self.wg.add_bi_edge(self.frame_rate_combo,
            self.frame_rate_fraction_widget)
@@ -128,8 +137,18 @@ class ProjectSettingsDialog(GladeWindow):
         self.wg.add_edge(self.par_fraction_widget, self.par_combo,
             edge_func=self.updateParFromFractionWidget)
 
+        # constrain DAR and PAR values. because the combo boxes are already
+        # linked, we only have to link the fraction widgets together.
+        self.wg.add_edge(self.par_fraction_widget, self.dar_fraction_widget,
+            edge_func=self.updateDarFromPar)
+        self.wg.add_edge(self.dar_fraction_widget, self.par_fraction_widget,
+            edge_func=self.updateParFromDar)
+
         self.updateUI()
 
+    def constrained(self):
+        return self.constrain_sar_button.props.active
+
     def _updateFraction(self, unused, fraction, combo):
         fraction.setWidgetValue(get_combo_value(combo))
 
@@ -141,6 +160,19 @@ class ProjectSettingsDialog(GladeWindow):
         height = int(self.height_spinbutton.get_value())
         return gst.Fraction(width, height)
 
+    def _constrainSarButtonToggledCb(self, button):
+        if button.props.active:
+            self.sar = self.getSAR()
+
+
+    def updateWidth(self):
+        height = int(self.height_spinbutton.get_value())
+        self.width_spinbutton.set_value(height * self.sar)
+
+    def updateHeight(self):
+        width = int(self.width_spinbutton.get_value())
+        self.height_spinbutton.set_value(width * (1 / self.sar))
+
     def updateDarFromPar(self):
         par = self.par_fraction_widget.getWidgetValue()
         sar = self.getSAR()



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