Commit 3f78e856 authored by Alexandru Băluț's avatar Alexandru Băluț

ruler: Show the hours and millis only if useful

parent ec18c353
...@@ -325,6 +325,7 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable): ...@@ -325,6 +325,7 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
style = self.get_style_context() style = self.get_style_context()
setCairoColor(context, style.get_color(state)) setCairoColor(context, style.get_color(state))
y_bearing = context.text_extents("0")[1] y_bearing = context.text_extents("0")[1]
millis = scale < 1
def split(x): def split(x):
# Seven elements: h : mm : ss . mmm # Seven elements: h : mm : ss . mmm
...@@ -337,13 +338,18 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable): ...@@ -337,13 +338,18 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
while paintpos < width: while paintpos < width:
context.move_to(int(paintpos), 1 - y_bearing) context.move_to(int(paintpos), 1 - y_bearing)
current = split(time_to_string(long(current_time))) current = split(time_to_string(long(current_time)))
self._drawTime(context, current, previous) self._drawTime(context, current, previous, millis)
previous = current previous = current
paintpos += spacing paintpos += spacing
current_time += interval current_time += interval
def _drawTime(self, context, current, previous): def _drawTime(self, context, current, previous, millis):
hour = int(current[0])
for index, (element, previous_element) in enumerate(zip(current, previous)): for index, (element, previous_element) in enumerate(zip(current, previous)):
if index <= 1 and not hour:
continue
if index >= 5 and not millis:
break
if element == previous_element: if element == previous_element:
color = self._color_dimmed color = self._color_dimmed
else: else:
......
...@@ -718,6 +718,7 @@ class Timeline(Gtk.Grid, Zoomable, Loggable): ...@@ -718,6 +718,7 @@ class Timeline(Gtk.Grid, Zoomable, Loggable):
self._projectmanager = None self._projectmanager = None
self._project = None self._project = None
self.pipeline = None self.pipeline = None
self.bTimeline = None
self._createUi() self._createUi()
self._createActions() self._createActions()
......
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