OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::DragDropPanel Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/DragDropPanel.hpp>

Inheritance diagram for Slic3r::GUI::DragDropPanel:
Collaboration diagram for Slic3r::GUI::DragDropPanel:

Public Member Functions

 DragDropPanel (wxWindow *parent, const wxString &label, bool is_auto, bool has_title=true, bool is_sub=false)
void AddColorBlock (const wxColour &color, const std::string &type, int filament_id, bool update_ui=true)
void RemoveColorBlock (ColorPanel *panel, bool update_ui=true)
void DoDragDrop (ColorPanel *panel, const wxColour &color, const std::string &type, int filament_id)
void UpdateLabel (const wxString &label)
std::vector< int > GetAllFilaments () const
void set_is_draging (bool is_draging)
bool is_draging () const
std::vector< ColorPanel * > get_filament_blocks () const

Private Member Functions

void NotifyDragDropCompleted ()

Private Attributes

wxBoxSizer * m_sizer
wxGridSizer * m_grid_item_sizer
Label * m_title_label = nullptr
bool m_is_auto
std::vector< ColorPanel * > m_filament_blocks
bool m_is_draging = false

Detailed Description

Constructor & Destructor Documentation

◆ DragDropPanel()

Slic3r::GUI::DragDropPanel::DragDropPanel ( wxWindow * parent,
const wxString & label,
bool is_auto,
bool has_title = true,
bool is_sub = false )
232 : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE)
234{
235 SetBackgroundColour(0xF8F8F8);
236
237 m_sizer = new wxBoxSizer(wxVERTICAL);
238
239 if (has_title) {
240 auto title_panel = new wxPanel(this);
241 title_panel->SetBackgroundColour(is_sub ? wxColour(0xF8F8F8) : wxColour(0xEEEEEE));
242 auto title_sizer = new wxBoxSizer(wxHORIZONTAL);
243 title_panel->SetSizer(title_sizer);
244
245 m_title_label = new Label(this, label);
246 m_title_label->SetFont(is_sub ? Label::Body_12 : Label::Head_13);
247 if (is_sub)
248 m_title_label->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#6B6B6B")));
249 m_title_label->SetBackgroundColour(is_sub ? wxColour(0xF8F8F8) : wxColour(0xEEEEEE));
250
251 title_sizer->Add(m_title_label, 0, wxALIGN_CENTER | wxALL, FromDIP(5));
252
253 m_sizer->Add(title_panel, 0, wxEXPAND);
254 m_sizer->AddSpacer(10);
255 }
256
257 if (is_sub) {
258 m_grid_item_sizer = new wxGridSizer(0, 3, FromDIP(6), FromDIP(6));
259 m_sizer->Add(m_grid_item_sizer, 0, wxEXPAND);
260 } else {
261 m_grid_item_sizer = new wxGridSizer(0, 6, FromDIP(8), FromDIP(8)); // row = 0, col = 3, 10 10 is space
262 m_sizer->Add(m_grid_item_sizer, 1, wxEXPAND | wxALL, FromDIP(8));
263 }
264
265 // set droptarget
266 auto drop_target = new ColorDropTarget(this);
267 SetDropTarget(drop_target);
268
269 SetSizer(m_sizer);
270 Layout();
271 Fit();
272}
static wxFont Head_13
Definition Label.hpp:46
static wxFont Body_12
Definition Label.hpp:55
wxBoxSizer * m_sizer
Definition DragDropPanel.hpp:45
bool m_is_auto
Definition DragDropPanel.hpp:48
Label * m_title_label
Definition DragDropPanel.hpp:47
wxGridSizer * m_grid_item_sizer
Definition DragDropPanel.hpp:46
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
bool is_auto(SupportType stype)
Definition PrintConfig.hpp:389

References Label::Body_12, StateColor::darkModeColorFor(), Label::Head_13, Slic3r::is_auto(), m_grid_item_sizer, m_is_auto, m_sizer, and m_title_label.

Here is the call graph for this function:

Member Function Documentation

◆ AddColorBlock()

void Slic3r::GUI::DragDropPanel::AddColorBlock ( const wxColour & color,
const std::string & type,
int filament_id,
bool update_ui = true )
275{
276 ColorPanel *panel = new ColorPanel(this, color, filament_id, type);
277 panel->SetMinSize(wxSize(FromDIP(30), FromDIP(60)));
278 m_grid_item_sizer->Add(panel, 0);
279 m_filament_blocks.push_back(panel);
280 if (update_ui) {
281 Freeze();
282
283 m_grid_item_sizer->Layout();
284 Layout();
285 Fit();
286 GetParent()->GetParent()->Layout();
287 GetParent()->GetParent()->Fit();
288 m_filament_blocks.front()->Refresh(); // FIX BUG: STUDIO-8467
289
290 Thaw();
292 }
293}
static void update_ui(wxWindow *window)
Definition WipeTowerDialog.cpp:60
std::vector< ColorPanel * > m_filament_blocks
Definition DragDropPanel.hpp:50
void NotifyDragDropCompleted()
Definition DragDropPanel.cpp:350

References m_filament_blocks, m_grid_item_sizer, NotifyDragDropCompleted(), and update_ui().

Here is the call graph for this function:

◆ DoDragDrop()

void Slic3r::GUI::DragDropPanel::DoDragDrop ( ColorPanel * panel,
const wxColour & color,
const std::string & type,
int filament_id )
314{
315 if (m_is_auto)
316 return;
317
318 ColorDropSource source(this, panel, color, type, filament_id);
319 if (source.DoDragDrop(wxDrag_CopyOnly) == wxDragResult::wxDragCopy) {
320 this->RemoveColorBlock(panel);
321 }
322}
void RemoveColorBlock(ColorPanel *panel, bool update_ui=true)
Definition DragDropPanel.cpp:295

References m_is_auto, and RemoveColorBlock().

Here is the call graph for this function:

◆ get_filament_blocks()

std::vector< ColorPanel * > Slic3r::GUI::DragDropPanel::get_filament_blocks ( ) const
inline
42{ return m_filament_blocks; }

References m_filament_blocks.

◆ GetAllFilaments()

std::vector< int > Slic3r::GUI::DragDropPanel::GetAllFilaments ( ) const
334{
335 std::vector<int> filaments;
336 for (size_t i = 0; i < m_grid_item_sizer->GetItemCount(); ++i) {
337 wxSizerItem *item = m_grid_item_sizer->GetItem(i);
338 if (item != nullptr) {
339 wxWindow * window = item->GetWindow();
340 ColorPanel *colorPanel = dynamic_cast<ColorPanel *>(window);
341 if (colorPanel != nullptr) {
342 filaments.push_back(colorPanel->GetFilamentId());
343 }
344 }
345 }
346
347 return filaments;
348}

References Slic3r::GUI::ColorPanel::GetFilamentId(), and m_grid_item_sizer.

Here is the call graph for this function:

◆ is_draging()

bool Slic3r::GUI::DragDropPanel::is_draging ( ) const
inline
40{ return m_is_draging; }
bool m_is_draging
Definition DragDropPanel.hpp:54

References m_is_draging.

Referenced by set_is_draging().

Here is the caller graph for this function:

◆ NotifyDragDropCompleted()

void Slic3r::GUI::DragDropPanel::NotifyDragDropCompleted ( )
private
351{
352 wxCommandEvent event(wxEVT_DRAG_DROP_COMPLETED);
353 event.SetEventObject(this);
354
355 wxWindow *parent = GetParent();
356 while (parent) {
357 auto name = parent->GetName();
358 if (name == wxT("FilamentMapManualPanel")) {
359 parent->GetEventHandler()->ProcessEvent(event);
360 break;
361 }
362 parent = parent->GetParent();
363 }
364}

Referenced by AddColorBlock(), and RemoveColorBlock().

Here is the caller graph for this function:

◆ RemoveColorBlock()

void Slic3r::GUI::DragDropPanel::RemoveColorBlock ( ColorPanel * panel,
bool update_ui = true )
296{
297 m_grid_item_sizer->Detach(panel);
298 panel->Destroy();
299 m_filament_blocks.erase(std::remove(m_filament_blocks.begin(), m_filament_blocks.end(), panel), m_filament_blocks.end());
300 if (update_ui) {
301 Freeze();
302
303 Layout();
304 Fit();
305 GetParent()->GetParent()->Layout();
306 GetParent()->GetParent()->Fit();
307
308 Thaw();
310 }
311}

References m_filament_blocks, m_grid_item_sizer, NotifyDragDropCompleted(), and update_ui().

Referenced by DoDragDrop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_is_draging()

void Slic3r::GUI::DragDropPanel::set_is_draging ( bool is_draging)
inline
bool is_draging() const
Definition DragDropPanel.hpp:40

References is_draging(), and m_is_draging.

Here is the call graph for this function:

◆ UpdateLabel()

void Slic3r::GUI::DragDropPanel::UpdateLabel ( const wxString & label)
325{
326 if (m_title_label) {
327 m_title_label->SetLabel(label);
328 m_title_label->Refresh();
329 Layout();
330 }
331}

References m_title_label.

Member Data Documentation

◆ m_filament_blocks

std::vector<ColorPanel *> Slic3r::GUI::DragDropPanel::m_filament_blocks
private

◆ m_grid_item_sizer

wxGridSizer* Slic3r::GUI::DragDropPanel::m_grid_item_sizer
private

◆ m_is_auto

bool Slic3r::GUI::DragDropPanel::m_is_auto
private

Referenced by DragDropPanel(), and DoDragDrop().

◆ m_is_draging

bool Slic3r::GUI::DragDropPanel::m_is_draging = false
private

Referenced by is_draging(), and set_is_draging().

◆ m_sizer

wxBoxSizer* Slic3r::GUI::DragDropPanel::m_sizer
private

Referenced by DragDropPanel().

◆ m_title_label

Label* Slic3r::GUI::DragDropPanel::m_title_label = nullptr
private

Referenced by DragDropPanel(), and UpdateLabel().


The documentation for this class was generated from the following files: