From f8d82956ed7726d82b1d315996734494a5b6ebbc Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 3 Oct 2023 17:57:15 +0200 Subject: [PATCH] Refactoring:rename uidemo to demo2d. --- .../UIDemo.cpp => 02_Demo2D/Demo2D.cpp} | 44 +++++-------------- samples/{02_UIDemo => 02_Demo2D}/README.md | 0 samples/CMakeLists.txt | 38 ++++++++-------- 3 files changed, 30 insertions(+), 52 deletions(-) rename samples/{02_UIDemo/UIDemo.cpp => 02_Demo2D/Demo2D.cpp} (64%) rename samples/{02_UIDemo => 02_Demo2D}/README.md (100%) diff --git a/samples/02_UIDemo/UIDemo.cpp b/samples/02_Demo2D/Demo2D.cpp similarity index 64% rename from samples/02_UIDemo/UIDemo.cpp rename to samples/02_Demo2D/Demo2D.cpp index e526ef638..ce0749df0 100644 --- a/samples/02_UIDemo/UIDemo.cpp +++ b/samples/02_Demo2D/Demo2D.cpp @@ -22,38 +22,30 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -----------------------------------------------------------------------------------------------*/ #include #include +#include #include +#include +#include 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(); @@ -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) + diff --git a/samples/02_UIDemo/README.md b/samples/02_Demo2D/README.md similarity index 100% rename from samples/02_UIDemo/README.md rename to samples/02_Demo2D/README.md diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 86be1819a..eceddbbdc 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -5,7 +5,7 @@ INCLUDE_DIRECTORIES( SET ( 00_helloworld_src 00_HelloWorld/HelloWorld.cpp - 00_HelloWorld/README.md + 00_HelloWorld/README.md ) SET ( 01_modelloading_src @@ -13,31 +13,31 @@ SET ( 01_modelloading_src 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( @@ -45,12 +45,12 @@ link_directories( ${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)