refactor: Update GUI components and integrate new palette widget
- Removed references to the old `EnhancedPaletteEditor` and replaced it with the new `PaletteWidget` across various files, including canvas and context menu implementations. - Updated CMake configurations to include the new `palette_widget` source files, ensuring proper integration into the build system. - Refactored GUI code to enhance modularity and maintainability, improving the overall user experience in palette management and editing functionalities. - Introduced new UI components for background rendering and editor selection dialogs, enhancing the application's graphical interface.
This commit is contained in:
@@ -1,380 +0,0 @@
|
||||
#include "background_renderer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include "app/gui/theme_manager.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
namespace yaze {
|
||||
namespace gui {
|
||||
|
||||
// BackgroundRenderer Implementation
|
||||
BackgroundRenderer& BackgroundRenderer::Get() {
|
||||
static BackgroundRenderer instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void BackgroundRenderer::RenderDockingBackground(ImDrawList* draw_list, const ImVec2& window_pos,
|
||||
const ImVec2& window_size, const Color& theme_color) {
|
||||
if (!draw_list) return;
|
||||
|
||||
UpdateAnimation(ImGui::GetIO().DeltaTime);
|
||||
|
||||
// Get current theme colors
|
||||
auto& theme_manager = ThemeManager::Get();
|
||||
auto current_theme = theme_manager.GetCurrentTheme();
|
||||
|
||||
// Create a subtle tinted background
|
||||
Color bg_tint = {
|
||||
current_theme.background.red * 1.1f,
|
||||
current_theme.background.green * 1.1f,
|
||||
current_theme.background.blue * 1.1f,
|
||||
0.3f
|
||||
};
|
||||
|
||||
ImU32 bg_color = ImGui::ColorConvertFloat4ToU32(ConvertColorToImVec4(bg_tint));
|
||||
draw_list->AddRectFilled(window_pos,
|
||||
ImVec2(window_pos.x + window_size.x, window_pos.y + window_size.y),
|
||||
bg_color);
|
||||
|
||||
// Render the grid if enabled
|
||||
if (grid_settings_.grid_size > 0) {
|
||||
RenderGridBackground(draw_list, window_pos, window_size, theme_color);
|
||||
}
|
||||
|
||||
// Add subtle corner accents
|
||||
if (current_theme.enable_glow_effects) {
|
||||
float corner_size = 60.0f;
|
||||
Color accent_faded = current_theme.accent;
|
||||
accent_faded.alpha = 0.1f + 0.05f * sinf(animation_time_ * 2.0f);
|
||||
|
||||
ImU32 corner_color = ImGui::ColorConvertFloat4ToU32(ConvertColorToImVec4(accent_faded));
|
||||
|
||||
// Top-left corner
|
||||
draw_list->AddRectFilledMultiColor(
|
||||
window_pos,
|
||||
ImVec2(window_pos.x + corner_size, window_pos.y + corner_size),
|
||||
corner_color, IM_COL32(0,0,0,0), IM_COL32(0,0,0,0), corner_color);
|
||||
|
||||
// Bottom-right corner
|
||||
draw_list->AddRectFilledMultiColor(
|
||||
ImVec2(window_pos.x + window_size.x - corner_size, window_pos.y + window_size.y - corner_size),
|
||||
ImVec2(window_pos.x + window_size.x, window_pos.y + window_size.y),
|
||||
IM_COL32(0,0,0,0), corner_color, corner_color, IM_COL32(0,0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
void BackgroundRenderer::RenderGridBackground(ImDrawList* draw_list, const ImVec2& window_pos,
|
||||
const ImVec2& window_size, const Color& grid_color) {
|
||||
if (!draw_list || grid_settings_.grid_size <= 0) return;
|
||||
|
||||
// Grid parameters with optional animation
|
||||
float grid_size = grid_settings_.grid_size;
|
||||
float offset_x = 0.0f;
|
||||
float offset_y = 0.0f;
|
||||
|
||||
// Apply animation if enabled
|
||||
if (grid_settings_.enable_animation) {
|
||||
float animation_offset = animation_time_ * grid_settings_.animation_speed * 10.0f;
|
||||
offset_x = fmodf(animation_offset, grid_size);
|
||||
offset_y = fmodf(animation_offset * 0.7f, grid_size); // Different speed for interesting effect
|
||||
}
|
||||
|
||||
// Window center for radial calculations
|
||||
ImVec2 center = ImVec2(window_pos.x + window_size.x * 0.5f,
|
||||
window_pos.y + window_size.y * 0.5f);
|
||||
float max_distance = sqrtf(window_size.x * window_size.x + window_size.y * window_size.y) * 0.5f;
|
||||
|
||||
// Apply breathing effect to color if enabled
|
||||
Color themed_grid_color = grid_color;
|
||||
themed_grid_color.alpha = grid_settings_.opacity;
|
||||
|
||||
if (grid_settings_.enable_breathing) {
|
||||
float breathing_factor = 1.0f + grid_settings_.breathing_intensity *
|
||||
sinf(animation_time_ * grid_settings_.breathing_speed);
|
||||
themed_grid_color.red = std::min(1.0f, themed_grid_color.red * breathing_factor);
|
||||
themed_grid_color.green = std::min(1.0f, themed_grid_color.green * breathing_factor);
|
||||
themed_grid_color.blue = std::min(1.0f, themed_grid_color.blue * breathing_factor);
|
||||
}
|
||||
|
||||
if (grid_settings_.enable_dots) {
|
||||
// Render grid as dots
|
||||
for (float x = window_pos.x - offset_x; x < window_pos.x + window_size.x + grid_size; x += grid_size) {
|
||||
for (float y = window_pos.y - offset_y; y < window_pos.y + window_size.y + grid_size; y += grid_size) {
|
||||
ImVec2 dot_pos(x, y);
|
||||
|
||||
// Calculate radial fade
|
||||
float fade_factor = 1.0f;
|
||||
if (grid_settings_.radial_fade) {
|
||||
float distance = sqrtf((dot_pos.x - center.x) * (dot_pos.x - center.x) +
|
||||
(dot_pos.y - center.y) * (dot_pos.y - center.y));
|
||||
fade_factor = 1.0f - std::min(distance / grid_settings_.fade_distance, 1.0f);
|
||||
fade_factor = fade_factor * fade_factor; // Square for smoother falloff
|
||||
}
|
||||
|
||||
if (fade_factor > 0.01f) {
|
||||
ImU32 dot_color = BlendColorWithFade(themed_grid_color, fade_factor);
|
||||
DrawGridDot(draw_list, dot_pos, dot_color, grid_settings_.dot_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Render grid as lines
|
||||
// Vertical lines
|
||||
for (float x = window_pos.x - offset_x; x < window_pos.x + window_size.x + grid_size; x += grid_size) {
|
||||
ImVec2 line_start(x, window_pos.y);
|
||||
ImVec2 line_end(x, window_pos.y + window_size.y);
|
||||
|
||||
// Calculate average fade for this line
|
||||
float avg_fade = 0.0f;
|
||||
if (grid_settings_.radial_fade) {
|
||||
for (float y = window_pos.y; y < window_pos.y + window_size.y; y += grid_size * 0.5f) {
|
||||
float distance = sqrtf((x - center.x) * (x - center.x) + (y - center.y) * (y - center.y));
|
||||
float fade = 1.0f - std::min(distance / grid_settings_.fade_distance, 1.0f);
|
||||
avg_fade += fade * fade;
|
||||
}
|
||||
avg_fade /= (window_size.y / (grid_size * 0.5f));
|
||||
} else {
|
||||
avg_fade = 1.0f;
|
||||
}
|
||||
|
||||
if (avg_fade > 0.01f) {
|
||||
ImU32 line_color = BlendColorWithFade(themed_grid_color, avg_fade);
|
||||
DrawGridLine(draw_list, line_start, line_end, line_color, grid_settings_.line_thickness);
|
||||
}
|
||||
}
|
||||
|
||||
// Horizontal lines
|
||||
for (float y = window_pos.y - offset_y; y < window_pos.y + window_size.y + grid_size; y += grid_size) {
|
||||
ImVec2 line_start(window_pos.x, y);
|
||||
ImVec2 line_end(window_pos.x + window_size.x, y);
|
||||
|
||||
// Calculate average fade for this line
|
||||
float avg_fade = 0.0f;
|
||||
if (grid_settings_.radial_fade) {
|
||||
for (float x = window_pos.x; x < window_pos.x + window_size.x; x += grid_size * 0.5f) {
|
||||
float distance = sqrtf((x - center.x) * (x - center.x) + (y - center.y) * (y - center.y));
|
||||
float fade = 1.0f - std::min(distance / grid_settings_.fade_distance, 1.0f);
|
||||
avg_fade += fade * fade;
|
||||
}
|
||||
avg_fade /= (window_size.x / (grid_size * 0.5f));
|
||||
} else {
|
||||
avg_fade = 1.0f;
|
||||
}
|
||||
|
||||
if (avg_fade > 0.01f) {
|
||||
ImU32 line_color = BlendColorWithFade(themed_grid_color, avg_fade);
|
||||
DrawGridLine(draw_list, line_start, line_end, line_color, grid_settings_.line_thickness);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BackgroundRenderer::RenderRadialGradient(ImDrawList* draw_list, const ImVec2& center,
|
||||
float radius, const Color& inner_color, const Color& outer_color) {
|
||||
if (!draw_list) return;
|
||||
|
||||
const int segments = 32;
|
||||
const int rings = 8;
|
||||
|
||||
for (int ring = 0; ring < rings; ++ring) {
|
||||
float ring_radius = radius * (ring + 1) / rings;
|
||||
float inner_ring_radius = radius * ring / rings;
|
||||
|
||||
// Interpolate colors for this ring
|
||||
float t = static_cast<float>(ring) / rings;
|
||||
Color ring_color = {
|
||||
inner_color.red * (1.0f - t) + outer_color.red * t,
|
||||
inner_color.green * (1.0f - t) + outer_color.green * t,
|
||||
inner_color.blue * (1.0f - t) + outer_color.blue * t,
|
||||
inner_color.alpha * (1.0f - t) + outer_color.alpha * t
|
||||
};
|
||||
|
||||
ImU32 color = ImGui::ColorConvertFloat4ToU32(ConvertColorToImVec4(ring_color));
|
||||
|
||||
if (ring == 0) {
|
||||
// Center circle
|
||||
draw_list->AddCircleFilled(center, ring_radius, color, segments);
|
||||
} else {
|
||||
// Ring
|
||||
for (int i = 0; i < segments; ++i) {
|
||||
float angle1 = (2.0f * M_PI * i) / segments;
|
||||
float angle2 = (2.0f * M_PI * (i + 1)) / segments;
|
||||
|
||||
ImVec2 p1_inner = ImVec2(center.x + cosf(angle1) * inner_ring_radius,
|
||||
center.y + sinf(angle1) * inner_ring_radius);
|
||||
ImVec2 p2_inner = ImVec2(center.x + cosf(angle2) * inner_ring_radius,
|
||||
center.y + sinf(angle2) * inner_ring_radius);
|
||||
ImVec2 p1_outer = ImVec2(center.x + cosf(angle1) * ring_radius,
|
||||
center.y + sinf(angle1) * ring_radius);
|
||||
ImVec2 p2_outer = ImVec2(center.x + cosf(angle2) * ring_radius,
|
||||
center.y + sinf(angle2) * ring_radius);
|
||||
|
||||
draw_list->AddQuadFilled(p1_inner, p2_inner, p2_outer, p1_outer, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BackgroundRenderer::UpdateAnimation(float delta_time) {
|
||||
if (grid_settings_.enable_animation) {
|
||||
animation_time_ += delta_time;
|
||||
}
|
||||
}
|
||||
|
||||
void BackgroundRenderer::UpdateForTheme(const Color& primary_color, const Color& background_color) {
|
||||
// Create a grid color that's a subtle blend of the theme's primary and background
|
||||
cached_grid_color_ = {
|
||||
(primary_color.red * 0.3f + background_color.red * 0.7f),
|
||||
(primary_color.green * 0.3f + background_color.green * 0.7f),
|
||||
(primary_color.blue * 0.3f + background_color.blue * 0.7f),
|
||||
grid_settings_.opacity
|
||||
};
|
||||
}
|
||||
|
||||
void BackgroundRenderer::DrawSettingsUI() {
|
||||
if (ImGui::CollapsingHeader("Background Grid Settings")) {
|
||||
ImGui::Indent();
|
||||
|
||||
ImGui::SliderFloat("Grid Size", &grid_settings_.grid_size, 8.0f, 128.0f, "%.0f px");
|
||||
ImGui::SliderFloat("Line Thickness", &grid_settings_.line_thickness, 0.5f, 3.0f, "%.1f px");
|
||||
ImGui::SliderFloat("Opacity", &grid_settings_.opacity, 0.01f, 0.3f, "%.3f");
|
||||
ImGui::SliderFloat("Fade Distance", &grid_settings_.fade_distance, 50.0f, 500.0f, "%.0f px");
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Visual Effects:");
|
||||
ImGui::Checkbox("Enable Animation", &grid_settings_.enable_animation);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("Makes the grid move slowly across the screen");
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Color Breathing", &grid_settings_.enable_breathing);
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("Grid color pulses with a breathing effect");
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Radial Fade", &grid_settings_.radial_fade);
|
||||
ImGui::Checkbox("Use Dots Instead of Lines", &grid_settings_.enable_dots);
|
||||
|
||||
// Animation settings (only show if animation is enabled)
|
||||
if (grid_settings_.enable_animation) {
|
||||
ImGui::Indent();
|
||||
ImGui::SliderFloat("Animation Speed", &grid_settings_.animation_speed, 0.1f, 3.0f, "%.1fx");
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
// Breathing settings (only show if breathing is enabled)
|
||||
if (grid_settings_.enable_breathing) {
|
||||
ImGui::Indent();
|
||||
ImGui::SliderFloat("Breathing Speed", &grid_settings_.breathing_speed, 0.5f, 3.0f, "%.1fx");
|
||||
ImGui::SliderFloat("Breathing Intensity", &grid_settings_.breathing_intensity, 0.1f, 0.8f, "%.1f");
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
if (grid_settings_.enable_dots) {
|
||||
ImGui::SliderFloat("Dot Size", &grid_settings_.dot_size, 1.0f, 8.0f, "%.1f px");
|
||||
}
|
||||
|
||||
// Preview
|
||||
ImGui::Spacing();
|
||||
ImGui::Text("Preview:");
|
||||
ImVec2 preview_size(200, 100);
|
||||
ImVec2 preview_pos = ImGui::GetCursorScreenPos();
|
||||
|
||||
ImDrawList* preview_draw_list = ImGui::GetWindowDrawList();
|
||||
auto& theme_manager = ThemeManager::Get();
|
||||
auto theme_color = theme_manager.GetCurrentTheme().primary;
|
||||
|
||||
// Draw preview background
|
||||
preview_draw_list->AddRectFilled(preview_pos,
|
||||
ImVec2(preview_pos.x + preview_size.x, preview_pos.y + preview_size.y),
|
||||
IM_COL32(30, 30, 30, 255));
|
||||
|
||||
// Draw preview grid
|
||||
RenderGridBackground(preview_draw_list, preview_pos, preview_size, theme_color);
|
||||
|
||||
// Advance cursor
|
||||
ImGui::Dummy(preview_size);
|
||||
|
||||
ImGui::Unindent();
|
||||
}
|
||||
}
|
||||
|
||||
float BackgroundRenderer::CalculateRadialFade(const ImVec2& pos, const ImVec2& center, float max_distance) const {
|
||||
float distance = sqrtf((pos.x - center.x) * (pos.x - center.x) +
|
||||
(pos.y - center.y) * (pos.y - center.y));
|
||||
float fade = 1.0f - std::min(distance / max_distance, 1.0f);
|
||||
return fade * fade; // Square for smoother falloff
|
||||
}
|
||||
|
||||
ImU32 BackgroundRenderer::BlendColorWithFade(const Color& base_color, float fade_factor) const {
|
||||
Color faded_color = {
|
||||
base_color.red,
|
||||
base_color.green,
|
||||
base_color.blue,
|
||||
base_color.alpha * fade_factor
|
||||
};
|
||||
return ImGui::ColorConvertFloat4ToU32(ConvertColorToImVec4(faded_color));
|
||||
}
|
||||
|
||||
void BackgroundRenderer::DrawGridLine(ImDrawList* draw_list, const ImVec2& start, const ImVec2& end,
|
||||
ImU32 color, float thickness) const {
|
||||
draw_list->AddLine(start, end, color, thickness);
|
||||
}
|
||||
|
||||
void BackgroundRenderer::DrawGridDot(ImDrawList* draw_list, const ImVec2& pos, ImU32 color, float size) const {
|
||||
draw_list->AddCircleFilled(pos, size, color);
|
||||
}
|
||||
|
||||
// DockSpaceRenderer Implementation
|
||||
bool DockSpaceRenderer::background_enabled_ = true;
|
||||
bool DockSpaceRenderer::grid_enabled_ = true;
|
||||
bool DockSpaceRenderer::effects_enabled_ = true;
|
||||
ImVec2 DockSpaceRenderer::last_dockspace_pos_{};
|
||||
ImVec2 DockSpaceRenderer::last_dockspace_size_{};
|
||||
|
||||
void DockSpaceRenderer::BeginEnhancedDockSpace(ImGuiID dockspace_id, const ImVec2& size,
|
||||
ImGuiDockNodeFlags flags) {
|
||||
// Store window info
|
||||
last_dockspace_pos_ = ImGui::GetWindowPos();
|
||||
last_dockspace_size_ = ImGui::GetWindowSize();
|
||||
|
||||
// Create the actual dockspace first
|
||||
ImGui::DockSpace(dockspace_id, size, flags);
|
||||
|
||||
// NOW draw the background effects on the foreground draw list so they're visible
|
||||
if (background_enabled_) {
|
||||
ImDrawList* fg_draw_list = ImGui::GetForegroundDrawList();
|
||||
auto& theme_manager = ThemeManager::Get();
|
||||
auto current_theme = theme_manager.GetCurrentTheme();
|
||||
|
||||
if (grid_enabled_) {
|
||||
auto& bg_renderer = BackgroundRenderer::Get();
|
||||
// Use the main viewport for full-screen grid
|
||||
const ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
ImVec2 grid_pos = viewport->WorkPos;
|
||||
ImVec2 grid_size = viewport->WorkSize;
|
||||
|
||||
// Use subtle grid color that doesn't distract
|
||||
Color subtle_grid_color = current_theme.primary;
|
||||
// Use the grid settings opacity for consistency
|
||||
subtle_grid_color.alpha = bg_renderer.GetGridSettings().opacity;
|
||||
|
||||
bg_renderer.RenderGridBackground(fg_draw_list, grid_pos, grid_size, subtle_grid_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DockSpaceRenderer::EndEnhancedDockSpace() {
|
||||
// Additional post-processing effects could go here
|
||||
// For now, this is just for API consistency
|
||||
}
|
||||
|
||||
} // namespace gui
|
||||
} // namespace yaze
|
||||
@@ -1,96 +0,0 @@
|
||||
#ifndef YAZE_APP_GUI_BACKGROUND_RENDERER_H
|
||||
#define YAZE_APP_GUI_BACKGROUND_RENDERER_H
|
||||
|
||||
#include "imgui/imgui.h"
|
||||
#include "app/gui/color.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace gui {
|
||||
|
||||
/**
|
||||
* @class BackgroundRenderer
|
||||
* @brief Renders themed background effects for docking windows
|
||||
*/
|
||||
class BackgroundRenderer {
|
||||
public:
|
||||
struct GridSettings {
|
||||
float grid_size = 32.0f; // Size of grid cells
|
||||
float line_thickness = 1.0f; // Thickness of grid lines
|
||||
float opacity = 0.12f; // Subtle but visible opacity
|
||||
float fade_distance = 400.0f; // Distance over which grid fades
|
||||
bool enable_animation = false; // Animation toggle (default off)
|
||||
bool enable_breathing = false; // Color breathing effect toggle (default off)
|
||||
bool radial_fade = true; // Re-enable subtle radial fade
|
||||
bool enable_dots = false; // Use dots instead of lines
|
||||
float dot_size = 2.0f; // Size of grid dots
|
||||
float animation_speed = 1.0f; // Animation speed multiplier
|
||||
float breathing_speed = 1.5f; // Breathing effect speed
|
||||
float breathing_intensity = 0.3f; // How much color changes during breathing
|
||||
};
|
||||
|
||||
static BackgroundRenderer& Get();
|
||||
|
||||
// Main rendering functions
|
||||
void RenderDockingBackground(ImDrawList* draw_list, const ImVec2& window_pos,
|
||||
const ImVec2& window_size, const Color& theme_color);
|
||||
void RenderGridBackground(ImDrawList* draw_list, const ImVec2& window_pos,
|
||||
const ImVec2& window_size, const Color& grid_color);
|
||||
void RenderRadialGradient(ImDrawList* draw_list, const ImVec2& center,
|
||||
float radius, const Color& inner_color, const Color& outer_color);
|
||||
|
||||
// Configuration
|
||||
void SetGridSettings(const GridSettings& settings) { grid_settings_ = settings; }
|
||||
const GridSettings& GetGridSettings() const { return grid_settings_; }
|
||||
|
||||
// Animation
|
||||
void UpdateAnimation(float delta_time);
|
||||
void SetAnimationEnabled(bool enabled) { grid_settings_.enable_animation = enabled; }
|
||||
|
||||
// Theme integration
|
||||
void UpdateForTheme(const Color& primary_color, const Color& background_color);
|
||||
|
||||
// UI for settings
|
||||
void DrawSettingsUI();
|
||||
|
||||
private:
|
||||
BackgroundRenderer() = default;
|
||||
|
||||
GridSettings grid_settings_;
|
||||
float animation_time_ = 0.0f;
|
||||
Color cached_grid_color_{0.5f, 0.5f, 0.5f, 0.1f};
|
||||
|
||||
// Helper functions
|
||||
float CalculateRadialFade(const ImVec2& pos, const ImVec2& center, float max_distance) const;
|
||||
ImU32 BlendColorWithFade(const Color& base_color, float fade_factor) const;
|
||||
void DrawGridLine(ImDrawList* draw_list, const ImVec2& start, const ImVec2& end,
|
||||
ImU32 color, float thickness) const;
|
||||
void DrawGridDot(ImDrawList* draw_list, const ImVec2& pos, ImU32 color, float size) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class DockSpaceRenderer
|
||||
* @brief Enhanced docking space with themed background effects
|
||||
*/
|
||||
class DockSpaceRenderer {
|
||||
public:
|
||||
static void BeginEnhancedDockSpace(ImGuiID dockspace_id, const ImVec2& size = ImVec2(0, 0),
|
||||
ImGuiDockNodeFlags flags = 0);
|
||||
static void EndEnhancedDockSpace();
|
||||
|
||||
// Configuration
|
||||
static void SetBackgroundEnabled(bool enabled) { background_enabled_ = enabled; }
|
||||
static void SetGridEnabled(bool enabled) { grid_enabled_ = enabled; }
|
||||
static void SetEffectsEnabled(bool enabled) { effects_enabled_ = enabled; }
|
||||
|
||||
private:
|
||||
static bool background_enabled_;
|
||||
static bool grid_enabled_;
|
||||
static bool effects_enabled_;
|
||||
static ImVec2 last_dockspace_pos_;
|
||||
static ImVec2 last_dockspace_size_;
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_GUI_BACKGROUND_RENDERER_H
|
||||
@@ -67,7 +67,7 @@ void Canvas::InitializeDefaults() {
|
||||
selection_.Clear();
|
||||
|
||||
// Initialize palette editor
|
||||
palette_editor_ = std::make_unique<EnhancedPaletteEditor>();
|
||||
palette_editor_ = std::make_unique<PaletteWidget>();
|
||||
|
||||
// Initialize interaction handler
|
||||
interaction_handler_.Initialize(canvas_id_);
|
||||
@@ -1744,7 +1744,7 @@ void Canvas::ShowAdvancedCanvasProperties() {
|
||||
}
|
||||
}
|
||||
|
||||
// Old ShowPaletteManager method removed - now handled by EnhancedPaletteEditor
|
||||
// Old ShowPaletteManager method removed - now handled by PaletteWidget
|
||||
|
||||
void Canvas::ShowScalingControls() {
|
||||
// Use the new modal system if available
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/gui/canvas_utils.h"
|
||||
#include "app/gui/enhanced_palette_editor.h"
|
||||
#include "app/gui/widgets/palette_widget.h"
|
||||
#include "app/gfx/bpp_format_manager.h"
|
||||
#include "app/gui/bpp_format_ui.h"
|
||||
#include "app/gui/canvas/canvas_modals.h"
|
||||
@@ -412,7 +412,7 @@ class Canvas {
|
||||
// Modular configuration and state
|
||||
CanvasConfig config_;
|
||||
CanvasSelection selection_;
|
||||
std::unique_ptr<EnhancedPaletteEditor> palette_editor_;
|
||||
std::unique_ptr<PaletteWidget> palette_editor_;
|
||||
|
||||
// Core canvas state
|
||||
bool is_hovered_ = false;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "app/gfx/performance_profiler.h"
|
||||
#include "app/gfx/performance_dashboard.h"
|
||||
#include "app/gui/enhanced_palette_editor.h"
|
||||
#include "app/gui/widgets/palette_widget.h"
|
||||
#include "app/gui/bpp_format_ui.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/canvas/canvas_modals.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "app/gfx/performance_profiler.h"
|
||||
#include "app/gfx/performance_dashboard.h"
|
||||
#include "app/gui/enhanced_palette_editor.h"
|
||||
#include "app/gui/widgets/palette_widget.h"
|
||||
#include "app/gui/bpp_format_ui.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "imgui/imgui.h"
|
||||
@@ -421,9 +421,9 @@ void CanvasModals::RenderPaletteEditorModal(const std::string& canvas_id,
|
||||
ImGui::Text("%s %s", ICON_MD_PALETTE, modal_title.c_str());
|
||||
ImGui::Separator();
|
||||
|
||||
// Use the existing EnhancedPaletteEditor
|
||||
static std::unique_ptr<gui::EnhancedPaletteEditor> palette_editor =
|
||||
std::make_unique<gui::EnhancedPaletteEditor>();
|
||||
// Use the existing PaletteWidget
|
||||
static std::unique_ptr<gui::PaletteWidget> palette_editor =
|
||||
std::make_unique<gui::PaletteWidget>();
|
||||
|
||||
if (options.palette) {
|
||||
palette_editor->ShowPaletteEditor(*options.palette, modal_title);
|
||||
@@ -454,9 +454,9 @@ void CanvasModals::RenderColorAnalysisModal(const std::string& canvas_id,
|
||||
ImGui::Text("%s %s", ICON_MD_ZOOM_IN, modal_title.c_str());
|
||||
ImGui::Separator();
|
||||
|
||||
// Use the existing EnhancedPaletteEditor for color analysis
|
||||
static std::unique_ptr<gui::EnhancedPaletteEditor> palette_editor =
|
||||
std::make_unique<gui::EnhancedPaletteEditor>();
|
||||
// Use the existing PaletteWidget for color analysis
|
||||
static std::unique_ptr<gui::PaletteWidget> palette_editor =
|
||||
std::make_unique<gui::PaletteWidget>();
|
||||
|
||||
if (options.bitmap) {
|
||||
palette_editor->ShowColorAnalysis(*options.bitmap, modal_title);
|
||||
|
||||
@@ -6,15 +6,14 @@ set(
|
||||
app/gui/widgets/collaboration_panel.cc
|
||||
app/gui/canvas.cc
|
||||
app/gui/canvas_utils.cc
|
||||
app/gui/enhanced_palette_editor.cc
|
||||
app/gui/widgets/palette_widget.cc
|
||||
app/gui/input.cc
|
||||
app/gui/style.cc
|
||||
app/gui/color.cc
|
||||
app/gui/theme_manager.cc
|
||||
app/gui/background_renderer.cc
|
||||
app/gui/bpp_format_ui.cc
|
||||
app/gui/widget_id_registry.cc
|
||||
app/gui/widget_auto_register.cc
|
||||
app/gui/widgets/widget_id_registry.cc
|
||||
app/gui/widgets/widget_auto_register.cc
|
||||
# Canvas system components
|
||||
app/gui/canvas/canvas_modals.cc
|
||||
app/gui/canvas/canvas_context_menu.cc
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "util/file_util.h"
|
||||
#include "app/gui/theme_manager.h"
|
||||
#include "app/gui/background_renderer.h"
|
||||
#include "app/editor/ui/background_renderer.h"
|
||||
#include "app/core/platform/font_loader.h"
|
||||
#include "app/gui/color.h"
|
||||
#include "app/gui/icons.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "enhanced_palette_editor.h"
|
||||
#include "app/gui/widgets/palette_widget.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
@@ -11,7 +11,7 @@ namespace gui {
|
||||
|
||||
using core::Renderer;
|
||||
|
||||
void EnhancedPaletteEditor::Initialize(Rom* rom) {
|
||||
void PaletteWidget::Initialize(Rom* rom) {
|
||||
rom_ = rom;
|
||||
rom_palettes_loaded_ = false;
|
||||
if (rom_) {
|
||||
@@ -19,7 +19,7 @@ void EnhancedPaletteEditor::Initialize(Rom* rom) {
|
||||
}
|
||||
}
|
||||
|
||||
void EnhancedPaletteEditor::ShowPaletteEditor(gfx::SnesPalette& palette, const std::string& title) {
|
||||
void PaletteWidget::ShowPaletteEditor(gfx::SnesPalette& palette, const std::string& title) {
|
||||
if (ImGui::BeginPopupModal(title.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::Text("Enhanced Palette Editor");
|
||||
ImGui::Separator();
|
||||
@@ -63,7 +63,7 @@ void EnhancedPaletteEditor::ShowPaletteEditor(gfx::SnesPalette& palette, const s
|
||||
}
|
||||
}
|
||||
|
||||
void EnhancedPaletteEditor::ShowROMPaletteManager() {
|
||||
void PaletteWidget::ShowROMPaletteManager() {
|
||||
if (!show_rom_manager_) return;
|
||||
|
||||
if (ImGui::Begin("ROM Palette Manager", &show_rom_manager_)) {
|
||||
@@ -92,7 +92,7 @@ void EnhancedPaletteEditor::ShowROMPaletteManager() {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void EnhancedPaletteEditor::ShowColorAnalysis(const gfx::Bitmap& bitmap, const std::string& title) {
|
||||
void PaletteWidget::ShowColorAnalysis(const gfx::Bitmap& bitmap, const std::string& title) {
|
||||
if (!show_color_analysis_) return;
|
||||
|
||||
if (ImGui::Begin(title.c_str(), &show_color_analysis_)) {
|
||||
@@ -150,7 +150,7 @@ void EnhancedPaletteEditor::ShowColorAnalysis(const gfx::Bitmap& bitmap, const s
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
bool EnhancedPaletteEditor::ApplyROMPalette(gfx::Bitmap* bitmap, int group_index, int palette_index) {
|
||||
bool PaletteWidget::ApplyROMPalette(gfx::Bitmap* bitmap, int group_index, int palette_index) {
|
||||
if (!bitmap || !rom_palettes_loaded_ ||
|
||||
group_index < 0 || group_index >= static_cast<int>(rom_palette_groups_.size())) {
|
||||
return false;
|
||||
@@ -181,7 +181,7 @@ bool EnhancedPaletteEditor::ApplyROMPalette(gfx::Bitmap* bitmap, int group_index
|
||||
}
|
||||
}
|
||||
|
||||
const gfx::SnesPalette* EnhancedPaletteEditor::GetSelectedROMPalette() const {
|
||||
const gfx::SnesPalette* PaletteWidget::GetSelectedROMPalette() const {
|
||||
if (!rom_palettes_loaded_ || current_group_index_ < 0 ||
|
||||
current_group_index_ >= static_cast<int>(rom_palette_groups_.size())) {
|
||||
return nullptr;
|
||||
@@ -190,11 +190,11 @@ const gfx::SnesPalette* EnhancedPaletteEditor::GetSelectedROMPalette() const {
|
||||
return &rom_palette_groups_[current_group_index_];
|
||||
}
|
||||
|
||||
void EnhancedPaletteEditor::SavePaletteBackup(const gfx::SnesPalette& palette) {
|
||||
void PaletteWidget::SavePaletteBackup(const gfx::SnesPalette& palette) {
|
||||
backup_palette_ = palette;
|
||||
}
|
||||
|
||||
bool EnhancedPaletteEditor::RestorePaletteBackup(gfx::SnesPalette& palette) {
|
||||
bool PaletteWidget::RestorePaletteBackup(gfx::SnesPalette& palette) {
|
||||
if (backup_palette_.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ bool EnhancedPaletteEditor::RestorePaletteBackup(gfx::SnesPalette& palette) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void EnhancedPaletteEditor::DrawPaletteGrid(gfx::SnesPalette& palette, int cols) {
|
||||
void PaletteWidget::DrawPaletteGrid(gfx::SnesPalette& palette, int cols) {
|
||||
for (int i = 0; i < static_cast<int>(palette.size()); i++) {
|
||||
if (i % cols != 0) ImGui::SameLine();
|
||||
|
||||
@@ -281,7 +281,7 @@ void EnhancedPaletteEditor::DrawPaletteGrid(gfx::SnesPalette& palette, int cols)
|
||||
}
|
||||
}
|
||||
|
||||
void EnhancedPaletteEditor::DrawROMPaletteSelector() {
|
||||
void PaletteWidget::DrawROMPaletteSelector() {
|
||||
if (!rom_palettes_loaded_) {
|
||||
LoadROMPalettes();
|
||||
}
|
||||
@@ -323,7 +323,7 @@ void EnhancedPaletteEditor::DrawROMPaletteSelector() {
|
||||
}
|
||||
}
|
||||
|
||||
void EnhancedPaletteEditor::DrawColorEditControls(gfx::SnesColor& color, int color_index) {
|
||||
void PaletteWidget::DrawColorEditControls(gfx::SnesColor& color, int color_index) {
|
||||
ImVec4 rgba = color.rgb();
|
||||
|
||||
ImGui::PushID(color_index);
|
||||
@@ -359,7 +359,7 @@ void EnhancedPaletteEditor::DrawColorEditControls(gfx::SnesColor& color, int col
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void EnhancedPaletteEditor::DrawPaletteAnalysis(const gfx::SnesPalette& palette) {
|
||||
void PaletteWidget::DrawPaletteAnalysis(const gfx::SnesPalette& palette) {
|
||||
ImGui::Text("Palette Information:");
|
||||
ImGui::Text("Size: %zu colors", palette.size());
|
||||
|
||||
@@ -413,7 +413,7 @@ void EnhancedPaletteEditor::DrawPaletteAnalysis(const gfx::SnesPalette& palette)
|
||||
ImGui::ProgressBar(avg_brightness, ImVec2(-1, 0), "Avg");
|
||||
}
|
||||
|
||||
void EnhancedPaletteEditor::LoadROMPalettes() {
|
||||
void PaletteWidget::LoadROMPalettes() {
|
||||
if (!rom_ || rom_palettes_loaded_) return;
|
||||
|
||||
try {
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef YAZE_APP_GUI_ENHANCED_PALETTE_EDITOR_H
|
||||
#define YAZE_APP_GUI_ENHANCED_PALETTE_EDITOR_H
|
||||
#ifndef YAZE_APP_GUI_PALETTE_WIDGET_H
|
||||
#define YAZE_APP_GUI_PALETTE_WIDGET_H
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@@ -12,11 +12,18 @@ namespace yaze {
|
||||
namespace gui {
|
||||
|
||||
/**
|
||||
* @brief Enhanced palette editor with ROM integration and analysis tools
|
||||
* @brief Palette widget with ROM integration, analysis tools, and AI tool call support
|
||||
*
|
||||
* This widget provides comprehensive palette editing capabilities including:
|
||||
* - Grid-based color editing with preview
|
||||
* - ROM palette browser and manager
|
||||
* - Color analysis and statistics
|
||||
* - Export/import functionality
|
||||
* - AI agent tool call integration for programmatic palette access
|
||||
*/
|
||||
class EnhancedPaletteEditor {
|
||||
class PaletteWidget {
|
||||
public:
|
||||
EnhancedPaletteEditor() = default;
|
||||
PaletteWidget() = default;
|
||||
|
||||
/**
|
||||
* @brief Initialize the palette editor with ROM data
|
||||
@@ -89,4 +96,4 @@ private:
|
||||
} // namespace gui
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_GUI_ENHANCED_PALETTE_EDITOR_H
|
||||
#endif // YAZE_APP_GUI_WIDGETS_PALETTE_WIDGET_H
|
||||
Reference in New Issue
Block a user