Cogs.Core
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Cogs::Core::Editor Class Reference
Inheritance diagram for Cogs::Core::Editor:
Cogs::Core::IEditor

Public Member Functions

 Editor (Context *context)
 
void initialize () override
 
void cleanup () override
 
void show () override
 
void processShortcuts ()
 
void beginFrame () override
 
bool isActive () const override
 
EditorStategetState () override
 
void showText (const char *format,...) const
 Show the same type of label as ImGui::Text, but with the added ability to highlight and copy text. Max 255 characters.
 
bool showModel (ModelHandle &modelHandle)
 
bool showTexture (const StringView &header, TextureHandle &textureHandle) override
 
bool showMaterialInstance (FieldInfo &fieldInfo, MaterialInstanceHandle &materialInstanceHandle)
 
bool imageButton (Icon icon, int size, int padding)
 
void clear (bool interactive=true) override
 
void open (const StringView &path, bool openInRoot, bool synchronous) override
 Open file.
 
void save () override
 
void saveAs () override
 
void saveIncremental () override
 
void importStatic ()
 
void exportEntities (bool exportScene=false)
 
void cut () override
 
void copy () override
 
void paste () override
 
void invokeCommand (const StringView &key) override
 
void destroy () override
 
void destroyPermanently ()
 
void changeMode (EditingMode mode)
 
void focusSelected ()
 
void focusAll ()
 
bool focusBoundingBox (const Cogs::Geometry::DBoundingBox &boundingBox)
 
void setStatusbarText (const std::string &text, bool guiStatus)
 
void showHide (bool visible)
 Show or hide selected entity and all children.
 
void hideUnselected ()
 Make all non-selected entities invisible.
 
void showAll ()
 Make all entities visible.
 
void selectFurthestAway ()
 Search and select visible entity furthest away from selection. Ie.e. find outliers.
 
void invertVisibility ()
 
void selectAll ()
 
void selectOne (EntityId id)
 
void clearCommands ()
 
void onlineHelp (bool generalHelp)
 
void showLicenses ()
 
void showAbout ()
 
EditorCommanddoApply (std::unique_ptr< EditorCommand > &&newCommand)
 
template<typename Command , typename... Args>
Command * apply (Args... args)
 
template<typename Command , typename... Args>
Command * applySelected (Args... args)
 
void undo ()
 
void redo ()
 
virtual void initialize ()=0
 
virtual void cleanup ()=0
 
virtual void clear (bool interactive=true)=0
 
virtual void open (const StringView &path, bool openInRoot, bool synchronous)=0
 Open file.
 
virtual void save ()=0
 
virtual void saveAs ()=0
 
virtual void saveIncremental ()=0
 
virtual void exportScene (const StringView &path)=0
 
virtual void cut ()=0
 
virtual void copy ()=0
 
virtual void paste ()=0
 
virtual void invokeCommand (const StringView &key)=0
 
virtual void destroy ()=0
 
virtual bool isActive () const =0
 
virtual EntityIds getSelected () const =0
 
virtual void select (const EntityIds &ids, SelectMode mode=SelectMode::Exclusive)=0
 
virtual void beginFrame ()=0
 
virtual void show ()=0
 
virtual EditorStategetState ()=0
 
virtual bool showTexture (const StringView &header, TextureHandle &texture)=0
 
virtual struct EditorCommandcreateCommand (const StringView &key)=0
 
virtual void createEntity (const StringView &type, const StringView &name)=0
 

Static Public Member Functions

static void COGSCORE_EDITOR_API registerExtensionCommand (const StringView &key, CommandCreator creator)
 
static COGSCORE_EDITOR_API std::vector< ExtensionCommand > & getExtensionCommands ()
 
static void COGSCORE_EDITOR_API registerExtensionItem (const StringView &key, const StringView &name)
 
static COGSCORE_EDITOR_API std::vector< ExtensionItem > & getExtensionItems ()
 

Private Member Functions

void handleMouseEvent (const struct Cogs::Core::InputEvent &event)
 
void showEntities ()
 
void showEntityDetails (ComponentModel::Entity *entity)
 
void showGizmo ()
 
void selectLayer (ComponentModel::Entity *entity, StringView layer)
 
void setLayerVisibility (ComponentModel::Entity *entity, StringView layer, bool visible)
 
bool getLayerVisibility (const ComponentModel::Entity *entity, StringView layer)
 Returns true if any Node in layer is visible.
 
bool isStandardEntity (const Cogs::ComponentModel::Entity *entity) const
 
bool isUserRootEntity (const Cogs::ComponentModel::Entity *entity) const
 Checks if the entity is.
 
void openInternal (const StringView &path, bool openInRoot, bool synchronous, bool interactive)
 
const std::string & getStatusbarText () const
 
bool showingGuiStatusbarText () const
 
float getStatusbarHeight () const
 
float getToolbarHeight () const
 
float getSidebarWidth () const
 
float getInspectorWidth () const
 
float getMenuHeight () const
 
virtual void exportScene (const StringView &path) override
 
virtual EntityIds getSelected () const override
 
virtual void select (const EntityIds &ids, SelectMode mode=SelectMode::Exclusive) override
 
virtual EditorCommandcreateCommand (const StringView &key) override
 
virtual void createEntity (const StringView &type, const StringView &name) override
 

Private Attributes

Contextcontext
 
std::unique_ptr< struct EditorStatestate
 
ModalEditorCommandmodalCommand = nullptr
 
std::vector< std::unique_ptr< EditorCommand > > commands
 
size_t commandIndex = NoCommand
 
std::unique_ptr< class MaterialEditormaterialEditor
 
std::vector< Cogs::Core::WeakEntityPtrstandardEntities
 Set of entities created when the Editor loads.
 
int textElementId = 0
 
bool initialized = false
 
bool active = false
 
float minWidth = 50
 
float sidebarWidth = 200
 
float inspectorWidth = 250
 
float menuHeight = 20
 
float toolbarHeight = 40
 
glm::vec2 buttonSize = glm::vec2{ 24 }
 
float statusbarHeight = 20
 
bool showStatusbar = true
 
std::string statusbarText
 
bool guiStatusInStatusbar = true
 
bool showToolbar = true
 
bool showSidebar = true
 
bool showInspector = true
 
bool showMenu = true
 

Static Private Attributes

static constexpr size_t NoCommand = static_cast<size_t>(-1)
 

Detailed Description

Definition at line 76 of file Editor.h.

Constructor & Destructor Documentation

◆ Editor()

Cogs::Core::Editor::Editor ( Context context)
explicit

Definition at line 591 of file Editor.cpp.

Member Function Documentation

◆ apply()

template<typename Command , typename... Args>
Command * Cogs::Core::Editor::apply ( Args...  args)
inline

Definition at line 190 of file Editor.h.

◆ applySelected()

template<typename Command , typename... Args>
Command * Cogs::Core::Editor::applySelected ( Args...  args)
inline

Definition at line 198 of file Editor.h.

◆ beginFrame()

void Cogs::Core::Editor::beginFrame ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 1584 of file Editor.cpp.

◆ changeMode()

void Cogs::Core::Editor::changeMode ( EditingMode  mode)

Definition at line 2583 of file Editor.cpp.

◆ cleanup()

void Cogs::Core::Editor::cleanup ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 670 of file Editor.cpp.

◆ clear()

void Cogs::Core::Editor::clear ( bool  interactive = true)
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 2171 of file Editor.cpp.

◆ clearCommands()

void Cogs::Core::Editor::clearCommands ( )

Definition at line 2919 of file Editor.cpp.

◆ copy()

void Cogs::Core::Editor::copy ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 2534 of file Editor.cpp.

◆ createCommand()

Cogs::Core::EditorCommand * Cogs::Core::Editor::createCommand ( const StringView key)
overrideprivatevirtual

Implements Cogs::Core::IEditor.

Definition at line 2142 of file Editor.cpp.

◆ createEntity()

void Cogs::Core::Editor::createEntity ( const StringView type,
const StringView name 
)
overrideprivatevirtual

Implements Cogs::Core::IEditor.

Definition at line 2147 of file Editor.cpp.

◆ cut()

void Cogs::Core::Editor::cut ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 2525 of file Editor.cpp.

◆ destroy()

void Cogs::Core::Editor::destroy ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 2569 of file Editor.cpp.

◆ destroyPermanently()

void Cogs::Core::Editor::destroyPermanently ( )

Definition at line 2576 of file Editor.cpp.

◆ doApply()

EditorCommand * Cogs::Core::Editor::doApply ( std::unique_ptr< EditorCommand > &&  newCommand)
inline

Definition at line 168 of file Editor.h.

◆ exportEntities()

void Cogs::Core::Editor::exportEntities ( bool  exportScene = false)

Definition at line 2492 of file Editor.cpp.

◆ exportScene()

void Cogs::Core::Editor::exportScene ( const StringView path)
overrideprivatevirtual

Implements Cogs::Core::IEditor.

Definition at line 2122 of file Editor.cpp.

◆ focusAll()

void Cogs::Core::Editor::focusAll ( )

Definition at line 2606 of file Editor.cpp.

◆ focusBoundingBox()

bool Cogs::Core::Editor::focusBoundingBox ( const Cogs::Geometry::DBoundingBox &  boundingBox)

Definition at line 2633 of file Editor.cpp.

◆ focusSelected()

void Cogs::Core::Editor::focusSelected ( )

Definition at line 2590 of file Editor.cpp.

◆ getExtensionCommands()

std::vector< Cogs::Core::ExtensionCommand > & Cogs::Core::Editor::getExtensionCommands ( )
static

Definition at line 610 of file Editor.cpp.

◆ getExtensionItems()

std::vector< Cogs::Core::ExtensionItem > & Cogs::Core::Editor::getExtensionItems ( )
static

Definition at line 625 of file Editor.cpp.

◆ getInspectorWidth()

float Cogs::Core::Editor::getInspectorWidth ( ) const
inlineprivate

Definition at line 271 of file Editor.h.

◆ getLayerVisibility()

bool Cogs::Core::Editor::getLayerVisibility ( const ComponentModel::Entity entity,
StringView  layer 
)
private

Returns true if any Node in layer is visible.

Definition at line 2072 of file Editor.cpp.

References Cogs::ComponentModel::Entity::getComponent().

◆ getMenuHeight()

float Cogs::Core::Editor::getMenuHeight ( ) const
inlineprivate

Definition at line 272 of file Editor.h.

◆ getSelected()

Cogs::Core::EntityIds Cogs::Core::Editor::getSelected ( ) const
overrideprivatevirtual

Implements Cogs::Core::IEditor.

Definition at line 2132 of file Editor.cpp.

◆ getSidebarWidth()

float Cogs::Core::Editor::getSidebarWidth ( ) const
inlineprivate

Definition at line 270 of file Editor.h.

◆ getState()

Cogs::Core::EditorState * Cogs::Core::Editor::getState ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 1826 of file Editor.cpp.

◆ getStatusbarHeight()

float Cogs::Core::Editor::getStatusbarHeight ( ) const
inlineprivate

Definition at line 268 of file Editor.h.

◆ getStatusbarText()

const std::string & Cogs::Core::Editor::getStatusbarText ( ) const
inlineprivate

Definition at line 266 of file Editor.h.

◆ getToolbarHeight()

float Cogs::Core::Editor::getToolbarHeight ( ) const
inlineprivate

Definition at line 269 of file Editor.h.

◆ handleMouseEvent()

void Cogs::Core::Editor::handleMouseEvent ( const struct Cogs::Core::InputEvent event)
private

Definition at line 1504 of file Editor.cpp.

◆ hideUnselected()

void Cogs::Core::Editor::hideUnselected ( )

Make all non-selected entities invisible.

Definition at line 2761 of file Editor.cpp.

References Cogs::Core::EntityStore::getEntities(), Cogs::Core::EntityStore::getEntityPtr(), and Cogs::Core::Context::store.

◆ imageButton()

bool Cogs::Core::Editor::imageButton ( Icon  icon,
int  size,
int  padding 
)

Definition at line 2152 of file Editor.cpp.

◆ importStatic()

void Cogs::Core::Editor::importStatic ( )

Definition at line 2453 of file Editor.cpp.

◆ initialize()

void Cogs::Core::Editor::initialize ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 633 of file Editor.cpp.

◆ invertVisibility()

void Cogs::Core::Editor::invertVisibility ( )

Toggle visibility all entities. First hideUnselected, then invertVisibility makes only unselected entities visible

Definition at line 2871 of file Editor.cpp.

References Cogs::Core::EntityStore::getEntities(), and Cogs::Core::Context::store.

◆ invokeCommand()

void Cogs::Core::Editor::invokeCommand ( const StringView key)
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 2564 of file Editor.cpp.

◆ isActive()

bool Cogs::Core::Editor::isActive ( ) const
inlineoverridevirtual

Implements Cogs::Core::IEditor.

Definition at line 96 of file Editor.h.

◆ isStandardEntity()

bool Cogs::Core::Editor::isStandardEntity ( const Cogs::ComponentModel::Entity entity) const
private

Checks if the given entity is a Basic Cogs.Runtime entity. E.g. Should not change visibility or delete.

Definition at line 2093 of file Editor.cpp.

References Cogs::ComponentModel::Entity::getComponent().

◆ isUserRootEntity()

bool Cogs::Core::Editor::isUserRootEntity ( const Cogs::ComponentModel::Entity entity) const
private

Checks if the entity is.

Definition at line 2109 of file Editor.cpp.

References Cogs::Core::EntityStore::getEntityParent(), and Cogs::Core::Context::store.

◆ onlineHelp()

void Cogs::Core::Editor::onlineHelp ( bool  generalHelp)

Definition at line 2925 of file Editor.cpp.

◆ open()

void Cogs::Core::Editor::open ( const StringView path,
bool  openInRoot,
bool  synchronous 
)
overridevirtual

Open file.

Parameters
pathPath of file
openInRootTrue if open file as root entity, false if open below selected if one selected.
synchronousTrue if Syncronous read.

Implements Cogs::Core::IEditor.

Definition at line 2348 of file Editor.cpp.

References Cogs::Core::EditorState::getAllSelectedIds(), Cogs::Core::EditorState::getSelectedId(), and Cogs::Core::EditorState::setSelection().

◆ openInternal()

void Cogs::Core::Editor::openInternal ( const StringView path,
bool  openInRoot,
bool  synchronous,
bool  interactive 
)
private

Definition at line 2189 of file Editor.cpp.

◆ paste()

void Cogs::Core::Editor::paste ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 2557 of file Editor.cpp.

◆ processShortcuts()

void Cogs::Core::Editor::processShortcuts ( )

Definition at line 1332 of file Editor.cpp.

◆ redo()

void Cogs::Core::Editor::redo ( )

Definition at line 2956 of file Editor.cpp.

◆ registerExtensionCommand()

void Cogs::Core::Editor::registerExtensionCommand ( const StringView key,
CommandCreator  creator 
)
static

Definition at line 602 of file Editor.cpp.

◆ registerExtensionItem()

void Cogs::Core::Editor::registerExtensionItem ( const StringView key,
const StringView name 
)
static

Definition at line 617 of file Editor.cpp.

◆ save()

void Cogs::Core::Editor::save ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 2384 of file Editor.cpp.

◆ saveAs()

void Cogs::Core::Editor::saveAs ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 2395 of file Editor.cpp.

◆ saveIncremental()

void Cogs::Core::Editor::saveIncremental ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 2412 of file Editor.cpp.

◆ select()

void Cogs::Core::Editor::select ( const EntityIds &  ids,
SelectMode  mode = SelectMode::Exclusive 
)
overrideprivatevirtual

Implements Cogs::Core::IEditor.

Definition at line 2137 of file Editor.cpp.

◆ selectAll()

void Cogs::Core::Editor::selectAll ( )

Definition at line 2892 of file Editor.cpp.

◆ selectFurthestAway()

void Cogs::Core::Editor::selectFurthestAway ( )

Search and select visible entity furthest away from selection. Ie.e. find outliers.

Definition at line 2813 of file Editor.cpp.

References Cogs::ComponentModel::Entity::getComponent(), Cogs::Core::EntityStore::getEntityPtr(), Cogs::ComponentModel::Entity::getId(), and Cogs::Core::Context::store.

◆ selectLayer()

void Cogs::Core::Editor::selectLayer ( ComponentModel::Entity entity,
StringView  layer 
)
private

Definition at line 2028 of file Editor.cpp.

◆ selectOne()

void Cogs::Core::Editor::selectOne ( EntityId  id)

Definition at line 2912 of file Editor.cpp.

◆ setLayerVisibility()

void Cogs::Core::Editor::setLayerVisibility ( ComponentModel::Entity entity,
StringView  layer,
bool  visible 
)
private

Definition at line 2049 of file Editor.cpp.

◆ setStatusbarText()

void Cogs::Core::Editor::setStatusbarText ( const std::string &  text,
bool  guiStatus 
)

Update editor statusbar text

Parameters
guiStatus- TRUE if status is for GUI entry, false if application status

Definition at line 2675 of file Editor.cpp.

◆ show()

void Cogs::Core::Editor::show ( )
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 702 of file Editor.cpp.

◆ showAbout()

void Cogs::Core::Editor::showAbout ( )

Definition at line 2940 of file Editor.cpp.

◆ showAll()

void Cogs::Core::Editor::showAll ( )

◆ showEntities()

void Cogs::Core::Editor::showEntities ( )
private

Definition at line 1952 of file Editor.cpp.

◆ showEntityDetails()

void Cogs::Core::Editor::showEntityDetails ( ComponentModel::Entity entity)
private

Definition at line 2018 of file Editor.cpp.

◆ showGizmo()

void Cogs::Core::Editor::showGizmo ( )
private

Definition at line 2023 of file Editor.cpp.

◆ showHide()

void Cogs::Core::Editor::showHide ( bool  visible)

Show or hide selected entity and all children.

Definition at line 2740 of file Editor.cpp.

References Cogs::ComponentModel::Entity::getComponent(), Cogs::Core::EntityStore::getEntityPtr(), and Cogs::Core::Context::store.

◆ showingGuiStatusbarText()

bool Cogs::Core::Editor::showingGuiStatusbarText ( ) const
inlineprivate

Definition at line 267 of file Editor.h.

◆ showLicenses()

void Cogs::Core::Editor::showLicenses ( )

Definition at line 2935 of file Editor.cpp.

◆ showMaterialInstance()

bool Cogs::Core::Editor::showMaterialInstance ( FieldInfo fieldInfo,
MaterialInstanceHandle materialInstanceHandle 
)

Definition at line 1947 of file Editor.cpp.

◆ showModel()

bool Cogs::Core::Editor::showModel ( ModelHandle modelHandle)

Definition at line 1862 of file Editor.cpp.

◆ showText()

void Cogs::Core::Editor::showText ( const char *  format,
  ... 
) const

Show the same type of label as ImGui::Text, but with the added ability to highlight and copy text. Max 255 characters.

Definition at line 1831 of file Editor.cpp.

◆ showTexture()

bool Cogs::Core::Editor::showTexture ( const StringView header,
TextureHandle textureHandle 
)
overridevirtual

Implements Cogs::Core::IEditor.

Definition at line 1896 of file Editor.cpp.

◆ undo()

void Cogs::Core::Editor::undo ( )

Definition at line 2945 of file Editor.cpp.

Member Data Documentation

◆ active

bool Cogs::Core::Editor::active = false
private

Definition at line 246 of file Editor.h.

◆ buttonSize

glm::vec2 Cogs::Core::Editor::buttonSize = glm::vec2{ 24 }
private

Definition at line 253 of file Editor.h.

◆ commandIndex

size_t Cogs::Core::Editor::commandIndex = NoCommand
private

Definition at line 236 of file Editor.h.

◆ commands

std::vector<std::unique_ptr<EditorCommand> > Cogs::Core::Editor::commands
private

Definition at line 234 of file Editor.h.

◆ context

Context* Cogs::Core::Editor::context
private

Definition at line 228 of file Editor.h.

◆ guiStatusInStatusbar

bool Cogs::Core::Editor::guiStatusInStatusbar = true
private

Definition at line 258 of file Editor.h.

◆ initialized

bool Cogs::Core::Editor::initialized = false
private

Definition at line 245 of file Editor.h.

◆ inspectorWidth

float Cogs::Core::Editor::inspectorWidth = 250
private

Definition at line 250 of file Editor.h.

◆ materialEditor

std::unique_ptr<class MaterialEditor> Cogs::Core::Editor::materialEditor
private

Definition at line 238 of file Editor.h.

◆ menuHeight

float Cogs::Core::Editor::menuHeight = 20
private

Definition at line 251 of file Editor.h.

◆ minWidth

float Cogs::Core::Editor::minWidth = 50
private

Definition at line 248 of file Editor.h.

◆ modalCommand

ModalEditorCommand* Cogs::Core::Editor::modalCommand = nullptr
private

Definition at line 232 of file Editor.h.

◆ NoCommand

constexpr size_t Cogs::Core::Editor::NoCommand = static_cast<size_t>(-1)
staticconstexprprivate

Definition at line 235 of file Editor.h.

◆ showInspector

bool Cogs::Core::Editor::showInspector = true
private

Definition at line 262 of file Editor.h.

◆ showMenu

bool Cogs::Core::Editor::showMenu = true
private

Definition at line 263 of file Editor.h.

◆ showSidebar

bool Cogs::Core::Editor::showSidebar = true
private

Definition at line 261 of file Editor.h.

◆ showStatusbar

bool Cogs::Core::Editor::showStatusbar = true
private

Definition at line 256 of file Editor.h.

◆ showToolbar

bool Cogs::Core::Editor::showToolbar = true
private

Definition at line 260 of file Editor.h.

◆ sidebarWidth

float Cogs::Core::Editor::sidebarWidth = 200
private

Definition at line 249 of file Editor.h.

◆ standardEntities

std::vector<Cogs::Core::WeakEntityPtr> Cogs::Core::Editor::standardEntities
private

Set of entities created when the Editor loads.

Definition at line 241 of file Editor.h.

◆ state

std::unique_ptr<struct EditorState> Cogs::Core::Editor::state
private

Definition at line 230 of file Editor.h.

◆ statusbarHeight

float Cogs::Core::Editor::statusbarHeight = 20
private

Definition at line 255 of file Editor.h.

◆ statusbarText

std::string Cogs::Core::Editor::statusbarText
private

Definition at line 257 of file Editor.h.

◆ textElementId

int Cogs::Core::Editor::textElementId = 0
mutableprivate

Definition at line 243 of file Editor.h.

◆ toolbarHeight

float Cogs::Core::Editor::toolbarHeight = 40
private

Definition at line 252 of file Editor.h.


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