Enhance examples (#17)
* enhance examples * doc enhancement * mv pool to stack * missing ; and doc update fix readme example image link
This commit is contained in:
committed by
Maximilian Kueffner
parent
244b00fa5c
commit
356f966d01
@@ -1 +1,2 @@
|
||||
add_subdirectory(simple)
|
||||
add_subdirectory(custom_0)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
set(SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/custom_0.cpp)
|
||||
|
||||
set(CUSTOM_0_NAME "${PROJECT_NAME}_custom_app")
|
||||
|
||||
add_executable(${CUSTOM_0_NAME} ${SRC})
|
||||
|
||||
target_link_libraries(${CUSTOM_0_NAME}
|
||||
PRIVATE pixelariumimagelib
|
||||
PRIVATE pixelariumrenderlib
|
||||
PRIVATE pixelariumutilslib
|
||||
PRIVATE pixelariumresourcelib
|
||||
PRIVATE pixelariumapplicationlib)
|
||||
|
||||
target_include_directories(${CUSTOM_0_NAME}
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/src
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/lib
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/lib/imaging
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/lib/app
|
||||
PRIVATE ${spdlog_DIR}/include
|
||||
PRIVATE ${LIBCZI_INCLUDE_DIR}
|
||||
PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
@@ -0,0 +1,53 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "DefaultApp.hpp"
|
||||
#include "resources/resource.hpp"
|
||||
#include "utilities/ILog.hpp"
|
||||
#include "utilities/SpdLogger.hpp"
|
||||
|
||||
using namespace pixelarium;
|
||||
using namespace std;
|
||||
using Log = utils::log::ILog;
|
||||
using Pool = resources::ImageResourcePool;
|
||||
|
||||
// setup a logger
|
||||
#ifdef _WIN32
|
||||
unique_ptr<Log> logger{
|
||||
make_unique<utils::log::SpdLogger>(string(getenv("APPDATA")) + "/pixelarium/simple_app.log", "default")};
|
||||
#else
|
||||
unique_ptr<Log> logger{
|
||||
make_unique<utils::log::SpdLogger>(string(getenv("HOME")) + "/.cache/pixelarium/simple_app.log", "default")};
|
||||
#endif
|
||||
|
||||
// create a custom app inheriting from the library's default app
|
||||
class MyApp : public application::DefaultApp
|
||||
{
|
||||
public:
|
||||
MyApp(const Log& log, Pool& pool) : application::DefaultApp(log, pool) {}
|
||||
|
||||
// override some of the defaults member functions
|
||||
void Run() override;
|
||||
void MenuBarOptionsColumn1() override {};
|
||||
void MenuBarOptionsColumn2() override {};
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
// some initial log message
|
||||
logger->Info(std::format("{}: Starting Application {}", __FUNCTION__, "Pixelarium"));
|
||||
|
||||
// instantiate an image pool for the application
|
||||
resources::ImageResourcePool image_pool;
|
||||
|
||||
// create a custom application, inject its dependencies and start it
|
||||
auto app{MyApp(*logger, image_pool)};
|
||||
|
||||
app.Start();
|
||||
}
|
||||
|
||||
void MyApp::Run()
|
||||
{
|
||||
this->gallery_.RenderGallery();
|
||||
this->gallery_.RenderImages();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
set(SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/simple.cpp)
|
||||
|
||||
set(SIMPLE_NAME "${PROJECT_NAME}_SIMPLE")
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#include <memory>
|
||||
|
||||
#include "DefaultApp.hpp"
|
||||
#include "resources/resource.hpp"
|
||||
#include "utilities/ILog.hpp"
|
||||
#include "utilities/SpdLogger.hpp"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
using namespace pixelarium;
|
||||
using namespace std;
|
||||
unique_ptr<utils::log::ILog> logger;
|
||||
#ifdef _WIN32
|
||||
logger = make_unique<utils::log::SpdLogger>(string(getenv("APPDATA")) + "/pixelarium/logfile.log", "default");
|
||||
#else
|
||||
logger = make_unique<utils::log::SpdLogger>(std::string(getenv("HOME")) + "/.cache/pixelarium/log.log", "default");
|
||||
#endif
|
||||
logger->Info(std::format("{}: Starting Application {}", __FUNCTION__, "Pixelarium"));
|
||||
|
||||
logger->ChangeLevel(utils::log::LogLevel::kDebug);
|
||||
auto image_pool{std::make_unique<resources::ImageResourcePool>()};
|
||||
|
||||
application::DefaultApp app = application::DefaultApp(*logger, *image_pool);
|
||||
|
||||
app.Start();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include <memory>
|
||||
|
||||
#include "DefaultApp.hpp"
|
||||
#include "resources/resource.hpp"
|
||||
#include "utilities/ILog.hpp"
|
||||
#include "utilities/SpdLogger.hpp"
|
||||
|
||||
using namespace pixelarium;
|
||||
using namespace std;
|
||||
using Log = utils::log::ILog;
|
||||
using Pool = resources::ImageResourcePool;
|
||||
|
||||
// setup a logger
|
||||
#ifdef _WIN32
|
||||
unique_ptr<Log> logger{
|
||||
make_unique<utils::log::SpdLogger>(string(getenv("APPDATA")) + "/pixelarium/simple_app.log", "default")};
|
||||
#else
|
||||
unique_ptr<Log> logger{
|
||||
make_unique<utils::log::SpdLogger>(string(getenv("HOME")) + "/.cache/pixelarium/simple_app.log", "default")};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
// some initial log message and default log level setting
|
||||
logger->Info(format("{}: Starting Application {}", __FUNCTION__, "Pixelarium"));
|
||||
logger->ChangeLevel(utils::log::LogLevel::kDebug);
|
||||
|
||||
// instantiate an image pool for the application
|
||||
resources::ImageResourcePool image_pool;
|
||||
|
||||
// create an application, inject its dependencies and start it
|
||||
auto app{application::DefaultApp(*logger, image_pool)};
|
||||
app.Start();
|
||||
}
|
||||
Reference in New Issue
Block a user