Skip to content

Commit

Permalink
blue selection
Browse files Browse the repository at this point in the history
  • Loading branch information
HalfdanJ committed Jul 15, 2010
1 parent eb181de commit c4af1e6
Show file tree
Hide file tree
Showing 21 changed files with 25,384 additions and 2,058 deletions.
12 changes: 11 additions & 1 deletion CueController.h
Expand Up @@ -8,6 +8,7 @@

#import <Cocoa/Cocoa.h>

#import "CueModel.h"

@interface CueController : NSObject <NSTableViewDelegate, NSTableViewDataSource> {
IBOutlet NSArrayController * cueArrayController;
Expand All @@ -16,10 +17,19 @@
IBOutlet NSTableView * cueTable;
}

- (NSArrayController *) cueArrayController;

- (CueModel*)cueBeforeCue:(CueModel*)cue;
- (CueModel*)cueAfterCue:(CueModel*)cue;

- (NSArray*) selectedCues;
- (IBAction)go:(id)sender;
- (IBAction)stop:(id)sender;
- (void) applyPropertiesForCue:(CueModel*)cue;


- (IBAction)addNewItem:(id)sender;
- (IBAction)removeSelectedItems:(id)sender;
- (IBAction)removeSelectedItems:(id)szender;
- (NSArray *)sortDescriptors;
- (void)renumberViewPositions;

Expand Down
81 changes: 79 additions & 2 deletions CueController.m
Expand Up @@ -9,6 +9,7 @@
#import "CueController.h"
#include "CueTimeCell.h"
#include "CueModel.h"
#import "DevicePropertyModel.h"

NSString *DemoItemsDropType = @"CueDropType";

Expand All @@ -32,13 +33,74 @@ -(void) awakeFromNib{
[cueTable registerForDraggedTypes:[NSArray arrayWithObjects:DemoItemsDropType, nil]];
cueController = self;

[NSEvent addLocalMonitorForEventsMatchingMask:(NSKeyDownMask) handler:^(NSEvent *incomingEvent) {
NSEvent *result = incomingEvent;
// NSLog(@"Events: %@",incomingEvent);

//Escape
if([incomingEvent keyCode] == 53){
[self stop:self];
}
return result;

}];

}



- (IBAction)go:(id)sender{
[self applyPropertiesForCue:[self cueBeforeCue:[[self selectedCues] lastObject]]];

[[[cueArrayController selectedObjects] lastObject] go];
[cueArrayController selectNext:self];
}

- (IBAction)stop:(id)sender{
for(CueModel * cue in [cueArrayController arrangedObjects]){
[cue stop];
}
}

-(void) applyPropertiesForCue:(CueModel *)cue{
NSManagedObjectContext *moc = [document managedObjectContext];
NSEntityDescription *entityDescription = [NSEntityDescription
entityForName:@"DeviceProperty" inManagedObjectContext:moc];
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:entityDescription];

NSError *error;
NSArray *array = [moc executeFetchRequest:request error:&error];
if (array == nil)
{
}
for(DevicePropertyModel * prop in array){
NSNumber * val = [prop valueInCue:cue];
[prop setValue:val forKey:@"outputValue"];
}

}

- (NSArray*) selectedCues{
return [cueArrayController selectedObjects];
}

- (CueModel*)cueBeforeCue:(CueModel*)cue{
int index = [[cueArrayController arrangedObjects] indexOfObject:cue];
if(index > 0)
return [[cueArrayController arrangedObjects] objectAtIndex:index-1];
else
return nil;
}
- (CueModel*)cueAfterCue:(CueModel*)cue{
int index = [[cueArrayController arrangedObjects] indexOfObject:cue];
if(index < [[cueArrayController arrangedObjects] count] - 1)
return [[cueArrayController arrangedObjects] objectAtIndex:index+1];
else
return nil;
}



- (IBAction)addNewItem:(id)sender
{
Expand Down Expand Up @@ -74,6 +136,10 @@ - (NSArray *)sortDescriptors
return _sortDescriptors;
}

- (NSArrayController *) cueArrayController{
return cueArrayController;
}



#pragma mark -
Expand Down Expand Up @@ -167,6 +233,7 @@ - (void)renumberViewPositions


#pragma mark TableController

-(CGFloat) tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row{
return 20;
}
Expand All @@ -177,14 +244,22 @@ -(void) tableView:(NSTableView *)tableView willDisplayCell:(id)aCell forTableCol
if ([[aTableColumn identifier] isEqualToString:@"preWait"] || [[aTableColumn identifier] isEqualToString:@"postWait"] || [[aTableColumn identifier] isEqualToString:@"fadeTime"] || [[aTableColumn identifier] isEqualToString:@"fadeDownTime"]) {

// if([[aTableColumn identifier] isEqualToString:@"preWait"])
CueModel * cue = [[cueArrayController arrangedObjects] objectAtIndex:row];

{
CueModel * cue = [[cueArrayController arrangedObjects] objectAtIndex:row];
[aCell setRunning:([[cue valueForKey:[NSString stringWithFormat:@"%@RunningTime",[aTableColumn identifier]]] doubleValue] > 0)?YES:NO];
[aCell setRunningTime:[[cue valueForKey:[NSString stringWithFormat:@"%@RunningTime",[aTableColumn identifier]]] doubleValue]];
[aCell setTotalTime:[[cue valueForKey:[aTableColumn identifier]] doubleValue]];
}

if ([[aCell objectValue] floatValue] > 0) { // if it is YES
if( [[aTableColumn identifier] isEqualToString:@"fadeDownTime"]){
if([[aCell objectValue] floatValue] == [[cue valueForKey:@"fadeTime"] floatValue]){
[aCell setTextColor:[[NSColor whiteColor] colorWithAlphaComponent:0.6]];
} else {
[aCell setTextColor:[NSColor whiteColor]];
}
}
else if ([[aCell objectValue] floatValue] > 0) { // if it is YES
[aCell setTextColor:[NSColor whiteColor]];
} else {
[aCell setTextColor:[[NSColor whiteColor] colorWithAlphaComponent:0.6]];
Expand All @@ -197,6 +272,8 @@ -(void) tableView:(NSTableView *)tableView willDisplayCell:(id)aCell forTableCol
[aCell setTextColor:[NSColor blackColor]];
}
}

[aCell setBackgroundStyle:NSBackgroundStyleDark];
}

- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pasteboard
Expand Down
19 changes: 19 additions & 0 deletions CueModel.h
Expand Up @@ -7,13 +7,19 @@
//

#import <Cocoa/Cocoa.h>
#import "CueDevicePropertyRelationModel.h"


@interface CueModel : NSManagedObject {
double preWaitRunningTime;
double fadeTimeRunningTime;
double fadeDownTimeRunningTime;
double postWaitRunningTime;

double fadePercent;
double fadeDownPercent;



NSTimer * preWaitTimer;
NSDate * preWaitTimerStartDate;
Expand All @@ -30,6 +36,8 @@
}

- (IBAction) go;
- (IBAction) stop;


- (void) startPreWait;
- (void) startFade;
Expand All @@ -41,9 +49,12 @@
- (void)fadeDownTimerFired:(NSTimer*)theTimer;
- (void)postWaitTimerFired:(NSTimer*)theTimer;

- (void) finishedRunning;

- (BOOL) running;


@property (readonly) BOOL running;

@property (readwrite) double preWaitRunningTime;
@property (readwrite) double fadeTimeRunningTime;
Expand All @@ -53,13 +64,21 @@
@property (readwrite) NSNumber * fadeTimeVisualRep;
@property (readwrite) NSNumber * fadeDownTimeVisualRep;
@property (readwrite) NSNumber * postWaitVisualRep;
@property (nonatomic, retain) NSNumber * fadeTime;
@property (nonatomic, retain) NSNumber * lineNumber;

@property (nonatomic, retain) NSSet* deviceRelations;

@property (readonly,retain) NSImage * statusImage;


- (void)addDeviceRelationsObject:(NSManagedObject *)value;
- (void)removeDeviceRelationsObject:(NSManagedObject *)value;
- (void)addDeviceRelations:(NSSet *)value;
- (void)removeDeviceRelations:(NSSet *)value;

@end




0 comments on commit c4af1e6

Please sign in to comment.