/* Copyright (c) 2004, Noah Sorscher
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 	• 	Redistributions of source code must retain the above copyright
 * 	notice, this list of conditions and the following disclaimer.
 * 	• 	Redistributions in binary form must reproduce the above copyright
 * 	notice, this list of conditions and the following disclaimer in the
 * 	documentation and/or other materials provided with the distribution.
 * 	• 	Neither the name of the Noah Sorscher nor the names of its
 * 	contributors may be used to endorse or promote products derived from
 * 	this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */
//
//  mhsTrack.h
//  Hootenanny
//
//  Created by Noah Sorscher on Sun Sep 28 2003.
//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import "Movies.h"
#import "WiredSpriteUtilities.h"
#import "SpriteUtilities.h"
#import "MHSpriteConstants.h"
#import "SpriteExtras.h"
#define TRACK_DURATION 100


typedef enum {
    gotoTime, // by TimeValue
    gotoTimeAndPlay,
    gotoTimeByName, // also plays
    setAudioTrack, // by track number, not the number of audio tracks
    setAudioTrackByName, // applies to all tracks by that name
    setTextTrack, // ditto audio track stuff, -1 for the value to turn off all text tracks
    setTextTrackByName,
    gotoBeginning,
    gotoEnd,
    stepForward,
    stepBackward
} MHSpriteAction;

typedef struct {
    NSPoint point;
    BOOL visible;
    short layer;
    QTAtomID cursor;
    PicHandle picImage;
    NSString *fileImage; // choose a file or PicHandle for each of Main, Rollover and Clicked.  Files must be in PICT format
    PicHandle picRollImage;
    NSString *fileRollImage;
    PicHandle picClickImage;
    NSString *fileClickImage;
    NSMovie *loopingMovie;
    MHSpriteAction action; // -1 for no action
    long longValue; // track index or TimeValue when relevant, ignored otherwise
    NSString *stringValue; // track/chapter name when relevant, ignored otherwise
    NSColor *keyColor;
} MHSpriteSpec;

@protocol mhsProt

- (void) postUpdate:(NSString *)string done:(double) fraction;

@end

@interface mhsTrack : NSObject {
    NSMovie *theMovie;
    Track theTrack;
    NSColor *theColor;
    QTAtomID picIndex, spriteIndex;
    QTAtomContainer theKeyFrameSample;
    long offset;
}

- (void) setOffset:(long)n;
- (mhsTrack *)initWithMovie:(NSMovie *)movie;
- (void)addSprites:(NSArray *)sprites sender:(id)sender;
- (void)setBGSource:(NSString *)imageSource;
- (void)setBGColor:(NSColor *)color;
- (RGBColor)RGBColor;
- (RGBColor)rgbColor:(NSColor *)aColor;

+ (void)insertSprite:(NSDictionary *)theSprite intoMovie:(NSMovie *)movie;
+ (void)addSprite:(NSDictionary *)theSprite overMovie:(NSMovie *)movie;

- (MHSpriteSpec)newSpec;
- (BOOL) setTrackEnabledAction:(QTAtomContainer)theSprite trackType:(OSType)theType ident:(id)theIdent;
- (void)createTrackAndMedia:(Movie)mov;
+ (Track)newTrackInMovie:(Movie)mov;
- (OSErr)addWiredSprite:(MHSpriteSpec)spec;

@end
