forked from Green-Sky/tomato
make main window injectable + start settings window
This commit is contained in:
parent
2a5937652e
commit
bc090bdaa8
@ -52,6 +52,9 @@ add_executable(tomato
|
|||||||
./send_image_popup.hpp
|
./send_image_popup.hpp
|
||||||
./send_image_popup.cpp
|
./send_image_popup.cpp
|
||||||
|
|
||||||
|
./settings_window.hpp
|
||||||
|
./settings_window.cpp
|
||||||
|
|
||||||
./chat_gui4.hpp
|
./chat_gui4.hpp
|
||||||
./chat_gui4.cpp
|
./chat_gui4.cpp
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,8 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, std::string save_path, std::stri
|
|||||||
mmil(rmm),
|
mmil(rmm),
|
||||||
tam(rmm, cr, conf),
|
tam(rmm, cr, conf),
|
||||||
sdlrtu(renderer_),
|
sdlrtu(renderer_),
|
||||||
cg(conf, rmm, cr, sdlrtu)
|
cg(conf, rmm, cr, sdlrtu),
|
||||||
|
sw(conf)
|
||||||
{
|
{
|
||||||
tel.subscribeAll(tc);
|
tel.subscribeAll(tc);
|
||||||
|
|
||||||
@ -87,11 +88,29 @@ Screen* MainScreen::poll(bool& quit) {
|
|||||||
|
|
||||||
tam.iterate();
|
tam.iterate();
|
||||||
|
|
||||||
|
// HACK: render the tomato main window first, with proper flags set.
|
||||||
|
// flags need to be set the first time begin() is called.
|
||||||
|
// and plugins are run before the main cg is run.
|
||||||
|
{
|
||||||
|
// TODO: maybe render cg earlier? or move the main window out of cg?
|
||||||
|
constexpr auto bg_window_flags =
|
||||||
|
ImGuiWindowFlags_NoDecoration |
|
||||||
|
ImGuiWindowFlags_NoMove |
|
||||||
|
ImGuiWindowFlags_NoResize |
|
||||||
|
ImGuiWindowFlags_NoSavedSettings |
|
||||||
|
ImGuiWindowFlags_MenuBar |
|
||||||
|
ImGuiWindowFlags_NoBringToFrontOnFocus;
|
||||||
|
|
||||||
|
ImGui::Begin("tomato", nullptr, bg_window_flags);
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
pm.tick(time_delta);
|
pm.tick(time_delta);
|
||||||
|
|
||||||
mts.iterate();
|
mts.iterate();
|
||||||
|
|
||||||
cg.render();
|
cg.render();
|
||||||
|
sw.render();
|
||||||
|
|
||||||
if constexpr (false) {
|
if constexpr (false) {
|
||||||
ImGui::ShowDemoWindow();
|
ImGui::ShowDemoWindow();
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "./sdlrenderer_texture_uploader.hpp"
|
#include "./sdlrenderer_texture_uploader.hpp"
|
||||||
#include "./chat_gui4.hpp"
|
#include "./chat_gui4.hpp"
|
||||||
|
#include "./settings_window.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -57,6 +58,7 @@ struct MainScreen final : public Screen {
|
|||||||
//OpenGLTextureUploader ogltu;
|
//OpenGLTextureUploader ogltu;
|
||||||
|
|
||||||
ChatGui4 cg;
|
ChatGui4 cg;
|
||||||
|
SettingsWindow sw;
|
||||||
|
|
||||||
MainScreen(SDL_Renderer* renderer_, std::string save_path, std::string save_password, std::vector<std::string> plugins);
|
MainScreen(SDL_Renderer* renderer_, std::string save_path, std::string save_password, std::vector<std::string> plugins);
|
||||||
~MainScreen(void);
|
~MainScreen(void);
|
||||||
|
35
src/settings_window.cpp
Normal file
35
src/settings_window.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include "./settings_window.hpp"
|
||||||
|
|
||||||
|
#include <imgui/imgui.h>
|
||||||
|
#include <imgui/misc/cpp/imgui_stdlib.h>
|
||||||
|
|
||||||
|
SettingsWindow::SettingsWindow(ConfigModelI& conf) : _conf(conf) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWindow::render(void) {
|
||||||
|
{ // main window menubar injection
|
||||||
|
// assumes the window "tomato" was rendered already by cg
|
||||||
|
if (ImGui::Begin("tomato")) {
|
||||||
|
if (ImGui::BeginMenuBar()) {
|
||||||
|
ImGui::Separator();
|
||||||
|
if (ImGui::BeginMenu("Settings")) {
|
||||||
|
if (ImGui::MenuItem("show settings window")) {
|
||||||
|
_show_window = true;
|
||||||
|
}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_show_window) {
|
||||||
|
if (ImGui::Begin("Settings", &_show_window)) {
|
||||||
|
ImGui::Text("Settings here sldjflsadfs");
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
14
src/settings_window.hpp
Normal file
14
src/settings_window.hpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct ConfigModelI;
|
||||||
|
|
||||||
|
class SettingsWindow {
|
||||||
|
bool _show_window {false};
|
||||||
|
ConfigModelI& _conf;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SettingsWindow(ConfigModelI& conf);
|
||||||
|
|
||||||
|
void render(void);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user