Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
DekiEditor::CustomEditor Class Referenceabstract

Custom editor for a specific component type. More...

#include <CustomEditor.h>

Inherits DekiEditor::EditorExtension.

Public Member Functions

virtual ~CustomEditor ()=default
EditorType GetEditorType () const override
const char * GetName () const override
virtual const char * GetComponentName () const =0
 Get the name of the component this editor handles.
virtual bool WantsInspectorOverride (DekiComponent *comp)
 Check if this editor wants to override the inspector.
virtual void OnInspectorGUI (DekiComponent *comp)
 Draw custom inspector GUI.
virtual void OnEditorUpdate (DekiComponent *comp)
 Called every frame before rendering for all components with editors.
virtual bool GetDisplaySize (DekiComponent *comp, float &outWidth, float &outHeight)
 Get display size for the component.
virtual bool HitTest (DekiComponent *comp, float localX, float localY, float width, float height)
 Hit test a point against the component.
virtual std::string GetTextureAssetGuid (DekiComponent *comp)
 Get the texture asset GUID for this component (if any).
virtual void GetResizeTarget (DekiComponent *comp, int32_t **outWidth, int32_t **outHeight)
 Get resize target pointers.
virtual void OnDrawGizmos (DekiComponent *comp)
virtual void OnDrawGizmosSelected (DekiComponent *comp)
Public Member Functions inherited from DekiEditor::EditorExtension
virtual ~EditorExtension ()=default

Detailed Description

Custom editor for a specific component type.

Provides inspector customization and display size info for components. Similar to Unity's CustomEditor attribute.

Inherits from EditorExtension for registration with REGISTER_EDITOR macro.

Usage:

class SpriteCustomEditor : public CustomEditor
{
public:
const char* GetComponentName() const override { return "SpriteComponent"; }
bool GetDisplaySize(DekiComponent* comp, float& outWidth, float& outHeight) override
{
auto* sprite = static_cast<SpriteComponent*>(comp);
outWidth = sprite->width;
outHeight = sprite->height;
return true;
}
};
REGISTER_EDITOR(SpriteCustomEditor)
#define REGISTER_EDITOR(EditorClass)
Macro for auto-registering editor extensions.
Definition EditorRegistry.h:133
Base class for all components (data-only).
Definition DekiComponent.h:51
Custom editor for a specific component type.
Definition CustomEditor.h:47
virtual bool GetDisplaySize(DekiComponent *comp, float &outWidth, float &outHeight)
Get display size for the component.
Definition CustomEditor.h:116
virtual const char * GetComponentName() const =0
Get the name of the component this editor handles.

Constructor & Destructor Documentation

◆ ~CustomEditor()

virtual DekiEditor::CustomEditor::~CustomEditor ( )
virtualdefault

Member Function Documentation

◆ GetEditorType()

EditorType DekiEditor::CustomEditor::GetEditorType ( ) const
inlineoverridevirtual

◆ GetName()

const char * DekiEditor::CustomEditor::GetName ( ) const
inlineoverridevirtual

◆ GetComponentName()

virtual const char * DekiEditor::CustomEditor::GetComponentName ( ) const
pure virtual

Get the name of the component this editor handles.

Returns
Component type name (e.g., "SpriteComponent")

◆ WantsInspectorOverride()

virtual bool DekiEditor::CustomEditor::WantsInspectorOverride ( DekiComponent * comp)
inlinevirtual

Check if this editor wants to override the inspector.

Parameters
compThe component being inspected
Returns
True to call OnInspectorGUI instead of default property editor

◆ OnInspectorGUI()

virtual void DekiEditor::CustomEditor::OnInspectorGUI ( DekiComponent * comp)
inlinevirtual

Draw custom inspector GUI.

Parameters
compThe component being inspected

Only called if WantsInspectorOverride() returns true.

Use EditorUI::Get() to access:

  • DrawDefaultInspector() - draw all properties
  • PropertyField(name) - draw specific property
  • PropertyField(offset) - draw property by offset

◆ OnEditorUpdate()

virtual void DekiEditor::CustomEditor::OnEditorUpdate ( DekiComponent * comp)
inlinevirtual

Called every frame before rendering for all components with editors.

Parameters
compThe component

Use this for lazy sync or dirty-checking that needs to run regardless of whether the object is selected.

◆ GetDisplaySize()

virtual bool DekiEditor::CustomEditor::GetDisplaySize ( DekiComponent * comp,
float & outWidth,
float & outHeight )
inlinevirtual

Get display size for the component.

Parameters
compThe component
outWidthOutput width
outHeightOutput height
Returns
True if component has a display size

◆ HitTest()

virtual bool DekiEditor::CustomEditor::HitTest ( DekiComponent * comp,
float localX,
float localY,
float width,
float height )
inlinevirtual

Hit test a point against the component.

Parameters
compThe component
localXLocal X coordinate (relative to object center)
localYLocal Y coordinate (relative to object center)
widthDisplay width
heightDisplay height
Returns
True if point is inside component bounds

◆ GetTextureAssetGuid()

virtual std::string DekiEditor::CustomEditor::GetTextureAssetGuid ( DekiComponent * comp)
inlinevirtual

Get the texture asset GUID for this component (if any).

Parameters
compThe component
Returns
Asset GUID or empty string

◆ GetResizeTarget()

virtual void DekiEditor::CustomEditor::GetResizeTarget ( DekiComponent * comp,
int32_t ** outWidth,
int32_t ** outHeight )
inlinevirtual

Get resize target pointers.

Parameters
compThe component
outWidthOutput pointer to width field
outHeightOutput pointer to height field

◆ OnDrawGizmos()

virtual void DekiEditor::CustomEditor::OnDrawGizmos ( DekiComponent * comp)
inlinevirtual

◆ OnDrawGizmosSelected()

virtual void DekiEditor::CustomEditor::OnDrawGizmosSelected ( DekiComponent * comp)
inlinevirtual

The documentation for this class was generated from the following file: