mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-15 20:01:31 +00:00
* Define validated color picker selection contract * Integrate web color picker with gradient and alpha controls Co-authored-by: yw4z <ywsyildiz@gmail.com> * Apply shared Orca theme to web color picker * Host color picker in a validated WebView dialog * Persist color picker favorites in user preferences * Integrate localized web color picker with filament actions * Add color picker browser regressions and verify direct includes * Fit color picker content in a borderless floating panel * Anchor color picker panels to their triggering controls * Use accent foreground for selected color picker switches * Integrate web color picker into generic color fields * Use web color picker for AMS custom colors * Use shared web color picker from Linux sidebar menu * Use web color picker when adding texture import material * Preserve alpha in filament color picker actions * Clean up color picker asset whitespace * Use application translations for color picker validation * Preserve existing formatting in color picker integration * Match SpeedDial rounded window handling on macOS * Align color picker host behavior with SpeedDial * Consolidate color picker implementation into its dialog * Remove native color picker fallback * Limit color picker interfaces to production consumers * Use shared WebView translation field name * Reapply anchored color picker placement after GTK show * update * fix increment buttons not working on spin inputs * Use thumb color from its own channel * init gradients with shifted color for second color * fix hsl sliders cannot move freely and lock downs other one * unify save button and color preview & increase stored color count to 32 * switch to hsl based calculation and fix plot and slider drag events * update * add support for multi colored gradients * Update test_filament_color_picker.cpp * add filtering color palette and store sidebar and combo state * open dialog with calculated size * apply shadow to dialog on windows * add tooltip for gradient add color button * Restore draggable fixed-size color picker frame * Fix color picker sidebar sizing in WebKit * Fix invisible default filament color button on macOS * Remove duplicated color defs for color picker * Remove duplicate HTML color picker frame * Match color picker tests to current theme roles * update icons * use focus color on background of filter box * align gradient switch with hex input * fix initial window sizing * Preserve caller color order when drawing filament icons --------- Co-authored-by: yw4z <ywsyildiz@gmail.com>
127 lines
3.9 KiB
C++
127 lines
3.9 KiB
C++
#ifndef slic3r_GUI_FilamentPickerDialog_hpp_
|
|
#define slic3r_GUI_FilamentPickerDialog_hpp_
|
|
|
|
#include "GUI_App.hpp"
|
|
#include "GUI.hpp"
|
|
#include "GUI_Utils.hpp"
|
|
#include "FilamentBitmapUtils.hpp"
|
|
#include "ColorPickerDialog.hpp"
|
|
#include <optional>
|
|
#include "Widgets/Button.hpp"
|
|
#include "EncodedFilament.hpp"
|
|
#include <wx/dialog.h>
|
|
#include <wx/string.h>
|
|
#include <wx/event.h>
|
|
#include <wx/gdicmn.h>
|
|
#include <wx/wx.h>
|
|
#include <wx/scrolwin.h>
|
|
#include <wx/bitmap.h>
|
|
#include <wx/region.h>
|
|
#include <wx/timer.h>
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
namespace Slic3r { namespace GUI {
|
|
|
|
class FilamentPickerDialog : public DPIDialog
|
|
{
|
|
public:
|
|
FilamentPickerDialog(wxWindow *parent, const wxString &fila_id, const FilamentColor &fila_color, const std::string &fila_type,
|
|
std::optional<FilamentColorPickerValue> ordered_color = std::nullopt);
|
|
virtual ~FilamentPickerDialog();
|
|
|
|
// Public interface methods
|
|
bool HasSelectionChanged() const { return m_selection_changed; }
|
|
const std::optional<ColorSelection>& GetCustomColorSelection() const { return m_custom_selection; }
|
|
bool IsDataLoaded() const { return m_is_data_loaded; }
|
|
wxColour GetSelectedColour() const;
|
|
const FilamentColor& GetSelectedFilamentColor() const { return m_cur_filament_color; }
|
|
|
|
protected:
|
|
void on_dpi_changed(const wxRect &suggested_rect) override;
|
|
|
|
// Event handlers
|
|
#ifdef __WXGTK__
|
|
void OnWindowCreate(wxWindowCreateEvent& event);
|
|
#endif
|
|
void OnMouseLeftDown(wxMouseEvent& event);
|
|
void OnMouseMove(wxMouseEvent& event);
|
|
void OnMouseLeftUp(wxMouseEvent& event);
|
|
void OnButtonPaint(wxPaintEvent& event);
|
|
void OnTimerCheck(wxTimerEvent& event);
|
|
void OnFlashTimer(wxTimerEvent& event);
|
|
|
|
// Platform-independent window detection
|
|
bool IsClickOnTopMostWindow(const wxPoint& mouse_pos);
|
|
void StartClickDetection();
|
|
void StopClickDetection();
|
|
void CleanupTimers();
|
|
|
|
private:
|
|
// UI creation methods
|
|
wxBoxSizer* CreatePreviewPanel(const FilamentColor& fila_color, const std::string& fila_type);
|
|
wxScrolledWindow* CreateColorGrid();
|
|
wxBoxSizer* CreateSeparatorLine();
|
|
void CreateMoreInfoButton();
|
|
void BindEvents();
|
|
|
|
// Preview panel helper methods
|
|
void CreateColorBitmap(const FilamentColor& fila_color);
|
|
wxBoxSizer* CreateInfoSection();
|
|
void SetupLabelsContent(const FilamentColor& fila_color, const std::string& fila_type);
|
|
|
|
// UI update methods
|
|
void UpdatePreview(const FilamentColorCode& filament);
|
|
void UpdateCustomColorPreview(const std::vector<wxColour>& colors, bool gradient);
|
|
void UpdateButtonStates(wxBitmapButton* selected_btn);
|
|
|
|
// Shaped window methods
|
|
void SetWindowShape();
|
|
void CreateShapedBitmap();
|
|
|
|
// Data loading
|
|
bool LoadFilamentData(const wxString& fila_id);
|
|
|
|
// Flash effect
|
|
void StartFlashing();
|
|
|
|
// UI elements
|
|
wxStaticBitmap* m_color_demo{nullptr};
|
|
wxStaticText* m_label_preview_color{nullptr};
|
|
wxStaticText* m_label_preview_idx{nullptr};
|
|
wxStaticText* m_label_preview_type{nullptr};
|
|
Button* m_more_btn{nullptr};
|
|
Button* m_ok_btn{nullptr};
|
|
Button* m_cancel_btn{nullptr};
|
|
|
|
// Data members
|
|
bool m_is_data_loaded{false};
|
|
wxString *m_cur_color_name{nullptr};
|
|
FilamentColorCodeQuery* m_color_query{nullptr};
|
|
FilamentColorCodes* m_cur_color_codes{nullptr};
|
|
wxBitmapButton* m_cur_selected_btn{nullptr};
|
|
FilamentColor m_cur_filament_color;
|
|
std::optional<FilamentColorPickerValue> m_ordered_color;
|
|
std::optional<ColorSelection> m_custom_selection;
|
|
bool m_selection_changed = false;
|
|
|
|
// Shaped window members
|
|
wxBitmap m_shape_bmp;
|
|
int m_corner_radius{8};
|
|
|
|
// Mouse drag members
|
|
wxPoint m_drag_delta;
|
|
|
|
// Click detection timers
|
|
wxTimer* m_click_timer{nullptr};
|
|
bool m_last_mouse_down{false};
|
|
|
|
// Flash effect timer
|
|
wxTimer* m_flash_timer{nullptr};
|
|
int m_flash_step{0};
|
|
};
|
|
|
|
}} // namespace Slic3r::GUI
|
|
|
|
#endif
|