chore: refactor

This commit is contained in:
2025-12-19 17:22:23 +03:00
parent 82998d688c
commit 4ada2c44ed
38 changed files with 1628 additions and 500 deletions

View File

@@ -1,17 +1,13 @@
#include <iostream>
#include <memory>
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#include "core/common/error.hpp"
#include "core/common/utils.hpp"
#include "core/config/config.hpp"
#include "core/io/toml_file.hpp"
#include "gui/backend/glfw_opengl.hpp"
#include "gui/helpers/imgui_helpers.hpp"
#include "gui/platform/font_loader.hpp"
#include "gui/layout/main_layout.hpp"
#include "gui/ui_manager.hpp"
#include "gui/views/about_window.hpp"
#include "gui/views/color_scheme_editor.hpp"
@@ -37,13 +33,12 @@ int main(int, char **)
static std::string ini_path = (base.parent_path() / "layout.ini").string();
bool first_time = !std::filesystem::exists(ini_path);
printf("GLFW Version: %s\n", glfwGetVersionString());
auto backend = clrsync::gui::backend::glfw_opengl_backend();
auto window_config = clrsync::gui::backend::window_config();
window_config.title = "clrsync";
window_config.width = 1280;
window_config.height = 720;
window_config.decorated = true;
window_config.transparent_framebuffer = true;
if (!backend.initialize(window_config))
@@ -52,14 +47,8 @@ int main(int, char **)
return 1;
}
std::cout << "GLFW runtime platform: ";
switch (glfwGetPlatform()) {
case GLFW_PLATFORM_WAYLAND: std::cout << "Wayland\n"; break;
case GLFW_PLATFORM_X11: std::cout << "X11\n"; break;
case GLFW_PLATFORM_COCOA: std::cout << "Cocoa\n"; break;
case GLFW_PLATFORM_WIN32: std::cout << "Win32\n"; break;
default: std::cout << "Unknown\n";
}
std::cout << "GLFW Version: " << backend.get_glfw_version() << std::endl;
std::cout << "GLFW runtime platform: " << backend.get_glfw_platform() << std::endl;
clrsync::gui::ui_manager ui_manager(&backend);
@@ -74,18 +63,11 @@ int main(int, char **)
return 1;
}
font_loader loader;
ImFont *font = loader.load_font(clrsync::core::config::instance().font().c_str(),
clrsync::core::config::instance().font_size());
if (font)
ImGui::GetIO().FontDefault = font;
clrsync::gui::layout::main_layout main_layout;
color_scheme_editor colorEditor;
template_editor templateEditor;
template_editor templateEditor(&ui_manager);
about_window aboutWindow;
settings_window settingsWindow;
settings_window settingsWindow(&ui_manager);
colorEditor.set_template_editor(&templateEditor);
colorEditor.set_settings_window(&settingsWindow);
@@ -96,18 +78,25 @@ int main(int, char **)
{
backend.begin_frame();
loader.push_default_font();
ui_manager.push_default_font();
ui_manager.begin_frame();
render_menu_bar(&aboutWindow, &settingsWindow);
setup_main_dockspace(first_time);
main_layout.render_menu_bar();
main_layout.setup_dockspace(first_time);
if (main_layout.should_show_about())
aboutWindow.show();
if (main_layout.should_show_settings())
settingsWindow.show();
main_layout.clear_actions();
templateEditor.render();
colorEditor.render_controls_and_colors();
colorEditor.render_preview();
aboutWindow.render(colorEditor.controller().current_palette());
settingsWindow.render();
loader.pop_font();
ui_manager.pop_font();
ui_manager.end_frame();
backend.end_frame();