yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
panel_registration.h File Reference
Include dependency graph for panel_registration.h:

Go to the source code of this file.

Namespaces

namespace  yaze
 
namespace  yaze::editor
 Editors are the view controllers for the application.
 

Macros

#define REGISTER_PANEL(PanelClass)
 Auto-registration macro for panels with default constructors.
 
#define REGISTER_PANEL_FACTORY(PanelClass, FactoryFunc)
 Registration macro for panels requiring custom factory logic.
 

Macro Definition Documentation

◆ REGISTER_PANEL

#define REGISTER_PANEL ( PanelClass)
Value:
namespace { \
struct PanelRegistrar_##PanelClass { \
PanelRegistrar_##PanelClass() { \
::yaze::editor::ContentRegistry::Panels::add<PanelClass>(); \
} \
}; \
[[maybe_unused]] static PanelRegistrar_##PanelClass \
s_panel_registrar_##PanelClass; \
}

Auto-registration macro for panels with default constructors.

Use this macro at file scope (after the class definition) to automatically register a panel type with ContentRegistry. The panel will be instantiated when ContentRegistry::Panels::CreateAll() is called.

Requirements:

  • Panel class must have a default constructor
  • Panel class must inherit from EditorPanel

Usage:

// In my_panel.h or my_panel.cc (after class definition)
class MyPanel : public EditorPanel {
public:
MyPanel() = default;
// ... implementation
};
REGISTER_PANEL(MyPanel);
#define REGISTER_PANEL(PanelClass)
Auto-registration macro for panels with default constructors.

The panel can then access shared resources via ContentRegistry::Context:

void MyPanel::Draw(bool* p_open) {
auto* rom = ContentRegistry::Context::rom();
auto* editor = ContentRegistry::Context::current_editor();
// ...
}

Definition at line 39 of file panel_registration.h.

◆ REGISTER_PANEL_FACTORY

#define REGISTER_PANEL_FACTORY ( PanelClass,
FactoryFunc )
Value:
namespace { \
struct PanelRegistrar_##PanelClass { \
PanelRegistrar_##PanelClass() { \
::yaze::editor::ContentRegistry::Panels::RegisterFactory( \
FactoryFunc); \
} \
}; \
[[maybe_unused]] static PanelRegistrar_##PanelClass \
s_panel_registrar_##PanelClass; \
}

Registration macro for panels requiring custom factory logic.

Use this when a panel needs constructor arguments or conditional creation. The factory function receives no arguments and should return a unique_ptr to the panel, or nullptr to skip creation.

Usage:

REGISTER_PANEL_FACTORY(MyPanel, []() -> std::unique_ptr<EditorPanel> {
auto* editor = ContentRegistry::Context::current_editor();
if (!editor) return nullptr;
return std::make_unique<MyPanel>(editor);
});
#define REGISTER_PANEL_FACTORY(PanelClass, FactoryFunc)
Registration macro for panels requiring custom factory logic.

Definition at line 66 of file panel_registration.h.