Add OpenGL spectrum renderer

This commit is contained in:
2026-05-25 20:16:37 +03:00
parent 16c5f6d428
commit 5090838563
7 changed files with 921 additions and 35 deletions
+41
View File
@@ -43,6 +43,7 @@ type
constructor Create(AOwner: TComponent); override;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
procedure DrawOverlay(Target: TBitmap; C: TCanvas; W, H: Integer);
procedure DrawOverlayBitmap(Target: TBitmap; W, H: Integer);
function HandleMouseMove(X, Y: Integer): Boolean;
function HandleMouseDown(Button: TMouseButton; X, Y: Integer): Boolean;
function HandleMouseLeave: Boolean;
@@ -242,6 +243,46 @@ begin
DrawSelf(Target, C, FLeft, FTop, Min(FWidth, W - FLeft), Min(FHeight, H - FTop));
end;
procedure TSampleRateOverlay.DrawOverlayBitmap(Target: TBitmap; W, H: Integer);
var
HitTarget: TBitmap;
I, ContentW: Integer;
begin
if (Target = nil) or (W <= 0) or (H <= 0) then Exit;
Target.PixelFormat := pf32bit;
Target.SetSize(8, 8);
Target.Canvas.Font.Name := 'Courier New';
Target.Canvas.Font.Size := 7;
Target.Canvas.Font.Style := [];
ContentW := PAD_X + HIDE_W + BTN_GAP;
for I := 0 to High(SPAN_NAMES) do
begin
Inc(ContentW, SpanBtnWidth(SPAN_NAMES[I], Target.Canvas));
if I < High(SPAN_NAMES) then Inc(ContentW, BTN_GAP);
end;
Inc(ContentW, PAD_X);
ContentW := Min(ContentW, W);
Target.SetSize(ContentW, H);
Target.Canvas.Brush.Color := TColor($00141414);
Target.Canvas.Brush.Style := bsSolid;
Target.Canvas.Pen.Style := psClear;
Target.Canvas.FillRect(Rect(0, 0, ContentW, H));
DrawSelf(Target, Target.Canvas, 0, 0, ContentW, H);
HitTarget := TBitmap.Create;
try
HitTarget.PixelFormat := pf32bit;
HitTarget.SetSize(Max(1, FLeft + ContentW), Max(1, FTop + H));
HitTarget.Canvas.Brush.Color := TColor($00141414);
HitTarget.Canvas.FillRect(Rect(0, 0, HitTarget.Width, HitTarget.Height));
DrawSelf(HitTarget, HitTarget.Canvas, FLeft, FTop, ContentW, H);
finally
HitTarget.Free;
end;
end;
function TSampleRateOverlay.HandleMouseMove(X, Y: Integer): Boolean;
var
I, OldHot: Integer;