Skip to content

Commit

Permalink
#123 Add controller for space scene
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed Apr 21, 2021
1 parent a5d2ee0 commit 29d12b5
Show file tree
Hide file tree
Showing 11 changed files with 366 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Projects/Editor/Source/Editor/CEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ This file is part of the "Skylicht Engine".
#include "Space/Property/CSpaceProperty.h"
#include "Space/Hierarchy/CSpaceHierarchy.h"

#include "SpaceController/CSceneController.h"
#include "SpaceController/CPropertyController.h"

#include "AssetManager/CAssetManager.h"

namespace Skylicht
Expand All @@ -53,10 +56,17 @@ namespace Skylicht
m_canvas = GUI::CGUIContext::getRoot();

m_assetWatcher = new CAssetWatcher();

// init controller
CSceneController::createGetInstance();
CPropertyController::createGetInstance();
}

CEditor::~CEditor()
{
CPropertyController::releaseInstance();
CSceneController::releaseInstance();

delete m_assetWatcher;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
!@
MIT License
CopyRight (c) 2021 Skylicht Technology CO., LTD
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the Rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRight HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file is part of the "Skylicht Engine".
https://github.com/skylicht-lab/skylicht-engine
!#
*/

#include "pch.h"
#include "CHierarchyController.h"

namespace Skylicht
{
namespace Editor
{
CHierarchyController::CHierarchyController(GUI::CCanvas* canvas, GUI::CTreeControl* tree)
{

}

CHierarchyController::~CHierarchyController()
{

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
!@
MIT License
CopyRight (c) 2021 Skylicht Technology CO., LTD
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the Rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRight HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file is part of the "Skylicht Engine".
https://github.com/skylicht-lab/skylicht-engine
!#
*/

#include "GUI/GUI.h"

namespace Skylicht
{
namespace Editor
{
class CHierarchyController
{
protected:
GUI::CCanvas* m_canvas;
GUI::CTreeControl* m_tree;

public:
CHierarchyController(GUI::CCanvas* canvas, GUI::CTreeControl* tree);

virtual ~CHierarchyController();
};
}
}
40 changes: 40 additions & 0 deletions Projects/Editor/Source/Editor/Space/Hierarchy/CSpaceHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,59 @@ This file is part of the "Skylicht Engine".
#include "pch.h"
#include "CSpaceHierarchy.h"

#include "Editor/SpaceController/CSceneController.h"

namespace Skylicht
{
namespace Editor
{
CSpaceHierarchy::CSpaceHierarchy(GUI::CWindow* window, CEditor* editor) :
CSpace(window, editor)
{
GUI::CToolbar* toolbar = new GUI::CToolbar(window);

m_btnAdd = toolbar->addButton(L"Add", GUI::ESystemIcon::Plus);

m_inputSearch = new GUI::CTextBox(toolbar);
m_inputSearch->setWidth(200.0f);
m_inputSearch->showIcon();
m_inputSearch->setStringHint(L"Search");
toolbar->addControl(m_inputSearch, true);

GUI::CBase* treeContainer = new GUI::CBase(window);
treeContainer->dock(GUI::EPosition::Fill);

GUI::CBase* searchInfo = new GUI::CBase(treeContainer);
searchInfo->setHeight(20.0f);
searchInfo->dock(GUI::EPosition::Top);
searchInfo->enableRenderFillRect(true);
searchInfo->setFillRectColor(GUI::CThemeConfig::WindowInnerColor);
searchInfo->setHidden(true);

m_labelSearch = new GUI::CLabel(searchInfo);
m_labelSearch->setString("Search asset: ");
m_labelSearch->setPadding(GUI::SPadding(5.0f, 3.0f, 0.0f, 0.0f));
m_labelSearch->dock(GUI::EPosition::Left);
m_labelSearch->sizeToContents();

m_buttonCancelSearch = new GUI::CIconButton(searchInfo);
m_buttonCancelSearch->setMargin(GUI::SMargin(5.0f, 0.0f, 0.0f, 0.0f));
m_buttonCancelSearch->setIcon(GUI::ESystemIcon::Close);
m_buttonCancelSearch->dock(GUI::EPosition::Left);

m_tree = new GUI::CTreeControl(treeContainer);
m_tree->dock(GUI::EPosition::Fill);

m_hierarchyController = new CHierarchyController(window->getCanvas(), m_tree);

CSceneController::getInstance()->setSpaceHierarchy(this);
}

CSpaceHierarchy::~CSpaceHierarchy()
{
delete m_hierarchyController;

CSceneController::getInstance()->setSpaceHierarchy(NULL);
}

void CSpaceHierarchy::update()
Expand Down
10 changes: 10 additions & 0 deletions Projects/Editor/Source/Editor/Space/Hierarchy/CSpaceHierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,23 @@ This file is part of the "Skylicht Engine".
#include "SkylichtEngine.h"

#include "Editor/Space/CSpace.h"
#include "CHierarchyController.h"

namespace Skylicht
{
namespace Editor
{
class CSpaceHierarchy : public CSpace
{
protected:
GUI::CButton* m_btnAdd;
GUI::CTextBox* m_inputSearch;
GUI::CLabel* m_labelSearch;
GUI::CButton* m_buttonCancelSearch;

GUI::CTreeControl* m_tree;

CHierarchyController* m_hierarchyController;
public:
CSpaceHierarchy(GUI::CWindow* window, CEditor* editor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This file is part of the "Skylicht Engine".
#include "pch.h"
#include "CSpaceProperty.h"
#include "Utils/CStringImp.h"
#include "Editor/SpaceController/CPropertyController.h"

namespace Skylicht
{
Expand Down Expand Up @@ -121,11 +122,13 @@ namespace Skylicht
addSlider(boxLayout, L"Direct multipler", 1.0f, 0.0f, 1.0f);

indirectLighting->setExpand(true);

CPropertyController::getInstance()->setSpaceProperty(this);
}

CSpaceProperty::~CSpaceProperty()
{

CPropertyController::getInstance()->setSpaceProperty(NULL);
}

void CSpaceProperty::addNumberInput(GUI::CBoxLayout* boxLayout, const wchar_t* name, float value, float step)
Expand Down
6 changes: 6 additions & 0 deletions Projects/Editor/Source/Editor/Space/Scene/CSpaceScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ This file is part of the "Skylicht Engine".
#include "CSpaceScene.h"
#include "GridPlane/CGridPlane.h"

#include "Editor/SpaceController/CSceneController.h"

using namespace std::placeholders;

namespace Skylicht
Expand Down Expand Up @@ -57,6 +59,8 @@ namespace Skylicht

GUI::SDimension size = window->getSize();
initRenderPipeline(size.Width, size.Height);

CSceneController::getInstance()->setSpaceScene(this);
}

CSpaceScene::~CSpaceScene()
Expand All @@ -66,6 +70,8 @@ namespace Skylicht

if (m_renderRP != NULL)
delete m_renderRP;

CSceneController::getInstance()->setSpaceScene(NULL);
}

void CSpaceScene::initDefaultScene()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
!@
MIT License
CopyRight (c) 2021 Skylicht Technology CO., LTD
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the Rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRight HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file is part of the "Skylicht Engine".
https://github.com/skylicht-lab/skylicht-engine
!#
*/

#include "pch.h"
#include "CPropertyController.h"

namespace Skylicht
{
namespace Editor
{
CPropertyController::CPropertyController() :
m_spaceProperty(NULL)
{

}

CPropertyController::~CPropertyController()
{

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
!@
MIT License
CopyRight (c) 2021 Skylicht Technology CO., LTD
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the Rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRight HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file is part of the "Skylicht Engine".
https://github.com/skylicht-lab/skylicht-engine
!#
*/

#pragma once

#include "Utils/CGameSingleton.h"
#include "Editor/Space/Property/CSpaceProperty.h"

namespace Skylicht
{
namespace Editor
{
class CPropertyController : public CGameSingleton<CPropertyController>
{
protected:
CSpaceProperty* m_spaceProperty;

public:
CPropertyController();

virtual ~CPropertyController();

inline void setSpaceProperty(CSpaceProperty* property)
{
m_spaceProperty = property;
}

inline CSpaceProperty* getSpaceProperty()
{
return m_spaceProperty;
}
};
}
}
44 changes: 44 additions & 0 deletions Projects/Editor/Source/Editor/SpaceController/CSceneController.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
!@
MIT License
CopyRight (c) 2021 Skylicht Technology CO., LTD
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the Rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRight HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file is part of the "Skylicht Engine".
https://github.com/skylicht-lab/skylicht-engine
!#
*/

#include "pch.h"
#include "CSceneController.h"

namespace Skylicht
{
namespace Editor
{
CSceneController::CSceneController() :
m_spaceHierarchy(NULL),
m_spaceScene(NULL)
{

}

CSceneController::~CSceneController()
{

}
}
}
Loading

0 comments on commit 29d12b5

Please sign in to comment.