OrcaSlicer/src/slic3r/GUI/Widgets/SideMenuPopup.cpp
lane.wei e9e4d75877 Update the codes to 01.01.00.10 for the formal release
1. first formal version of macos
2. add the bambu networking plugin install logic
3. auto compute the wipe volume when filament change
4. add the logic of wiping into support
5. refine the GUI layout and icons, improve the gui apperance in lots of
   small places
6. serveral improve to support
7. support AMS auto-mapping
8. disable lots of unstable features: such as params table, media file download, HMS
9. fix serveral kinds of bugs
10. update the document of building
11. ...
2022-07-22 20:35:34 +08:00

101 lines
2.1 KiB
C++

#include "SideMenuPopup.hpp"
#include "Label.hpp"
#include <wx/dcgraph.h>
wxBEGIN_EVENT_TABLE(SidePopup,wxPopupTransientWindow)
EVT_PAINT(SidePopup::paintEvent)
wxEND_EVENT_TABLE()
SidePopup::SidePopup(wxWindow* parent)
:wxPopupTransientWindow(parent,
wxBORDER_NONE |
wxPU_CONTAINS_CONTROLS)
{
#ifdef __WINDOWS__
SetDoubleBuffered(true);
#endif //__WINDOWS__
}
SidePopup::~SidePopup()
{
;
}
void SidePopup::OnDismiss()
{
wxPopupTransientWindow::OnDismiss();
}
bool SidePopup::ProcessLeftDown(wxMouseEvent& event)
{
return wxPopupTransientWindow::ProcessLeftDown(event);
}
bool SidePopup::Show( bool show )
{
return wxPopupTransientWindow::Show(show);
}
void SidePopup::Popup(wxWindow* focus)
{
Create();
int screenwidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X,NULL);
int max_width = 0;
for (auto btn : btn_list)
{
max_width = std::max(btn->GetMinSize().x, max_width);
}
if (focus) {
wxPoint pos = focus->ClientToScreen(wxPoint(0, -6));
if (pos.x + max_width > screenwidth)
Position({pos.x - (pos.x + max_width - screenwidth),pos.y}, {0, focus->GetSize().y + 12});
else
Position(pos, {0, focus->GetSize().y + 12});
}
wxPopupTransientWindow::Popup();
}
void SidePopup::Create()
{
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
int max_width = 0;
int height = 0;
for (auto btn : btn_list)
{
max_width = std::max(btn->GetMinSize().x, max_width);
}
for (auto btn : btn_list)
{
wxSize size = btn->GetMinSize();
height += size.y;
size.x = max_width;
btn->SetMinSize(size);
btn->SetSize(size);
sizer->Add(btn, 0, 0, 0);
}
SetSize(wxSize(max_width, height));
SetSizer(sizer, true);
Layout();
Refresh();
}
void SidePopup::paintEvent(wxPaintEvent& evt)
{
wxPaintDC dc(this);
wxSize size = GetSize();
dc.SetBrush(wxTransparentColour);
dc.DrawRectangle(0, 0, size.x, size.y);
}
void SidePopup::append_button(SideButton* btn)
{
btn_list.push_back(btn);
}