Add vertical timeline widget (which looks quite cool)

This commit is contained in:
René Stadler 2007-11-23 11:46:43 +02:00 committed by Stefan Sauer
parent be53d450ce
commit 19a3fef369
3 changed files with 126 additions and 18 deletions

View file

@ -895,6 +895,10 @@ class Window (object):
return self.widgets.vbox_main
def get_side_attach_point (self):
return self.widgets.hbox_view
def attach (self):
self.window_state.attach (window = self.gtk_window, state = self.app.state)

View file

@ -233,6 +233,73 @@ class UpdateProcess (object):
pass
class VerticalTimelineWidget (gtk.DrawingArea):
__gtype_name__ = "GstDebugViewerVerticalTimelineWidget"
def __init__ (self):
gtk.DrawingArea.__init__ (self)
self.logger = logging.getLogger ("ui.vtimeline")
self.params = None
self.connect ("expose-event", self.__handle_expose_event)
self.connect ("size-request", self.__handle_size_request)
def __handle_expose_event (self, self_, event):
self.__draw (self.window)
def __draw (self, drawable):
ctx = drawable.cairo_create ()
x, y, w, h = self.get_allocation ()
# White background rectangle.
ctx.set_line_width (0.)
ctx.rectangle (0, 0, w, h)
ctx.set_source_rgb (1., 1., 1.)
ctx.fill ()
ctx.new_path ()
if self.params is None:
return
first_y, cell_height, ts_list = self.params
first_ts, last_ts = ts_list[0], ts_list[-1]
ts_range = last_ts - first_ts
if ts_range == 0:
return
ctx.set_line_width (1.)
ctx.set_source_rgb (0., 0., 0.)
first_y += cell_height // 2 - .5
for i, ts in enumerate (ts_list):
ts_fraction = float (ts - first_ts) / ts_range
ts_offset = ts_fraction * h
row_offset = first_y + i * cell_height
ctx.move_to (-.5, ts_offset)
ctx.line_to (4.5, ts_offset)
ctx.line_to (w - 4.5, row_offset)
ctx.line_to (w + .5, row_offset)
ctx.stroke ()
def __handle_size_request (self, self_, req):
req.width = 64 # FIXME
def update (self, first_y, cell_height, ts_list):
# FIXME: Ideally we should be informed of the vertical position
# difference of the view (which is 0) with the current UI layout.
self.params = (first_y, cell_height, ts_list,)
self.queue_draw ()
class TimelineWidget (gtk.DrawingArea):
__gtype_name__ = "GstDebugViewerTimelineWidget"
@ -500,6 +567,12 @@ class TimelineFeature (FeatureBase):
box.pack_start (self.timeline, False, False, 0)
self.timeline.hide ()
box = window.get_side_attach_point ()
self.vtimeline = VerticalTimelineWidget ()
box.pack_start (self.vtimeline, False, False, 0)
self.vtimeline.hide ()
window.widgets.log_view_scrolled_window.props.vadjustment.connect ("value-changed",
self.handle_log_view_adjustment_value_changed)
@ -535,20 +608,37 @@ class TimelineFeature (FeatureBase):
model = self.log_view.props.model
start_path, end_path = self.log_view.get_visible_range ()
ts1 = model.get (model.get_iter (start_path),
model.COL_TIME)[0]
ts2 = model.get (model.get_iter (end_path),
model.COL_TIME)[0]
ts1 = model.get_value (model.get_iter (start_path),
model.COL_TIME)
ts2 = model.get_value (model.get_iter (end_path),
model.COL_TIME)
self.timeline.update_position (ts1, ts2)
column = self.log_view.get_column (0)
cell_rect = self.log_view.get_cell_area (start_path, column)
first_y = self.log_view.convert_bin_window_to_widget_coords (cell_rect.x, cell_rect.y)[1]
bg_rect = self.log_view.get_background_area (start_path, column)
cell_height = bg_rect.height
ts_list = []
tree_iter = model.get_iter (start_path)
while model.get_path (tree_iter) != end_path:
ts_list.append (model.get_value (tree_iter, model.COL_TIME))
tree_iter = model.iter_next (tree_iter)
self.vtimeline.update (first_y, cell_height, ts_list)
def handle_show_action_toggled (self, action):
show = action.props.active
if show:
self.timeline.show ()
self.vtimeline.show ()
else:
self.timeline.hide ()
self.vtimeline.hide ()
def handle_timeline_button_press_event (self, widget, event):

View file

@ -30,26 +30,40 @@
<property name="spacing">0</property>
<child>
<widget class="GtkScrolledWindow" id="log_view_scrolled_window">
<widget class="GtkHBox" id="hbox_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkTreeView" id="log_view">
<widget class="GtkScrolledWindow" id="log_view_scrolled_window">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">True</property>
<property name="reorderable">True</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="log_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">True</property>
<property name="reorderable">True</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
<packing>