[pitivi] elements: Change the border color when a clip is selected



commit 88790fb6482b9cca043e224722d0600944add250
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Mon Jan 6 20:01:20 2014 +0100

    elements: Change the border color when a clip is selected
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=635987

 pitivi/timeline/elements.py |   13 ++++++++-----
 pitivi/utils/ui.py          |    7 +++++++
 2 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 02e4933..ba53eee 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -38,7 +38,7 @@ from pitivi.utils.timeline import Zoomable, EditingContext, SELECT, UNSELECT, SE
 from previewers import AudioPreviewer, VideoPreviewer
 
 import pitivi.configure as configure
-from pitivi.utils.ui import EXPANDED_SIZE, SPACING, KEYFRAME_SIZE, CONTROL_WIDTH
+from pitivi.utils.ui import EXPANDED_SIZE, SPACING, KEYFRAME_SIZE, CONTROL_WIDTH, create_cogl_color
 
 # Colors for keyframes and clips (RGBA)
 KEYFRAME_LINE_COLOR = (237, 212, 0, 255)  # "Tango" yellow
@@ -47,6 +47,9 @@ 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)
 
+BORDER_NORMAL_COLOR = create_cogl_color(100, 100, 100, 255)
+BORDER_SELECTED_COLOR = create_cogl_color(200, 200, 10, 255)
+
 
 def get_preview_for_object(bElement, timeline):
     # FIXME: special preview for transitions, titles
@@ -351,6 +354,7 @@ class TimelineElement(Clutter.Actor, Zoomable):
         self.source = None
         self.keyframedElement = None
         self.rightHandle = None
+        self.isSelected = False
         size = self.bElement.get_duration()
 
         self._createBackground(track)
@@ -363,7 +367,6 @@ class TimelineElement(Clutter.Actor, Zoomable):
         self.update(True)
         self.set_reactive(True)
 
-        self.isSelected = False
         self._createMixingKeyframes()
 
         self._connectToEvents()
@@ -582,9 +585,7 @@ class TimelineElement(Clutter.Actor, Zoomable):
     def _createBorder(self):
         border = RoundedRectangle(0, 0, 0, 0)
         border.bElement = self.bElement
-        color = Cogl.Color()
-        color.init_from_4ub(100, 100, 100, 255)
-        border.set_border_color(color)
+        border.set_border_color(BORDER_NORMAL_COLOR)
         border.set_border_width(1)
         border.set_position(0, 0)
         self.add_child(border)
@@ -661,6 +662,8 @@ class TimelineElement(Clutter.Actor, Zoomable):
         if not isSelected:
             self.hideKeyframes()
         self.marquee.props.visible = isSelected
+        color = BORDER_SELECTED_COLOR if isSelected else BORDER_NORMAL_COLOR
+        self.border.set_border_color(color)
 
 
 class Gradient(Clutter.Actor):
diff --git a/pitivi/utils/ui.py b/pitivi/utils/ui.py
index c46aa50..37cf3dd 100644
--- a/pitivi/utils/ui.py
+++ b/pitivi/utils/ui.py
@@ -29,6 +29,7 @@ classes that help with UI drawing around the application
 
 from decimal import Decimal
 from gettext import ngettext, gettext as _
+from gi.repository import Cogl
 from gi.repository import GLib
 from gi.repository import GES
 from gi.repository import Gst
@@ -169,6 +170,12 @@ def hex_to_rgb(value):
     return tuple(float(int(value[i:i + 2], 16)) / 255.0 for i in range(0, 6, 2))
 
 
+def create_cogl_color(red, green, blue, alpha):
+    color = Cogl.Color()
+    color.init_from_4ub(red, green, blue, alpha)
+    return color
+
+
 #------ Helper to help beatify indos so they can be displayed in the UI -----#
 def beautify_info(info):
     ranks = {


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