-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d244e97
commit 9ced04c
Showing
3 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#ifndef SSGUI_TEMPLATE_EXTENSION_HPP | ||
#define SSGUI_TEMPLATE_EXTENSION_HPP | ||
|
||
#include "ssGUI/Extensions/Extension.hpp" | ||
|
||
namespace ssGUI | ||
{ | ||
|
||
//namespace: ssGUI::Extensions | ||
namespace Extensions | ||
{ | ||
/*class: ssGUI::Extensions::TemplateExtension | ||
A template Extension. Use this to create new Extension Classes. | ||
Variables & Constructor: | ||
============================== C++ ============================== | ||
protected: | ||
ssGUI::GUIObject* Container; //See <BindToObject> | ||
bool Enabled; //See <IsEnabled> | ||
================================================================= | ||
============================== C++ ============================== | ||
TemplateExtension::TemplateExtension() : Container(nullptr), | ||
Enabled(true) | ||
{} | ||
================================================================= | ||
*/ | ||
class TemplateExtension : public Extension | ||
{ | ||
public: | ||
friend class ssGUI::Factory; | ||
|
||
private: | ||
TemplateExtension& operator=(TemplateExtension const& other); | ||
|
||
protected: | ||
ssGUI::GUIObject* Container; //See <BindToObject> | ||
bool Enabled; //See <IsEnabled> | ||
|
||
TemplateExtension(); | ||
virtual ~TemplateExtension() override; | ||
TemplateExtension(TemplateExtension const& other); | ||
static void* operator new(size_t size) {return ::operator new(size);}; | ||
static void* operator new[](size_t size) {return ::operator new(size);}; | ||
static void operator delete(void* p) {free(p);}; | ||
static void operator delete[](void* p) {free(p);}; | ||
|
||
virtual void ConstructRenderInfo() override; | ||
virtual void ConstructRenderInfo( ssGUI::Backend::BackendDrawingInterface* drawingInterface, | ||
ssGUI::GUIObject* mainWindow, | ||
glm::vec2 mainWindowPositionOffset) override; | ||
|
||
public: | ||
static const std::string EXTENSION_NAME; | ||
|
||
//Override from Extension | ||
//function: SetEnabled | ||
//See <Extension::SetEnabled> | ||
virtual void SetEnabled(bool enabled) override; | ||
|
||
//function: IsEnabled | ||
//See <Extension::IsEnabled> | ||
virtual bool IsEnabled() const override; | ||
|
||
//function: Internal_Update | ||
//See <Extension::Internal_Update> | ||
virtual void Internal_Update( bool isPreUpdate, | ||
ssGUI::Backend::BackendSystemInputInterface* inputInterface, | ||
ssGUI::InputStatus& inputStatus, | ||
ssGUI::GUIObject* mainWindow) override; | ||
|
||
//function: Internal_Draw | ||
//See <Extension::Internal_Draw> | ||
virtual void Internal_Draw( bool isPreRender, | ||
ssGUI::Backend::BackendDrawingInterface* drawingInterface, | ||
ssGUI::GUIObject* mainWindow, | ||
glm::vec2 mainWindowPositionOffset) override; | ||
|
||
//function: GetExtensionName | ||
//See <Extension::GetExtensionName> | ||
virtual std::string GetExtensionName() override; | ||
|
||
//function: BindToObject | ||
//See <Extension::BindToObject> | ||
virtual void BindToObject(ssGUI::GUIObject* bindObj) override; | ||
|
||
//function: Copy | ||
//See <Extension::Copy> | ||
virtual void Copy(ssGUI::Extensions::Extension* extension) override; | ||
|
||
//function: Internal_GetObjectsReferences | ||
//See <Extension::Internal_GetObjectsReferences> | ||
virtual ObjectsReferences* Internal_GetObjectsReferences() override; | ||
|
||
//function: Clone | ||
//See <Extension::Clone> | ||
virtual TemplateExtension* Clone() override; | ||
}; | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include "ssGUI/Extensions/TemplateExtension.hpp" | ||
#include "ssGUI/GUIObjectClasses/GUIObject.hpp" | ||
|
||
namespace ssGUI | ||
{ | ||
|
||
namespace Extensions | ||
{ | ||
TemplateExtension::TemplateExtension() : Container(nullptr), | ||
Enabled(true) | ||
{} | ||
|
||
TemplateExtension::~TemplateExtension() | ||
{} | ||
|
||
TemplateExtension::TemplateExtension(TemplateExtension const& other) | ||
{ | ||
Container = nullptr; | ||
Enabled = other.IsEnabled(); | ||
} | ||
|
||
void TemplateExtension::ConstructRenderInfo() | ||
{} | ||
|
||
void TemplateExtension::ConstructRenderInfo(ssGUI::Backend::BackendDrawingInterface* drawingInterface, | ||
ssGUI::GUIObject* mainWindow, | ||
glm::vec2 mainWindowPositionOffset) | ||
{} | ||
|
||
const std::string TemplateExtension::EXTENSION_NAME = "Template Extension"; | ||
|
||
void TemplateExtension::SetEnabled(bool enabled) | ||
{ | ||
Enabled = enabled; | ||
} | ||
|
||
void TemplateExtension::Internal_Update(bool isPreUpdate, | ||
ssGUI::Backend::BackendSystemInputInterface* inputInterface, | ||
ssGUI::InputStatus& inputStatus, | ||
ssGUI::GUIObject* mainWindow) | ||
{ | ||
ssGUI_LOG_FUNC(); | ||
|
||
//This should be done in pre update | ||
if(!isPreUpdate || Container == nullptr || Container->GetParent() == nullptr || !Enabled) | ||
return; | ||
} | ||
|
||
void TemplateExtension::Internal_Draw( bool isPreRender, | ||
ssGUI::Backend::BackendDrawingInterface* drawingInterface, | ||
ssGUI::GUIObject* mainWindow, | ||
glm::vec2 mainWindowPositionOffset) | ||
{ | ||
//Nothing to draw | ||
} | ||
|
||
std::string TemplateExtension::GetExtensionName() | ||
{ | ||
return EXTENSION_NAME; | ||
} | ||
|
||
void TemplateExtension::BindToObject(ssGUI::GUIObject* bindObj) | ||
{ | ||
Container = bindObj; | ||
} | ||
|
||
void TemplateExtension::Copy(ssGUI::Extensions::Extension* extension) | ||
{ | ||
if(extension->GetExtensionName() != EXTENSION_NAME) | ||
return; | ||
|
||
ssGUI::Extensions::TemplateExtension* original = static_cast<ssGUI::Extensions::TemplateExtension*>(extension); | ||
Enabled = original->IsEnabled(); | ||
} | ||
|
||
ObjectsReferences* TemplateExtension::Internal_GetObjectsReferences() | ||
{ | ||
return nullptr; | ||
} | ||
|
||
TemplateExtension* TemplateExtension::Clone() | ||
{ | ||
TemplateExtension* temp = new TemplateExtension(*this); | ||
return temp; | ||
} | ||
} | ||
|
||
} |