[pitivi] Standardize timeline colors with constants and fix the ruler's bg color



commit 69d3dcac2a24bc0eac8d23a0a0ad973feb411802
Author: Jean-François Fortin Tam <nekohayo gmail com>
Date:   Fri Aug 2 17:30:08 2013 +0200

    Standardize timeline colors with constants and fix the ruler's bg color
    
    Fixes bug #704686

 pitivi/timeline/elements.py |   19 +++++++++++++------
 pitivi/timeline/ruler.py    |   13 +++++++++++--
 pitivi/timeline/timeline.py |   14 ++++++++++----
 3 files changed, 34 insertions(+), 12 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 838a92c..220d96a 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -38,6 +38,13 @@ from previewers import AudioPreviewer, VideoPreviewer, BORDER_WIDTH
 import pitivi.configure as configure
 from pitivi.utils.ui import EXPANDED_SIZE, SPACING, KEYFRAME_SIZE, CONTROL_WIDTH
 
+# Colors for keyframes and clips (RGBA)
+KEYFRAME_LINE_COLOR = (237, 212, 0, 255)  # "Tango" yellow
+KEYFRAME_NORMAL_COLOR = Clutter.Color.new(0, 0, 0, 200)
+KEYFRAME_SELECTED_COLOR = Clutter.Color.new(200, 200, 200, 200)
+CLIP_SELECTED_OVERLAY_COLOR = Clutter.Color.new(60, 60, 60, 100)
+GHOST_CLIP_COLOR = Clutter.Color.new(255, 255, 255, 50)
+
 
 def get_preview_for_object(bElement, timeline):
     # FIXME: special preview for transitions, titles
@@ -149,7 +156,7 @@ class Ghostclip(Clutter.Actor):
         Clutter.Actor.__init__(self)
         self.track_type = track_type
         self.bElement = bElement
-        self.set_background_color(Clutter.Color.new(255, 255, 255, 50))
+        self.set_background_color(GHOST_CLIP_COLOR)
         self.props.visible = False
         self.shouldCreateLayer = False
 
@@ -581,7 +588,7 @@ class TimelineElement(Clutter.Actor, Zoomable):
         # TODO: difference between Actor.new() and Actor()?
         self.marquee = Clutter.Actor()
         self.marquee.bElement = self.bElement
-        self.marquee.set_background_color(Clutter.Color.new(60, 60, 60, 100))
+        self.marquee.set_background_color(CLIP_SELECTED_OVERLAY_COLOR)
         self.marquee.props.visible = False
         self.add_child(self.marquee)
 
@@ -756,7 +763,7 @@ class Line(Clutter.Actor):
         cr.stroke()
         # Draw the actual line in the middle.
         # Do it last, so that it gets drawn on top and remains sharp.
-        cr.set_source_rgba(237, 212, 0, 255)
+        cr.set_source_rgba(*KEYFRAME_LINE_COLOR)
         cr.move_to(0, _max_height / 2)
         cr.line_to(width, _max_height / 2)
         cr.set_line_width(_max_height / 3)
@@ -859,7 +866,7 @@ class Keyframe(Clutter.Actor):
         self.lastClick = datetime.now()
 
         self.set_size(KEYFRAME_SIZE, KEYFRAME_SIZE)
-        self.set_background_color(Clutter.Color.new(0, 255, 0, 255))
+        self.set_background_color(KEYFRAME_NORMAL_COLOR)
 
         self.dragAction = Clutter.DragAction()
         self.add_action(self.dragAction)
@@ -883,7 +890,7 @@ class Keyframe(Clutter.Actor):
 
     def _unselect(self):
         self.timelineElement.set_reactive(True)
-        self.set_background_color(Clutter.Color.new(0, 255, 0, 255))
+        self.set_background_color(KEYFRAME_NORMAL_COLOR)
         
self.timelineElement.timeline._container.embed.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.ARROW))
 
     def remove(self):
@@ -913,7 +920,7 @@ class Keyframe(Clutter.Actor):
 
     def _enterEventCb(self, actor, event):
         self.timelineElement.set_reactive(False)
-        self.set_background_color(Clutter.Color.new(0, 0, 0, 255))
+        self.set_background_color(KEYFRAME_SELECTED_COLOR)
         
self.timelineElement.timeline._container.embed.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.HAND1))
 
     def _leaveEventCb(self, actor, event):
diff --git a/pitivi/timeline/ruler.py b/pitivi/timeline/ruler.py
index 9c91e68..15aba51 100644
--- a/pitivi/timeline/ruler.py
+++ b/pitivi/timeline/ruler.py
@@ -37,9 +37,18 @@ from pitivi.utils.timeline import Zoomable
 from pitivi.utils.loggable import Loggable
 from pitivi.utils.ui import time_to_string, beautify_length
 
+# Color #393f3f stolen from the dark variant of Adwaita.
+# There's *no way* to get the GTK3 theme's bg color there (it's always black)
+RULER_BACKGROUND_COLOR = (57, 63, 63)
+
 
 def setCairoColor(cr, color):
-    cr.set_source_rgb(float(color.red), float(color.green), float(color.blue))
+    if type(color) is tuple:
+        # Cairo's set_source_rgb function expects values from 0.0 to 1.0
+        cairo_color = map(lambda x: max(0, min(1, x / 255.0)), color)
+        cr.set_source_rgb(*cairo_color)
+    else:
+        cr.set_source_rgb(float(color.red), float(color.green), float(color.blue))
 
 
 class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
@@ -205,7 +214,7 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
 
     def drawBackground(self, cr):
         style = self.get_style_context()
-        setCairoColor(cr, style.get_background_color(Gtk.StateFlags.NORMAL))
+        setCairoColor(cr, RULER_BACKGROUND_COLOR)
         cr.rectangle(0, 0, cr.get_target().get_width(), cr.get_target().get_height())
         cr.fill()
         offset = int(self.nsToPixel(Gst.CLOCK_TIME_NONE)) - self.pixbuf_offset
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 02499d0..344589c 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -86,6 +86,12 @@ ALIGN = _("Align clips based on their soundtracks")
 SELECT_BEFORE = ("Select all sources before selected")
 SELECT_AFTER = ("Select all after selected")
 
+# Colors
+TIMELINE_BACKGROUND_COLOR = Clutter.Color.new(31, 30, 33, 255)
+SELECTION_MARQUEE_COLOR = Clutter.Color.new(100, 100, 100, 200)
+PLAYHEAD_COLOR = Clutter.Color.new(200, 0, 0, 255)
+SNAPPING_INDICATOR_COLOR = Clutter.Color.new(50, 150, 200, 200)
+
 ui = '''
 <ui>
     <menubar name="MainMenuBar">
@@ -348,7 +354,7 @@ class TimelineStage(Clutter.ScrollActor, Zoomable):
         self.set_reactive(True)
 
         self.marquee = Clutter.Actor()
-        self.marquee.set_background_color(Clutter.Color.new(100, 100, 100, 200))
+        self.marquee.set_background_color(SELECTION_MARQUEE_COLOR)
         self.marquee.hide()
         self.add_child(self.marquee)
 
@@ -400,7 +406,7 @@ class TimelineStage(Clutter.ScrollActor, Zoomable):
 
     def _createPlayhead(self):
         self.playhead = Clutter.Actor()
-        self.playhead.set_background_color(Clutter.Color.new(200, 0, 0, 255))
+        self.playhead.set_background_color(PLAYHEAD_COLOR)
         self.playhead.set_size(0, 0)
         self.playhead.set_position(0, 0)
         self.playhead.set_easing_duration(0)
@@ -409,7 +415,7 @@ class TimelineStage(Clutter.ScrollActor, Zoomable):
 
     def _createSnapIndicator(self):
         self._snap_indicator = Clutter.Actor()
-        self._snap_indicator.set_background_color(Clutter.Color.new(50, 150, 200, 200))
+        self._snap_indicator.set_background_color(SNAPPING_INDICATOR_COLOR)
         self._snap_indicator.props.visible = False
         self._snap_indicator.props.width = 3
         self._snap_indicator.props.y = 0
@@ -815,7 +821,7 @@ class Timeline(Gtk.VBox, Zoomable):
         perspective.fov_y = 90.
         self.stage.set_perspective(perspective)
 
-        self.stage.set_background_color(Clutter.Color.new(31, 30, 33, 255))
+        self.stage.set_background_color(TIMELINE_BACKGROUND_COLOR)
         self.timeline.set_position(CONTROL_WIDTH, 0)
         self.controls.set_position(0, 0)
         self.controls.set_z_position(2)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]