✨ 新增: 添加自定义主题设置相关函数
This commit is contained in:
+28
-2
@@ -5,7 +5,26 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <imgui.h>
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
|
||||
struct LogColors {
|
||||
ImVec4 error_color = ImVec4(1.0f, 0.4f, 0.4f, 1.0f);
|
||||
ImVec4 warn_color = ImVec4(1.0f, 1.0f, 0.4f, 1.0f);
|
||||
ImVec4 info_color = ImVec4(0.4f, 1.0f, 0.4f, 1.0f);
|
||||
ImVec4 debug_color = ImVec4(0.6f, 0.6f, 1.0f, 1.0f);
|
||||
ImVec4 trace_color = ImVec4(0.8f, 0.8f, 0.8f, 1.0f);
|
||||
|
||||
void ResetToDefaults() {
|
||||
error_color = ImVec4(1.0f, 0.4f, 0.4f, 1.0f);
|
||||
warn_color = ImVec4(1.0f, 1.0f, 0.4f, 1.0f);
|
||||
info_color = ImVec4(0.4f, 1.0f, 0.4f, 1.0f);
|
||||
debug_color = ImVec4(0.6f, 0.6f, 1.0f, 1.0f);
|
||||
trace_color = ImVec4(0.8f, 0.8f, 0.8f, 1.0f);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class AppState {
|
||||
public:
|
||||
@@ -50,8 +69,12 @@ public:
|
||||
std::vector<std::string> command_history;
|
||||
int max_command_history;
|
||||
|
||||
LogColors log_colors;
|
||||
bool use_custom_log_colors = false;
|
||||
bool use_ansi_colors = true;
|
||||
bool settings_dirty;
|
||||
|
||||
|
||||
private:
|
||||
// 环境变量序列化辅助函数
|
||||
std::string SerializeEnvironmentVariables() const;
|
||||
@@ -60,8 +83,11 @@ private:
|
||||
// 编码序列化辅助函数
|
||||
std::string SerializeOutputEncoding() const;
|
||||
void DeserializeOutputEncoding(const std::string& serialized);
|
||||
// 日志颜色序列化辅助
|
||||
std::string SerializeLogColors() const;
|
||||
void DeserializeLogColors(const std::string &serialized);
|
||||
|
||||
// 新增:命令历史记录序列化辅助函数
|
||||
// 命令历史记录序列化辅助函数
|
||||
std::string SerializeCommandHistory() const;
|
||||
void DeserializeCommandHistory(const std::string& serialized);
|
||||
};
|
||||
|
||||
+74
-58
@@ -37,6 +37,7 @@
|
||||
#include "AppState.h"
|
||||
#include "TrayIcon.h"
|
||||
|
||||
|
||||
class Manager {
|
||||
public:
|
||||
// 构造函数和析构函数
|
||||
@@ -45,59 +46,68 @@ public:
|
||||
~Manager();
|
||||
|
||||
// 核心生命周期管理
|
||||
bool Initialize(); // 初始化应用程序
|
||||
void Run(); // 运行主循环
|
||||
void Shutdown(); // 关闭应用程序
|
||||
bool Initialize(); // 初始化应用程序
|
||||
void Run(); // 运行主循环
|
||||
void Shutdown(); // 关闭应用程序
|
||||
|
||||
// 托盘事件回调
|
||||
void OnTrayShowWindow(); // 托盘显示窗口事件
|
||||
void OnTrayExit(); // 托盘退出事件
|
||||
void OnTrayExit(); // 托盘退出事件
|
||||
|
||||
// 公共成员变量
|
||||
AppState m_app_state; // 应用程序状态
|
||||
AppState m_app_state; // 应用程序状态
|
||||
|
||||
private:
|
||||
// 枚举类型定义
|
||||
enum class LayoutPreset {
|
||||
Classic, // 经典布局
|
||||
Development, // 开发布局
|
||||
Monitoring // 监控布局
|
||||
Classic, // 经典布局
|
||||
Development, // 开发布局
|
||||
Monitoring // 监控布局
|
||||
};
|
||||
|
||||
|
||||
// UI渲染相关方法
|
||||
void RenderUI(); // 渲染主UI
|
||||
void RenderMenuBar(); // 渲染菜单栏
|
||||
void RenderMainContent(); // 渲染主内容区域
|
||||
void RenderSettingsMenu(); // 渲染设置菜单
|
||||
void RenderStopCommandSettings(); // 渲染停止命令设置
|
||||
void RenderEnvironmentVariablesSettings(); // 渲染环境变量设置
|
||||
void RenderOutputEncodingSettings(); // 渲染输出编码设置
|
||||
void RenderControlPanel(float buttonWidth, float buttonHeight, float inputWidth); // 渲染控制面板
|
||||
void RenderCommandPanel(float buttonWidth, float inputWidth); // 渲染命令面板
|
||||
void RenderLogPanel(); // 渲染日志面板
|
||||
void RenderCommandHistory(); // 渲染命令历史
|
||||
void RenderStatusMessages(); // 渲染状态消息
|
||||
void RenderUI(); // 渲染主UI
|
||||
void RenderMenuBar(); // 渲染菜单栏
|
||||
void RenderMainContent(); // 渲染主内容区域
|
||||
|
||||
|
||||
void RenderSettingsMenu(); // 渲染设置菜单
|
||||
void RenderStopCommandSettings(); // 渲染停止命令设置
|
||||
void RenderEnvironmentVariablesSettings(); // 渲染环境变量设置
|
||||
void RenderOutputEncodingSettings(); // 渲染输出编码设置
|
||||
void RenderColorThemeSettings();
|
||||
|
||||
void RenderControlPanel(float buttonWidth, float buttonHeight, float inputWidth); // 渲染控制面板
|
||||
void RenderCommandPanel(float buttonWidth, float inputWidth); // 渲染命令面板
|
||||
void RenderLogPanel(); // 渲染日志面板
|
||||
void RenderCommandHistory(); // 渲染命令历史
|
||||
void RenderStatusMessages(); // 渲染状态消息
|
||||
|
||||
// 布局管理相关方法
|
||||
void SetupDefaultDockingLayout(ImGuiID dockspace_id); // 设置默认停靠布局
|
||||
void RenderLayoutMenu(); // 渲染布局菜单
|
||||
static void ApplyPresetLayout(LayoutPreset preset); // 应用预设布局
|
||||
void SaveCurrentLayout(); // 保存当前布局
|
||||
void LoadSavedLayout(); // 加载已保存布局
|
||||
void SetupDefaultDockingLayout(ImGuiID dockspace_id); // 设置默认停靠布局
|
||||
void RenderLayoutMenu(); // 渲染布局菜单
|
||||
static void ApplyPresetLayout(LayoutPreset preset); // 应用预设布局
|
||||
void SaveCurrentLayout(); // 保存当前布局
|
||||
void LoadSavedLayout(); // 加载已保存布局
|
||||
|
||||
// 事件处理相关方法
|
||||
void HandleMessages(); // 处理消息
|
||||
bool ShouldExit() const; // 检查是否应该退出
|
||||
static void ContentScaleCallback(GLFWwindow *window, float xscale, float yscale); // 内容缩放回调
|
||||
void HandleMessages(); // 处理消息
|
||||
bool ShouldExit() const; // 检查是否应该退出
|
||||
static void ContentScaleCallback(GLFWwindow *window, float xscale, float yscale); // 内容缩放回调
|
||||
|
||||
// 窗口管理相关方法
|
||||
void ShowMainWindow(); // 显示主窗口
|
||||
void HideMainWindow(); // 隐藏主窗口
|
||||
void ShowMainWindow(); // 显示主窗口
|
||||
void HideMainWindow(); // 隐藏主窗口
|
||||
|
||||
// DPI相关方法
|
||||
void UpdateDPIScale(); // 更新DPI缩放
|
||||
void ReloadFonts() const; // 重新加载字体
|
||||
void UpdateDPIScale(); // 更新DPI缩放
|
||||
void ReloadFonts() const; // 重新加载字体
|
||||
|
||||
void SaveCurrentTheme();
|
||||
void LoadSavedTheme();
|
||||
|
||||
ImVec4 GetCustomLogLevelColor(const std::string &log);
|
||||
|
||||
// 平台相关初始化方法
|
||||
#ifdef USE_WIN32_BACKEND
|
||||
@@ -108,17 +118,17 @@ private:
|
||||
static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); // 窗口过程
|
||||
#else
|
||||
|
||||
bool InitializeGLFW(); // 初始化GLFW
|
||||
void CleanupGLFW(); // 清理GLFW
|
||||
static void GlfwErrorCallback(int error, const char *description); // GLFW错误回调
|
||||
bool InitializeGLFW(); // 初始化GLFW
|
||||
void CleanupGLFW(); // 清理GLFW
|
||||
static void GlfwErrorCallback(int error, const char *description); // GLFW错误回调
|
||||
#endif
|
||||
|
||||
// 托盘相关方法
|
||||
bool InitializeTray(); // 初始化托盘
|
||||
void CleanupTray(); // 清理托盘
|
||||
bool InitializeTray(); // 初始化托盘
|
||||
void CleanupTray(); // 清理托盘
|
||||
#ifdef _WIN32
|
||||
|
||||
static HWND CreateHiddenWindow(); // 创建隐藏窗口
|
||||
static HWND CreateHiddenWindow(); // 创建隐藏窗口
|
||||
#endif
|
||||
|
||||
// 平台相关成员变量
|
||||
@@ -130,41 +140,47 @@ private:
|
||||
IDXGISwapChain* m_pSwapChain = nullptr; // 交换链
|
||||
ID3D11RenderTargetView* m_mainRenderTargetView = nullptr; // 主渲染目标视图
|
||||
#else
|
||||
GLFWwindow *m_window = nullptr; // GLFW窗口
|
||||
const char *m_glsl_version = nullptr; // GLSL版本
|
||||
GLFWwindow *m_window = nullptr; // GLFW窗口
|
||||
const char *m_glsl_version = nullptr; // GLSL版本
|
||||
#endif
|
||||
|
||||
// 托盘相关成员变量
|
||||
std::unique_ptr<TrayIcon> m_tray; // 托盘图标
|
||||
std::unique_ptr<TrayIcon> m_tray; // 托盘图标
|
||||
#ifdef _WIN32
|
||||
HWND m_tray_hwnd = nullptr; // 托盘窗口句柄
|
||||
HWND m_tray_hwnd = nullptr; // 托盘窗口句柄
|
||||
#endif
|
||||
|
||||
// 控制标志
|
||||
bool m_should_exit = false; // 是否应该退出
|
||||
bool m_initialized = false; // 是否已初始化
|
||||
bool m_should_exit = false; // 是否应该退出
|
||||
bool m_initialized = false; // 是否已初始化
|
||||
bool m_fullscreen = false;
|
||||
bool m_padding = false;
|
||||
// DPI缩放相关
|
||||
float m_dpi_scale = 1.0f; // 当前DPI缩放
|
||||
float m_last_dpi_scale = 1.0f; // 上次DPI缩放
|
||||
float m_dpi_scale = 1.0f; // 当前DPI缩放
|
||||
float m_last_dpi_scale = 1.0f; // 上次DPI缩放
|
||||
|
||||
// 布局相关成员变量
|
||||
ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_MenuBar;
|
||||
bool m_apply_preset_layout = false; // 是否需要应用预设布局
|
||||
LayoutPreset m_pending_preset = LayoutPreset::Classic; // 待应用的预设布局
|
||||
bool m_reset_layout = false; // 是否重置布局
|
||||
bool m_show_save_success = false; // 是否显示保存成功消息
|
||||
bool m_show_load_success = false; // 是否显示加载成功消息
|
||||
float m_save_success_timer = 0.0f; // 保存成功消息计时器
|
||||
float m_load_success_timer = 0.0f; // 加载成功消息计时器
|
||||
bool m_apply_preset_layout = false; // 是否需要应用预设布局
|
||||
LayoutPreset m_pending_preset = LayoutPreset::Classic; // 待应用的预设布局
|
||||
bool m_reset_layout = false; // 是否重置布局
|
||||
bool m_show_save_success = false; // 是否显示保存成功消息
|
||||
bool m_show_load_success = false; // 是否显示加载成功消息
|
||||
float m_save_success_timer = 0.0f; // 保存成功消息计时器
|
||||
float m_load_success_timer = 0.0f; // 加载成功消息计时器
|
||||
|
||||
// UI状态相关成员变量
|
||||
char env_key_input_[256] = {}; // 环境变量键输入缓冲区
|
||||
char env_value_input_[512] = {}; // 环境变量值输入缓冲区
|
||||
bool show_env_settings_ = false; // 是否显示环境变量设置
|
||||
bool show_encoding_settings_ = false; // 是否显示编码设置
|
||||
bool show_command_history_ = false; // 是否显示命令历史
|
||||
char env_key_input_[256] = {}; // 环境变量键输入缓冲区
|
||||
char env_value_input_[512] = {}; // 环境变量值输入缓冲区
|
||||
bool show_env_settings_ = false; // 是否显示环境变量设置
|
||||
bool show_encoding_settings_ = false; // 是否显示编码设置
|
||||
bool show_command_history_ = false; // 是否显示命令历史
|
||||
|
||||
bool m_show_theme_save_success = true;
|
||||
float m_theme_save_success_timer = 3.0f;
|
||||
|
||||
float m_theme_load_success_timer = 0.0f;
|
||||
bool m_show_theme_load_success = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user