Add a themed WebView color picker with persistent favorites (#16197)

* 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>
This commit is contained in:
Noisyfox
2026-10-15 15:29:49 +08:00
committed by GitHub
co-authored by yw4z
parent 5d73410281
commit 26f5fd6251
29 changed files with 4066 additions and 449 deletions
+19 -42
View File
@@ -10,6 +10,11 @@
#include "GUI_App.hpp"
#include "MsgDialog.hpp"
#include "ColorDecomposeDialog.hpp"
#include "ColorPickerDialog.hpp"
#include "libslic3r/Color.hpp"
#include <optional>
#include <variant>
#include <wx/weakref.h>
#include "ColorDecomposeSupport.hpp"
#include "Widgets/StateColor.hpp"
#include "Widgets/StaticLine.hpp"
@@ -32,9 +37,7 @@
#include <mutex>
#include <wx/button.h>
#include <wx/colour.h>
#include <wx/colordlg.h>
#include <wx/dc.h>
#include <wx/colourdata.h>
#include <wx/dcclient.h>
#include <wx/dcbuffer.h>
#include <wx/dialog.h>
@@ -509,30 +512,6 @@ static wxString auto_mix_mode_label(TextureAutoMixMode mode)
_L("One-click RYBW auto-mix");
}
static wxPoint constrained_dialog_position(wxWindow* anchor, const wxSize& dialog_size)
{
if (!anchor)
return wxDefaultPosition;
wxSize size = dialog_size;
if (size.x <= 0 || size.y <= 0)
size = wxSize(anchor->FromDIP(450), anchor->FromDIP(350));
wxPoint pos = anchor->ClientToScreen(wxPoint(0, anchor->GetSize().y));
wxRect display_rect;
int display_idx = wxDisplay::GetFromPoint(pos);
if (display_idx != wxNOT_FOUND)
display_rect = wxDisplay(display_idx).GetClientArea();
else
display_rect = wxDisplay().GetClientArea();
pos.x = std::clamp(pos.x, display_rect.GetLeft(),
std::max(display_rect.GetLeft(), display_rect.GetRight() - size.x));
pos.y = std::clamp(pos.y, display_rect.GetTop(),
std::max(display_rect.GetTop(), display_rect.GetBottom() - size.y));
return pos;
}
// ============================================================
// FilamentSelectPopup
// ============================================================
@@ -653,24 +632,22 @@ public:
auto on_add_filament = m_on_add_filament;
wxWindow* popup_parent = GetParent();
wxWindow* color_anchor = m_dialog_anchor ? m_dialog_anchor : popup_parent;
wxWeakRef<FilamentSelectPopup> popup(this);
m_closing_from_action = true;
Dismiss();
wxColourData cd;
cd.SetChooseFull(true);
wxColourDialog dlg(popup_parent, &cd);
auto move_color_dialog = [&dlg, color_anchor]() {
dlg.Move(constrained_dialog_position(color_anchor, dlg.GetBestSize()));
};
dlg.Bind(wxEVT_SHOW, [move_color_dialog](wxShowEvent& e) mutable {
e.Skip();
if (e.IsShown())
move_color_dialog();
});
move_color_dialog();
if (dlg.ShowModal() == wxID_OK) {
wxColour clr = dlg.GetColourData().GetColour();
if (on_add_filament) on_add_filament(clr);
std::optional<wxColour> selected;
{
// Capture the stable mapping row before the transient popup is dismissed.
ColorPickerDialog dlg(popup_parent, ColorRGBA(0.f, 0.f, 0.f, 1.f), {}, false, color_anchor);
if (popup) popup->Dismiss();
// Dismissal can delete the popup. Only copied locals are used below.
if (dlg.ShowModal() == wxID_OK && dlg.selection()) {
const auto& color = std::get<ColorRGBA>(*dlg.selection());
selected = wxColour(static_cast<unsigned char>(std::lround(color.r() * 255.f)),
static_cast<unsigned char>(std::lround(color.g() * 255.f)),
static_cast<unsigned char>(std::lround(color.b() * 255.f)));
}
}
if (selected && on_add_filament) on_add_filament(*selected);
});
m_content->SetSizer(outer);