42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "SLeafWidget.h"
|
|
|
|
class FPluginHost;
|
|
/**
|
|
*
|
|
*/
|
|
class ARONA_API SPianoKey : public SLeafWidget
|
|
{
|
|
public:
|
|
SLATE_BEGIN_ARGS(SPianoKey)
|
|
{
|
|
}
|
|
SLATE_ATTRIBUTE(float, KeyHeight)
|
|
SLATE_ATTRIBUTE(float, KeyWidth)
|
|
|
|
SLATE_END_ARGS()
|
|
|
|
/** Constructs this widget with InArgs */
|
|
void Construct(const FArguments& InArgs, FPluginHost* InPluginHost);
|
|
|
|
|
|
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
|
|
virtual FVector2D ComputeDesiredSize(float LayoutScaleMultiplier) const override;
|
|
|
|
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
|
virtual FReply OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
|
virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
|
private:
|
|
int32 HeightToNoteNumber(float Height) const;
|
|
float WidthToVelocity(float Width) const;
|
|
|
|
int32 LastNoteNumber = -1;
|
|
FPluginHost* PluginHost = nullptr;
|
|
TAttribute<float> KeyHeight; // 白键高度
|
|
TAttribute<float> KeyWidth;
|
|
};
|