mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-21 06:21:16 +00:00
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:
1 parent
5d73410281
commit
26f5fd6251
29 files changed
+4066
-449
No files matched your search
@@ -22,6 +22,13 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <wx/colour.h>
|
||||
#ifdef __WXMSW__
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <cstdlib>
|
||||
#include <utility>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
#endif
|
||||
#include <wx/string.h>
|
||||
|
||||
#include "libslic3r/FilamentMixer.hpp"
|
||||
@@ -260,3 +267,71 @@ TEST_CASE("sample_gradient_ramp returns nothing without a usable curve or step c
|
||||
curve.points = {{0.0, kGradientMaxRatio, NAN, NAN}, {1.0, kGradientMinRatio, NAN, NAN}};
|
||||
REQUIRE(Slic3r::GUI::sample_gradient_ramp(wxColour(255, 0, 0), wxColour(0, 0, 255), curve, 0).empty());
|
||||
}
|
||||
|
||||
// The headless GTK/macOS suite does not initialize GUI display/font stock objects.
|
||||
// Exercise native bitmap pixels on Windows without adding that dependency elsewhere.
|
||||
#ifdef __WXMSW__
|
||||
TEST_CASE("Filament gradient pixels follow both endpoint directions without changing input", "[FilamentBitmapUtils]")
|
||||
{
|
||||
const bool reverse = GENERATE(false, true);
|
||||
const std::vector<wxColour> colors = reverse ? std::vector<wxColour>{wxColour(0, 0, 255), wxColour(255, 0, 0)}
|
||||
: std::vector<wxColour>{wxColour(255, 0, 0), wxColour(0, 0, 255)};
|
||||
const auto original = colors;
|
||||
const wxBitmap bitmap = Slic3r::GUI::create_filament_bitmap(colors, wxSize(64, 16), true);
|
||||
REQUIRE(bitmap.IsOk());
|
||||
const wxImage image = bitmap.ConvertToImage();
|
||||
REQUIRE(image.IsOk());
|
||||
// Interior pixels avoid backend-specific rasterization at the gradient boundary.
|
||||
for (const auto& sample : {std::pair<int, wxColour>{2, colors.front()}, {61, colors.back()}}) {
|
||||
REQUIRE(std::abs(int(image.GetRed(sample.first, 8)) - int(sample.second.Red())) <= 16);
|
||||
REQUIRE(std::abs(int(image.GetBlue(sample.first, 8)) - int(sample.second.Blue())) <= 16);
|
||||
}
|
||||
REQUIRE(colors == original);
|
||||
}
|
||||
|
||||
TEST_CASE("Filament halves preserve the same caller color order as gradients", "[FilamentBitmapUtils]")
|
||||
{
|
||||
const bool reverse = GENERATE(false, true);
|
||||
const std::vector<wxColour> colors = reverse ? std::vector<wxColour>{wxColour(0, 0, 255), wxColour(255, 0, 0)}
|
||||
: std::vector<wxColour>{wxColour(255, 0, 0), wxColour(0, 0, 255)};
|
||||
const auto original = colors;
|
||||
const wxBitmap bitmap = Slic3r::GUI::create_filament_bitmap(colors, wxSize(64, 16), false);
|
||||
REQUIRE(bitmap.IsOk());
|
||||
const wxImage image = bitmap.ConvertToImage();
|
||||
REQUIRE(image.IsOk());
|
||||
require_same_rgb(wxColour(image.GetRed(16, 8), image.GetGreen(16, 8), image.GetBlue(16, 8)), colors.front());
|
||||
require_same_rgb(wxColour(image.GetRed(48, 8), image.GetGreen(48, 8), image.GetBlue(48, 8)), colors.back());
|
||||
REQUIRE(colors == original);
|
||||
}
|
||||
|
||||
TEST_CASE("Three color filament stripes retain caller order", "[FilamentBitmapUtils]")
|
||||
{
|
||||
const std::vector<wxColour> colors{wxColour(0, 0, 255), wxColour(0, 255, 0), wxColour(255, 0, 0)};
|
||||
const auto original = colors;
|
||||
const wxBitmap bitmap = Slic3r::GUI::create_filament_bitmap(colors, wxSize(72, 24), false);
|
||||
REQUIRE(bitmap.IsOk());
|
||||
const wxImage image = bitmap.ConvertToImage();
|
||||
REQUIRE(image.IsOk());
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
const int x = 12 + i * 24;
|
||||
require_same_rgb(wxColour(image.GetRed(x, 12), image.GetGreen(x, 12), image.GetBlue(x, 12)), colors[i]);
|
||||
}
|
||||
REQUIRE(colors == original);
|
||||
}
|
||||
|
||||
TEST_CASE("Four color filament quadrants retain caller order", "[FilamentBitmapUtils]")
|
||||
{
|
||||
const std::vector<wxColour> colors{wxColour(0, 0, 255), wxColour(0, 255, 0), wxColour(255, 0, 0), wxColour(255, 255, 0)};
|
||||
const auto original = colors;
|
||||
const wxBitmap bitmap = Slic3r::GUI::create_filament_bitmap(colors, wxSize(64, 32), false);
|
||||
REQUIRE(bitmap.IsOk());
|
||||
const wxImage image = bitmap.ConvertToImage();
|
||||
REQUIRE(image.IsOk());
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const int x = i % 2 ? 48 : 16, y = i / 2 ? 24 : 8;
|
||||
require_same_rgb(wxColour(image.GetRed(x, y), image.GetGreen(x, y), image.GetBlue(x, y)), colors[i]);
|
||||
}
|
||||
REQUIRE(colors == original);
|
||||
}
|
||||
|
||||
#endif // __WXMSW__
|
||||
Reference in new issue
Block a user