forked from Green-Sky/tomato
screen concept
This commit is contained in:
parent
e92c7cbfa0
commit
3a1c15f313
@ -3,6 +3,12 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
add_executable(tomato
|
||||
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)
|
||||
|
11
src/main.cpp
11
src/main.cpp
@ -7,6 +7,8 @@
|
||||
|
||||
#include "./theme.hpp"
|
||||
|
||||
#include "./start_screen.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
@ -50,6 +52,8 @@ int main(int argc, char** argv) {
|
||||
ImGui_ImplSDLRenderer3_Init(renderer.get());
|
||||
auto imgui_sdlrenderer_scope = std::async(std::launch::deferred, &ImGui_ImplSDLRenderer3_Shutdown);
|
||||
|
||||
std::unique_ptr<Screen> screen = std::make_unique<StartScreen>();
|
||||
|
||||
bool quit = false;
|
||||
while (!quit) {
|
||||
SDL_Event event;
|
||||
@ -68,7 +72,12 @@ int main(int argc, char** argv) {
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
ImGui::ShowDemoWindow();
|
||||
//ImGui::ShowDemoWindow();
|
||||
|
||||
Screen* ret_screen = screen->poll(quit);
|
||||
if (ret_screen != nullptr) {
|
||||
screen.reset(ret_screen);
|
||||
}
|
||||
|
||||
ImGui::Render();
|
||||
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData());
|
||||
|
17
src/main_screen.cpp
Normal file
17
src/main_screen.cpp
Normal 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
15
src/main_screen.hpp
Normal 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
10
src/screen.hpp
Normal 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
23
src/start_screen.cpp
Normal 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
13
src/start_screen.hpp
Normal 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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user