mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-01-04 22:07:41 -07:00
FIX: Show RGB for custom color and allow staying in official picker dialog
- Display RGB values when a custom color is selected - Prevent official color picker dialog from closing when custom color dialog is canceled - Ensure multi-color materials are correctly displayed when importing new 3MF files jira: STUDIO-12938, STUDIO-12937, STUDIO-12933, STUDIO-13110 Change-Id: Iab410585bf8cc5e9e81c6f0da23fe4ddba561785 (cherry picked from commit 2c20d591b998b02b0b66ac81b048a28fa26bd409)
This commit is contained in:
parent
0bbd563a79
commit
ea826815af
6 changed files with 82 additions and 14 deletions
|
|
@ -7,6 +7,7 @@
|
|||
#include "Widgets/Label.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/StateColor.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include <wx/wx.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/stattext.h>
|
||||
|
|
@ -283,6 +284,14 @@ void FilamentPickerDialog::SetupLabelsContent(const FilamentColor &fila_color, c
|
|||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (fila_color.ColorCount() == 1) {
|
||||
m_label_preview_color->SetLabel(fila_color.m_colors.begin()->GetAsString(wxC2S_HTML_SYNTAX));
|
||||
}
|
||||
else{
|
||||
m_label_preview_color->SetLabel(_L("Multiple Color"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxBoxSizer* FilamentPickerDialog::CreateSeparatorLine()
|
||||
|
|
@ -441,6 +450,28 @@ void FilamentPickerDialog::UpdatePreview(const FilamentColorCode& color_code)
|
|||
Layout();
|
||||
}
|
||||
|
||||
void FilamentPickerDialog::UpdateCustomColorPreview(const wxColour& custom_color)
|
||||
{
|
||||
std::vector<wxColour> wx_colors = {custom_color};
|
||||
|
||||
// Update preview bitmap
|
||||
wxBitmap bmp = create_filament_bitmap(wx_colors, COLOR_DEMO_SIZE, false);
|
||||
|
||||
if (bmp.IsOk()) {
|
||||
BOOST_LOG_TRIVIAL(debug) << "Custom color bitmap created successfully: " << bmp.GetWidth() << "x" << bmp.GetHeight();
|
||||
m_color_demo->SetBitmap(bmp);
|
||||
m_color_demo->SetBackgroundColour(custom_color);
|
||||
m_color_demo->Refresh();
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "Failed to create custom color bitmap";
|
||||
}
|
||||
|
||||
// Update preview labels for custom color
|
||||
m_label_preview_color->SetLabel(custom_color.GetAsString(wxC2S_HTML_SYNTAX));
|
||||
m_label_preview_idx->SetLabel(_L(""));
|
||||
Layout();
|
||||
}
|
||||
|
||||
void FilamentPickerDialog::UpdateButtonStates(wxBitmapButton* selected_btn)
|
||||
{
|
||||
// Reset selected button appearance
|
||||
|
|
@ -530,6 +561,16 @@ wxBoxSizer* FilamentPickerDialog::CreateButtonPanel()
|
|||
return btn_sizer;
|
||||
}
|
||||
|
||||
wxColourData FilamentPickerDialog::GetSingleColorData()
|
||||
{
|
||||
wxColourData data;
|
||||
data.SetChooseFull(true);
|
||||
if (m_current_filament_color.ColorCount() > 0) {
|
||||
data.SetColour(*m_current_filament_color.m_colors.begin());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void FilamentPickerDialog::BindEvents()
|
||||
{
|
||||
// Bind mouse events
|
||||
|
|
@ -555,10 +596,23 @@ void FilamentPickerDialog::BindEvents()
|
|||
// Bind more colors button event
|
||||
if (m_more_btn) {
|
||||
m_more_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
|
||||
auto parent = dynamic_cast<PlaterPresetComboBox*>(GetParent());
|
||||
if (parent) {
|
||||
parent->show_default_color_picker();
|
||||
EndModal(wxID_CANCEL);
|
||||
wxColourData original_data = GetSingleColorData();
|
||||
wxColourData result = show_sys_picker_dialog(this, original_data);
|
||||
|
||||
// Check if user actually selected a different color
|
||||
if (result.GetColour() != original_data.GetColour()) {
|
||||
wxColour selected_color = result.GetColour();
|
||||
|
||||
// Update m_current_filament_color with the selected color
|
||||
m_current_filament_color.m_colors.clear();
|
||||
m_current_filament_color.m_colors.insert(selected_color);
|
||||
m_current_filament_color.m_color_type = FilamentColor::ColorType::SINGLE_CLR;
|
||||
|
||||
// Update preview
|
||||
UpdateCustomColorPreview(selected_color);
|
||||
|
||||
// Clear currently selected button since custom color selected
|
||||
UpdateButtonStates(nullptr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ private:
|
|||
|
||||
// UI update methods
|
||||
void UpdatePreview(const FilamentColorCode& filament);
|
||||
void UpdateCustomColorPreview(const wxColour& custom_color);
|
||||
void UpdateButtonStates(wxBitmapButton* selected_btn);
|
||||
|
||||
// Shaped window methods
|
||||
|
|
@ -64,6 +65,7 @@ private:
|
|||
|
||||
// Data loading
|
||||
bool LoadFilamentData(const wxString& fila_id);
|
||||
wxColourData GetSingleColorData();
|
||||
|
||||
// UI elements
|
||||
wxStaticBitmap* m_color_demo{nullptr};
|
||||
|
|
|
|||
|
|
@ -5826,7 +5826,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
}
|
||||
// If there is no multi-color data or color is not match, use single color as default value
|
||||
for (size_t i = 0; i < filament_count; i++) {
|
||||
std::vector<std::string> colors = Slic3r::split_string(filament_multi_color->values[i], ',');
|
||||
std::vector<std::string> colors = Slic3r::split_string(filament_multi_color->values[i], ' ');
|
||||
if (i >= filament_multi_color->values.size() || colors.empty() || colors[0] != filament_color->values[i] ) {
|
||||
filament_multi_color->values[i] = filament_color->values[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1421,13 +1421,11 @@ FilamentColor PlaterPresetComboBox::get_cur_color_info()
|
|||
|
||||
void PlaterPresetComboBox::show_default_color_picker()
|
||||
{
|
||||
wxColourDialog dialog(this, &m_clrData);
|
||||
dialog.SetTitle(_L("Please choose the filament colour"));
|
||||
if (dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
m_clrData = dialog.GetColourData();
|
||||
std::vector<std::string> color = {m_clrData.GetColour().GetAsString(wxC2S_HTML_SYNTAX).ToStdString()};
|
||||
this->sync_colour_config(color, false);
|
||||
wxColourData data = show_sys_picker_dialog(this, m_clrData);
|
||||
if(m_clrData.GetColour() != data.GetColour()) {
|
||||
std::vector<std::string> color = {data.GetColour().GetAsString(wxC2S_HTML_SYNTAX).ToStdString()};
|
||||
m_clrData.SetColour(data.GetColour());
|
||||
sync_colour_config(color, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -581,6 +581,19 @@ std::vector<std::vector<std::string>> read_color_pack(std::vector<std::string> c
|
|||
return color_info;
|
||||
}
|
||||
|
||||
wxColourData show_sys_picker_dialog(wxWindow *parent, const wxColourData &clr_data)
|
||||
{
|
||||
wxColourData data;
|
||||
data.SetChooseFull(true);
|
||||
data.SetColour(clr_data.GetColour());
|
||||
wxColourDialog dialog(parent, &data);
|
||||
dialog.SetTitle(_L("Please choose the filament colour"));
|
||||
if (dialog.ShowModal() == wxID_OK) {
|
||||
data = dialog.GetColourData();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
wxBitmap *get_extruder_color_icon(std::vector<std::string> colors, bool is_gradient, std::string label, int icon_width, int icon_height){
|
||||
|
||||
static Slic3r::GUI::BitmapCache bmp_cache;
|
||||
|
|
@ -751,7 +764,6 @@ void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
|
|||
(*ctrl)->SetSelection(0);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// LockButton
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@
|
|||
#include <wx/bmpcbox.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/scrolwin.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/scrolwin.h>
|
||||
#include <wx/colordlg.h>
|
||||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
|
@ -77,6 +78,7 @@ std::vector<wxBitmap *> get_extruder_color_icons(bool thin_icon = false);
|
|||
wxBitmap * get_extruder_color_icon(std::string color, std::string label, int icon_width, int icon_height);
|
||||
wxBitmap * get_extruder_color_icon(std::vector<std::string> colors, bool is_gradient, std::string label, int icon_width, int icon_height);
|
||||
std::vector<std::vector<std::string>> read_color_pack(std::vector<std::string> color_pack);
|
||||
wxColourData show_sys_picker_dialog(wxWindow *parent, const wxColourData &clr_data);
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue