Files
UnrealEngineUWP/Engine/Source/Editor/PropertyEditor/Private/ItemPropertyNode.h
jared cotton 6d13f63c39 UE-191200 - "Add UE support for [at]editable fields of optional types"
Add's support for `[at]editable` on optionals:

`FOptionalProperty` changes:
- Added custom `__INIT__` logic for `FOptionalProperty::ExportText` which previously could output no text as the optional value was initialized but returned an empty string as its export text (ie: empty arrays, maps, sets, etc). This caused the future text imports to be incorrect.

`FPropertyNode` changes:
- Added `OptionalValueNode` as private member similar in idea to existing `PropertyKeyNode`. It stores the generated `FPropertyNode` for a FOptionalValue's Value when it is set.
- Added helper function `GetOrCreateOptionalValueNode` which either returns the existing `OptionalValueNode` OR creates one if appropriate.
    - Note: This is where we bind a lambda to our Optional's Value FPropertyNode's `RebuildChildren` event which is how we update/rebuild when needed. In places where we would update/rebuild we instead call our Value to do so instead if set and then update after that has been done via this callback.

Added new widget `SPropertyEditorOptional`
- This either:
    - shows a dropdown of "Set all" or "Unset all" if we have multiple values selected
    - generates the editor for whatever our set value is if we have a single value (See `GetSingleReadAddress`)
    - shows a 'set value' button if we are not set

#JIRA UE-191200
#rb karen.jirak
#rb kurtis.schmidt

[CL 28253719 by jared cotton in ue5-main branch]
2023-09-26 18:57:13 -04:00

79 lines
2.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "PropertyNode.h"
class FItemPropertyNode : public FPropertyNode
{
public:
FItemPropertyNode();
virtual ~FItemPropertyNode();
virtual uint8* GetValueBaseAddress(uint8* StartAddress, bool bIsSparseData, bool bIsStruct) const override;
virtual uint8* GetValueAddress(uint8* StartAddress, bool bIsSparseData, bool bIsStruct) const override;
/**
* Overridden function to get the derived object node
*/
virtual FItemPropertyNode* AsItemPropertyNode() override { return this; }
virtual const FItemPropertyNode* AsItemPropertyNode() const override { return this; }
/** Display name override to use instead of the property name */
void SetDisplayNameOverride( const FText& InDisplayNameOverride ) override;
/**
* @return true if the property is mark as a favorite
*/
virtual void SetFavorite(bool FavoriteValue) override;
/**
* @return true if the property is mark as a favorite
*/
virtual bool IsFavorite() const override;
/**
* @return The formatted display name for the property in this node
*/
virtual FText GetDisplayName() const override;
/**
* Sets the tooltip override to use instead of the property tooltip
*/
virtual void SetToolTipOverride( const FText& InToolTipOverride ) override;
/**
* @return The tooltip for the property in this node
*/
virtual FText GetToolTipText() const override;
/**
* If this is node contains a FOptionalProperty, get its Value FPropertyNode node if set (may create the node if necessary).
*/
virtual TSharedPtr<FPropertyNode>& GetOrCreateOptionalValueNode() override;
protected:
/**
* Overridden function for special setup
*/
virtual void InitExpansionFlags() override;
/**
* Overridden function for Creating Child Nodes
*/
virtual void InitChildNodes() override;
private:
/** Display name override to use instead of the property name */
FText DisplayNameOverride;
/** Tooltip override to use instead of the property tooltip */
FText ToolTipOverride;
/**
* Option to know if we can display the favorite icon in the property editor
*/
bool bCanDisplayFavorite;
};