Skip to content

Instantly share code, notes, and snippets.

@johnfredcee
Last active October 26, 2023 10:35
Show Gist options
  • Save johnfredcee/b3166d9eabaa70ba3871547a27a8ea85 to your computer and use it in GitHub Desktop.
Save johnfredcee/b3166d9eabaa70ba3871547a27a8ea85 to your computer and use it in GitHub Desktop.
UMG Polyline Editor Widget Header
// Copyright (C) John Connors 2023
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#pragma once
#include "CoreMinimal.h"
#include "Delegates/Delegate.h"
#include "Blueprint/UserWidget.h"
#include "SPolylineEditor.h"
#include "PolylineEditorWidget.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnPointsModified);
/**
*
*/
UCLASS(BlueprintType)
class SANDBOXTOOLS_API UPolylineEditorWidget : public UWidget
{
GENERATED_BODY()
public:
UPolylineEditorWidget(const FObjectInitializer& ObjectInitializer);
virtual void ReleaseSlateResources(bool bReleaseChildren) override;
virtual const FText GetPaletteCategory() override;
virtual void SynchronizeProperties() override;
protected:
virtual TSharedRef<SWidget> RebuildWidget() override;
TSharedPtr<SPolylineEditor> PolylineEditor;
void HandlePointAdded();
void HandlePointRemoved();
void HandlePointMoved();
UPROPERTY(BlueprintAssignable)
FOnPointsModified PointsModified;
UFUNCTION(BlueprintCallable, Category = "Geometry")
void ComputeAllPoints(TArray<FVector2f>& AllPoints);
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Appearance")
FSlateBrush Brush;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Geometry")
TArray<FVector2f> Points;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Geometry")
float LineThickness;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Geometry")
float XRange;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Geometry")
float YRange;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Geometry")
bool bClosedLine;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Geometry")
bool bMirror;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment