Title: [commits] (jeffrey) [11348] Continued bug 6233 work on calendar lozenges
Revision
11348
Author
jeffrey
Date
2006-08-07 18:04:10 -0700 (Mon, 07 Aug 2006)

Log Message

Continued bug 6233 work on calendar lozenges
- Add support for gradients that aren't just changes to saturation
- Added color scheme for FYI/anytime/zero-duration events

Modified Paths

Diff

Modified: trunk/chandler/application/styles.conf (11347 => 11348)

--- trunk/chandler/application/styles.conf	2006-08-07 23:45:25 UTC (rev 11347)
+++ trunk/chandler/application/styles.conf	2006-08-08 01:04:10 UTC (rev 11348)
@@ -28,22 +28,22 @@
 ######### Selected Lozenges ################
 
 SelectedGradientLeftSaturation    = 1.0
-SelectedGradientLeftValue         = 1.0
+SelectedGradientLeftValue         = 0.5
 
-SelectedGradientRightSaturation   = 0.8
-SelectedGradientRightValue        = 1.0
+SelectedGradientRightSaturation   = 1.0
+SelectedGradientRightValue        = 0.8
 
-SelectedOutlineSaturation         = 0.6
-SelectedOutlineValue              = 1.0
+SelectedOutlineSaturation         = 0.75
+SelectedOutlineValue              = 0.75
 
 SelectedTextSaturation            = 0.0
 SelectedTextValue                 = 1.0
 
 ######### Unselected Lozenges ##############
-UnSelectedGradientLeftSaturation    = 0.8
-UnSelectedGradientLeftValue         = 1.0
+UnSelectedGradientLeftSaturation    = 1.0
+UnSelectedGradientLeftValue         = 0.8
 
-UnSelectedGradientRightSaturation   = 0.5
+UnSelectedGradientRightSaturation   = 0.8
 UnSelectedGradientRightValue        = 1.0
 
 UnSelectedOutlineSaturation         = 0.6
@@ -53,14 +53,54 @@
 UnSelectedTextValue                 = 1.0
 
 ########## Overlaid Lozenges ###############
-OverlayGradientLeftSaturation    = 0.4
+OverlayGradientLeftSaturation    = 0.33
 OverlayGradientLeftValue         = 1.0
 
-OverlayGradientRightSaturation   = 0.4
+OverlayGradientRightSaturation   = 0.33
 OverlayGradientRightValue        = 1.0
 
 OverlayOutlineSaturation         = 0.3
 OverlayOutlineValue              = 1.0
 
-OverlayTextSaturation            = 0.67
-OverlayTextValue                 = 0.5
+OverlayTextSaturation            = 1.0
+OverlayTextValue                 = 0.8
+
+#### Selected FYI/Anytime/@Time Lozenges ########
+
+SelectedFYIGradientLeftSaturation    = 0.4
+SelectedFYIGradientLeftValue         = 1.0
+
+SelectedFYIGradientRightSaturation   = 0.1
+SelectedFYIGradientRightValue        = 1.0
+
+SelectedFYIOutlineSaturation         = 0.8
+SelectedFYIOutlineValue              = 1.0
+
+SelectedFYITextSaturation            = 1.0
+SelectedFYITextValue                 = 0.8
+
+#### Unselected FYI/Anytime/@Time Lozenges ######
+UnSelectedFYIGradientLeftSaturation    = 0.1
+UnSelectedFYIGradientLeftValue         = 1.0
+
+UnSelectedFYIGradientRightSaturation   = 0.05
+UnSelectedFYIGradientRightValue        = 1.0
+
+UnSelectedFYIOutlineSaturation         = 0.8
+UnSelectedFYIOutlineValue              = 1.0
+
+UnSelectedFYITextSaturation            = 1.0
+UnSelectedFYITextValue                 = 0.8
+
+#### Overlaid FYI/Anytime/@Time Lozenges ########
+OverlayFYIGradientLeftSaturation    = 0.1
+OverlayFYIGradientLeftValue         = 1.0
+
+OverlayFYIGradientRightSaturation   = 0.05
+OverlayFYIGradientRightValue        = 1.0
+
+OverlayFYIOutlineSaturation         = 0.3
+OverlayFYIOutlineValue              = 1.0
+
+OverlayFYITextSaturation            = 1.0
+OverlayFYITextValue                 = 0.8

Modified: trunk/chandler/parcels/osaf/framework/blocks/DrawingUtilities.py (11347 => 11348)

--- trunk/chandler/parcels/osaf/framework/blocks/DrawingUtilities.py	2006-08-07 23:45:25 UTC (rev 11347)
+++ trunk/chandler/parcels/osaf/framework/blocks/DrawingUtilities.py	2006-08-08 01:04:10 UTC (rev 11348)
@@ -187,8 +187,24 @@
                 return
         #assert False, "Didn't draw any text!"
 
+class vector(list):
 
-        
+    def __add__(self, other):
+        return vector(map(lambda x,y: x+y, self, other))
+
+    def __neg__(self):
+        return vector(map(lambda x: -x, self))
+
+    def __sub__(self, other):
+        return vector(map(lambda x,y: x-y, self, other))
+
+    def __mul__(self, const):
+	return vector(map(lambda x: x*const, self))
+    
+    def __rmul__(self, other):
+	    return (self*other)
+
+
 class Gradients(object):
     """
     Gradient cache. 
@@ -240,20 +256,12 @@
             image = wx.EmptyImage(1, bitmapWidth)
         leftHSV = rgb_to_hsv(*color2rgb(*leftColor))
         rightHSV = rgb_to_hsv(*color2rgb(*rightColor))
-
-        # make sure they are the same hue and brightness
-        # XXX: this doesn't quite work, because sometimes division issues
-        # cause numbers to be very close, but not quite the same
-        # (i.e. 0.4 != 0.40000001 etc)
-        #assert leftHSV.hue == rightHSV.hue
-        #assert leftHSV.value == rightHSV.value
         
-        hue = leftHSV[0]
-        value = leftHSV[2]
-        satStart = leftHSV[1]
-        satDelta = rightHSV[1] - leftHSV[1]
+        left  = vector(leftHSV)
+        right = vector(rightHSV)
+                
         if bitmapWidth == 0: bitmapWidth = 1
-        satStep = satDelta / bitmapWidth
+        step = (right - left) * (1.0 / bitmapWidth)
         
         # assign a sliding scale of floating point values from left to right
         # in the bitmap
@@ -273,12 +281,9 @@
             # ensures we're dealing with x<offset correctly
             gradientIndex = (x - offset + bitmapWidth) % bitmapWidth
             
-            # now offset within the gradient range
-            gradientIndex %= bitmapWidth
-            
             # now calculate the actual color from the gradient index
-            sat = satStart + satStep * gradientIndex
-            color = rgb2color(*hsv_to_rgb(hue, sat, value))
+	    hsvVector = left + step * gradientIndex
+            color = rgb2color(*hsv_to_rgb(*hsvVector))
 
             # use the image buffer to write values directly
             # amazingly, this %c techinque to convert

Modified: trunk/chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py (11347 => 11348)

--- trunk/chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py	2006-08-07 23:45:25 UTC (rev 11347)
+++ trunk/chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py	2006-08-08 01:04:10 UTC (rev 11348)
@@ -134,52 +134,32 @@
 
         color = UserCollection(collection).ensureColor().color
         self.hue = rgb_to_hsv(*color2rgb(color.red,color.green,color.blue))[0]
-
-    # to be used like a property, i.e. prop = tintedColor(0.5, 1.0)
-    # takes HSV 'S' and 'V' and returns an color based tuple property
-    def tintedColor(saturation, value = 1.0):
-        def getSaturatedColor(self):
-            return rgb2color(*hsv_to_rgb(self.hue, saturation, value))
-        return property(getSaturatedColor)
-
-    def tupleProperty(*args):
+    
+    def getColorsProperty(prefix):
         """
-        Untangle a tuple of property objects.
-
-        If you try to just declare a tuple of attributes
-        that are property objects, you end up with a tuple
-        of property objects, rather than a tuple of evaluated
-        property values.
+        takes HSV 'S' and 'V' from conf files, hue from self, returns a tuple of
+        four RGB colors.
+        
         """
-        def demangledTupleGetter(self):
-            return tuple([val.fget(self) for val in args])
-        return property(demangledTupleGetter)
+        suffixes = 'GradientLeft', 'GradientRight', 'Outline', 'Text'
+        names = [prefix + suffix for suffix in suffixes]
+        
+        def saturationAndValue(name):
+            return (float(confstyles.cfg.get('calendarcanvas', name + 'Saturation')),
+                    float(confstyles.cfg.get('calendarcanvas', name + 'Value')))
+        
+        def getSaturatedColors(self):
+            return [rgb2color(*hsv_to_rgb(self.hue, saturation, value)) for
+                    saturation, value in map(saturationAndValue, names)]
 
-    # these are all for when this calendar is the 'current' one
-    def get_style(name):
-        return (float(confstyles.cfg.get('calendarcanvas', name+'Saturation')),
-                float(confstyles.cfg.get('calendarcanvas', name+'Value')))
-                
-    gradientLeft  = tintedColor(*get_style('UnSelectedGradientLeft'))
-    gradientRight = tintedColor(*get_style('UnSelectedGradientRight'))
-    outlineColor  = tintedColor(*get_style('UnSelectedOutline'))
-    textColor     = tintedColor(*get_style('UnSelectedText'))
-    defaultColors = tupleProperty(gradientLeft, gradientRight, outlineColor, textColor)
-
-    # when a user selects a calendar event, use these
-    selectedGradientLeft  = tintedColor(*get_style('SelectedGradientLeft'))
-    selectedGradientRight = tintedColor(*get_style('SelectedGradientRight'))
-    selectedOutlineColor  = tintedColor(*get_style('SelectedOutline'))
-    selectedTextColor     = tintedColor(*get_style('SelectedText'))
-    selectedColors = tupleProperty(selectedGradientLeft, selectedGradientRight, selectedOutlineColor, selectedTextColor)
+        return property(getSaturatedColors)
     
-    # 'visible' means that its not the 'current' calendar, but is still visible
-    visibleGradientLeft  = tintedColor(*get_style('OverlayGradientLeft'))
-    visibleGradientRight = tintedColor(*get_style('OverlayGradientRight'))
-    visibleOutlineColor  = tintedColor(*get_style('OverlayOutline'))
-    visibleTextColor     = tintedColor(*get_style('OverlayText'))
-                                       
-    visibleColors = tupleProperty(visibleGradientLeft, visibleGradientRight, visibleOutlineColor, visibleTextColor)
+    defaultColors     = getColorsProperty('UnSelected')
+    selectedColors    = getColorsProperty('Selected')
+    visibleColors     = getColorsProperty('Overlay')
+    defaultFYIColors  = getColorsProperty('UnSelectedFYI')
+    selectedFYIColors = getColorsProperty('SelectedFYI')
+    visibleFYIColors  = getColorsProperty('OverlayFYI')
 
 
 # wrapper around 
@@ -266,6 +246,8 @@
         self.itsItem.clearSelection()
         self.selectedOccurrences = set()
 
+zero_delta = timedelta(0)
+
 class CalendarCanvasItem(CollectionCanvas.CanvasItem):
     """
     Base class for calendar items. Covers:
@@ -307,41 +289,32 @@
         size -= (12, self.timeHeight + self.textMargin*2 + 3)
         return size
 
-
-    def DrawStatusBar(self, dc, color, (x,y1,y2)):
-        # probably should use styles to determine a good pen color
+    def invertColors(self):
         item = self.item
-
-        if item.transparency in ("fyi", "confirmed"):
-            pen = wx.Pen(color, 5)
-        elif (item.transparency == "tentative"):
-            if '__WXMAC__' in wx.PlatformInfo:
-                pen = wx.Pen(color, 4, wx.USER_DASH)
-                pen.SetDashes(TRANSPARENCY_DASHES)
-            else:
-                pen = wx.Pen(color, 4, wx.DOT)
-
-        pen.SetCap(wx.CAP_BUTT)
-        dc.SetPen(pen)
-        dc.DrawLine(x, y1, x, y2)
-        if item.transparency == "fyi":
-            pen = wx.Pen(wx.WHITE, 2)
-            pen.SetCap(wx.CAP_BUTT)
-            dc.SetPen(pen)
-            dc.DrawLine(x+1, y1, x+1, y2)
-
+        return (((item.anyTime or item.duration == zero_delta) and
+                  not item.allDay) or
+                item.transparency == 'fyi' )
+    
+    
     def getEventColors(self, selected):
         """
         Returns the appropriate tuple of selected, normal, and visible colors.
         """
-
-        if selected:
-            return self.colorInfo.selectedColors
-        elif self.isActive:
-            return self.colorInfo.defaultColors
-
-        return self.colorInfo.visibleColors
-
+        if self.invertColors():
+            if selected:
+                return self.colorInfo.selectedFYIColors
+            elif self.isActive:
+                return self.colorInfo.defaultFYIColors
+    
+            return self.colorInfo.visibleFYIColors
+        else:
+            if selected:
+                return self.colorInfo.selectedColors
+            elif self.isActive:
+                return self.colorInfo.defaultColors
+    
+            return self.colorInfo.visibleColors
+            
     def GetAnyTimeOrAllDay(self):	
         item = self.item
         anyTime = getattr(item, 'anyTime', False)
@@ -465,22 +438,8 @@
                                         hasTopRightRounded,
                                         hasBottomRightRounded,
                                         rightSideCutOff)
-                
-                # if the left side is rounded, we don't need a status bar
-                if not hasLeftRounded:
-                    self.DrawStatusBar(dc, outlineColor,
-                                       (itemRect.x+1,
-                                        itemRect.y+1,
-                                        itemRect.y-1 + itemRect.height))
+                    
     
-     
-                #self.textOffset = wx.Point(self.textMargin, self.textMargin)
-                
-                #if hasLeftRounded:
-                    #self.textOffset.x += RADIUS
-                #else:
-                    #self.textOffset.x += 3
-    
                 # Shift text to account for rounded corners
                 x = itemRect.x + self.textOffset.x
                 y = itemRect.y + self.textOffset.y




_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to