Author: ericwa
Date: Sun Mar 23 08:13:10 2014
New Revision: 10617

URL: http://svn.gna.org/viewcvs/etoile?rev=10617&view=rev
Log:
Graph renderer: gray out lines & nodes that are not ancestors of the current 
node

Modified:
    trunk/Etoile/Frameworks/CoreObject/Samples/CommonUI/EWGraphRenderer.h
    trunk/Etoile/Frameworks/CoreObject/Samples/CommonUI/EWGraphRenderer.m

Modified: trunk/Etoile/Frameworks/CoreObject/Samples/CommonUI/EWGraphRenderer.h
URL: 
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Samples/CommonUI/EWGraphRenderer.h?rev=10617&r1=10616&r2=10617&view=diff
==============================================================================
--- trunk/Etoile/Frameworks/CoreObject/Samples/CommonUI/EWGraphRenderer.h       
(original)
+++ trunk/Etoile/Frameworks/CoreObject/Samples/CommonUI/EWGraphRenderer.h       
Sun Mar 23 08:13:10 2014
@@ -19,6 +19,7 @@
        NSMutableDictionary *revisionInfoForUUID;
        NSMutableDictionary *childrenForUUID;
        NSMutableDictionary *levelForUUID;
+       NSMutableSet *currentUUIDAndAncestors;
        NSMutableArray *graphRows;
        
        id<COTrack> track;

Modified: trunk/Etoile/Frameworks/CoreObject/Samples/CommonUI/EWGraphRenderer.m
URL: 
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Samples/CommonUI/EWGraphRenderer.m?rev=10617&r1=10616&r2=10617&view=diff
==============================================================================
--- trunk/Etoile/Frameworks/CoreObject/Samples/CommonUI/EWGraphRenderer.m       
(original)
+++ trunk/Etoile/Frameworks/CoreObject/Samples/CommonUI/EWGraphRenderer.m       
Sun Mar 23 08:13:10 2014
@@ -219,6 +219,29 @@
        for (ETUUID *root in roots)
        {
                [self assignLevelForUUID: root greaterThanSiblingLevel: -1];
+       }
+}
+
+- (void) addUUIDAndParents: (ETUUID *)aNode toSet: (NSMutableSet *)dest
+{
+       if ([dest containsObject: aNode])
+               return;
+       
+       [dest addObject: aNode];
+       
+       for (ETUUID *parent in [self parentUUIDsForRevisionUUID: aNode])
+       {
+               [self addUUIDAndParents: parent toSet: dest];
+       }
+}
+
+- (void) buildCurrentUUIDAndAncestors
+{
+       currentUUIDAndAncestors = [NSMutableSet new];
+       
+       if ([track currentNode] != nil)
+       {
+               [self addUUIDAndParents: [[track currentNode] UUID] toSet: 
currentUUIDAndAncestors];
        }
 }
 
@@ -267,7 +290,7 @@
        [self buildChildrenForUUID];
        [self buildLevelForUUID];
        [self buildGraphRows];
-//     [self buildBranchForRevisionUUID];
+       [self buildCurrentUUIDAndAncestors];
 }
 
 - (NSUInteger) count
@@ -329,6 +352,18 @@
        [bp stroke];
 }
 
+- (NSColor *)colorForUUID: (ETUUID *)commit
+{
+       if ([currentUUIDAndAncestors containsObject: commit])
+       {
+               return [NSColor colorWithCalibratedRed: 0 green: 0.2 blue: 0.5 
alpha: 1.0];
+       }
+       else
+       {
+               return [NSColor colorWithCalibratedRed: 0.7 green: 0.7 blue: 
0.7 alpha: 1.0];
+       }
+}
+
 - (void) drawRevisionAtIndex: (NSUInteger)index inRect: (NSRect)aRect
 {
        [NSGraphicsContext saveGraphicsState];
@@ -339,14 +374,6 @@
        ETUUID *commit = [revisionInfo UUID];
        const NSInteger level = [levelForUUID[commit] integerValue];
 
-       if ([revisionInfo.metadata[@"minorEdit"] isEqual: @(YES)])
-       {
-               [[NSColor grayColor] set];
-       }
-       else
-       {
-               [[NSColor blueColor] set];
-       }
 
        // Draw lines
        
@@ -356,10 +383,12 @@
        {
                for (ETUUID *child in [self childrenForUUID: parent])
                {
+                       [[self colorForUUID: child] setStroke];
                        [self drawLineFromUUID: parent toUUID: child 
currentRow: index inRect: aRect];
                }
        }
        
+       [[self colorForUUID: commit] setStroke];
        [[NSColor whiteColor] setFill];
        NSBezierPath *circle = [NSBezierPath bezierPathWithOvalInRect: [self 
circleRectAtLevel: level inRect: aRect]];
        [circle setLineWidth: [[[track currentNode] UUID] isEqual: commit] ? 2 
: 1];


_______________________________________________
Etoile-cvs mailing list
Etoile-cvs@gna.org
https://mail.gna.org/listinfo/etoile-cvs

Reply via email to