[pitivi] ui: add edge snap and clip color preferences
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi] ui: add edge snap and clip color preferences
- Date: Thu, 30 Apr 2009 12:19:50 -0400 (EDT)
commit 4e2947a29bbe3945214f6fab787ec8d45daa701f
Author: Brandon Lewis <brandon lewis berkeley edu>
Date: Wed Apr 29 22:36:02 2009 -0700
ui: add edge snap and clip color preferences
---
pitivi/ui/mainwindow.py | 2 +-
pitivi/ui/timeline.py | 5 +-
pitivi/ui/timelinecanvas.py | 46 +++++++++++++---
pitivi/ui/track.py | 5 +-
pitivi/ui/trackobject.py | 118 +++++++++++++++++++++++++++++++++++--------
5 files changed, 140 insertions(+), 36 deletions(-)
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index ef0353c..9492848 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -334,7 +334,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
vpaned = gtk.VPaned()
vbox.pack_start(vpaned)
- self.timeline = Timeline(self.uimanager)
+ self.timeline = Timeline(instance, self.uimanager)
self.timeline.project = self.project
vpaned.pack2(self.timeline, resize=True, shrink=False)
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 12f86c3..87b523c 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -111,7 +111,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
# from zoomed out to zoomed in
- def __init__(self, ui_manager):
+ def __init__(self, instance, ui_manager):
gtk.Table.__init__(self, rows=2, columns=1, homogeneous=False)
Loggable.__init__(self)
Zoomable.__init__(self)
@@ -119,6 +119,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self.project = None
self.ui_manager = ui_manager
+ self.app = instance
self._temp_objects = None
self._factories = None
self._finish_drag = False
@@ -148,7 +149,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self.attach(self.ruler, 1, 2, 0, 1, yoptions=0)
# proportional timeline
- self._canvas = TimelineCanvas()
+ self._canvas = TimelineCanvas(self.app)
timelinewindow = gtk.ScrolledWindow(self.hadj, self.vadj)
timelinewindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
timelinewindow.add(self._canvas)
diff --git a/pitivi/ui/timelinecanvas.py b/pitivi/ui/timelinecanvas.py
index 8383013..2bdac58 100644
--- a/pitivi/ui/timelinecanvas.py
+++ b/pitivi/ui/timelinecanvas.py
@@ -27,7 +27,9 @@ from pitivi.ui.track import Track
from pitivi.ui.trackobject import TrackObject
from pitivi.ui.point import Point
from pitivi.ui.zoominterface import Zoomable
-from common import TRACK_SPACING
+from pitivi.settings import GlobalSettings
+from pitivi.ui.prefs import PreferencesDialog
+from pitivi.ui.common import TRACK_SPACING, unpack_cairo_pattern
import gtk
# cursors to be used for resizing objects
@@ -35,16 +37,27 @@ ARROW = gtk.gdk.Cursor(gtk.gdk.ARROW)
# TODO: replace this with custom cursor
RAZOR_CURSOR = gtk.gdk.Cursor(gtk.gdk.XTERM)
-# In pixels
-DEADBAND = 5
+GlobalSettings.addConfigOption('edgeSnapDeadband',
+ section = "user-interface",
+ key = "edge-snap-deadband",
+ default = 5,
+ notify = True)
+
+PreferencesDialog.addNumericPreference('edgeSnapDeadband',
+ section = "Behavior",
+ label = "Snap Distance (pixels)",
+ description = "Threshold distance (in pixels) used for all snapping"
+ "operations",
+ lower = 0)
class TimelineCanvas(goocanvas.Canvas, Zoomable):
_tracks = None
- def __init__(self, timeline=None):
+ def __init__(self, instance, timeline=None):
goocanvas.Canvas.__init__(self)
Zoomable.__init__(self)
+ self.app = instance
self._selected_sources = []
self._tracks = []
self._height = 0
@@ -56,6 +69,7 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable):
self._createUI()
self.timeline = timeline
+ self.settings = instance.settings
def _createUI(self):
self._cursor = ARROW
@@ -63,8 +77,8 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable):
self.tracks = goocanvas.Group()
root.add_child(self.tracks)
self._marquee = goocanvas.Rect(
- stroke_color_rgba=0x33CCFF66,
- fill_color_rgba=0x33CCFF66,
+ stroke_pattern = unpack_cairo_pattern(0x33CCFF66),
+ fill_pattern = unpack_cairo_pattern(0x33CCFF66),
visibility = goocanvas.ITEM_INVISIBLE)
self._razor = goocanvas.Rect(
line_width=0,
@@ -175,7 +189,7 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable):
def _razorMovedCb(self, canvas, event):
def snap(x):
pos = self.nsToPixel(self._position)
- if abs(x - pos) <= DEADBAND:
+ if abs(x - pos) <= self.settings.edgeSnapDeadband:
return pos
return x
x, y = self.convert_from_pixels(event.x, event.y)
@@ -214,9 +228,22 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable):
def zoomChanged(self):
if self.timeline:
- self.timeline.dead_band = self.pixelToNs(DEADBAND)
+ self.timeline.dead_band = self.pixelToNs(
+ self.settings.edgeSnapDeadband)
self._request_size()
+
+## settings callbacks
+
+ def _setSettings(self):
+ self.zoomChanged()
+
+ settings = receiver(_setSettings)
+
+ @handler(settings, "edgeSnapDeadbandChanged")
+ def _edgeSnapDeadbandChangedCb(self, settings):
+ self.zoomChanged()
+
## Timeline callbacks
def _set_timeline(self):
@@ -225,12 +252,13 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable):
if self.timeline:
for track in self.timeline.tracks:
self._trackAdded(None, track)
+ self.zoomChanged()
timeline = receiver(_set_timeline)
@handler(timeline, "track-added")
def _trackAdded(self, timeline, track):
- track = Track(track, self.timeline)
+ track = Track(self.app, track, self.timeline)
self._tracks.append(track)
track.set_canvas(self)
self.tracks.add_child(track)
diff --git a/pitivi/ui/track.py b/pitivi/ui/track.py
index d662ae2..8e9a88c 100644
--- a/pitivi/ui/track.py
+++ b/pitivi/ui/track.py
@@ -7,9 +7,10 @@ import goocanvas
class Track(goocanvas.Group, Zoomable):
__gtype_name__ = 'Track'
- def __init__(self, track, timeline=None):
+ def __init__(self, instance, track, timeline=None):
goocanvas.Group.__init__(self)
Zoomable.__init__(self)
+ self.app = instance
self.widgets = {}
self.timeline = timeline
self.track = track
@@ -49,7 +50,7 @@ class Track(goocanvas.Group, Zoomable):
@handler(track, "track-object-added")
def _objectAdded(self, unused_timeline, track_object):
- w = TrackObject(track_object, self.track, self.timeline)
+ w = TrackObject(self.app, track_object, self.track, self.timeline)
self.widgets[track_object] = w
self.add_child(w)
diff --git a/pitivi/ui/trackobject.py b/pitivi/ui/trackobject.py
index 743b58c..64fd484 100644
--- a/pitivi/ui/trackobject.py
+++ b/pitivi/ui/trackobject.py
@@ -14,8 +14,11 @@ from pitivi.timeline.track import TrackError
from preview import Preview
import gst
from common import LAYER_HEIGHT_EXPANDED, LAYER_HEIGHT_COLLAPSED
-from common import LAYER_SPACING
+from common import LAYER_SPACING, unpack_cairo_pattern
from pitivi.ui.point import Point
+from pitivi.ui.prefs import PreferencesDialog
+from pitivi.settings import GlobalSettings
+from pitivi.stream import AudioStream, VideoStream
LEFT_SIDE = gtk.gdk.Cursor(gtk.gdk.LEFT_SIDE)
RIGHT_SIDE = gtk.gdk.Cursor(gtk.gdk.RIGHT_SIDE)
@@ -27,6 +30,51 @@ TRIMBAR_PIXBUF_FOCUS = gtk.gdk.pixbuf_new_from_file(
import gst
+GlobalSettings.addConfigOption('videoClipBg',
+ section = 'user-interface',
+ key = 'videoclip-background',
+ default = 0x3182bdC0,
+ notify = True)
+
+PreferencesDialog.addColorPreference('videoClipBg',
+ section = "Appearance",
+ label = "Video Clip Background Color",
+ description = "The background color for clips in video tracks.")
+
+GlobalSettings.addConfigOption('audioClipBg',
+ section = 'user-interface',
+ key = 'audioclip-background',
+ default = 0x3182bdC0,
+ notify = True)
+
+PreferencesDialog.addColorPreference('audioClipBg',
+ section = "Appearance",
+ label = "Audio Clip Baground Color",
+ description = "The background color for clips in audio tracks.")
+
+GlobalSettings.addConfigOption('selectedBorderColor',
+ section = 'user-interface',
+ key = 'selectedBorderColor',
+ default = 0xffea00FF,
+ notify = True)
+
+PreferencesDialog.addColorPreference('selectedBorderColor',
+ section = "Appearance",
+ label = "Selection Border Color",
+ description = "The color of the clip's border when it is selected")
+
+GlobalSettings.addConfigOption('clipFontDesc',
+ section = 'user-interface',
+ key = 'clip-font-name',
+ default = "Sans 9",
+ notify = True)
+
+GlobalSettings.addConfigOption('clipFontColor',
+ section = 'user-interface',
+ key = 'clip-font-color',
+ default = 0xFFFFFFAA,
+ notify = True)
+
def text_size(text):
ink, logical = text.get_natural_extents()
x1, y1, x2, y2 = [pango.PIXELS(x) for x in logical]
@@ -100,8 +148,6 @@ class EndHandle(TrimHandle):
class TrackObject(View, goocanvas.Group, Zoomable):
- __BACKGROUND__ = 0x3182bdC0
- __BORDER__ = 0xffea00FF
class Controller(TimelineController):
@@ -129,42 +175,33 @@ class TrackObject(View, goocanvas.Group, Zoomable):
LAYER_SPACING)))
self._view.element.setObjectPriority(priority)
- def __init__(self, element, track, timeline):
+ def __init__(self, instance, element, track, timeline):
goocanvas.Group.__init__(self)
View.__init__(self)
Zoomable.__init__(self)
-
- self.element = element
+ self.app = instance
self.track = track
self.timeline = timeline
+ self.namewidth = 0
self.bg = goocanvas.Rect(
height=self.height,
- fill_color_rgba=self.__BACKGROUND__,
- stroke_color_rgba=self.__BORDER__,
line_width=0)
- self.content = Preview(self.element)
+ self.content = Preview(element)
self.name = goocanvas.Text(
x=10,
y=5,
- text=os.path.basename(unquote(element.factory.name)),
- font="Sans 9",
- fill_color_rgba=0xFFFFFFAA,
+
operator = cairo.OPERATOR_ADD,
alignment=pango.ALIGN_LEFT)
- twidth, theight = text_size(self.name)
self.namebg = goocanvas.Rect(
radius_x = 2,
radius_y = 2,
x = 8,
y = 3,
- width = twidth + 4,
- height = theight + 4,
- line_width = 0,
- fill_color_rgba = self.__BACKGROUND__)
- self.namewidth = twidth
+ line_width = 0)
self.start_handle = StartHandle(element, timeline,
height=self.height)
@@ -175,8 +212,8 @@ class TrackObject(View, goocanvas.Group, Zoomable):
self.end_handle, self.namebg, self.name):
self.add_child(thing)
- if element:
- self.zoomChanged()
+ self.element = element
+ self.settings = instance.settings
self.normal()
## Properties
@@ -230,9 +267,47 @@ class TrackObject(View, goocanvas.Group, Zoomable):
def zoomChanged(self):
self._update()
+## settings signals
+
+ def _setSettings(self):
+ if self.settings:
+ self.clipAppearanceSettingsChanged()
+
+ settings = receiver(_setSettings)
+
+ @handler(settings, "audioClipBgChanged")
+ @handler(settings, "videoClipBgChanged")
+ @handler(settings, "selectedBorderColorChanged")
+ def clipAppearanceSettingsChanged(self, *args):
+ if isinstance(self.element.stream, VideoStream):
+ color = self.settings.videoClipBg
+ elif isinstance(self.element.stream, AudioStream):
+ color = self.settings.audioClipBg
+ pattern = unpack_cairo_pattern(color)
+ self.bg.props.fill_pattern = pattern
+
+ self.namebg.props.fill_pattern = pattern
+
+ self.bg.props.stroke_pattern = unpack_cairo_pattern(
+ self.settings.selectedBorderColor)
+
+ self.name.props.font = self.settings.clipFontDesc
+ self.name.props.fill_pattern = unpack_cairo_pattern(
+ self.settings.clipFontColor)
+
## element signals
- element = receiver()
+ def _setElement(self):
+ if self.element:
+ self.name.props.text = os.path.basename(unquote(
+ self.element.factory.name))
+ twidth, theight = text_size(self.name)
+ self.namewidth = twidth
+ self.namebg.props.width = twidth + 6.0
+ self.namebg.props.height = theight + 4.0
+ self._update()
+
+ element = receiver(_setElement)
@handler(element, "start-changed")
@handler(element, "duration-changed")
@@ -266,4 +341,3 @@ class TrackObject(View, goocanvas.Group, Zoomable):
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]