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 @@ ...@@ -3,15 +3,15 @@
<interface> <interface>
<requires lib="gtk+" version="3.10"/> <requires lib="gtk+" version="3.10"/>
<object class="GtkAdjustment" id="position_x_adj"> <object class="GtkAdjustment" id="position_x_adj">
<property name="upper">2</property> <property name="upper">100</property>
<property name="lower">-2</property> <property name="lower">-100</property>
<property name="value">0.5</property> <property name="value">0.5</property>
<property name="step_increment">0.050000000000000003</property> <property name="step_increment">0.050000000000000003</property>
<property name="page_increment">0.10000000000000001</property> <property name="page_increment">0.10000000000000001</property>
</object> </object>
<object class="GtkAdjustment" id="position_y_adj"> <object class="GtkAdjustment" id="position_y_adj">
<property name="upper">2</property> <property name="upper">100</property>
<property name="lower">-2</property> <property name="lower">-100</property>
<property name="value">0.5</property> <property name="value">0.5</property>
<property name="step_increment">0.050000000000000003</property> <property name="step_increment">0.050000000000000003</property>
<property name="page_increment">0.10000000000000001</property> <property name="page_increment">0.10000000000000001</property>
...@@ -275,7 +275,7 @@ ...@@ -275,7 +275,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSpinButton" id="xpos"> <object class="GtkSpinButton" id="x-absolute">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="invisible_char"></property> <property name="invisible_char"></property>
...@@ -290,7 +290,7 @@ ...@@ -290,7 +290,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSpinButton" id="ypos"> <object class="GtkSpinButton" id="y-absolute">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="invisible_char"></property> <property name="invisible_char"></property>
......
...@@ -87,18 +87,18 @@ class TitleEditor(Loggable): ...@@ -87,18 +87,18 @@ class TitleEditor(Loggable):
self.foreground_color_button = builder.get_object("fore_text_color") self.foreground_color_button = builder.get_object("fore_text_color")
self.background_color_button = builder.get_object("back_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: for setting in settings:
self.settings[setting] = builder.get_object(setting) self.settings[setting] = builder.get_object(setting)
for n, en in list({_("Custom"): "position", for n, en in list({_("Absolute"): "absolute",
_("Top"): "top", _("Top"): "top",
_("Center"): "center", _("Center"): "center",
_("Bottom"): "bottom", _("Bottom"): "bottom",
_("Baseline"): "baseline"}.items()): _("Baseline"): "baseline"}.items()):
self.settings["valignment"].append(en, n) self.settings["valignment"].append(en, n)
for n, en in list({_("Custom"): "position", for n, en in list({_("Absolute"): "absolute",
_("Left"): "left", _("Left"): "left",
_("Center"): "center", _("Center"): "center",
_("Right"): "right"}.items()): _("Right"): "right"}.items()):
...@@ -132,8 +132,8 @@ class TitleEditor(Loggable): ...@@ -132,8 +132,8 @@ class TitleEditor(Loggable):
def _updateFromSource(self, source): def _updateFromSource(self, source):
self.textbuffer.set_text(source.get_child_property("text")[1] or "") self.textbuffer.set_text(source.get_child_property("text")[1] or "")
self.settings['xpos'].set_value(source.get_child_property("xpos")[1]) self.settings['x-absolute'].set_value(source.get_child_property("x-absolute")[1])
self.settings['ypos'].set_value(source.get_child_property("ypos")[1]) self.settings['y-absolute'].set_value(source.get_child_property("y-absolute")[1])
self.settings['valignment'].set_active_id( self.settings['valignment'].set_active_id(
source.get_child_property("valignment")[1].value_name) source.get_child_property("valignment")[1].value_name)
self.settings['halignment'].set_active_id( self.settings['halignment'].set_active_id(
...@@ -182,10 +182,10 @@ class TitleEditor(Loggable): ...@@ -182,10 +182,10 @@ class TitleEditor(Loggable):
return return
def _updateWidgetsVisibility(self): def _updateWidgetsVisibility(self):
visible = self.settings["valignment"].get_active_id() == "position" visible = self.settings["valignment"].get_active_id() == "absolute"
self.settings["ypos"].set_visible(visible) self.settings["y-absolute"].set_visible(visible)
visible = self.settings["halignment"].get_active_id() == "position" visible = self.settings["halignment"].get_active_id() == "absolute"
self.settings["xpos"].set_visible(visible) self.settings["x-absolute"].set_visible(visible)
def set_source(self, source): def set_source(self, source):
""" """
...@@ -244,7 +244,7 @@ class TitleEditor(Loggable): ...@@ -244,7 +244,7 @@ class TitleEditor(Loggable):
if self.textbuffer.props.text == value: if self.textbuffer.props.text == value:
return return
self.textbuffer.props.text = value 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: if self.settings[pspec.name].get_value() == value:
return return
self.settings[pspec.name].set_value(value) self.settings[pspec.name].set_value(value)
......
...@@ -53,8 +53,8 @@ class TitleOverlay(Overlay): ...@@ -53,8 +53,8 @@ class TitleOverlay(Overlay):
cr.line_to(*self.__position.tolist()) cr.line_to(*self.__position.tolist())
def __get_source_position(self): def __get_source_position(self):
res_x, x = self._source.get_child_property("xpos") res_x, x = self._source.get_child_property("x-absolute")
res_y, y = self._source.get_child_property("ypos") res_y, y = self._source.get_child_property("y-absolute")
assert res_x and res_y assert res_x and res_y
return numpy.array([x, y]) return numpy.array([x, y])
...@@ -71,8 +71,8 @@ class TitleOverlay(Overlay): ...@@ -71,8 +71,8 @@ class TitleOverlay(Overlay):
return numpy.array([w, h]) return numpy.array([w, h])
def __set_source_position(self, position): def __set_source_position(self, position):
self._source.set_child_property("xpos", float(position[0])) self._source.set_child_property("x-absolute", float(position[0]))
self._source.set_child_property("ypos", float(position[1])) self._source.set_child_property("y-absolute", float(position[1]))
def __update_corners(self): def __update_corners(self):
self.__corners = [ self.__corners = [
...@@ -125,9 +125,12 @@ class TitleOverlay(Overlay): ...@@ -125,9 +125,12 @@ class TitleOverlay(Overlay):
def on_motion_notify(self, cursor_position): def on_motion_notify(self, cursor_position):
if not isinstance(self.stack.click_position, numpy.ndarray): if not isinstance(self.stack.click_position, numpy.ndarray):
return 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.__update_from_motion(self.__click_window_position + self.stack.get_drag_distance(cursor_position))
self.queue_draw() 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.__set_source_position(title_position)
self._commit() 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