[pitivi] titleoverlay: Use new absolute range.



commit ce8330d86f13b796971e304149cf18f670ff6b4e
Author: Lubosz Sarnecki <lubosz sarnecki collabora co uk>
Date:   Fri Mar 11 12:36:55 2016 +0100

    titleoverlay: Use new absolute range.
    
    Differential Revision: https://phabricator.freedesktop.org/D841

 data/ui/titleeditor.ui         |   12 ++++++------
 pitivi/titleeditor.py          |   20 ++++++++++----------
 pitivi/viewer/title_overlay.py |   13 ++++++++-----
 3 files changed, 24 insertions(+), 21 deletions(-)
---
diff --git a/data/ui/titleeditor.ui b/data/ui/titleeditor.ui
index ae76fa9..5f8aa41 100644
--- a/data/ui/titleeditor.ui
+++ b/data/ui/titleeditor.ui
@@ -3,15 +3,15 @@
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkAdjustment" id="position_x_adj">
-    <property name="upper">2</property>
-    <property name="lower">-2</property>
+    <property name="upper">100</property>
+    <property name="lower">-100</property>
     <property name="value">0.5</property>
     <property name="step_increment">0.050000000000000003</property>
     <property name="page_increment">0.10000000000000001</property>
   </object>
   <object class="GtkAdjustment" id="position_y_adj">
-    <property name="upper">2</property>
-    <property name="lower">-2</property>
+    <property name="upper">100</property>
+    <property name="lower">-100</property>
     <property name="value">0.5</property>
     <property name="step_increment">0.050000000000000003</property>
     <property name="page_increment">0.10000000000000001</property>
@@ -275,7 +275,7 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkSpinButton" id="xpos">
+                          <object class="GtkSpinButton" id="x-absolute">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="invisible_char">•</property>
@@ -290,7 +290,7 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkSpinButton" id="ypos">
+                          <object class="GtkSpinButton" id="y-absolute">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="invisible_char">•</property>
diff --git a/pitivi/titleeditor.py b/pitivi/titleeditor.py
index ecabb11..1b22036 100644
--- a/pitivi/titleeditor.py
+++ b/pitivi/titleeditor.py
@@ -87,18 +87,18 @@ class TitleEditor(Loggable):
         self.foreground_color_button = builder.get_object("fore_text_color")
         self.background_color_button = builder.get_object("back_color")
 
-        settings = ["valignment", "halignment", "xpos", "ypos"]
+        settings = ["valignment", "halignment", "x-absolute", "y-absolute"]
         for setting in settings:
             self.settings[setting] = builder.get_object(setting)
 
-        for n, en in list({_("Custom"): "position",
+        for n, en in list({_("Absolute"): "absolute",
                            _("Top"): "top",
                            _("Center"): "center",
                            _("Bottom"): "bottom",
                            _("Baseline"): "baseline"}.items()):
             self.settings["valignment"].append(en, n)
 
-        for n, en in list({_("Custom"): "position",
+        for n, en in list({_("Absolute"): "absolute",
                            _("Left"): "left",
                            _("Center"): "center",
                            _("Right"): "right"}.items()):
@@ -132,8 +132,8 @@ class TitleEditor(Loggable):
 
     def _updateFromSource(self, source):
         self.textbuffer.set_text(source.get_child_property("text")[1] or "")
-        self.settings['xpos'].set_value(source.get_child_property("xpos")[1])
-        self.settings['ypos'].set_value(source.get_child_property("ypos")[1])
+        self.settings['x-absolute'].set_value(source.get_child_property("x-absolute")[1])
+        self.settings['y-absolute'].set_value(source.get_child_property("y-absolute")[1])
         self.settings['valignment'].set_active_id(
             source.get_child_property("valignment")[1].value_name)
         self.settings['halignment'].set_active_id(
@@ -182,10 +182,10 @@ class TitleEditor(Loggable):
                 return
 
     def _updateWidgetsVisibility(self):
-        visible = self.settings["valignment"].get_active_id() == "position"
-        self.settings["ypos"].set_visible(visible)
-        visible = self.settings["halignment"].get_active_id() == "position"
-        self.settings["xpos"].set_visible(visible)
+        visible = self.settings["valignment"].get_active_id() == "absolute"
+        self.settings["y-absolute"].set_visible(visible)
+        visible = self.settings["halignment"].get_active_id() == "absolute"
+        self.settings["x-absolute"].set_visible(visible)
 
     def set_source(self, source):
         """
@@ -244,7 +244,7 @@ class TitleEditor(Loggable):
             if self.textbuffer.props.text == value:
                 return
             self.textbuffer.props.text = value
-        elif pspec.name in ["xpos", "ypos"]:
+        elif pspec.name in ["x-absolute", "y-absolute"]:
             if self.settings[pspec.name].get_value() == value:
                 return
             self.settings[pspec.name].set_value(value)
diff --git a/pitivi/viewer/title_overlay.py b/pitivi/viewer/title_overlay.py
index 4aec33c..995cc61 100644
--- a/pitivi/viewer/title_overlay.py
+++ b/pitivi/viewer/title_overlay.py
@@ -53,8 +53,8 @@ class TitleOverlay(Overlay):
         cr.line_to(*self.__position.tolist())
 
     def __get_source_position(self):
-        res_x, x = self._source.get_child_property("xpos")
-        res_y, y = self._source.get_child_property("ypos")
+        res_x, x = self._source.get_child_property("x-absolute")
+        res_y, y = self._source.get_child_property("y-absolute")
         assert res_x and res_y
         return numpy.array([x, y])
 
@@ -71,8 +71,8 @@ class TitleOverlay(Overlay):
         return numpy.array([w, h])
 
     def __set_source_position(self, position):
-        self._source.set_child_property("xpos", float(position[0]))
-        self._source.set_child_property("ypos", float(position[1]))
+        self._source.set_child_property("x-absolute", float(position[0]))
+        self._source.set_child_property("y-absolute", float(position[1]))
 
     def __update_corners(self):
         self.__corners = [
@@ -125,9 +125,12 @@ class TitleOverlay(Overlay):
     def on_motion_notify(self, cursor_position):
         if not isinstance(self.stack.click_position, numpy.ndarray):
                 return
-        title_position = self.__click_source_position + 
self.stack.get_normalized_drag_distance(cursor_position)
+
         self.__update_from_motion(self.__click_window_position + 
self.stack.get_drag_distance(cursor_position))
         self.queue_draw()
+
+        title_position = self.__position / (self.stack.window_size * (1 - self.__get_text_size() / 
self.project_size))
+
         self.__set_source_position(title_position)
         self._commit()
 


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