509 :
PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS)
520 {
522 SetBackgroundColour(pop_bg);
523
524
525 Bind(wxEVT_PAINT, [this](wxPaintEvent& evt) {
526 wxPaintDC dc(this);
528 dc.SetBrush(*wxTRANSPARENT_BRUSH);
529 dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
530 });
531
532 m_content =
new wxScrolledWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL);
534 m_content->SetScrollRate(0, FromDIP(20));
535 auto* outer = new wxBoxSizer(wxVERTICAL);
536
537 const int pop_w = std::max(FromDIP(213), popup_width);
538 const int row_h = FromDIP(32);
539 const int pad = FromDIP(8);
540 const int max_visible_rows = 10;
542
543 auto add_section_header = [&](const wxString& label) {
545 wxFont hf = hdr->GetFont();
546 hf.SetPointSize(9);
547 hdr->SetFont(hf);
548 hdr->SetForegroundColour(header_clr);
549 outer->Add(hdr, 0, wxLEFT | wxRIGHT | wxTOP, pad);
552 outer->Add(line, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, pad);
553 };
554
556 bool has_any = false;
558 if (entry.kind == kind) {
559 has_any = true;
560 break;
561 }
562 }
563 if (!has_any)
564 return;
565 add_section_header(label);
567 if (entry.kind != kind)
568 continue;
571 outer->Add(row, 0, wxEXPAND | wxLEFT | wxRIGHT, pad);
572 }
573 };
574
575
576
577
582
583 auto* decompose_label =
new wxStaticText(
this, wxID_ANY,
_L(
"Decompose Color"));
584 auto* add_label =
new wxStaticText(
this, wxID_ANY,
_L(
"+ Add Material"));
585 wxFont af = add_label->GetFont();
586 af.SetPointSize(10);
587 add_label->SetFont(af);
588 decompose_label->SetFont(af);
590 const wxColour action_clr = wxColour("#009688");
591 add_label->SetForegroundColour(add_enabled ? action_clr : header_clr);
592 decompose_label->SetForegroundColour(add_enabled ? action_clr : header_clr);
593 add_label->SetCursor(wxCursor(add_enabled ? wxCURSOR_HAND : wxCURSOR_ARROW));
594 decompose_label->SetCursor(wxCursor(add_enabled ? wxCURSOR_HAND : wxCURSOR_ARROW));
595 if (!add_enabled)
596 add_label->SetToolTip(wxString::Format(
597 _L_PLURAL(
"The project supports up to %d filament. Extra filaments will be discarded.",
598 "The project supports up to %d filaments. Extra filaments will be discarded.",
601 decompose_label->Bind(wxEVT_LEFT_DOWN, [
this](
wxMouseEvent&) {
603 return;
606 Dismiss();
607 if (on_decompose_color)
608 on_decompose_color();
609 });
610 add_label->Bind(wxEVT_LEFT_DOWN, [
this](
wxMouseEvent&) {
612 return;
613 }
615 wxWindow* popup_parent = GetParent();
617 wxWeakRef<FilamentSelectPopup> popup(this);
619 std::optional<wxColour> selected;
620 {
621
622 ColorPickerDialog dlg(popup_parent, ColorRGBA(0.f, 0.f, 0.f, 1.f), {}, false, color_anchor);
623 if (popup) popup->Dismiss();
624
625 if (dlg.ShowModal() == wxID_OK && dlg.selection()) {
626 const auto& color = std::get<ColorRGBA>(*dlg.selection());
627 selected = wxColour(static_cast<unsigned char>(std::lround(color.r() * 255.f)),
628 static_cast<unsigned char>(std::lround(color.g() * 255.f)),
629 static_cast<unsigned char>(std::lround(color.b() * 255.f)));
630 }
631 }
632 if (selected && on_add_filament) on_add_filament(*selected);
633 });
634
637
638 auto* top_sizer = new wxBoxSizer(wxVERTICAL);
639 int list_h = outer->GetMinSize().y;
641 list_h -= ((int)
m_colors_rgba.size() - max_visible_rows) * row_h;
642 m_content->SetMinSize(wxSize(pop_w, list_h));
643 m_content->SetMaxSize(wxSize(pop_w, list_h));
644 top_sizer->Add(
m_content, 0, wxEXPAND | wxALL, FromDIP(1));
645
646 top_sizer->AddSpacer(FromDIP(4));
647 auto* sep_line = new StaticLine(this);
649 top_sizer->Add(sep_line, 0, wxEXPAND | wxLEFT | wxRIGHT, pad);
650 top_sizer->Add(decompose_label, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM, pad);
651 auto* sep_line2 = new StaticLine(this);
653 top_sizer->Add(sep_line2, 0, wxEXPAND | wxLEFT | wxRIGHT, pad);
654 top_sizer->Add(add_label, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM, pad);
655 SetSizerAndFit(top_sizer);
656
657 SetSize(pop_w, top_sizer->GetMinSize().y);
658 }
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static constexpr const char * SEPARATOR_COLOUR_KEY
Definition TextureImportDialog.cpp:99
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
wxMouseEvent
Definition CameraPopup.cpp:47
static bool texture_entry_is_mixed(TextureFilamentKind kind)
Definition TextureImportDialog.cpp:407
TextureFilamentKind
Definition TextureImportDialog.hpp:54
@ NewMixed
Definition TextureImportDialog.hpp:58
@ ExistingMixed
Definition TextureImportDialog.hpp:56
@ NewPhysical
Definition TextureImportDialog.hpp:57
@ ExistingPhysical
Definition TextureImportDialog.hpp:55
@ ExtruderMax
Definition TriangleSelector.hpp:66
#define _L_PLURAL(s, plural, n)
Definition I18N.hpp:96