#include "BaseTransparentDPIFrame.hpp" #include #include #include #include #include #include "GUI_App.hpp" #include "Tab.hpp" #include "PartPlate.hpp" #include "I18N.hpp" #include "MainFrame.hpp" #include "Widgets/Button.hpp" #include "Widgets/TextInput.hpp" #include "Notebook.hpp" #include #include "Widgets/Button.hpp" #include "Widgets/CheckBox.hpp" #include "CapsuleButton.hpp" using namespace Slic3r; using namespace Slic3r::GUI; namespace Slic3r { namespace GUI { #define ANIMATION_REFRESH_INTERVAL 15 BaseTransparentDPIFrame::BaseTransparentDPIFrame( wxWindow *parent, int win_width, wxPoint dialog_pos, int ok_button_width, wxString win_text, wxString ok_text, wxString cancel_text, DisappearanceMode disappearance_mode) : DPIFrame(static_cast(wxGetApp().mainframe), wxID_ANY, "", wxDefaultPosition, wxDefaultSize, !wxCAPTION | !wxCLOSE_BOX | wxBORDER_NONE) , m_timed_disappearance_mode(disappearance_mode) { // SetBackgroundStyle(wxBackgroundStyle::wxBG_STYLE_TRANSPARENT); SetTransparent(220); SetBackgroundColour(wxColour(23, 25, 22, 128)); SetMinSize(wxSize(FromDIP(win_width), -1)); SetMaxSize(wxSize(FromDIP(win_width), -1)); SetPosition(dialog_pos); m_sizer_main = new wxBoxSizer(wxVERTICAL); wxBoxSizer *text_sizer = new wxBoxSizer(wxHORIZONTAL); text_sizer->AddSpacer(FromDIP(20)); auto image_sizer = new wxBoxSizer(wxVERTICAL); auto imgsize = FromDIP(25); auto completedimg = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("completed", this, 25), wxDefaultPosition, wxSize(imgsize, imgsize), 0); image_sizer->Add(completedimg, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, FromDIP(0)); image_sizer->AddStretchSpacer(); text_sizer->Add(image_sizer); text_sizer->AddSpacer(FromDIP(5)); auto finish_text = new Label(this, win_text, LB_AUTO_WRAP); finish_text->SetMinSize(wxSize(FromDIP(win_width - 64), -1)); finish_text->SetMaxSize(wxSize(FromDIP(win_width - 64), -1)); finish_text->SetForegroundColour(wxColour(255, 255, 255, 255)); text_sizer->Add(finish_text, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 0); text_sizer->AddSpacer(FromDIP(20)); m_sizer_main->Add(text_sizer, FromDIP(0), wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxTOP, FromDIP(15)); wxBoxSizer *bSizer_button = new wxBoxSizer(wxHORIZONTAL); bSizer_button->SetMinSize(wxSize(FromDIP(100), -1)); /* m_checkbox = new wxCheckBox(this, wxID_ANY, _L("Don't show again"), wxDefaultPosition, wxDefaultSize, 0); bSizer_button->Add(m_checkbox, 0, wxALIGN_LEFT);*/ bSizer_button->AddStretchSpacer(1); StateColor btn_bg_green(std::pair(wxColour(27, 136, 68), StateColor::Pressed), std::pair(wxColour(61, 203, 115), StateColor::Hovered), std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); StateColor btn_bg_white(std::pair(wxColour(23, 25, 22), StateColor::Pressed), std::pair(wxColour(43, 45, 42), StateColor::Hovered), std::pair(wxColour(23, 25, 22), StateColor::Normal)); m_button_ok = new Button(this, ok_text); m_button_ok->SetBackgroundColor(btn_bg_green); m_button_ok->SetBorderWidth(0); m_button_ok->SetTextColor(wxColour(0xFEFEFE)); m_button_ok->SetFont(Label::Body_12); m_button_ok->SetSize(wxSize(FromDIP(60), FromDIP(30))); m_button_ok->SetMinSize(wxSize(FromDIP(90), FromDIP(30))); m_button_ok->SetCornerRadius(FromDIP(6)); bSizer_button->Add(m_button_ok, 0, wxALIGN_RIGHT | wxLEFT | wxTOP, FromDIP(10)); m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { deal_ok(); }); m_button_cancel = new Button(this, cancel_text); m_button_cancel->SetBackgroundColor(btn_bg_white); m_button_cancel->SetBorderColor(wxColour(93, 93, 91)); m_button_cancel->SetFont(Label::Body_12); m_button_cancel->SetTextColor(wxColour(0xFEFEFE)); m_button_cancel->SetSize(wxSize(FromDIP(65), FromDIP(30))); m_button_cancel->SetMinSize(wxSize(FromDIP(65), FromDIP(30))); m_button_cancel->SetCornerRadius(FromDIP(6)); bSizer_button->Add(m_button_cancel, 0, wxALIGN_RIGHT | wxLEFT | wxTOP, FromDIP(10)); m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { deal_cancel(); }); m_sizer_main->Add(bSizer_button, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, FromDIP(20)); Bind(wxEVT_CLOSE_WINDOW, [this](auto &e) { this->on_hide(); }); SetSizer(m_sizer_main); Layout(); Fit(); if (m_timed_disappearance_mode != DisappearanceMode::None) { init_timer(); Bind(wxEVT_TIMER, &BaseTransparentDPIFrame::on_timer, this); Bind(wxEVT_ENTER_WINDOW, [this](auto &e) { clear_timer_count(); m_refresh_timer->Stop(); }); Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) { m_refresh_timer->Start(ANIMATION_REFRESH_INTERVAL); }); } } BaseTransparentDPIFrame::~BaseTransparentDPIFrame() { } bool BaseTransparentDPIFrame::Show(bool show) { if (show) { if (m_refresh_timer) { m_refresh_timer->Start(ANIMATION_REFRESH_INTERVAL); } } else { if (m_refresh_timer) { m_refresh_timer->Stop(); } } Layout(); return DPIFrame::Show(show); } void BaseTransparentDPIFrame::on_dpi_changed(const wxRect &suggested_rect) { m_button_ok->Rescale(); m_button_cancel->Rescale(); } void BaseTransparentDPIFrame::on_show() { Show(); Raise(); } void BaseTransparentDPIFrame::on_hide() { this->Hide(); if (wxGetApp().mainframe != nullptr) { wxGetApp().mainframe->Show(); wxGetApp().mainframe->Raise(); } } void BaseTransparentDPIFrame::clear_timer_count() { m_timer_count = 0; } void BaseTransparentDPIFrame::init_timer() { m_refresh_timer = new wxTimer(); m_refresh_timer->SetOwner(this); } void BaseTransparentDPIFrame::on_timer(wxTimerEvent &event) { m_timer_count++; if (m_timed_disappearance_mode == DisappearanceMode::TimedDisappearance) { auto cur_time = ANIMATION_REFRESH_INTERVAL * m_timer_count; if (cur_time > m_disappearance_second) { on_hide(); } } } void BaseTransparentDPIFrame::deal_ok(){} void BaseTransparentDPIFrame::deal_cancel(){} }} // namespace Slic3r::GUI