mirror of
https://github.com/obsqrbtz/clrsync.git
synced 2026-04-08 20:19:04 +03:00
fix: minor ui fixes
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
{
|
{
|
||||||
|
|
||||||
const std::string GIT_SEMVER = "0.1.7+git.g4ada2c4";
|
const std::string GIT_SEMVER = "0.1.7+git.g8112096";
|
||||||
|
|
||||||
const std::string version_string();
|
const std::string version_string();
|
||||||
} // namespace clrsync::core
|
} // namespace clrsync::core
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ Result<void> config::save_config_value(const std::string §ion, const std::st
|
|||||||
if (!m_temp_file)
|
if (!m_temp_file)
|
||||||
{
|
{
|
||||||
m_temp_file = std::make_unique<clrsync::core::io::toml_file>(m_temp_config_path);
|
m_temp_file = std::make_unique<clrsync::core::io::toml_file>(m_temp_config_path);
|
||||||
m_temp_file->parse();
|
(void)m_temp_file->parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_temp_file->set_value(section, key, value);
|
m_temp_file->set_value(section, key, value);
|
||||||
@@ -347,7 +347,7 @@ Result<void> config::remove_template(const std::string &key)
|
|||||||
if (!m_temp_file)
|
if (!m_temp_file)
|
||||||
{
|
{
|
||||||
m_temp_file = std::make_unique<clrsync::core::io::toml_file>(m_temp_config_path);
|
m_temp_file = std::make_unique<clrsync::core::io::toml_file>(m_temp_config_path);
|
||||||
m_temp_file->parse();
|
(void)m_temp_file->parse();
|
||||||
}
|
}
|
||||||
m_temp_file->remove_section("templates." + key);
|
m_temp_file->remove_section("templates." + key);
|
||||||
return m_temp_file->save_file();
|
return m_temp_file->save_file();
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ void main_layout::render_menu_bar()
|
|||||||
ImGui::Begin("##TopBar", nullptr, flags);
|
ImGui::Begin("##TopBar", nullptr, flags);
|
||||||
|
|
||||||
ImGuiStyle &style = ImGui::GetStyle();
|
ImGuiStyle &style = ImGui::GetStyle();
|
||||||
|
style.FrameBorderSize = 1.0f;
|
||||||
|
|
||||||
const char *settings_label = "Settings";
|
const char *settings_label = "Settings";
|
||||||
const char *about_label = "About";
|
const char *about_label = "About";
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ void about_window::render(const clrsync::core::palette &pal)
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
ImGui::Text("Links:");
|
|
||||||
|
|
||||||
constexpr float button_width = 200.0f;
|
constexpr float button_width = 200.0f;
|
||||||
float spacing = ImGui::GetStyle().ItemSpacing.x;
|
float spacing = ImGui::GetStyle().ItemSpacing.x;
|
||||||
float total_width = 2.0f * button_width + spacing;
|
float total_width = 2.0f * button_width + spacing;
|
||||||
|
|||||||
@@ -114,11 +114,15 @@ void color_table_renderer::render(const clrsync::core::palette ¤t,
|
|||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8, 6));
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8, 6));
|
||||||
|
|
||||||
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::Text("Filter:");
|
ImGui::Text("Filter:");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetNextItemWidth(200);
|
ImGui::SetNextItemWidth(200);
|
||||||
bool filter_changed = ImGui::InputTextWithHint("##color_filter", "Search colors...",
|
bool filter_changed =
|
||||||
m_filter_text, sizeof(m_filter_text));
|
ImGui::InputTextWithHint("##color_filter",
|
||||||
|
"Search colors...",
|
||||||
|
m_filter_text,
|
||||||
|
sizeof(m_filter_text));
|
||||||
|
|
||||||
if (m_filter_text[0] != '\0')
|
if (m_filter_text[0] != '\0')
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
#include "gui/views/settings_window.hpp"
|
#include "gui/views/settings_window.hpp"
|
||||||
#include "core/common/error.hpp"
|
#include "core/common/error.hpp"
|
||||||
#include "core/config/config.hpp"
|
#include "core/config/config.hpp"
|
||||||
#include "gui/widgets/section_header.hpp"
|
|
||||||
#include "gui/ui_manager.hpp"
|
#include "gui/ui_manager.hpp"
|
||||||
|
#include "gui/widgets/section_header.hpp"
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
settings_window::settings_window(clrsync::gui::ui_manager* ui_mgr)
|
settings_window::settings_window(clrsync::gui::ui_manager *ui_mgr) : m_ui_manager(ui_mgr)
|
||||||
: m_ui_manager(ui_mgr)
|
|
||||||
{
|
{
|
||||||
if (m_ui_manager)
|
if (m_ui_manager)
|
||||||
m_available_fonts = m_ui_manager->get_system_fonts();
|
m_available_fonts = m_ui_manager->get_system_fonts();
|
||||||
@@ -17,7 +16,7 @@ settings_window::settings_window(clrsync::gui::ui_manager* ui_mgr)
|
|||||||
|
|
||||||
void settings_window::setup_widgets()
|
void settings_window::setup_widgets()
|
||||||
{
|
{
|
||||||
m_form.set_path_browse_callback([this](const std::string& current_path) -> std::string {
|
m_form.set_path_browse_callback([this](const std::string ¤t_path) -> std::string {
|
||||||
if (m_ui_manager)
|
if (m_ui_manager)
|
||||||
return m_ui_manager->select_folder_dialog("Select Directory", current_path);
|
return m_ui_manager->select_folder_dialog("Select Directory", current_path);
|
||||||
return "";
|
return "";
|
||||||
@@ -57,25 +56,27 @@ void settings_window::render()
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
clrsync::gui::widgets::settings_buttons_callbacks callbacks{
|
clrsync::gui::widgets::settings_buttons_callbacks callbacks{
|
||||||
.on_ok = [this]() {
|
.on_ok =
|
||||||
apply_settings();
|
[this]() {
|
||||||
if (!m_error.has_error())
|
apply_settings();
|
||||||
{
|
if (!m_error.has_error())
|
||||||
m_visible = false;
|
{
|
||||||
m_settings_changed = false;
|
m_visible = false;
|
||||||
}
|
m_settings_changed = false;
|
||||||
},
|
}
|
||||||
.on_apply = [this]() {
|
},
|
||||||
apply_settings();
|
.on_apply =
|
||||||
if (!m_error.has_error())
|
[this]() {
|
||||||
m_settings_changed = false;
|
apply_settings();
|
||||||
},
|
if (!m_error.has_error())
|
||||||
|
m_settings_changed = false;
|
||||||
|
},
|
||||||
.on_reset = [this]() { reset_to_defaults(); },
|
.on_reset = [this]() { reset_to_defaults(); },
|
||||||
.on_cancel = [this]() {
|
.on_cancel =
|
||||||
load_settings();
|
[this]() {
|
||||||
m_visible = false;
|
load_settings();
|
||||||
}
|
m_visible = false;
|
||||||
};
|
}};
|
||||||
m_buttons.render(callbacks, m_settings_changed);
|
m_buttons.render(callbacks, m_settings_changed);
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@@ -83,7 +84,7 @@ void settings_window::render()
|
|||||||
|
|
||||||
void settings_window::load_settings()
|
void settings_window::load_settings()
|
||||||
{
|
{
|
||||||
auto& cfg = clrsync::core::config::instance();
|
auto &cfg = clrsync::core::config::instance();
|
||||||
|
|
||||||
m_default_theme = cfg.default_theme();
|
m_default_theme = cfg.default_theme();
|
||||||
m_palettes_path = cfg.palettes_path();
|
m_palettes_path = cfg.palettes_path();
|
||||||
@@ -106,7 +107,7 @@ void settings_window::load_settings()
|
|||||||
|
|
||||||
void settings_window::apply_settings()
|
void settings_window::apply_settings()
|
||||||
{
|
{
|
||||||
auto& cfg = clrsync::core::config::instance();
|
auto &cfg = clrsync::core::config::instance();
|
||||||
|
|
||||||
if (m_default_theme.empty())
|
if (m_default_theme.empty())
|
||||||
{
|
{
|
||||||
@@ -176,22 +177,22 @@ void settings_window::render_general_tab()
|
|||||||
|
|
||||||
section_header("Theme Settings", m_current_palette);
|
section_header("Theme Settings", m_current_palette);
|
||||||
|
|
||||||
form_field_config theme_cfg{
|
form_field_config theme_cfg;
|
||||||
.label = "Default Theme",
|
theme_cfg.label = "Default Theme";
|
||||||
.tooltip = "The default color scheme to load on startup",
|
theme_cfg.label_width = 150.0f;
|
||||||
.field_width = -100.0f
|
theme_cfg.tooltip = "The default color scheme to load on startup";
|
||||||
};
|
theme_cfg.field_width = -100.0f;
|
||||||
if (m_form.render_text(theme_cfg, m_default_theme))
|
if (m_form.render_text(theme_cfg, m_default_theme))
|
||||||
m_settings_changed = true;
|
m_settings_changed = true;
|
||||||
|
|
||||||
section_header("Path Settings", m_current_palette);
|
section_header("Path Settings", m_current_palette);
|
||||||
|
|
||||||
form_field_config path_cfg{
|
form_field_config path_cfg;
|
||||||
.label = "Palettes Directory",
|
path_cfg.label = "Palettes Directory";
|
||||||
.tooltip = "Directory where color palettes are stored\nSupports ~ for home directory",
|
path_cfg.label_width = 150.0f;
|
||||||
.field_width = -1.0f,
|
path_cfg.tooltip = "Directory where color palettes are stored\nSupports ~ for home directory";
|
||||||
.type = field_type::path
|
path_cfg.field_width = -1.0f;
|
||||||
};
|
path_cfg.type = field_type::path;
|
||||||
if (m_form.render_path(path_cfg, m_palettes_path))
|
if (m_form.render_path(path_cfg, m_palettes_path))
|
||||||
m_settings_changed = true;
|
m_settings_changed = true;
|
||||||
}
|
}
|
||||||
@@ -202,28 +203,28 @@ void settings_window::render_appearance_tab()
|
|||||||
|
|
||||||
section_header("Font Settings", m_current_palette);
|
section_header("Font Settings", m_current_palette);
|
||||||
|
|
||||||
form_field_config font_cfg{
|
form_field_config font_cfg;
|
||||||
.label = "Font Family",
|
font_cfg.label = "Font Family";
|
||||||
.tooltip = "Select font family for the application interface",
|
font_cfg.label_width = 150.0f;
|
||||||
.field_width = -1.0f,
|
font_cfg.tooltip = "Select font family for the application interface";
|
||||||
.type = field_type::combo
|
font_cfg.field_width = -1.0f;
|
||||||
};
|
font_cfg.type = field_type::combo;
|
||||||
if (m_form.render_combo(font_cfg, m_available_fonts, m_selected_font_idx, m_font))
|
if (m_form.render_combo(font_cfg, m_available_fonts, m_selected_font_idx, m_font))
|
||||||
m_settings_changed = true;
|
m_settings_changed = true;
|
||||||
|
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
form_field_config size_cfg{
|
form_field_config size_cfg;
|
||||||
.label = "Font Size",
|
size_cfg.label = "Font Size",
|
||||||
.tooltip = "Font size for the application interface (8-48)",
|
size_cfg.label_width = 150.0f;
|
||||||
.field_width = 120.0f,
|
size_cfg.tooltip = "Font size for the application interface (8-48)";
|
||||||
.type = field_type::slider,
|
size_cfg.field_width = 120.0f;
|
||||||
.min_value = 8.0f,
|
size_cfg.type = field_type::slider;
|
||||||
.max_value = 48.0f,
|
size_cfg.min_value = 8.0f;
|
||||||
.format = "%d px",
|
size_cfg.max_value = 48.0f;
|
||||||
.show_reset = true,
|
size_cfg.format = "%d px";
|
||||||
.default_value = 14
|
size_cfg.show_reset = true;
|
||||||
};
|
size_cfg.default_value = 14;
|
||||||
if (m_form.render_slider(size_cfg, m_font_size))
|
if (m_form.render_slider(size_cfg, m_font_size))
|
||||||
m_settings_changed = true;
|
m_settings_changed = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user