[pitivi] ui.track: tracks can now be expanded/contracted
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi] ui.track: tracks can now be expanded/contracted
- Date: Wed, 18 Mar 2009 14:08:39 -0400 (EDT)
commit 7fd501234d273d2551a741ba3c2a5bc0e56990f4
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date: Sun Mar 15 01:22:26 2009 -0700
ui.track: tracks can now be expanded/contracted
---
pitivi/ui/common.py | 2 +-
pitivi/ui/timelinecanvas.py | 6 ++--
pitivi/ui/timelinecontrols.py | 24 ++++++++++++++--
pitivi/ui/track.py | 6 ++++
pitivi/ui/trackobject.py | 60 ++++++++++++++++++++++++++---------------
5 files changed, 69 insertions(+), 29 deletions(-)
diff --git a/pitivi/ui/common.py b/pitivi/ui/common.py
index b9c772a..f8b8d1d 100644
--- a/pitivi/ui/common.py
+++ b/pitivi/ui/common.py
@@ -2,6 +2,6 @@ from pitivi.settings import GlobalSettings
GlobalSettings.addConfigSection("user-interface")
LAYER_HEIGHT_EXPANDED = 50
-LAYER_HEIGHT_COLLAPSED = 10
+LAYER_HEIGHT_COLLAPSED = 15
LAYER_SPACING = 5
TRACK_SPACING = 5
diff --git a/pitivi/ui/timelinecanvas.py b/pitivi/ui/timelinecanvas.py
index e2ce9ec..b533f92 100644
--- a/pitivi/ui/timelinecanvas.py
+++ b/pitivi/ui/timelinecanvas.py
@@ -219,16 +219,16 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable):
self._tracks.append(track)
track.set_canvas(self)
self.tracks.add_child(track)
- self._regroup_tracks()
+ self.regroupTracks()
@handler(timeline, "track-removed")
def _trackRemoved(self, unused_timeline, position):
track = self._tracks[position]
del self._tracks[position]
track.remove()
- self._regroup_tracks()
+ self.regroupTracks()
- def _regroup_tracks(self):
+ def regroupTracks(self):
height = 0
for i, track in enumerate(self._tracks):
track.set_simple_transform(0, height, 1, 0)
diff --git a/pitivi/ui/timelinecontrols.py b/pitivi/ui/timelinecontrols.py
index 58952bd..f1bc8ee 100644
--- a/pitivi/ui/timelinecontrols.py
+++ b/pitivi/ui/timelinecontrols.py
@@ -2,7 +2,7 @@ import gtk
from pitivi.receiver import receiver, handler
import pitivi.stream as stream
from gettext import gettext as _
-from common import LAYER_HEIGHT_EXPANDED, LAYER_SPACING
+from common import LAYER_HEIGHT_EXPANDED, LAYER_HEIGHT_COLLAPSED, LAYER_SPACING
TRACK_CONTROL_WIDTH = 75
@@ -17,14 +17,32 @@ def track_name(track):
class TrackControls(gtk.Expander):
+ __gtype_name__ = 'TrackControls'
+
+ __gsignals__ = {
+ "activate" : "override",
+ }
+
def __init__(self, track):
gtk.Expander.__init__(self, track_name(track))
self.props.use_markup = True
- self.props.expanded = True
- self.props.sensitive = False
+ self.set_expanded(track.expanded)
self.track = track
self.set_size_request(TRACK_CONTROL_WIDTH, LAYER_HEIGHT_EXPANDED)
+ def do_activate(self):
+ self.track.expanded = not self.track.expanded
+
+ track = receiver()
+
+ @handler(track, "expanded-changed")
+ def _expandedChanged(self, track):
+ if self.track.expanded:
+ self.set_size_request(TRACK_CONTROL_WIDTH, LAYER_HEIGHT_EXPANDED)
+ else:
+ self.set_size_request(TRACK_CONTROL_WIDTH, LAYER_HEIGHT_COLLAPSED)
+ self.set_expanded(self.track.expanded)
+
class TimelineControls(gtk.VBox):
def __init__(self, timeline):
diff --git a/pitivi/ui/track.py b/pitivi/ui/track.py
index f03da4c..fbe7d07 100644
--- a/pitivi/ui/track.py
+++ b/pitivi/ui/track.py
@@ -43,3 +43,9 @@ class Track(goocanvas.Group, Zoomable):
self.remove_child(w)
del self.widgets[track_object]
Zoomable.removeInstance(w)
+
+ @handler(track, "expanded-changed")
+ def _expandedChanged(self, track):
+ for widget in self.widgets.itervalues():
+ widget.expanded = track.expanded
+ self.get_canvas().regroupTracks()
diff --git a/pitivi/ui/trackobject.py b/pitivi/ui/trackobject.py
index 15a0a3e..ca0c5c9 100644
--- a/pitivi/ui/trackobject.py
+++ b/pitivi/ui/trackobject.py
@@ -176,19 +176,42 @@ class TrackObject(View, goocanvas.Group, Zoomable):
## Properties
- __height = LAYER_HEIGHT_EXPANDED
+ _height = LAYER_HEIGHT_EXPANDED
def setHeight(self, height):
- self.__height
+ self._height = height
self.start_handle.props.height = height
self.end_handle.props.height = height
- self.__update()
+ self._update()
def getHeight(self):
- return self.__height
+ return self._height
height = property(getHeight, setHeight)
+ _expanded = True
+
+ def setExpanded(self, expanded):
+ self._expanded = expanded
+ if not self._expanded:
+ self.height = LAYER_HEIGHT_COLLAPSED
+ self.content.props.visibility = goocanvas.ITEM_INVISIBLE
+ self.namebg.props.visibility = goocanvas.ITEM_INVISIBLE
+ self.bg.props.height = LAYER_HEIGHT_COLLAPSED
+ self.name.props.y = 0
+ else:
+ self.height = LAYER_HEIGHT_EXPANDED
+ self.content.props.visibility = goocanvas.ITEM_VISIBLE
+ self.namebg.props.visibility = goocanvas.ITEM_VISIBLE
+ self.bg.props.height = LAYER_HEIGHT_EXPANDED
+ self.height = LAYER_HEIGHT_EXPANDED
+ self.name.props.y = 5
+
+ def getExpanded(self):
+ return self._expanded
+
+ expanded = property(getExpanded, setExpanded)
+
## Public API
def focus(self):
@@ -200,14 +223,7 @@ class TrackObject(View, goocanvas.Group, Zoomable):
self.end_handle.unfocus()
def zoomChanged(self):
- self.__update()
-
- def expand(self):
- self.content.props.visibility = goocanvas.ITEM_VISIBLE
- self.height = LAYER_HEIGHT
-
- def collapse(self):
- self.content.props.visibility = goocanvas.ITEM_INVISIBLE
+ self._update()
## element signals
@@ -216,7 +232,7 @@ class TrackObject(View, goocanvas.Group, Zoomable):
@handler(element, "start-changed")
@handler(element, "duration-changed")
def startChangedCb(self, track_object, start):
- self.__update()
+ self._update()
@handler(element, "selected-changed")
def selected_changed(self, element, state):
@@ -227,22 +243,22 @@ class TrackObject(View, goocanvas.Group, Zoomable):
@handler(element, "priority-changed")
def priority_changed(self, element, priority):
- self.__update()
+ self._update()
- def __update(self):
+ def _update(self):
x = self.nsToPixel(self.element.start)
- y = (LAYER_HEIGHT_EXPANDED + LAYER_SPACING) * self.element.priority
+ y = (self.height + LAYER_SPACING) * self.element.priority
self.set_simple_transform(x, y, 1, 0)
-
width = self.nsToPixel(self.element.duration)
w = width - self.end_handle.props.width
self.name.props.clip_path = "M%g,%g h%g v%g h-%g z" % (
0, 0, w, self.height, w)
- if w - 10 > 0:
- self.namebg.props.width = min(w - 8, self.namewidth)
- self.namebg.props.visibility = goocanvas.ITEM_VISIBLE
- else:
- self.namebg.props.visibility = goocanvas.ITEM_INVISIBLE
self.bg.props.width = width
self.end_handle.props.x = w
+ if self.expanded:
+ if w - 10 > 0:
+ self.namebg.props.width = min(w - 8, self.namewidth)
+ self.namebg.props.visibility = goocanvas.ITEM_VISIBLE
+ else:
+ self.namebg.props.visibility = goocanvas.ITEM_INVISIBLE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]