Compare commits

...

2 Commits

Author SHA1 Message Date
3a1c15f313
screen concept 2023-07-26 12:24:18 +02:00
e92c7cbfa0
add exe icon 2023-07-26 02:02:06 +02:00
9 changed files with 96 additions and 1 deletions

BIN
res/icon/tomato_v1_128.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -2,6 +2,13 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
add_executable(tomato add_executable(tomato
main.cpp main.cpp
icon.rc
screen.hpp
start_screen.hpp
start_screen.cpp
main_screen.hpp
main_screen.cpp
) )
target_compile_features(tomato PUBLIC cxx_std_17) target_compile_features(tomato PUBLIC cxx_std_17)

1
src/icon.rc Normal file
View File

@ -0,0 +1 @@
1 ICON "../res/icon/tomato_v1_128.ico"

View File

@ -7,6 +7,8 @@
#include "./theme.hpp" #include "./theme.hpp"
#include "./start_screen.hpp"
#include <memory> #include <memory>
#include <future> #include <future>
#include <iostream> #include <iostream>
@ -50,6 +52,8 @@ int main(int argc, char** argv) {
ImGui_ImplSDLRenderer3_Init(renderer.get()); ImGui_ImplSDLRenderer3_Init(renderer.get());
auto imgui_sdlrenderer_scope = std::async(std::launch::deferred, &ImGui_ImplSDLRenderer3_Shutdown); auto imgui_sdlrenderer_scope = std::async(std::launch::deferred, &ImGui_ImplSDLRenderer3_Shutdown);
std::unique_ptr<Screen> screen = std::make_unique<StartScreen>();
bool quit = false; bool quit = false;
while (!quit) { while (!quit) {
SDL_Event event; SDL_Event event;
@ -68,7 +72,12 @@ int main(int argc, char** argv) {
ImGui_ImplSDL3_NewFrame(); ImGui_ImplSDL3_NewFrame();
ImGui::NewFrame(); ImGui::NewFrame();
ImGui::ShowDemoWindow(); //ImGui::ShowDemoWindow();
Screen* ret_screen = screen->poll(quit);
if (ret_screen != nullptr) {
screen.reset(ret_screen);
}
ImGui::Render(); ImGui::Render();
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData());

17
src/main_screen.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "./main_screen.hpp"
#include <imgui/imgui.h>
#include <memory>
MainScreen::MainScreen(std::string save_path) {
}
Screen* MainScreen::poll(bool& quit) {
bool open = !quit;
ImGui::ShowDemoWindow(&open);
quit = !open;
return nullptr;
}

15
src/main_screen.hpp Normal file
View File

@ -0,0 +1,15 @@
#pragma once
#include "./screen.hpp"
#include <string>
struct MainScreen final : public Screen {
MainScreen(std::string save_path);
~MainScreen(void) = default;
// return nullptr if not next
// sets bool quit to true if exit
Screen* poll(bool&) override;
};

10
src/screen.hpp Normal file
View File

@ -0,0 +1,10 @@
#pragma once
struct Screen {
virtual ~Screen(void) = default;
// return nullptr if not next
// sets bool quit to true if exit
virtual Screen* poll(bool& quit) = 0;
};

23
src/start_screen.cpp Normal file
View File

@ -0,0 +1,23 @@
#include "./start_screen.hpp"
#include "./main_screen.hpp"
#include <memory>
StartScreen::StartScreen(void) {
}
Screen* StartScreen::poll(bool&) {
// TODO: imgui tox profile selector?
// +------------------------
// | +------+ +--------
// | | ICON | | fileselector/dropdown?
// | | | | password input
// | +------+ +--------
// +------------------------
auto new_screen = std::make_unique<MainScreen>("tomato.tox");
return new_screen.release();
}

13
src/start_screen.hpp Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#include "./screen.hpp"
struct StartScreen final : public Screen {
StartScreen(void);
~StartScreen(void) = default;
// return nullptr if not next
// sets bool quit to true if exit
Screen* poll(bool&) override;
};