Plasma Engine  2.0
Loading...
Searching...
No Matches
DefaultState.h
1#pragma once
2
3#include <GuiFoundation/GuiFoundationDLL.h>
4
5#include <Foundation/Basics.h>
6#include <Foundation/Serialization/AbstractObjectGraph.h>
7#include <Foundation/Types/SharedPtr.h>
8#include <Foundation/Types/Status.h>
9#include <GuiFoundation/PropertyGrid/Declarations.h>
10
15
17class PL_GUIFOUNDATION_DLL plDefaultState
18{
19public:
26
28 static void RegisterDefaultStateProvider(CreateStateProviderFunc func);
30 static void UnregisterDefaultStateProvider(CreateStateProviderFunc func);
31
32private:
33 friend class plDefaultObjectState;
34 friend class plDefaultContainerState;
36};
37
41class PL_GUIFOUNDATION_DLL plDefaultObjectState
42{
43 PL_DISALLOW_COPY_AND_ASSIGN(plDefaultObjectState);
44
45public:
50
52 plColorGammaUB GetBackgroundColor() const;
54 plString GetStateProviderName() const;
55
56 bool IsDefaultValue(const char* szProperty) const;
57 bool IsDefaultValue(const plAbstractProperty* pProp) const;
58 plStatus RevertProperty(const char* szProperty);
59 plStatus RevertProperty(const plAbstractProperty* pProp);
60 plStatus RevertObject();
61 plVariant GetDefaultValue(const char* szProperty, plUInt32 uiSelectionIndex = 0) const;
62 plVariant GetDefaultValue(const plAbstractProperty* pProp, plUInt32 uiSelectionIndex = 0) const;
63
64
65private:
66 plObjectAccessorBase* m_pAccessor = nullptr;
69};
70
74class PL_GUIFOUNDATION_DLL plDefaultContainerState
75{
76 PL_DISALLOW_COPY_AND_ASSIGN(plDefaultContainerState);
77
78public:
83 plDefaultContainerState(plObjectAccessorBase* pAccessor, const plArrayPtr<plPropertySelection> selection, const char* szProperty);
84
87 plColorGammaUB GetBackgroundColor() const;
90 plString GetStateProviderName() const;
91
92 bool IsDefaultElement(plVariant index) const;
93 bool IsDefaultContainer() const;
94 plStatus RevertElement(plVariant index);
95 plStatus RevertContainer();
96 plVariant GetDefaultElement(plVariant index, plUInt32 uiSelectionIndex = 0) const;
97 plVariant GetDefaultContainer(plUInt32 uiSelectionIndex = 0) const;
98
99private:
100 plObjectAccessorBase* m_pAccessor = nullptr;
101 const plAbstractProperty* m_pProp = nullptr;
104};
105
109class PL_GUIFOUNDATION_DLL plDefaultStateProvider : public plRefCounted
110{
111public:
116
126 virtual plInt32 GetRootDepth() const = 0;
127
130
132 virtual plString GetStateProviderName() const = 0;
133
142 virtual plVariant GetDefaultValue(SuperArray superPtr, plObjectAccessorBase* pAccessor, const plDocumentObject* pObject, const plAbstractProperty* pProp, plVariant index = plVariant()) = 0;
143
153
154public:
155 virtual bool IsDefaultValue(SuperArray superPtr, plObjectAccessorBase* pAccessor, const plDocumentObject* pObject, const plAbstractProperty* pProp, plVariant index = plVariant());
156 virtual plStatus RevertProperty(SuperArray superPtr, plObjectAccessorBase* pAccessor, const plDocumentObject* pObject, const plAbstractProperty* pProp, plVariant index = plVariant());
157 virtual plStatus RevertObjectContainer(SuperArray superPtr, plObjectAccessorBase* pAccessor, const plDocumentObject* pObject, const plAbstractProperty* pProp);
158
160 static bool DoesVariantMatchProperty(const plVariant& value, const plAbstractProperty* pProp, plVariant index = plVariant());
161};
This is the base interface for all properties in the reflection system. It provides enough informatio...
Definition AbstractProperty.h:150
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
A 8bit per channel unsigned normalized (values interpreted as 0-1) color storage format that represen...
Definition Color8UNorm.h:99
Object used to query and revert to the default state of all elements of a container of an object.
Definition DefaultState.h:75
Object used to query and revert to the default state of all properties of an object.
Definition DefaultState.h:42
Registry for all plDefaultStateProvider factory functions.
Definition DefaultState.h:18
Interface for querying and restoring the default state of objects and containers.
Definition DefaultState.h:110
virtual plString GetStateProviderName() const =0
Returns the name of this state provider. Can be used to check what the outer most provider is for GUI...
virtual plStatus CreateRevertContainerDiff(SuperArray superPtr, plObjectAccessorBase *pAccessor, const plDocumentObject *pObject, const plAbstractProperty *pProp, plDeque< plAbstractGraphDiffOperation > &out_diff)=0
Queries an array of diff operations that can be executed to revert the object container.
virtual plColorGammaUB GetBackgroundColor() const =0
Returns a color to be used in the property grid. Only the hue of the color is used....
virtual plInt32 GetRootDepth() const =0
Returns the root depth of this provider instance.
virtual plVariant GetDefaultValue(SuperArray superPtr, plObjectAccessorBase *pAccessor, const plDocumentObject *pObject, const plAbstractProperty *pProp, plVariant index=plVariant())=0
Returns the default value of an object's property at a given index.
Definition Deque.h:270
Definition DocumentObjectBase.h:11
Definition DynamicArray.h:81
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Definition ObjectAccessorBase.h:8
Base class for reference counted objects.
Definition RefCounted.h:52
A Shared ptr manages a shared object and destroys that object when no one references it anymore....
Definition SharedPtr.h:10
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
An plResult with an additional message for the reason of failure.
Definition Status.h:12