コード例 #1
0
ファイル: TExportZone.cpp プロジェクト: ModeenF/UltraDV
void TExportZone::ResolutionChanged(int32 resizePixels)
{	
	const BRect bounds = Bounds();
	
	// Get start and duration in pixels
	uint32 startTime = m_CueSheetWindow->GetCueSheetView()->GetExportStartTime();
	uint32 stopTime  = m_CueSheetWindow->GetCueSheetView()->GetExportStopTime();
		
	uint32 inPixels 	= TimeToPixels( startTime, GetCurrentTimeFormat(), GetCurrentResolution());
	uint32 outPixels = TimeToPixels( stopTime, GetCurrentTimeFormat(), GetCurrentResolution());

	//	Update slider zones
	m_InRect.left 	= inPixels;
	m_InRect.right 	= m_InRect.left + kExportSliderWidth;

	m_OutRect.right	 = outPixels;
	m_OutRect.left 	 = m_OutRect.right - kExportSliderWidth;
	
	// Update channel zone
	m_ExportChannel.left  = m_InRect.right;
	m_ExportChannel.right = m_OutRect.left;

	// Force redraw
	Invalidate();
}
コード例 #2
0
ファイル: TMIDICue.cpp プロジェクト: Barrett17/UltraDV
void TMIDICue::Init()
{

	// Editor is closed
	fEditorOpen = false;

	// Set up default settings
	fIsLocked                       = false;
	fIsSelected             = false;
	fLowColor                       = kWhite;
	fHighColor              = kBlack;
	fIsPrepared             = false;
	fIsPlaying              = false;
	fIsVisible                      = false;
	fHasDuration            = true;
	fCanLoop                        = true;
	fCanStretch             = true;
	fCanEnvelope            = true;
	fHasEditor              = true;
	fCanWindow                      = true;
	fCanTransition          = false;
	fCanPath                        = false;

	// Default initialization
	TCueView::Init();

	// Create MIDIStore and MIDIEngine
	fMIDIStore = new BMidiStore();
	assert(fMIDIStore);
	fMIDIStore->Import(&fFileRef);
	fMIDIEngine = new TMIDIEngine(fMIDIStore);

	// Set cues fFile to point to the fMIDIFile
	fFile = fMIDIFile;

	// Calcaluate duration
	CalcDuration();

	// Adjust bounds based on cue duration
	int32 newWidth = TimeToPixels(fDuration, GetCurrentTimeFormat(), GetCurrentResolution());
	ResizeBy( newWidth - Bounds().Width(), 0);

	// Add the cue to the cue channel
	if ( fChannel->CanInsertCue(this, fInsertTime, true)) {
		fChannel->InsertCue(this, fInsertTime);
		Select();

		// We are now fully instantiated
		fIsInstantiated = true;
	}

	// Set expanded status
	if (fChannel->IsExpanded()) {
		fIsExpanded = false;
		Expand();
	} else {
		fIsExpanded = true;
		Contract();
	}
}
コード例 #3
0
ファイル: TCueSheetWindow.cpp プロジェクト: Barrett17/UltraDV
void TCueSheetWindow::AdjustScrollBars()
{
	const BRect scrollRect = Bounds();

	// Get start and duration in pixels
	int32 startPixels        = TimeToPixels( fCueSheetView->StartTime(), fCueSheetView->GetTimeFormat(), fCueSheetView->GetResolution());
	int32 durationPixels = TimeToPixels( fCueSheetView->Duration(),  fCueSheetView->GetTimeFormat(), fCueSheetView->GetResolution());
	int32 resizePixels       = durationPixels - startPixels;

	// Adjust horizontal scrollbar
	AdjustScrollBar( fHScroll, scrollRect.Width(), kTickSpacing, resizePixels+kTimeScalerWidth+1, scrollRect.left);

	//      Vertical scrollbar area is total combined height of all channels
	//	Iterate through all of the channels and calculate height
	int32 totalHeight = 0;
	for (int32 index = 0; index < fCueSheetView->GetTotalChannels(); index++) {
		TCueChannel* theChannel = (TCueChannel*)fCueSheetView->GetChannelList()->ItemAt(index);
		if (theChannel)
			totalHeight += (int32)(theChannel->Bounds().Height());
	}

	// Adjust vertical scrollbar
	AdjustScrollBar( fVScroll, scrollRect.Height()-(kTimelineHeight+kToolbarHeight+kMenuHeight+10), kTickSpacing, totalHeight+kTimelineHeight+kToolbarHeight+kMenuHeight+1, scrollRect.top);
}
コード例 #4
0
ファイル: TExportZone.cpp プロジェクト: ModeenF/UltraDV
void TExportZone::TrackOutMarker(BPoint mousePt)
{					
	//	Constrain to out time of cue sheet
	uint32 outPixels = TimeToPixels( Duration() - StartTime(), GetCurrentTimeFormat(), GetCurrentResolution());
	
	if (mousePt.x > outPixels)
		mousePt.x = outPixels;

	//	Don't allow overlap with m_InRect
	if ( (mousePt.x-kExportSliderWidth) < m_InRect.right)
		mousePt.x = m_InRect.right + kExportSliderWidth;

	// Save oldRect for redraw														
	BRect oldRect 	= m_OutRect;	
	m_OutRect.right = mousePt.x;	
	m_OutRect.left = m_OutRect.right - kExportSliderWidth;	
	
	
	// Exit if there is no change in position
	if (oldRect == m_OutRect)
		return;

	//	Update m_ExportChannel
	m_ExportChannel.right = m_OutRect.left;
	
	//	Clean up old position
	BRect updateRect = oldRect;
	
	if (m_OutRect.left <= oldRect.left)
	{
		updateRect.left = m_OutRect.left;		
	}
	else
	{
		updateRect.right  = m_OutRect.right;
	}
	
	Draw(updateRect);
	
	//	Update CueSheet variable
	uint32 newOutTime = StartTime() + PixelsToTime(m_OutRect.right, GetCurrentTimeFormat(), GetCurrentResolution());
	m_CueSheetWindow->GetCueSheetView()->SetExportStopTime(newOutTime);

	//	Update text
	m_CueSheetWindow->GetExportTimeView()->DrawOutText();
	
}
コード例 #5
0
ファイル: TExportZone.cpp プロジェクト: ModeenF/UltraDV
void TExportZone::HandleDoubleClick(BPoint where)
{
	//	Get window bounds
	const BRect winBounds = Window()->Bounds();
	
	//	Get cue sheet bounds
	const BRect bounds = Bounds();
	
	//	Get total pixel length for bounds checking
	int32 pixelWidth = TimeToPixels( Duration(), GetCurrentTimeFormat(), GetCurrentResolution() );
	
	//	Update tracking rects
	m_InRect.left 	= bounds.left;
	m_InRect.right 	= m_InRect.left + kExportSliderWidth;

	//	Set up out rect.  Check for right side length bounds violation
	int32 outRight = (bounds.left + winBounds.Width()) - kHeaderWidth;
	if (outRight > pixelWidth)
		outRight = pixelWidth;
	
	m_OutRect.right	 = outRight;
	m_OutRect.left 	 = m_OutRect.right - kExportSliderWidth;
	
	//	Update m_ExportChannel
	m_ExportChannel.left  = m_InRect.right;
	m_ExportChannel.right = m_OutRect.left;
	
	//	Update cue sheet variables
	m_CueSheetWindow->GetCueSheetView()->SetExportStartTime( PixelsToTime(m_InRect.left, GetCurrentTimeFormat(), GetCurrentResolution()) );
	m_CueSheetWindow->GetCueSheetView()->SetExportStopTime( PixelsToTime(m_OutRect.right, GetCurrentTimeFormat(), GetCurrentResolution()) );
	
	//	Update text items
	m_CueSheetWindow->GetExportTimeView()->DrawInText();
	m_CueSheetWindow->GetExportTimeView()->DrawOutText();

	//	Redraw
	Invalidate();
}
コード例 #6
0
ファイル: TCueSheetWindow.cpp プロジェクト: Barrett17/UltraDV
void TCueSheetWindow::MessageReceived(BMessage* message)
{
	switch (message->what)
	{
	// These messages come from the transport
	case START_BUTTON_MSG:
	{
		fCueSheetView->SetCurrentTime( StartTime() );

		// Inform Transport
		BMessage* theMessage = new BMessage(UPDATE_TIMELINE_MSG);
		theMessage->AddInt32("TheTime", GetCurrentTime());
		TTransportPalette* theTransport = static_cast<MuseumApp*>(be_app)->GetTransport();
		theTransport->PostMessage(theMessage, theTransport->GetTransportPaletteView());
		delete theMessage;
	}
	break;

	case REWIND_BUTTON_MSG:
		/*{
		        // Calculate new time
		        uint32 increment = 1000 / ( GetFPSValue(GetCurrentTimeFormat())+1);
		        uint32 newTime = GetCurrentTime() - (increment-=2);

		        // Don't allow underflow
		        if (newTime < StartTime())
		                newTime = StartTime();

		        fCueSheetView->SetCurrentTime(newTime);

		        // Inform Transport
		        BMessage *theMessage = new BMessage(UPDATE_TIMELINE_MSG);
		        theMessage->AddInt32("TheTime", GetCurrentTime());
		        TTransportPalette *theTransport = static_cast<MuseumApp *>(be_app)->GetTransport();
		        theTransport->PostMessage(theMessage, theTransport->GetTransportPaletteView());
		        delete theMessage;

		        char textStr[256];
		        TimeToString(GetCurrentTime(), GetCurrentTimeFormat(), textStr, false);
		   }*/
		break;

	case PLAY_BUTTON_MSG:
		break;

	case PAUSE_BUTTON_MSG:
		break;

	case STOP_BUTTON_MSG:
		break;

	case FF_BUTTON_MSG:
		/*{
		        // Calculate new time
		        uint32 increment = 1000 / ( GetFPSValue(GetCurrentTimeFormat()));
		        uint32 newTime = GetCurrentTime() + (increment+=2);

		        // Don't allow overflow
		        if (newTime > StartTime() + Duration())
		                newTime = StartTime() + Duration();

		        fCueSheetView->SetCurrentTime(newTime);

		        // Inform Transport
		        BMessage *theMessage = new BMessage(UPDATE_TIMELINE_MSG);
		        theMessage->AddInt32("TheTime", GetCurrentTime());
		        TTransportPalette *theTransport = static_cast<MuseumApp *>(be_app)->GetTransport();
		        theTransport->PostMessage(theMessage, theTransport->GetTransportPaletteView());
		        delete theMessage;

		        char textStr[256];
		        TimeToString(GetCurrentTime(), GetCurrentTimeFormat(), textStr, false);
		   }*/
		break;

	case END_BUTTON_MSG:
	{
		fCueSheetView->SetCurrentTime(StartTime() + Duration());

		// Inform Transport
		BMessage* theMessage = new BMessage(UPDATE_TIMELINE_MSG);
		theMessage->AddInt32("TheTime", GetCurrentTime());
		TTransportPalette* theTransport = static_cast<MuseumApp*>(be_app)->GetTransport();
		theTransport->PostMessage(theMessage, theTransport->GetTransportPaletteView());
		delete theMessage;
	}
	break;

	case RECORD_BUTTON_MSG:
		break;

	case RESOLUTION_CHANGE_MSG:
	{
		Lock();

		// Get start and duration in pixels
		int32 startPixels        = TimeToPixels( fCueSheetView->StartTime(), GetCurrentTimeFormat(), GetCurrentResolution());
		int32 durationPixels = TimeToPixels( fCueSheetView->Duration(), GetCurrentTimeFormat(), GetCurrentResolution());
		int32 resizePixels       = durationPixels - startPixels;

		fCueSheetView->ResolutionChanged(message);
		fExportZone->ResolutionChanged(resizePixels);
		fTimeline->ResolutionChanged(resizePixels);

		// Update scroll bars
		AdjustScrollBars();

		Unlock();
	}
	break;

	// These messages come from the BFilePanel when saving a cue sheet
	case B_SAVE_REQUESTED:
		Save(message);
		break;

	case B_CANCEL:
		break;

	default:
		BWindow::MessageReceived(message);
		break;
	}
}
コード例 #7
0
ファイル: TCueSheetWindow.cpp プロジェクト: Barrett17/UltraDV
void TCueSheetWindow::Init()
{
	// Init Undo Engine
	fUndoEngine = new TUndoEngine();

	// Member file used for saves
	fFile = NULL;

	// Dialog box state
	fPanelOpen = false;

	// Create the stage window
	BRect stageRect(0,0,420,340);
	fStageWindow = new TStageWindow(stageRect, this);
	CenterWindow(fStageWindow);

	// Set up menu bar
	BRect mbarRect = Bounds();
	mbarRect.bottom = mbarRect.top+kMenuHeight;
	BMenuBar* mbar = new BMenuBar(mbarRect, "MuseumMenu");

	// Set up application menus.
	// Create a new TMuseumMenu object and pass the  BMenuBar object in to the constructor.
	// Then add the individual menu items with the TMuseumMenu object
	fAppMenu = new TMuseumMenus(mbar);

	AddChild(mbar);

	//      Set the channel length to an hour duration in milliseconds
	float channelLength = TimeToPixels( 60 * 60 * 1000L, B_TIMECODE_24, 3);

	//      Create Toolbar.  It is always at the top of the window, below the menu.
	BRect toolRect = Bounds();
	toolRect.Set(toolRect.left, kMenuHeight, toolRect.right, kMenuHeight+kToolbarHeight);
	fToolbar = new TToolbar(toolRect, this);
	AddChild(fToolbar);
	fToolbar->Show();

	//      Create ExportTimeView.  It is always located below the toolbar and to the
	//      very left of the cue sheet.  It is as wide as the cue sheet headers.
	BRect exportTimeRect;
	exportTimeRect.left             = fToolbar->Frame().left;
	exportTimeRect.top              = fToolbar->Frame().bottom+1;
	exportTimeRect.right    = exportTimeRect.left + kHeaderWidth;
	exportTimeRect.bottom   = exportTimeRect.top + kExportZoneHeight + 11;
	fExportTimeView = new TExportTimeView(this, exportTimeRect);
	AddChild(fExportTimeView);
	fExportTimeView->Show();

	//      Create CueSheet Time Zone.  It is always located below the toolbar and to the
	//      very left of the cue sheet.  It is as wide as the cue sheet headers.
	BRect zoneRect;
	zoneRect.left   = exportTimeRect.left;
	zoneRect.top    = exportTimeRect.bottom+1;
	zoneRect.right  = zoneRect.left+kHeaderWidth;
	zoneRect.bottom = zoneRect.top + kTimelineHeight - 11;
	fTimeZone = new TCueSheetTimeView(this, zoneRect);
	AddChild(fTimeZone);
	fTimeZone->Show();

	//	Create ExportZone.  It is always located below the toolbar and to the right
	//	of the TimeZone.  This is where the user determines the span of the cue sheet
	//	to preview or export
	BRect exportRect;
	exportRect.left         = zoneRect.right + 1;
	exportRect.top          = fToolbar->Frame().bottom+1;
	exportRect.right        = Bounds().right;
	exportRect.bottom   = exportRect.top + kExportZoneHeight;
	fExportZone = new TExportZone(exportRect, this);
	AddChild(fExportZone);
	fExportZone->Show();

	//      Create Timeline.  It is always located below the toolbar and to the right
	//	of the TimeZone.  This is where the time is indicated and the playback head resides
	BRect timeRect;
	timeRect.left   = exportRect.left;
	timeRect.top    = exportRect.bottom + 1;
	timeRect.right  = Bounds().right;
	timeRect.bottom = timeRect.top + kTimelineHeight;
	fTimeline = new TTimelineView(timeRect, this);
	AddChild(fTimeline);
	fTimeline->Show();

	// Create Header Container View
	BRect containerRect  = Bounds();
	containerRect.top    = fTimeline->Frame().bottom;
	containerRect.right  = containerRect.left + kHeaderWidth;
	containerRect.bottom -= kScrollHeight+1;
	fHeaderContainer = new THeaderContainerView(containerRect);
	AddChild(fHeaderContainer);
	fHeaderContainer->SetViewColor(kMediumGrey);


	// Create cue sheet view.  Add one pixel to left to fix drawing bug with header...
	BRect bounds = fTimeline->Frame();
	bounds.Set(bounds.left, bounds.bottom+1, Bounds().right-(kScrollWidth+1), Bounds().bottom - (kScrollHeight+1));
	fCueSheetView = new TCueSheetView(bounds, this);
	fCueSheetView->SetViewColor(kGrey);


	//
	// Create scroll bars
	//

	// Horizontal
	BRect scrollRect = Bounds();
	scrollRect.Set(scrollRect.left+kTimeScalerWidth, scrollRect.bottom-kScrollHeight, scrollRect.right-kScrollWidth, scrollRect.bottom);
	fHScroll = new TCueSheetScrollBarH(this, scrollRect, NULL, 0, channelLength);
	AddChild(fHScroll);
	fHScroll->SetSteps(kTickSpacing, kTickSpacing*4);

	// Vertical
	scrollRect = Bounds();
	scrollRect.Set(scrollRect.right-kScrollWidth, scrollRect.top + (fTimeline->Frame().bottom+1), scrollRect.right, scrollRect.bottom-kScrollHeight);
	fVScroll = new TCueSheetScrollBarV(this, scrollRect, fCueSheetView, 0, channelLength);
	AddChild(fVScroll);
	fVScroll->SetSteps(kTickSpacing, kTickSpacing*4);

	// Create TimeScaler
	BRect scalerRect(0, Bounds().bottom-14,kTimeScalerWidth, Bounds().bottom);
	fTimeScaler = new TTimeScalerView(scalerRect, fCueSheetView);
	AddChild(fTimeScaler);

	// Limit the window size
	SetSizeLimits( 280, 1500, 280, 1500);

	// Add CueSheetView to frame
	AddChild(fCueSheetView);

	// Adjust the scroll bars
	AdjustScrollBars();

	// Add ourself to cue sheet list
	static_cast<MuseumApp*>(be_app)->GetCueSheetList()->AddItem(this);

	// Create the video engine
	fVideoEngine = new TVideoEngine(fCueSheetView);
	ASSERT(fVideoEngine);

	//	Create audio engine
	fAudioEngine = new TAudioEngine();

	// Set Pulse rate for views that need it
	SetPulseRate(5000);
}
コード例 #8
0
ファイル: TExportZone.cpp プロジェクト: ModeenF/UltraDV
void TExportZone::TrackZone(BPoint mousePt)
{		
	//	Set up variables	
	const float width 	= m_ExportChannel.Width();	
	const int32 delta 	= mousePt.x - m_ExportChannel.left;			
	
	//	Save mousePt
	BPoint oldPt = mousePt;

	// Check to see if button is down
	uint32 	buttons = 0;
	GetMouse(&mousePt, &buttons, true);	
	
	//	Track while mouse is down
	while(buttons)
	{						
		if (mousePt.x != oldPt.x)		
		{													
			// Save oldRect for redraw														
			BRect oldRect = m_ExportChannel;
			oldRect.left  -= kExportSliderWidth;
			oldRect.right += kExportSliderWidth;
			
			//	Update m_ExportChannel
			m_ExportChannel.left  += mousePt.x - oldPt.x;
			m_ExportChannel.right = m_ExportChannel.left + width;
			
			//	Correct left side bounds violation
			if ( m_ExportChannel.left - kExportSliderWidth < 0)
			{
				m_ExportChannel.left = 0 + kExportSliderWidth;
				m_ExportChannel.right = m_ExportChannel.left + width;
			}

			//	Correct right side bounds violation
			uint32 outPixels = TimeToPixels( Duration() - StartTime(), GetCurrentTimeFormat(), GetCurrentResolution());
			if ( m_ExportChannel.right + kExportSliderWidth > outPixels)
			{
				m_ExportChannel.right = outPixels - kExportSliderWidth;
				m_ExportChannel.left  = m_ExportChannel.right - width;
			}
			
			//	Update m_InRect and m_InRect
			m_InRect.left 	= m_ExportChannel.left - kExportSliderWidth;
			m_InRect.right 	= m_InRect.left + kExportSliderWidth;
		
			m_OutRect.left 	 = m_ExportChannel.right;
			m_OutRect.right	 = m_OutRect.left + kExportSliderWidth;									
													
			//	Update CueSheet variables
			uint32 newInTime  = StartTime() + PixelsToTime(m_InRect.left, GetCurrentTimeFormat(), GetCurrentResolution());
			uint32 newOutTime = StartTime() + PixelsToTime(m_OutRect.right, GetCurrentTimeFormat(), GetCurrentResolution());			
			m_CueSheetWindow->GetCueSheetView()->SetExportStartTime(newInTime);
			m_CueSheetWindow->GetCueSheetView()->SetExportStopTime(newOutTime);
		
			//	Calculate updateRect
			BRect updateRect = oldRect;
			
			//	Did we move forward
			if (updateRect.left < m_InRect.left)
			{
				updateRect.right = m_OutRect.right;
			}
			//	We moved back
			else
			{
				updateRect.left = m_InRect.left;	
			}
			
			//	Force redraw
			if (oldRect != updateRect)
				Invalidate(updateRect);
			
			//	Save point for future compare
			oldPt = mousePt;
			
			//	Update text items
			m_CueSheetWindow->GetExportTimeView()->DrawInText();
			m_CueSheetWindow->GetExportTimeView()->DrawOutText();
		}
						
		// Get new mouse location and button state
		GetMouse(&mousePt, &buttons, true);
		
		//
		//	Clip mouse
		
		// Constrain mouse x to the m_ExportZone
		if (mousePt.x < 0)
			mousePt.x = 0;
				
		//if (mousePt.x >= m_ExportZone.right)
		//	mousePt.x = m_ExportZone.right - (kExportSliderWidth/2);

	}
}
コード例 #9
0
ファイル: TMovieCue.cpp プロジェクト: ModeenF/UltraDV
void TMovieCue::Init()
{				
	bool retVal;
				
	//	Set up RIFFReader
	m_Reader = new TRIFFReader(m_File);
	
	//	Create audio and video codec
	retVal = InitCodecs();
	
	//	Init current frames
	m_CurrentVideoFrame = 0;
	m_CurrentAudioFrame = 0;
	
	//	Get AVIHeader
	AVIHeader *header = m_Reader->GetAVIHeader();
	
	//	Create offscreen
	BRect movieRect( 0, 0, header->Width-1, header->Height-1); 
	m_Bitmap = new BBitmap(movieRect, B_RGB32);
					
	// Default initialization
	TVisualCue::Init();

	// Set up area rectangles	
	m_CuePosition->Outline(movieRect);

	// Editor is closed
	m_EditorOpen = false;
	
	// Set up default settings	
	m_IsLocked 			= false;	
	m_IsSelected 		= false;	
	m_LowColor 			= kWhite;	
	m_HighColor 		= kBlack;	
	m_IsPrepared 		= false;
	m_IsPlaying 		= false;	
	m_IsVisible			= true;	
	m_HasDuration 		= true;					
	m_CanLoop			= true;
	m_CanStretch		= true;		
	m_CanEnvelope		= true;
	m_HasEditor 		= true;		
	m_CanWindow			= true;
	m_CanTransition		= true;
	m_CanPath			= true;
				
	//	Calculate duration in milliseconds
	m_MSecsPerFrame = header->TimeBetweenFrames / 1000;
	m_Duration 	    = header->TotalNumberOfFrames * m_MSecsPerFrame;

		
	// Add the cue to the cue channel
	if ( m_Channel->CanInsertCue(this, m_InsertTime, true))
	{
		m_Channel->InsertCue(this, m_InsertTime);		
		Select();								
				
		// We are now fully instantiated
		m_IsInstantiated = true;
	}
	
	// Adjust cue length based on duration
	ResizeTo( TimeToPixels(m_Duration, GetCurrentTimeFormat(), GetCurrentResolution()), Bounds().Height());		
}