-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SUTK] Added ANCHOR test for testing the anchors
- Loading branch information
Showing
3 changed files
with
83 additions
and
1 deletion.
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,34 @@ | ||
#pragma once | ||
|
||
#include <sutk/ITest.hpp> | ||
|
||
#include <sge-cpp/sge.hpp> | ||
|
||
#include <sutk/UIDriver.hpp> | ||
|
||
namespace SUTK | ||
{ | ||
class IGfxDriver; | ||
|
||
class AnchorTest : public ITest | ||
{ | ||
private: | ||
UIDriver* m_uiDriver; | ||
IGfxDriver* m_gfxDriver; | ||
RenderRectFill* m_renderRect; | ||
RenderRectContainer* m_renderRectContainer; | ||
|
||
public: | ||
AnchorTest() : m_uiDriver(NULL), m_gfxDriver(NULL) { } | ||
|
||
DriverInitializationData getInitializationData() override; | ||
|
||
void initialize(SGE::Driver& driver) override; | ||
|
||
void terminate(SGE::Driver& driver) override; | ||
|
||
void render(SGE::Driver& driver) override; | ||
|
||
void update(SGE::Driver& driver, float deltaTime) override; | ||
}; | ||
} |
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,46 @@ | ||
#include <sutk/tests/AnchorTest.hpp> | ||
|
||
#include <sutk/RenderRect.hpp> | ||
#include <sutk/SGEGfxDriver.hpp> | ||
#include <sutk/RenderRectContainer.hpp> | ||
#include <sutk/FullWindowContainer.hpp> | ||
|
||
namespace SUTK | ||
{ | ||
DriverInitializationData AnchorTest::getInitializationData() | ||
{ | ||
auto data = ITest::getInitializationData(); | ||
data.title = "Anchor Test"; | ||
return data; | ||
} | ||
|
||
void AnchorTest::initialize(SGE::Driver& driver) | ||
{ | ||
m_gfxDriver = new SGEGfxDriver(driver); | ||
m_uiDriver = new UIDriver(*m_gfxDriver); | ||
FullWindowContainer* rootContainer = m_uiDriver->createContainer<FullWindowContainer>(NULL); | ||
m_renderRectContainer = m_uiDriver->createContainer<RenderRectContainer>(rootContainer); | ||
m_renderRectContainer->setRect({ 1.0f, 1.0f, 7, 7 }); | ||
AnchorRect* anchor = m_renderRectContainer->getAnchorRect(); | ||
anchor->setTopLeft({ 0, 0 }); | ||
anchor->setBottomRight({ 1, 1 }); | ||
m_renderRect = m_uiDriver->createRenderRect<RenderRectFill>(m_renderRectContainer); | ||
m_renderRect->setColor(Color3::green()); | ||
} | ||
|
||
void AnchorTest::terminate(SGE::Driver& driver) | ||
{ | ||
delete m_uiDriver; | ||
delete m_gfxDriver; | ||
} | ||
|
||
void AnchorTest::render(SGE::Driver& driver) | ||
{ | ||
// SUTK::UIDriver::render() should only be called when there is an update in the UI or screen resize | ||
m_uiDriver->render(); | ||
} | ||
|
||
void AnchorTest::update(SGE::Driver& driver, float deltaTime) | ||
{ | ||
} | ||
} |