DEKI/ENGINE docs
Deki 0.19.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
DekiEditor::CustomEditor Class Referenceabstract

Custom editor for one component type, like Unity's CustomEditor: it can replace the component's Inspector UI and tell the scene view its size. More...

#include <C:/Users/kirby/Documents/Github/deki/deki-editor/deki-editor/include/deki-editor/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
 The component type this editor handles, e.g. "SpriteComponent".
virtual bool WantsInspectorOverride (Deki::Component *comp)
 Return true to have OnInspectorGUI draw this component instead of the default property editor.
virtual void OnInspectorGUI (Deki::Component *comp)
 Draws the Inspector for the component.
virtual void OnEditorUpdate (Deki::Component *comp)
 Called every frame before rendering, for every component that has an editor, selected or not.
virtual bool GetDisplaySize (Deki::Component *comp, float &outWidth, float &outHeight)
 The component's size in the scene view. Returns false when it has none.
virtual bool HitTest (Deki::Component *comp, float localX, float localY, float width, float height)
 Whether a point hits the component.
virtual std::string GetTextureAssetGuid (Deki::Component *comp)
 The GUID of the texture the component shows, or "".
virtual void GetResizeTarget (Deki::Component *comp, int32_t **outWidth, int32_t **outHeight)
 Points outWidth/outHeight at the component's width and height fields, so the resize tool can edit them.
virtual void OnDrawGizmos (Deki::Component *comp)
virtual void OnDrawGizmosSelected (Deki::Component *comp)
Public Member Functions inherited from DekiEditor::EditorExtension
virtual ~EditorExtension ()=default

Detailed Description

Custom editor for one component type, like Unity's CustomEditor: it can replace the component's Inspector UI and tell the scene view its size.

Register it with REGISTER_EDITOR.

Usage: class SpriteCustomEditor : public CustomEditor { public: const char* GetComponentName() const override { return "SpriteComponent"; }

bool GetDisplaySize(Deki::Component* comp, float& outWidth, float& outHeight) override { auto* sprite = static_cast<SpriteComponent*>(comp); outWidth = sprite->width; outHeight = sprite->height; return true; } };

REGISTER_EDITOR(SpriteCustomEditor)

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

The component type this editor handles, e.g. "SpriteComponent".

◆ WantsInspectorOverride()

virtual bool DekiEditor::CustomEditor::WantsInspectorOverride ( Deki::Component * comp)
inlinevirtual

Return true to have OnInspectorGUI draw this component instead of the default property editor.

◆ OnInspectorGUI()

virtual void DekiEditor::CustomEditor::OnInspectorGUI ( Deki::Component * comp)
inlinevirtual

Draws the Inspector for the component.

Called only when WantsInspectorOverride() returns true.

EditorUI::Get() offers:

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

◆ OnEditorUpdate()

virtual void DekiEditor::CustomEditor::OnEditorUpdate ( Deki::Component * comp)
inlinevirtual

Called every frame before rendering, for every component that has an editor, selected or not.

Use it for lazy sync or dirty checks.

◆ GetDisplaySize()

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

The component's size in the scene view. Returns false when it has none.

◆ HitTest()

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

Whether a point hits the component.

localX/localY are relative to the object's center; width/height are its display size.

◆ GetTextureAssetGuid()

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

The GUID of the texture the component shows, or "".

◆ GetResizeTarget()

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

Points outWidth/outHeight at the component's width and height fields, so the resize tool can edit them.

Null when it has none.

◆ OnDrawGizmos()

virtual void DekiEditor::CustomEditor::OnDrawGizmos ( Deki::Component * comp)
inlinevirtual

◆ OnDrawGizmosSelected()

virtual void DekiEditor::CustomEditor::OnDrawGizmosSelected ( Deki::Component * comp)
inlinevirtual

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