public void DrawProjectAudioTimeline( Graphics g, int Width, int Height, VidkaProj proj, ProjectDimensions dimdim, VidkaClipAudio currentAudioClip, EditorDraggy draggy) { // draw video events long curFrame = 0; int y1 = dimdim.getY_audio1(Height); int y2 = dimdim.getY_audio2(Height); int cliph = y2 - y1; foreach (var aclip in proj.ClipsAudio) { if (dimdim.isEvenOnTheScreen(curFrame, curFrame + aclip.LengthFrameCalc, Width)) { int x1 = dimdim.convert_Frame2ScreenX(curFrame); int x2 = dimdim.convert_Frame2ScreenX(curFrame + aclip.LengthFrameCalc); int clipw = x2 - x1; // active video clip deserves a special outline //if (aclip == currentAudioClip) // g.FillRectangle(brushActive, x1, y1, clipw, clipvh); //else // g.FillRectangle(brushWhite, x1, y1, clipw, clipvh); throw new NotImplementedException("DrawWaveform that takes Audio clip!!!"); //DrawWaveform(g, proj, aclip, x1, y1, clipw, cliph, // proj.FrameToSec(aclip.FrameStart), proj.FrameToSec(aclip.FrameEnd)); // outline rect g.DrawRectangle(penDefault, x1, y1, clipw, cliph); } curFrame += aclip.LengthFrameCalc; } if (draggy.Mode == EditorDraggyMode.AudioTimeline) { var draggyX = draggy.MouseX - draggy.MouseXOffset; var draggyW = dimdim.convert_FrameToAbsX(draggy.FrameLength); // hacky, i know g.DrawRectangle(penBorderDrag, draggyX, y1, draggyW, cliph); } }
public void DrawProjectVideoTimeline( Graphics g, int Width, int Height, VidkaProj proj, VidkaFileMapping projMapping, ProjectDimensions dimdim, VidkaClipVideo currentVideoClip, EditorDraggy draggy) { // draw video events long curFrame = 0; int y1 = dimdim.getY_main1(Height); int y2 = dimdim.getY_main2(Height); int yaudio = dimdim.getY_main_half(Height); int cliph = y2 - y1; // clip height (video and audio) int clipvh = yaudio - y1; // clip (only video) height (just the video part, no audio!) int index = 0; int draggyVideoShoveIndex = dimdim.GetVideoClipDraggyShoveIndex(draggy); foreach (var vclip in proj.ClipsVideo) { if (dimdim.isEvenOnTheScreen(curFrame, curFrame + vclip.LengthFrameCalc, Width)) { if (draggy.Mode == EditorDraggyMode.VideoTimeline && draggyVideoShoveIndex == index) { drawDraggyVideo(g, curFrame, y1, cliph, clipvh, draggy, dimdim); curFrame += draggy.FrameLength; } if (draggy.VideoClip != vclip) { var brush = brushWhite; if (vclip == currentVideoClip && vclip.IsLocked) { brush = brushLockedActiveClip; } else if (vclip == currentVideoClip) { brush = brushActive; } else if (vclip.IsLocked) { brush = brushLockedClip; } drawVideoClip(g, vclip, curFrame, y1, cliph, clipvh, brush, proj, projMapping, dimdim ); } } index++; if (draggy.VideoClip != vclip) { curFrame += vclip.LengthFrameCalc; } } if (draggy.Mode == EditorDraggyMode.VideoTimeline && draggyVideoShoveIndex == index) { drawDraggyVideo(g, curFrame, y1, cliph, clipvh, draggy, dimdim); } }
private void drawDraggyVideo(Graphics g, long curFrame, int y1, int cliph, int clipvh, EditorDraggy draggy, ProjectDimensions dimdim) { var draggyX = dimdim.convert_Frame2ScreenX(curFrame); var draggyW = dimdim.convert_FrameToAbsX(draggy.FrameLength); // hacky, i know if (draggy.VideoClip != null) { g.FillRectangle(brushWhite, draggyX, y1, draggyW, cliph); g.FillRectangle(brushActive, draggyX, y1, draggyW, clipvh); } g.DrawRectangle(penBorderDrag, draggyX, y1, draggyW, cliph); g.DrawString(draggy.Text, fontDefault, brushDefault, draggyX + 5, y1 + 5); // debug rect //g.DrawRectangle(penDefault, draggy.MouseX-draggy.MouseXOffset, y1-2, draggyW, cliph+5); }
/// <summary> /// Returns index of the clip before which the draggy should be inserted had it been dropped /// </summary> public int GetVideoClipDraggyShoveIndex(EditorDraggy draggy) { if (draggy.Mode != EditorDraggyMode.VideoTimeline) return -1; //long draggyFrameLeft = convert_ScreenX2Frame(draggy.MouseX - draggy.MouseXOffset); long draggyFrameLeft = convert_ScreenX2Frame(draggy.MouseX); long totalFrames = 0; int index = 0; foreach (var clip in proj.ClipsVideo) { if (totalFrames + clip.LengthFrameCalc / 2 >= draggyFrameLeft) return index; totalFrames += clip.LengthFrameCalc; index++; } return index; }