protected override void OnRender(Direct2DGraphics g) { g.FillRectangle(0, 0, Width, Height, toolbarBrush); var pt = this.PointToClient(Cursor.Position); // Buttons foreach (var btn in buttons) { bool hover = btn.IsPointIn(pt.X, pt.Y); var bmp = btn.GetBitmap != null?btn.GetBitmap() : btn.Bmp; if (bmp == null) { bmp = btn.Bmp; } bool enabled = btn.Enabled != null?btn.Enabled() : true; g.DrawBitmap(bmp, btn.X, btn.Y, enabled ? (hover ? 0.75f : 1.0f) : 0.25f); } // Timecode int frame = App.CurrentFrame; int patternIdx = frame / App.Song.PatternLength; int noteIdx = frame % App.Song.PatternLength; g.FillAndDrawRectangleHalfPixel(TimecodePosX, 4, TimecodePosX + TimecodeSizeX, Height - 4, theme.DarkGreyFillBrush1, theme.BlackBrush); g.DrawText($"{patternIdx:D3}:{noteIdx:D3}", Theme.FontHuge, TimecodePosX + 30, 2, theme.LightGreyFillBrush1, TimecodeSizeX); // Tooltip if (!string.IsNullOrEmpty(tooltip)) { g.DrawText(tooltip, Theme.FontMediumRight, Width - 314, 12, theme.BlackBrush, 300); } }
protected override void OnRender(Direct2DGraphics g) { g.Clear(Theme.DarkGreyFillColor1); g.DrawLineHalfPixel(0, 0, 0, Height, theme.BlackBrush); int actualWidth = Width - ScrollBarSizeX; int y = -scrollY; foreach (var button in buttons) { var icon = bmpButtonIcons[(int)button.type]; g.PushTranslation(0, y); g.FillAndDrawRectangleHalfPixel(0, 0, actualWidth, ButtonSizeY, g.GetVerticalGradientBrush(button.GetColor(), ButtonSizeY, 0.8f), theme.BlackBrush); g.DrawText(button.GetText(App.Project), button.GetFont(selectedSong, selectedInstrument), icon == null ? 5 : 24, 5, theme.BlackBrush, actualWidth - 10); if (icon != null) { g.DrawBitmap(icon, 4, 4); } var subButtons = button.GetSubButtons(out var active); if (subButtons != null) { for (int i = 0, x = actualWidth - 20; i < subButtons.Length; i++, x -= 20) { g.DrawBitmap(bmpSubButtonIcons[(int)subButtons[i]], x, 4, active[i] ? 1.0f : 0.2f); } } g.PopTransform(); y += ButtonSizeY; } if (NeedsScrollBar) { int virtualSizeY = VirtualSizeY; int scrollBarSizeY = (int)Math.Round(Height * (Height / (float)virtualSizeY)); int scrollBarPosY = (int)Math.Round(Height * (scrollY / (float)virtualSizeY)); g.FillAndDrawRectangleHalfPixel(actualWidth, 0, Width - 1, Height, theme.DarkGreyFillBrush1, theme.BlackBrush); g.FillAndDrawRectangleHalfPixel(actualWidth, scrollBarPosY, Width - 1, scrollBarPosY + scrollBarSizeY, theme.LightGreyFillBrush1, theme.BlackBrush); } }
protected override void OnRender(Direct2DGraphics g) { g.Clear(Theme.DarkGreyFillColor1); g.DrawLineHalfPixel(0, 0, 0, Height, theme.BlackBrush); int actualWidth = Width - ScrollBarSizeX; int y = -scrollY; g.PushTranslation(0, y); g.FillAndDrawRectangleHalfPixel(0, 0, actualWidth, ButtonSizeY, g.GetVerticalGradientBrush(Theme.LightGreyFillColor2, ButtonSizeY, 0.8f), theme.BlackBrush); g.DrawText("Songs", Theme.FontMediumBoldCenter, 0, 5, theme.BlackBrush, actualWidth); g.DrawBitmap(bmpAdd, actualWidth - 20, 4); g.PopTransform(); y += ButtonSizeY; for (int i = 0; i < App.Project.Songs.Count; i++, y += ButtonSizeY) { var song = App.Project.Songs[i]; g.PushTranslation(0, y); g.FillAndDrawRectangleHalfPixel(0, 0, actualWidth, ButtonSizeY, g.GetVerticalGradientBrush(Direct2DGraphics.ToRawColor4(song.Color), ButtonSizeY, 0.8f), theme.BlackBrush); g.DrawText(song.Name, song == selectedSong ? Theme.FontMediumBold : Theme.FontMedium, 24, 5, theme.BlackBrush); g.DrawBitmap(bmpSong, 4, 4); //var rcVolume = GetVolumeRect(); //g.DrawBitmap(bmpVolume, rcVolume.X, rcVolume.Y, instrument.Envelopes[Envelope.Volume].Length > 0 ? 1.0f : 0.2f); g.PopTransform(); } g.PushTranslation(0, y); g.FillAndDrawRectangleHalfPixel(0, 0, actualWidth, ButtonSizeY, g.GetVerticalGradientBrush(Theme.LightGreyFillColor2, ButtonSizeY, 0.8f), theme.BlackBrush); g.DrawText("Instruments", Theme.FontMediumBoldCenter, 0, 5, theme.BlackBrush, actualWidth); g.DrawBitmap(bmpAdd, actualWidth - 20, 4); g.PopTransform(); y += ButtonSizeY; g.PushTranslation(0, y); g.FillAndDrawRectangleHalfPixel(0, 0, actualWidth, ButtonSizeY, g.GetVerticalGradientBrush(Theme.LightGreyFillColor1, ButtonSizeY, 0.8f), theme.BlackBrush); g.DrawText("DPCM Samples", SelectedInstrument == null ? Theme.FontMediumBold : Theme.FontMedium, 24, 5, theme.BlackBrush); g.DrawBitmap(bmpInstrument, 4, 4); g.DrawBitmap(bmpDPCM, actualWidth - 20, 4); g.PopTransform(); y += ButtonSizeY; for (int i = 0; i < App.Project.Instruments.Count; i++, y += ButtonSizeY) { var instrument = App.Project.Instruments[i]; g.PushTranslation(0, y); g.FillAndDrawRectangleHalfPixel(0, 0, actualWidth, ButtonSizeY, g.GetVerticalGradientBrush(instrument.Color, ButtonSizeY, 0.8f), theme.BlackBrush); g.DrawText(instrument.Name, instrument == SelectedInstrument ? Theme.FontMediumBold : Theme.FontMedium, 24, 5, theme.BlackBrush); var rcVolume = GetButtonRect(4); var rcPitch = GetButtonRect(3); var rcArpeggio = GetButtonRect(2); var rcDuty = GetButtonRect(1); g.DrawBitmap(bmpInstrument, 4, 4); g.DrawBitmap(bmpVolume, rcVolume.X, rcVolume.Y, instrument.Envelopes[Envelope.Volume].Length > 0 ? 1.0f : 0.2f); g.DrawBitmap(bmpPitch, rcPitch.X, rcPitch.Y, instrument.Envelopes[Envelope.Pitch].Length > 0 ? 1.0f : 0.2f); g.DrawBitmap(bmpArpeggio, rcArpeggio.X, rcArpeggio.Y, instrument.Envelopes[Envelope.Arpeggio].Length > 0 ? 1.0f : 0.2f); g.DrawBitmap(bmpDuty[instrument.DutyCycle], rcDuty.X, rcDuty.Y, 1.0f); g.PopTransform(); } if (NeedsScrollBar) { int virtualSizeY = VirtualSizeY; int scrollBarSizeY = (int)Math.Round(Height * (Height / (float)virtualSizeY)); int scrollBarPosY = (int)Math.Round(Height * (scrollY / (float)virtualSizeY)); g.FillAndDrawRectangleHalfPixel(actualWidth, 0, Width - 1, Height, theme.DarkGreyFillBrush1, theme.BlackBrush); g.FillAndDrawRectangleHalfPixel(actualWidth, scrollBarPosY, Width - 1, scrollBarPosY + scrollBarSizeY, theme.LightGreyFillBrush1, theme.BlackBrush); } }
protected override void OnRender(Direct2DGraphics g) { g.Clear(Theme.DarkGreyFillColor1); int patternSizeX = PatternSizeX; int minVisiblePattern = Math.Max((int)Math.Floor(scrollX / (float)patternSizeX), 0); int maxVisiblePattern = Math.Min((int)Math.Ceiling((scrollX + Width) / (float)patternSizeX), Song.Length); // Track name background g.FillRectangle(0, 0, TrackNameSizeX, Height, whiteKeyBrush); // Header g.DrawLineHalfPixel(0, 0, Width, 0, theme.BlackBrush); g.DrawLineHalfPixel(TrackNameSizeX - 1, 0, TrackNameSizeX - 1, HeaderSizeY, theme.DarkGreyLineBrush1); g.PushTranslation(TrackNameSizeX, 0); g.PushClipHalfPixel(0, 0, Width, Height); for (int i = minVisiblePattern, x = minVisiblePattern * patternSizeX - scrollX; i <= maxVisiblePattern; i++, x += patternSizeX) { if (i != 0) { g.DrawLineHalfPixel(x, 0, x, Height, theme.DarkGreyLineBrush1); } } for (int i = minVisiblePattern, x = minVisiblePattern * patternSizeX - scrollX; i < maxVisiblePattern; i++, x += patternSizeX) { g.PushTranslation(x, 0); g.DrawText(i.ToString(), Theme.FontMediumCenter, 0, 2, theme.LightGreyFillBrush1, patternSizeX); g.PopTransform(); } g.PopClip(); g.PopTransform(); g.PushTranslation(0, HeaderSizeY); // Icons for (int i = 0, y = 0; i < Song.Channels.Length; i++, y += TrackSizeY) { g.DrawBitmap(bmpTracks[(int)Song.Channels[i].Type], 4, y + 4, (App.ChannelMask & (1 << i)) != 0 ? 1.0f : 0.2f); } // Track names for (int i = 0, y = 0; i < Song.Channels.Length; i++, y += TrackSizeY) { g.DrawText(Song.Channels[i].Name, i == selectedChannel ? Theme.FontMediumBold : Theme.FontMedium, 24, y + 4, theme.BlackBrush); } // Ghost note icons for (int i = 0, y = 0; i < Song.Channels.Length; i++, y += TrackSizeY) { g.DrawBitmap(bmpGhostNote, TrackNameSizeX - 16, y + TrackSizeY - 15, (App.GhostChannelMask & (1 << i)) != 0 ? 1.0f : 0.2f); } // Vertical line seperating the track labels. g.DrawLineHalfPixel(TrackNameSizeX - 1, 0, TrackNameSizeX - 1, Height, theme.DarkGreyLineBrush1); // Grey background rectangles ever other pattern + vertical lines g.PushClipHalfPixel(TrackNameSizeX, 0, Width, Height); g.PushTranslation(TrackNameSizeX, 0); for (int i = minVisiblePattern, x = minVisiblePattern * patternSizeX - scrollX; i < maxVisiblePattern; i++, x += patternSizeX) { if ((i & 1) == 0) { g.FillRectangle(x, 0, x + patternSizeX, Height, theme.DarkGreyFillBrush2); } } for (int i = minVisiblePattern, x = minVisiblePattern * patternSizeX - scrollX; i <= maxVisiblePattern; i++, x += patternSizeX) { if (i != 0) { g.DrawLineHalfPixel(x, 0, x, Height, theme.DarkGreyLineBrush1); } } g.PopTransform(); g.PopClip(); // Horizontal lines for (int i = 0, y = 0; i < Song.Channels.Length; i++, y += TrackSizeY) { g.DrawLineHalfPixel(0, y, Width, y, theme.DarkGreyLineBrush1); } g.PushClipHalfPixel(TrackNameSizeX, 0, Width, Height); // Seek int xxx = ScaleForZoom(App.CurrentFrame) + TrackNameSizeX - scrollX; g.DrawLineHalfPixel(xxx, -HeaderSizeY, xxx, Height, playPositionBrush); // Patterns for (int t = 0, y = 0; t < Song.Channels.Length; t++, y += TrackSizeY) { for (int i = minVisiblePattern, x = minVisiblePattern * patternSizeX + TrackNameSizeX - scrollX; i < maxVisiblePattern; i++, x += patternSizeX) { var pattern = Song.Channels[t].PatternInstances[i]; if (pattern != null) { var bmp = GetPatternBitmapFromCache(pattern); g.PushTranslation(x, y); g.FillRectangle(1, 1, patternSizeX, PatternHeaderSizeY, g.GetVerticalGradientBrush(pattern.Color, PatternHeaderSizeY, 0.9f)); g.DrawLineHalfPixel(0, PatternHeaderSizeY, patternSizeX, PatternHeaderSizeY, theme.DarkGreyLineBrush1); if (IsPatternSelected(t, i)) { g.FillRectangle(1, 1 + PatternHeaderSizeY, PatternSizeX, PatternHeaderSizeY + bmp.Size.Height + 1, selectedPatternBrush); } g.DrawBitmap(bmp, 1, 1 + PatternHeaderSizeY, PatternSizeX - 1, bmp.Size.Height); g.PushClipHalfPixel(0, 0, PatternSizeX, Height); g.DrawText(pattern.Name, Theme.FontSmall, 2, 3, theme.BlackBrush); g.PopClip(); g.PopTransform(); } } } // Dragging selection if (isDraggingSelection) { var pt = this.PointToClient(Cursor.Position); //pt.X -= TrackNameSizeX; pt.Y -= HeaderSizeY; var drawX = pt.X - selectionDragAnchorX; var drawY = minSelectedChannelIdx * TrackSizeY; var sizeX = (maxSelectedPatternIdx - minSelectedPatternIdx + 1) * patternSizeX; var sizeY = (maxSelectedChannelIdx - minSelectedChannelIdx + 1) * TrackSizeY; g.FillRectangle(drawX, drawY, drawX + sizeX, drawY + sizeY, selectedPatternBrush); } g.PopClip(); g.PopTransform(); g.DrawLineHalfPixel(0, Height - 1, Width, Height - 1, theme.DarkGreyLineBrush1); }