mirror of
https://github.com/obsqrbtz/clrsync.git
synced 2026-04-09 12:37:41 +03:00
chore: refactor
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "gui/views/about_window.hpp"
|
||||
#include "core/common/version.hpp"
|
||||
#include "gui/helpers/imgui_helpers.hpp"
|
||||
#include "gui/widgets/colors.hpp"
|
||||
#include "imgui.h"
|
||||
|
||||
about_window::about_window()
|
||||
@@ -22,14 +22,14 @@ void about_window::render(const clrsync::core::palette &pal)
|
||||
const char *title = "clrsync";
|
||||
const float title_size = ImGui::CalcTextSize(title).x;
|
||||
ImGui::SetCursorPosX((window_width - title_size) * 0.5f);
|
||||
ImVec4 title_color = palette_utils::get_color(pal, "info", "accent");
|
||||
ImVec4 title_color = clrsync::gui::widgets::palette_color(pal, "info", "accent");
|
||||
ImGui::TextColored(title_color, "%s", title);
|
||||
ImGui::PopFont();
|
||||
|
||||
std::string version = "Version " + clrsync::core::version_string();
|
||||
const float version_size = ImGui::CalcTextSize(version.c_str()).x;
|
||||
ImGui::SetCursorPosX((window_width - version_size) * 0.5f);
|
||||
ImVec4 subtitle_color = palette_utils::get_color(pal, "editor_inactive", "foreground");
|
||||
ImVec4 subtitle_color = clrsync::gui::widgets::palette_color(pal, "editor_inactive", "foreground");
|
||||
ImGui::TextColored(subtitle_color, "%s", version.c_str());
|
||||
|
||||
ImGui::Spacing();
|
||||
@@ -79,7 +79,7 @@ void about_window::render(const clrsync::core::palette &pal)
|
||||
ImGui::Separator();
|
||||
ImGui::Spacing();
|
||||
|
||||
ImVec4 license_color = palette_utils::get_color(pal, "editor_inactive", "foreground");
|
||||
ImVec4 license_color = clrsync::gui::widgets::palette_color(pal, "editor_inactive", "foreground");
|
||||
ImGui::TextColored(license_color, "MIT License");
|
||||
ImGui::TextWrapped(
|
||||
"Copyright (c) 2025 Daniel Dada\n\n"
|
||||
@@ -93,4 +93,4 @@ void about_window::render(const clrsync::core::palette &pal)
|
||||
"copies or substantial portions of the Software.");
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#include "color_scheme_editor.hpp"
|
||||
#include "gui/controllers/theme_applier.hpp"
|
||||
#include "gui/helpers/imgui_helpers.hpp"
|
||||
#include "gui/widgets/dialogs.hpp"
|
||||
#include "gui/widgets/palette_selector.hpp"
|
||||
#include "gui/widgets/input_dialog.hpp"
|
||||
#include "gui/widgets/action_buttons.hpp"
|
||||
#include "imgui.h"
|
||||
#include "settings_window.hpp"
|
||||
#include "template_editor.hpp"
|
||||
#include <iostream>
|
||||
#include <ranges>
|
||||
|
||||
color_scheme_editor::color_scheme_editor()
|
||||
{
|
||||
@@ -20,6 +22,8 @@ color_scheme_editor::color_scheme_editor()
|
||||
{
|
||||
std::cout << "WARNING: No palette loaded, skipping theme application\n";
|
||||
}
|
||||
|
||||
setup_widgets();
|
||||
}
|
||||
|
||||
void color_scheme_editor::notify_palette_changed()
|
||||
@@ -78,102 +82,22 @@ void color_scheme_editor::render_controls()
|
||||
ImGui::Text("Palette:");
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::SetNextItemWidth(200.0f);
|
||||
if (ImGui::BeginCombo("##scheme", current.name().c_str()))
|
||||
{
|
||||
for (const auto &name : palettes | std::views::keys)
|
||||
{
|
||||
const bool selected = current.name() == name;
|
||||
if (ImGui::Selectable(name.c_str(), selected))
|
||||
{
|
||||
m_controller.select_palette(name);
|
||||
apply_themes();
|
||||
}
|
||||
if (selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Select a color palette to edit");
|
||||
m_palette_selector.render(m_controller, 200.0f);
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 8);
|
||||
|
||||
static char new_palette_name_buf[128] = "";
|
||||
if (ImGui::Button(" + New "))
|
||||
{
|
||||
new_palette_name_buf[0] = 0;
|
||||
ImGui::OpenPopup("New Palette");
|
||||
m_new_palette_dialog.open("New Palette", "Enter a name for the new palette:", "Palette name...");
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Create a new palette");
|
||||
|
||||
if (ImGui::BeginPopupModal("New Palette", nullptr, ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
ImGui::Text("Enter a name for the new palette:");
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::SetNextItemWidth(250);
|
||||
ImGui::InputTextWithHint("##new_palette_input", "Palette name...", new_palette_name_buf,
|
||||
IM_ARRAYSIZE(new_palette_name_buf));
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
ImGui::Spacing();
|
||||
|
||||
bool can_create = strlen(new_palette_name_buf) > 0;
|
||||
|
||||
if (!can_create)
|
||||
ImGui::BeginDisabled();
|
||||
|
||||
if (ImGui::Button("Create", ImVec2(120, 0)))
|
||||
{
|
||||
m_controller.create_palette(new_palette_name_buf);
|
||||
m_controller.select_palette(new_palette_name_buf);
|
||||
apply_themes();
|
||||
new_palette_name_buf[0] = 0;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
if (!can_create)
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Cancel", ImVec2(120, 0)))
|
||||
{
|
||||
new_palette_name_buf[0] = 0;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
m_new_palette_dialog.render();
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(" Save "))
|
||||
{
|
||||
m_controller.save_current_palette();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Save current palette to file");
|
||||
|
||||
ImGui::SameLine();
|
||||
auto error = palette_utils::get_color(current, "error");
|
||||
auto error_hover = ImVec4(error.x * 1.1f, error.y * 1.1f, error.z * 1.1f, error.w);
|
||||
auto error_active = ImVec4(error.x * 0.8f, error.y * 0.8f, error.z * 0.8f, error.w);
|
||||
auto on_error = palette_utils::get_color(current, "on_error");
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, error);
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, error_hover);
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, error_active);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, on_error);
|
||||
if (ImGui::Button(" Delete "))
|
||||
{
|
||||
m_show_delete_confirmation = true;
|
||||
}
|
||||
ImGui::PopStyleColor(4);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Delete current palette");
|
||||
m_action_buttons.render(current);
|
||||
|
||||
if (m_show_delete_confirmation)
|
||||
{
|
||||
@@ -181,21 +105,47 @@ void color_scheme_editor::render_controls()
|
||||
m_show_delete_confirmation = false;
|
||||
}
|
||||
|
||||
palette_utils::render_delete_confirmation_popup("Delete Palette?", current.name(), "palette",
|
||||
clrsync::gui::widgets::delete_confirmation_dialog("Delete Palette?", current.name(), "palette",
|
||||
current, [this]() {
|
||||
m_controller.delete_current_palette();
|
||||
apply_themes();
|
||||
});
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 16);
|
||||
|
||||
if (ImGui::Button(" Apply Theme "))
|
||||
{
|
||||
m_controller.apply_current_theme();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Apply current palette to all enabled templates");
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
void color_scheme_editor::setup_widgets()
|
||||
{
|
||||
m_palette_selector.set_on_selection_changed([this](const std::string &name) {
|
||||
m_controller.select_palette(name);
|
||||
apply_themes();
|
||||
});
|
||||
|
||||
m_new_palette_dialog.set_on_submit([this](const std::string &name) {
|
||||
m_controller.create_palette(name);
|
||||
m_controller.select_palette(name);
|
||||
apply_themes();
|
||||
});
|
||||
|
||||
m_action_buttons.add_button({
|
||||
" Save ",
|
||||
"Save current palette to file",
|
||||
[this]() { m_controller.save_current_palette(); }
|
||||
});
|
||||
|
||||
m_action_buttons.add_button({
|
||||
" Delete ",
|
||||
"Delete current palette",
|
||||
[this]() { m_show_delete_confirmation = true; },
|
||||
true,
|
||||
true
|
||||
});
|
||||
|
||||
m_action_buttons.add_button({
|
||||
" Apply Theme ",
|
||||
"Apply current palette to all enabled templates",
|
||||
[this]() { m_controller.apply_current_theme(); }
|
||||
});
|
||||
|
||||
m_action_buttons.set_spacing(16.0f);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include "gui/controllers/palette_controller.hpp"
|
||||
#include "gui/views/color_table_renderer.hpp"
|
||||
#include "gui/views/preview_renderer.hpp"
|
||||
#include "gui/widgets/palette_selector.hpp"
|
||||
#include "gui/widgets/input_dialog.hpp"
|
||||
#include "gui/widgets/action_buttons.hpp"
|
||||
|
||||
class template_editor;
|
||||
class settings_window;
|
||||
@@ -32,6 +35,7 @@ class color_scheme_editor
|
||||
void render_controls();
|
||||
void apply_themes();
|
||||
void notify_palette_changed();
|
||||
void setup_widgets();
|
||||
|
||||
palette_controller m_controller;
|
||||
color_table_renderer m_color_table;
|
||||
@@ -39,6 +43,10 @@ class color_scheme_editor
|
||||
template_editor *m_template_editor{nullptr};
|
||||
settings_window *m_settings_window{nullptr};
|
||||
bool m_show_delete_confirmation{false};
|
||||
|
||||
clrsync::gui::widgets::palette_selector m_palette_selector;
|
||||
clrsync::gui::widgets::input_dialog m_new_palette_dialog;
|
||||
clrsync::gui::widgets::action_buttons m_action_buttons;
|
||||
};
|
||||
|
||||
#endif // CLRSYNC_GUI_COLOR_SCHEME_EDITOR_HPP
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "gui/views/color_table_renderer.hpp"
|
||||
#include "gui/helpers/imgui_helpers.hpp"
|
||||
#include "gui/widgets/colors.hpp"
|
||||
#include "imgui.h"
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
@@ -36,7 +36,7 @@ void color_table_renderer::render_color_row(const std::string &name,
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
const float key_col_width = ImGui::GetContentRegionAvail().x;
|
||||
|
||||
ImVec4 text_color = palette_utils::get_color(current, "info", "accent");
|
||||
ImVec4 text_color = clrsync::gui::widgets::palette_color(current, "info", "accent");
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, text_color);
|
||||
const bool copied = ImGui::Selectable(name.c_str(), false, 0, ImVec2(key_col_width, 0.0f));
|
||||
ImGui::PopStyleColor();
|
||||
@@ -107,7 +107,7 @@ void color_table_renderer::render(const clrsync::core::palette ¤t,
|
||||
{
|
||||
if (current.colors().empty())
|
||||
{
|
||||
ImVec4 warning_color = palette_utils::get_color(current, "warning", "accent");
|
||||
ImVec4 warning_color = clrsync::gui::widgets::palette_color(current, "warning", "accent");
|
||||
ImGui::TextColored(warning_color, "No palette loaded");
|
||||
return;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ void color_table_renderer::render(const clrsync::core::palette ¤t,
|
||||
if (!has_matches)
|
||||
return;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, palette_utils::get_color(current, "accent"));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, clrsync::gui::widgets::palette_color(current, "accent"));
|
||||
bool header_open = ImGui::TreeNodeEx(title, ImGuiTreeNodeFlags_DefaultOpen |
|
||||
ImGuiTreeNodeFlags_SpanAvailWidth);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "gui/views/preview_renderer.hpp"
|
||||
#include "gui/controllers/theme_applier.hpp"
|
||||
#include "gui/helpers/imgui_helpers.hpp"
|
||||
#include "gui/widgets/colors.hpp"
|
||||
#include "imgui.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -236,7 +236,7 @@ void preview_renderer::render(const clrsync::core::palette ¤t)
|
||||
{
|
||||
if (current.colors().empty())
|
||||
{
|
||||
ImVec4 error_color = palette_utils::get_color(current, "error", "accent");
|
||||
ImVec4 error_color = clrsync::gui::widgets::palette_color(current, "error", "accent");
|
||||
ImGui::TextColored(error_color, "Current palette is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#include "gui/views/settings_window.hpp"
|
||||
#include "core/common/error.hpp"
|
||||
#include "core/config/config.hpp"
|
||||
#include "gui/helpers/imgui_helpers.hpp"
|
||||
#include "gui/platform/file_browser.hpp"
|
||||
#include "gui/platform/font_loader.hpp"
|
||||
#include "gui/widgets/colors.hpp"
|
||||
#include "gui/ui_manager.hpp"
|
||||
#include "imgui.h"
|
||||
#include <cstring>
|
||||
|
||||
settings_window::settings_window()
|
||||
: m_font_size(14), m_selected_font_idx(0), m_settings_changed(false), m_current_tab(0)
|
||||
settings_window::settings_window(clrsync::gui::ui_manager* ui_mgr)
|
||||
: m_font_size(14), m_selected_font_idx(0), m_settings_changed(false), m_current_tab(0),
|
||||
m_ui_manager(ui_mgr)
|
||||
{
|
||||
m_default_theme[0] = '\0';
|
||||
m_palettes_path[0] = '\0';
|
||||
m_font[0] = '\0';
|
||||
|
||||
font_loader loader;
|
||||
m_available_fonts = loader.get_system_fonts();
|
||||
if (m_ui_manager)
|
||||
m_available_fonts = m_ui_manager->get_system_fonts();
|
||||
|
||||
load_settings();
|
||||
}
|
||||
@@ -145,10 +145,14 @@ void settings_window::apply_settings()
|
||||
return;
|
||||
}
|
||||
|
||||
font_loader fn_loader;
|
||||
auto font = fn_loader.load_font(m_font, m_font_size);
|
||||
if (font)
|
||||
ImGui::GetIO().FontDefault = font;
|
||||
if (m_ui_manager)
|
||||
{
|
||||
if (!m_ui_manager->reload_font(m_font, m_font_size))
|
||||
{
|
||||
m_error_message = "Failed to load font: " + std::string(m_font);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_error_message.clear();
|
||||
m_settings_changed = false;
|
||||
@@ -158,7 +162,7 @@ void settings_window::render_general_tab()
|
||||
{
|
||||
ImGui::Spacing();
|
||||
|
||||
auto accent_color = palette_utils::get_color(m_current_palette, "accent");
|
||||
auto accent_color = clrsync::gui::widgets::palette_color(m_current_palette, "accent");
|
||||
ImGui::TextColored(accent_color, "Theme Settings");
|
||||
ImGui::Separator();
|
||||
ImGui::Spacing();
|
||||
@@ -186,7 +190,7 @@ void settings_window::render_general_tab()
|
||||
if (ImGui::Button("Browse"))
|
||||
{
|
||||
std::string selected_path =
|
||||
file_dialogs::select_folder_dialog("Select Palettes Directory", m_palettes_path);
|
||||
m_ui_manager->select_folder_dialog("Select Palettes Directory", m_palettes_path);
|
||||
if (!selected_path.empty())
|
||||
{
|
||||
strncpy(m_palettes_path, selected_path.c_str(), sizeof(m_palettes_path) - 1);
|
||||
@@ -200,7 +204,7 @@ void settings_window::render_appearance_tab()
|
||||
{
|
||||
ImGui::Spacing();
|
||||
|
||||
auto accent_color = palette_utils::get_color(m_current_palette, "accent");
|
||||
auto accent_color = clrsync::gui::widgets::palette_color(m_current_palette, "accent");
|
||||
ImGui::TextColored(accent_color, "Font Settings");
|
||||
ImGui::Separator();
|
||||
ImGui::Spacing();
|
||||
@@ -254,8 +258,8 @@ void settings_window::render_status_messages()
|
||||
{
|
||||
ImGui::Spacing();
|
||||
|
||||
auto error_bg_color = palette_utils::get_color(m_current_palette, "error");
|
||||
auto error_text_color = palette_utils::get_color(m_current_palette, "on_error");
|
||||
auto error_bg_color = clrsync::gui::widgets::palette_color(m_current_palette, "error");
|
||||
auto error_text_color = clrsync::gui::widgets::palette_color(m_current_palette, "on_error");
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, error_bg_color);
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, error_bg_color);
|
||||
@@ -375,4 +379,4 @@ void settings_window::reset_to_defaults()
|
||||
m_font_size = 14;
|
||||
m_error_message.clear();
|
||||
m_settings_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,15 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace clrsync::gui
|
||||
{
|
||||
class ui_manager;
|
||||
}
|
||||
|
||||
class settings_window
|
||||
{
|
||||
public:
|
||||
settings_window();
|
||||
settings_window(clrsync::gui::ui_manager* ui_mgr);
|
||||
void render();
|
||||
void show()
|
||||
{
|
||||
@@ -55,6 +60,7 @@ class settings_window
|
||||
int m_current_tab;
|
||||
|
||||
clrsync::core::palette m_current_palette;
|
||||
clrsync::gui::ui_manager* m_ui_manager;
|
||||
};
|
||||
|
||||
#endif // CLRSYNC_GUI_SETTINGS_WINDOW_HPP
|
||||
@@ -3,8 +3,9 @@
|
||||
#include "core/config/config.hpp"
|
||||
#include "core/palette/color_keys.hpp"
|
||||
#include "core/theme/theme_template.hpp"
|
||||
#include "gui/helpers/imgui_helpers.hpp"
|
||||
#include "gui/platform/file_browser.hpp"
|
||||
#include "gui/widgets/colors.hpp"
|
||||
#include "gui/widgets/dialogs.hpp"
|
||||
#include "gui/ui_manager.hpp"
|
||||
#include "imgui.h"
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
@@ -18,7 +19,8 @@ const std::vector<std::string> COLOR_FORMATS = {
|
||||
"l", "hsl", "hsla"};
|
||||
}
|
||||
|
||||
template_editor::template_editor() : m_template_name("new_template")
|
||||
template_editor::template_editor(clrsync::gui::ui_manager* ui_mgr)
|
||||
: m_template_name("new_template"), m_ui_manager(ui_mgr)
|
||||
{
|
||||
m_autocomplete_bg_color = ImVec4(0.12f, 0.12f, 0.15f, 0.98f);
|
||||
m_autocomplete_border_color = ImVec4(0.4f, 0.4f, 0.45f, 1.0f);
|
||||
@@ -56,7 +58,7 @@ void template_editor::apply_current_palette(const clrsync::core::palette &pal)
|
||||
if (colors.empty())
|
||||
return;
|
||||
auto get_color_u32 = [&](const std::string &key, const std::string &fallback = "") -> uint32_t {
|
||||
return palette_utils::get_color_u32(pal, key, fallback);
|
||||
return clrsync::gui::widgets::palette_color_u32(pal, key, fallback);
|
||||
};
|
||||
|
||||
auto palette = m_editor.GetPalette();
|
||||
@@ -99,14 +101,14 @@ void template_editor::apply_current_palette(const clrsync::core::palette &pal)
|
||||
|
||||
m_editor.SetPalette(palette);
|
||||
|
||||
m_autocomplete_bg_color = palette_utils::get_color(pal, "surface", "background");
|
||||
m_autocomplete_bg_color = clrsync::gui::widgets::palette_color(pal, "surface", "background");
|
||||
m_autocomplete_bg_color.w = 0.98f;
|
||||
m_autocomplete_border_color = palette_utils::get_color(pal, "border", "surface_variant");
|
||||
m_autocomplete_selected_color = palette_utils::get_color(pal, "accent", "surface_variant");
|
||||
m_autocomplete_text_color = palette_utils::get_color(pal, "on_surface", "foreground");
|
||||
m_autocomplete_selected_text_color = palette_utils::get_color(pal, "on_surface", "foreground");
|
||||
m_autocomplete_border_color = clrsync::gui::widgets::palette_color(pal, "border", "surface_variant");
|
||||
m_autocomplete_selected_color = clrsync::gui::widgets::palette_color(pal, "accent", "surface_variant");
|
||||
m_autocomplete_text_color = clrsync::gui::widgets::palette_color(pal, "on_surface", "foreground");
|
||||
m_autocomplete_selected_text_color = clrsync::gui::widgets::palette_color(pal, "on_surface", "foreground");
|
||||
m_autocomplete_dim_text_color =
|
||||
palette_utils::get_color(pal, "on_surface_variant", "editor_inactive");
|
||||
clrsync::gui::widgets::palette_color(pal, "on_surface_variant", "editor_inactive");
|
||||
}
|
||||
|
||||
void template_editor::update_autocomplete_suggestions()
|
||||
@@ -358,7 +360,7 @@ void template_editor::render()
|
||||
m_show_delete_confirmation = false;
|
||||
}
|
||||
|
||||
palette_utils::render_delete_confirmation_popup(
|
||||
clrsync::gui::widgets::delete_confirmation_dialog(
|
||||
"Delete Template?", m_template_name, "template", m_current_palette, [this]() {
|
||||
bool success = m_template_controller.remove_template(m_template_name);
|
||||
if (success)
|
||||
@@ -403,10 +405,10 @@ void template_editor::render_controls()
|
||||
if (m_is_editing_existing)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
auto error = palette_utils::get_color(m_current_palette, "error");
|
||||
auto error = clrsync::gui::widgets::palette_color(m_current_palette, "error");
|
||||
auto error_hover = ImVec4(error.x * 1.1f, error.y * 1.1f, error.z * 1.1f, error.w);
|
||||
auto error_active = ImVec4(error.x * 0.8f, error.y * 0.8f, error.z * 0.8f, error.w);
|
||||
auto on_error = palette_utils::get_color(m_current_palette, "on_error");
|
||||
auto on_error = clrsync::gui::widgets::palette_color(m_current_palette, "on_error");
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, error);
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, error_hover);
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, error_active);
|
||||
@@ -426,9 +428,9 @@ void template_editor::render_controls()
|
||||
bool enabled_changed = false;
|
||||
if (m_enabled)
|
||||
{
|
||||
ImVec4 success_color = palette_utils::get_color(m_current_palette, "success", "accent");
|
||||
ImVec4 success_color = clrsync::gui::widgets::palette_color(m_current_palette, "success", "accent");
|
||||
ImVec4 success_on_color =
|
||||
palette_utils::get_color(m_current_palette, "on_success", "on_surface");
|
||||
clrsync::gui::widgets::palette_color(m_current_palette, "on_success", "on_surface");
|
||||
ImVec4 success_hover =
|
||||
ImVec4(success_color.x * 1.2f, success_color.y * 1.2f, success_color.z * 1.2f, 0.6f);
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg,
|
||||
@@ -438,9 +440,9 @@ void template_editor::render_controls()
|
||||
}
|
||||
else
|
||||
{
|
||||
ImVec4 error_color = palette_utils::get_color(m_current_palette, "error", "accent");
|
||||
ImVec4 error_color = clrsync::gui::widgets::palette_color(m_current_palette, "error", "accent");
|
||||
ImVec4 error_on_color =
|
||||
palette_utils::get_color(m_current_palette, "on_error", "on_surface");
|
||||
clrsync::gui::widgets::palette_color(m_current_palette, "on_error", "on_surface");
|
||||
ImVec4 error_hover =
|
||||
ImVec4(error_color.x * 1.2f, error_color.y * 1.2f, error_color.z * 1.2f, 0.6f);
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg,
|
||||
@@ -503,7 +505,7 @@ void template_editor::render_controls()
|
||||
if (ImGui::Button("Browse##input"))
|
||||
{
|
||||
std::string selected_path =
|
||||
file_dialogs::open_file_dialog("Select Template File", m_input_path);
|
||||
m_ui_manager->open_file_dialog("Select Template File", m_input_path);
|
||||
if (!selected_path.empty())
|
||||
{
|
||||
m_input_path = selected_path;
|
||||
@@ -540,7 +542,7 @@ void template_editor::render_controls()
|
||||
if (ImGui::Button("Browse##output"))
|
||||
{
|
||||
std::string selected_path =
|
||||
file_dialogs::save_file_dialog("Select Output File", m_output_path);
|
||||
m_ui_manager->save_file_dialog("Select Output File", m_output_path);
|
||||
if (!selected_path.empty())
|
||||
{
|
||||
m_output_path = selected_path;
|
||||
@@ -575,7 +577,7 @@ void template_editor::render_controls()
|
||||
if (!m_validation_error.empty())
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImVec4 error_color = palette_utils::get_color(m_current_palette, "error", "accent");
|
||||
ImVec4 error_color = clrsync::gui::widgets::palette_color(m_current_palette, "error", "accent");
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, error_color);
|
||||
ImGui::TextWrapped("%s", m_validation_error.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
@@ -588,7 +590,7 @@ void template_editor::render_editor()
|
||||
|
||||
if (!m_is_editing_existing)
|
||||
{
|
||||
ImVec4 success_color = palette_utils::get_color(m_current_palette, "success", "accent");
|
||||
ImVec4 success_color = clrsync::gui::widgets::palette_color(m_current_palette, "success", "accent");
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, success_color);
|
||||
ImGui::Text(" New Template");
|
||||
ImGui::PopStyleColor();
|
||||
@@ -608,7 +610,7 @@ void template_editor::render_editor()
|
||||
if (m_has_unsaved_changes)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
ImVec4 warning_color = palette_utils::get_color(m_current_palette, "warning", "accent");
|
||||
ImVec4 warning_color = clrsync::gui::widgets::palette_color(m_current_palette, "warning", "accent");
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, warning_color);
|
||||
ImGui::Text("(unsaved)");
|
||||
ImGui::PopStyleColor();
|
||||
@@ -697,7 +699,7 @@ void template_editor::render_template_list()
|
||||
|
||||
if (!m_is_editing_existing)
|
||||
{
|
||||
ImVec4 success_color = palette_utils::get_color(m_current_palette, "success", "accent");
|
||||
ImVec4 success_color = clrsync::gui::widgets::palette_color(m_current_palette, "success", "accent");
|
||||
ImVec4 success_bg = ImVec4(success_color.x, success_color.y, success_color.z, 0.5f);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, success_color);
|
||||
ImGui::PushStyleColor(ImGuiCol_Header, success_bg);
|
||||
@@ -714,7 +716,7 @@ void template_editor::render_template_list()
|
||||
|
||||
if (!tmpl.enabled())
|
||||
{
|
||||
ImVec4 disabled_color = palette_utils::get_color(
|
||||
ImVec4 disabled_color = clrsync::gui::widgets::palette_color(
|
||||
m_current_palette, "on_surface_variant", "editor_inactive");
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, disabled_color);
|
||||
}
|
||||
@@ -951,4 +953,4 @@ void template_editor::delete_template()
|
||||
void template_editor::refresh_templates()
|
||||
{
|
||||
m_template_controller.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,15 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace clrsync::gui
|
||||
{
|
||||
class ui_manager;
|
||||
}
|
||||
|
||||
class template_editor
|
||||
{
|
||||
public:
|
||||
template_editor();
|
||||
template_editor(clrsync::gui::ui_manager* ui_mgr);
|
||||
void render();
|
||||
void apply_current_palette(const clrsync::core::palette &pal);
|
||||
|
||||
@@ -62,6 +67,7 @@ class template_editor
|
||||
ImVec4 m_autocomplete_dim_text_color;
|
||||
|
||||
clrsync::core::palette m_current_palette;
|
||||
clrsync::gui::ui_manager* m_ui_manager;
|
||||
};
|
||||
|
||||
#endif // CLRSYNC_GUI_TEMPLATE_EDITOR_HPP
|
||||
Reference in New Issue
Block a user