Commit ce8330d8 authored by Lubosz Sarnecki's avatar Lubosz Sarnecki Committed by Thibault Saunier

titleoverlay: Use new absolute range.

Differential Revision: https://phabricator.freedesktop.org/D841
parent 92c799eb
......@@ -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>
......
......@@ -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)
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment