Skip to content

Commit

Permalink
Refactoring:rename uidemo to demo2d.
Browse files Browse the repository at this point in the history
  • Loading branch information
kimkulling committed Oct 3, 2023
1 parent c1758f4 commit f8d8295
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 52 deletions.
44 changes: 11 additions & 33 deletions samples/02_UIDemo/UIDemo.cpp → samples/02_Demo2D/Demo2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,30 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------------*/
#include <osre/App/AppBase.h>
#include <osre/App/AssetRegistry.h>
#include <osre/Properties/Settings.h>
#include <osre/Common/Logger.h>
#include <osre/RenderBackend/RenderCommon.h>
#include <osre/RenderBackend/TransformMatrixBlock.h>

using namespace ::OSRE;
using namespace ::OSRE::RenderBackend;
using namespace ::OSRE::UI;
using namespace ::OSRE::Platform;
using namespace ::OSRE::App;

// To identify local log entries
static const c8 Tag[] = "ModelLoadingApp";

// The example application, will create the render environment and render a simple triangle onto it
class UIDemoApp : public App::AppBase {
Canvas *m_canvas;
TransformMatrixBlock m_transformMatrix;
class Demo2DApp : public App::AppBase {
TransformMatrixBlock mTransformMatrix;

public:
UIDemoApp(int argc, char *argv[]) :
Demo2DApp(int argc, char *argv[]) :
AppBase(argc, (const char **)argv),
m_canvas(nullptr),
m_transformMatrix() {
mTransformMatrix() {
// empty
}

~UIDemoApp() override {
// empty
}

void openFileCallback(ui32, void *) {
IO::Uri loc;
PlatformOperations::getFileOpenDialog("All\0 *.*\0", loc);
}
~Demo2DApp() override = default;

void quitCallback(ui32, void *) {
AppBase::requestShutdown();
Expand All @@ -66,33 +58,19 @@ class UIDemoApp : public App::AppBase {
return false;
}

baseSettings->setString(Properties::Settings::WindowsTitle, "Demo UI!");
baseSettings->setString(Properties::Settings::WindowsTitle, "Demo in 2D!");
if (!AppBase::onCreate()) {
return false;
}

AssetRegistry::registerAssetPathInBinFolder("assets", "assets");

m_canvas = AppBase::createScreen("UiDemo");

Panel *panel = new Panel("panel", m_canvas);
panel->setRect(10, 10, 500, 500);

ButtonBase *btnOpenFile = new ButtonBase( "Open file", panel);
btnOpenFile->registerCallback(WidgetState::Pressed, UiFunctor::Make(this, &UIDemoApp::openFileCallback));
btnOpenFile->setRect( 20, 20, 100, 20 );
btnOpenFile->setLabel("Open file");

ButtonBase *btnQuit = new ButtonBase( "Quit", panel );
btnQuit->setRect( 400, 20, 100, 20 );
btnQuit->registerCallback(WidgetState::Pressed, UiFunctor::Make( this, &UIDemoApp::quitCallback ) );

TextBase *tb = new TextBase("test", panel);
tb->setLabel("Test");
tb->setRect(20, 20, 400, 60);

return true;
}
};

OSRE_MAIN(UIDemoApp)
OSRE_MAIN(Demo2DApp)

File renamed without changes.
38 changes: 19 additions & 19 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,52 @@ INCLUDE_DIRECTORIES(

SET ( 00_helloworld_src
00_HelloWorld/HelloWorld.cpp
00_HelloWorld/README.md
00_HelloWorld/README.md
)

SET ( 01_modelloading_src
01_ModelLoading/ModelLoading.cpp
01_ModelLoading/README.md
)

SET ( 02_UIDemo_src
02_UIDemo/UIDemo.cpp
02_UIDemo/README.md
SET ( 02_demo2d_src
02_Demo2D/Demo2D.cpp
02_Demo2D/README.md
)

SET ( 03_instancing_src
03_Instancing/Instancing.cpp
03_Instancing/README.md
03_Instancing/Instancing.cpp
03_Instancing/README.md
)


ADD_EXECUTABLE( HelloWorld
ADD_EXECUTABLE( helloworld
${00_helloworld_src}
)

ADD_EXECUTABLE( ModelLoading
ADD_EXECUTABLE( modelloading
${01_modelloading_src}
)

ADD_EXECUTABLE( Instancing
ADD_EXECUTABLE( instancing
${03_instancing_src}
)

ADD_EXECUTABLE(UIDemo
${03_instancing_src}
ADD_EXECUTABLE(demo2d
${02_demo2d_src}
)

link_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../../ThirdParty/glew/Debug
${CMAKE_CURRENT_SOURCE_DIR}/../../ThirdParty/glew/Release
)

target_link_libraries(HelloWorld osre)
target_link_libraries(ModelLoading osre)
target_link_libraries(UIDemo osre)
target_link_libraries(Instancing osre)
target_link_libraries(helloworld osre)
target_link_libraries(modelloading osre)
target_link_libraries(demo2d osre)
target_link_libraries(instancing osre)

set_target_properties(HelloWorld PROPERTIES FOLDER Samples)
set_target_properties(ModelLoading PROPERTIES FOLDER Samples)
set_target_properties(UIDemo PROPERTIES FOLDER Samples)
set_target_properties(Instancing PROPERTIES FOLDER Samples)
set_target_properties(helloworld PROPERTIES FOLDER Samples)
set_target_properties(modelloading PROPERTIES FOLDER Samples)
set_target_properties(demo2d PROPERTIES FOLDER Samples)
set_target_properties(instancing PROPERTIES FOLDER Samples)

0 comments on commit f8d8295

Please sign in to comment.