ENH: modify the UI of filament map dialog

jira: none
Change-Id: I513a518de4509fb7adbc81d9fc3b0fc43fb3244a
(cherry picked from commit 631baa3999ece2540c66cbf1488c55b64cadaf8e)
This commit is contained in:
zhimin.zeng 2024-09-23 11:38:10 +08:00 committed by Noisyfox
parent df7a9b1267
commit 7c6edc004f
4 changed files with 111 additions and 69 deletions

View file

@ -64,33 +64,14 @@ private:
/////////////// ColorPanel start ////////////////////////
// The UI panel of drag item
class ColorPanel : public wxPanel
ColorPanel::ColorPanel(DragDropPanel *parent, const wxColour &color, int filament_id)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(50, 50), wxBORDER_SIMPLE), m_parent(parent), m_color(color), m_filament_id(filament_id)
{
public:
ColorPanel(DragDropPanel *parent, const wxColour &color, int filament_id)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(50, 50), wxBORDER_SIMPLE)
, m_parent(parent)
, m_color(color)
, m_filament_id(filament_id)
{
SetBackgroundColour(color);
Bind(wxEVT_LEFT_DOWN, &ColorPanel::OnLeftDown, this);
Bind(wxEVT_LEFT_UP, &ColorPanel::OnLeftUp, this);
Bind(wxEVT_PAINT, &ColorPanel::OnPaint, this);
}
wxColour GetColor() const { return GetBackgroundColour(); }
int GetFilamentId() const { return m_filament_id; }
private:
void OnLeftDown(wxMouseEvent &event);
void OnLeftUp(wxMouseEvent &event);
void OnPaint(wxPaintEvent &event);
DragDropPanel *m_parent;
wxColor m_color;
int m_filament_id;
};
SetBackgroundColour(color);
Bind(wxEVT_LEFT_DOWN, &ColorPanel::OnLeftDown, this);
Bind(wxEVT_LEFT_UP, &ColorPanel::OnLeftUp, this);
Bind(wxEVT_PAINT, &ColorPanel::OnPaint, this);
}
void ColorPanel::OnLeftDown(wxMouseEvent &event)
{
@ -198,6 +179,7 @@ void DragDropPanel::AddColorBlock(const wxColour &color, int filament_id)
ColorPanel *panel = new ColorPanel(this, color, filament_id);
panel->SetMinSize(wxSize(50, 50));
m_grid_item_sizer->Add(panel, 0, wxALIGN_CENTER | wxALL, 5);
m_filament_blocks.push_back(panel);
Layout();
}
@ -205,6 +187,7 @@ void DragDropPanel::RemoveColorBlock(ColorPanel *panel)
{
m_sizer->Detach(panel);
panel->Destroy();
m_filament_blocks.erase(std::remove(m_filament_blocks.begin(), m_filament_blocks.end(), panel), m_filament_blocks.end());
Layout();
}