Merge branch 'master-remote' into feature/1.5

Signed-off-by: SoftFever <softfeverever@gmail.com>

# Conflicts:
#	bbl/i18n/BambuStudio.pot
#	bbl/i18n/de/BambuStudio_de.po
#	bbl/i18n/en/BambuStudio_en.po
#	bbl/i18n/es/BambuStudio_es.po
#	bbl/i18n/fr/BambuStudio_fr.po
#	bbl/i18n/hu/BambuStudio_hu.po
#	bbl/i18n/it/BambuStudio_it.po
#	bbl/i18n/nl/BambuStudio_nl.po
#	bbl/i18n/sv/BambuStudio_sv.po
#	bbl/i18n/zh_cn/BambuStudio_zh_CN.po
#	deps/Boost/Boost.cmake
#	deps/wxWidgets/wxWidgets.cmake
#	resources/config.json
#	resources/i18n/de/BambuStudio.mo
#	resources/i18n/en/BambuStudio.mo
#	resources/i18n/es/BambuStudio.mo
#	resources/i18n/fr/BambuStudio.mo
#	resources/i18n/hu/BambuStudio.mo
#	resources/i18n/it/BambuStudio.mo
#	resources/i18n/nl/BambuStudio.mo
#	resources/i18n/sv/BambuStudio.mo
#	resources/i18n/zh_cn/BambuStudio.mo
#	resources/images/tips_arrow.svg
#	resources/profiles/Anycubic.json
#	resources/profiles/Anycubic/filament/Anycubic Generic ABS.json
#	resources/profiles/Anycubic/filament/Anycubic Generic ASA.json
#	resources/profiles/Anycubic/filament/Anycubic Generic PA-CF.json
#	resources/profiles/Anycubic/filament/Anycubic Generic PA.json
#	resources/profiles/Anycubic/filament/Anycubic Generic PC.json
#	resources/profiles/Anycubic/filament/Anycubic Generic PETG.json
#	resources/profiles/Anycubic/filament/Anycubic Generic PLA-CF.json
#	resources/profiles/Anycubic/filament/Anycubic Generic PLA.json
#	resources/profiles/Anycubic/filament/Anycubic Generic PVA.json
#	resources/profiles/Anycubic/filament/Anycubic Generic TPU.json
#	resources/profiles/Anycubic/filament/fdm_filament_common.json
#	resources/profiles/Anycubic/machine/Anycubic 4Max Pro 0.4 nozzle.json
#	resources/profiles/Anycubic/machine/Anycubic 4Max Pro.json
#	resources/profiles/Anycubic/process/0.20mm Standard @4MaxPro.json
#	resources/profiles/Anycubic/process/fdm_process_common.json
#	resources/profiles/BBL.json
#	resources/profiles/BBL/machine/Bambu Lab P1P 0.2 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab P1P 0.4 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab P1P 0.6 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab P1P 0.8 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 0.2 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 0.4 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 0.6 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 0.8 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.2 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.4 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.6 nozzle.json
#	resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.8 nozzle.json
#	resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json
#	resources/profiles/Voron.json
#	resources/web/data/text.js
#	resources/web/image/printer/Anycubic 4Max Pro_cover.png
#	src/BambuStudio.cpp
#	src/libslic3r/GCode.cpp
#	src/libslic3r/GCode.hpp
#	src/libslic3r/GCode/GCodeProcessor.cpp
#	src/libslic3r/GCodeWriter.hpp
#	src/libslic3r/PerimeterGenerator.cpp
#	src/libslic3r/PresetBundle.cpp
#	src/libslic3r/Print.cpp
#	src/libslic3r/Print.hpp
#	src/libslic3r/PrintConfig.cpp
#	src/libslic3r/PrintConfig.hpp
#	src/libslic3r/PrintObject.cpp
#	src/slic3r/GUI/AMSMaterialsSetting.cpp
#	src/slic3r/GUI/AMSMaterialsSetting.hpp
#	src/slic3r/GUI/AmsMappingPopup.cpp
#	src/slic3r/GUI/AmsMappingPopup.hpp
#	src/slic3r/GUI/Auxiliary.cpp
#	src/slic3r/GUI/BackgroundSlicingProcess.cpp
#	src/slic3r/GUI/ConfigManipulation.cpp
#	src/slic3r/GUI/DeviceManager.cpp
#	src/slic3r/GUI/DeviceManager.hpp
#	src/slic3r/GUI/ExtrusionCalibration.cpp
#	src/slic3r/GUI/GCodeViewer.cpp
#	src/slic3r/GUI/GCodeViewer.hpp
#	src/slic3r/GUI/GUI_App.cpp
#	src/slic3r/GUI/IMSlider.cpp
#	src/slic3r/GUI/Jobs/PrintJob.cpp
#	src/slic3r/GUI/Jobs/PrintJob.hpp
#	src/slic3r/GUI/Jobs/SendJob.cpp
#	src/slic3r/GUI/Jobs/SendJob.hpp
#	src/slic3r/GUI/MainFrame.cpp
#	src/slic3r/GUI/MainFrame.hpp
#	src/slic3r/GUI/MediaPlayCtrl.cpp
#	src/slic3r/GUI/OptionsGroup.cpp
#	src/slic3r/GUI/PhysicalPrinterDialog.cpp
#	src/slic3r/GUI/Plater.cpp
#	src/slic3r/GUI/PrintHostDialogs.cpp
#	src/slic3r/GUI/Printer/BambuTunnel.h
#	src/slic3r/GUI/Printer/PrinterFileSystem.cpp
#	src/slic3r/GUI/Printer/gstbambusrc.c
#	src/slic3r/GUI/Printer/gstbambusrc.h
#	src/slic3r/GUI/ReleaseNote.cpp
#	src/slic3r/GUI/ReleaseNote.hpp
#	src/slic3r/GUI/SelectMachine.cpp
#	src/slic3r/GUI/SendToPrinter.cpp
#	src/slic3r/GUI/SetBedTypeDialog.cpp
#	src/slic3r/GUI/StatusPanel.cpp
#	src/slic3r/GUI/StatusPanel.hpp
#	src/slic3r/GUI/Tab.cpp
#	src/slic3r/GUI/Widgets/AMSControl.cpp
#	src/slic3r/GUI/Widgets/AMSControl.hpp
#	src/slic3r/GUI/Widgets/ImageSwitchButton.cpp
#	src/slic3r/GUI/Widgets/Label.cpp
#	src/slic3r/GUI/WipeTowerDialog.cpp
#	src/slic3r/Utils/Process.cpp
#	src/slic3r/Utils/bambu_networking.hpp
#	version.inc
This commit is contained in:
SoftFever 2023-03-08 00:08:26 +08:00
commit 5ef51f6c8a
339 changed files with 37169 additions and 5445 deletions

View file

@ -9,21 +9,12 @@
namespace Slic3r { namespace GUI {
static const int LOAD_STEP_COUNT = 5;
static const int UNLOAD_STEP_COUNT = 3;
static const int LOAD_STEP_COUNT = 5;
static const int UNLOAD_STEP_COUNT = 3;
static const int VT_LOAD_STEP_COUNT = 4;
static const wxColour AMS_TRAY_DEFAULT_COL = wxColour(255, 255, 255);
static wxString FILAMENT_LOAD_STEP_STRING[LOAD_STEP_COUNT] = {
_L("Heat the nozzle"),
_L("Cut filament"),
_L("Pull back current filament"),
_L("Push new filament into extruder"),
_L("Purge old filament"),
};
static wxString FILAMENT_UNLOAD_STEP_STRING[UNLOAD_STEP_COUNT] = {_L("Heat the nozzle"), _L("Cut filament"), _L("Pull back current filament")};
wxDEFINE_EVENT(EVT_AMS_EXTRUSION_CALI, wxCommandEvent);
wxDEFINE_EVENT(EVT_AMS_LOAD, SimpleEvent);
wxDEFINE_EVENT(EVT_AMS_UNLOAD, SimpleEvent);
@ -834,8 +825,8 @@ AMSRoad::AMSRoad(wxWindow *parent, wxWindowID id, Caninfo info, int canindex, in
auto mouse_pos = ClientToScreen(e.GetPosition());
auto rect = ClientToScreen(wxPoint(0, 0));
if (mouse_pos.x > rect.x + GetSize().x - FromDIP(20) &&
mouse_pos.y > rect.y + GetSize().y - FromDIP(40)) {
if (mouse_pos.x > rect.x + GetSize().x - FromDIP(25) &&
mouse_pos.y > rect.y + GetSize().y - FromDIP(25)) {
wxCommandEvent event(EVT_AMS_SHOW_HUMIDITY_TIPS);
wxPostEvent(GetParent()->GetParent(), event);
}
@ -1459,11 +1450,10 @@ void AmsCans::PlayRridLoading(wxString canid)
std::string AmsCans::GetCurrentCan()
{
if (m_canlib_selection > -1 && m_canlib_selection < m_can_lib_list.size()) {
CanLibs *lib = m_can_lib_list[m_canlib_selection];
return lib->canLib->m_info.can_id;
}
return "";
if (m_canlib_selection < 0)
return "";
return wxString::Format("%d", m_canlib_selection).ToStdString();
}
void AmsCans::StopRridLoading(wxString canid)
@ -1805,9 +1795,15 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_filament_unload_step->SetSize(AMS_STEP_SIZE);
m_filament_unload_step->SetBackgroundColour(*wxWHITE);
m_filament_vt_load_step = new ::StepIndicator(m_simplebook_right, wxID_ANY);
m_filament_vt_load_step->SetMinSize(AMS_STEP_SIZE);
m_filament_vt_load_step->SetSize(AMS_STEP_SIZE);
m_filament_vt_load_step->SetBackgroundColour(*wxWHITE);
m_simplebook_right->AddPage(tip_right, wxEmptyString, false);
m_simplebook_right->AddPage(m_filament_load_step, wxEmptyString, false);
m_simplebook_right->AddPage(m_filament_unload_step, wxEmptyString, false);
m_simplebook_right->AddPage(m_filament_vt_load_step, wxEmptyString, false);
m_button_ams_setting_normal = ScalableBitmap(this, "ams_setting_normal", 24);
@ -1947,6 +1943,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
wxPoint popup_pos(img_pos.x, img_pos.y + GetRect().height);
m_Humidity_tip_popup.Position(popup_pos, wxSize(0, 0));
m_Humidity_tip_popup.Popup();
m_Humidity_tip_popup.GetParent()->SetFocus();
});
@ -2009,51 +2006,19 @@ wxColour AMSControl::GetCanColour(std::string amsid, std::string canid)
return col;
}
void AMSControl::SetActionState(AMSAction action, bool support_virtual_tray)
void AMSControl::SetActionState(bool button_status[])
{
m_button_area->Layout();
m_button_area->Fit();
if (button_status[ActionButton::ACTION_BTN_CALI]) m_button_extrusion_cali->Enable();
else m_button_extrusion_cali->Disable();
switch (action) {
case Slic3r::GUI::AMSAction::AMS_ACTION_NONE: break;
case Slic3r::GUI::AMSAction::AMS_ACTION_LOAD:
m_button_extrusion_cali->Enable();
m_button_extruder_feed->Enable();
m_button_extruder_back->Disable();
break;
case Slic3r::GUI::AMSAction::AMS_ACTION_UNLOAD:
m_button_extrusion_cali->Enable();
m_button_extruder_feed->Disable();
m_button_extruder_back->Enable();
break;
case Slic3r::GUI::AMSAction::AMS_ACTION_PRINTING:
m_button_extrusion_cali->Disable();
m_button_extruder_feed->Disable();
m_button_extruder_back->Disable();
break;
case Slic3r::GUI::AMSAction::AMS_ACTION_NORMAL:
m_button_extrusion_cali->Enable();
m_button_extruder_feed->Enable();
m_button_extruder_back->Enable();
break;
case Slic3r::GUI::AMSAction::AMS_ACTION_CALI:
m_button_extrusion_cali->Enable();
m_button_extruder_feed->Disable();
m_button_extruder_back->Disable();
break;
case Slic3r::GUI::AMSAction::AMS_ACTION_NOAMS:
if (support_virtual_tray)
m_button_extrusion_cali->Enable();
else
m_button_extrusion_cali->Disable();
m_button_extruder_feed->Disable();
m_button_extruder_back->Disable();
break;
default: break;
}
if (button_status[ActionButton::ACTION_BTN_LOAD]) m_button_extruder_feed->Enable();
else m_button_extruder_feed->Disable();
if (button_status[ActionButton::ACTION_BTN_UNLOAD]) m_button_extruder_back->Enable();
else m_button_extruder_back->Disable();
}
void AMSControl::EnterNoneAMSMode()
void AMSControl::EnterNoneAMSMode(bool support_vt_load)
{
m_simplebook_amsitems->Hide();
m_panel_top->Hide();
@ -2063,8 +2028,14 @@ void AMSControl::EnterNoneAMSMode()
m_button_ams_setting->Hide();
m_button_guide->Hide();
m_button_retry->Hide();
m_button_extruder_feed->Hide();
m_button_extruder_back->Hide();
if (support_vt_load) {
m_button_extruder_feed->Show();
m_button_extruder_back->Show();
} else {
m_button_extruder_feed->Hide();
m_button_extruder_back->Hide();
}
ShowFilamentTip(false);
m_amswin->Layout();
m_amswin->Fit();
@ -2162,8 +2133,36 @@ void AMSControl::msw_rescale()
void AMSControl::UpdateStepCtrl()
{
for (int i = 0; i < LOAD_STEP_COUNT; i++) { m_filament_load_step->AppendItem(FILAMENT_LOAD_STEP_STRING[i]); }
for (int i = 0; i < UNLOAD_STEP_COUNT; i++) { m_filament_unload_step->AppendItem(FILAMENT_UNLOAD_STEP_STRING[i]); }
wxString FILAMENT_LOAD_STEP_STRING[LOAD_STEP_COUNT] = {
_L("Heat the nozzle"),
_L("Cut filament"),
_L("Pull back current filament"),
_L("Push new filament into extruder"),
_L("Purge old filament"),
};
wxString VT_TRAY_LOAD_STEP_STRING[VT_LOAD_STEP_COUNT] = {
_L("Heat the nozzle"),
_L("Feed new filament from external spool"),
_L("Confirm whether the filament has been extruded"),
_L("Purge old filament"),
};
wxString FILAMENT_UNLOAD_STEP_STRING[UNLOAD_STEP_COUNT] = {
_L("Heat the nozzle"),
_L("Cut filament"),
_L("Pull back current filament")
};
for (int i = 0; i < LOAD_STEP_COUNT; i++) {
m_filament_load_step->AppendItem(FILAMENT_LOAD_STEP_STRING[i]);
}
for (int i = 0; i < UNLOAD_STEP_COUNT; i++) {
m_filament_unload_step->AppendItem(FILAMENT_UNLOAD_STEP_STRING[i]);
}
for (int i = 0; i < VT_LOAD_STEP_COUNT; i++) {
m_filament_vt_load_step->AppendItem(VT_TRAY_LOAD_STEP_STRING[i]);
}
}
void AMSControl::CreateAms()
@ -2204,7 +2203,7 @@ void AMSControl::Reset()
m_current_senect = "";
}
void AMSControl::show_noams_mode(bool show, bool support_virtual_tray)
void AMSControl::show_noams_mode(bool show, bool support_virtual_tray, bool support_vt_load)
{
show_vams(support_virtual_tray);
m_sizer_ams_tips->Show(support_virtual_tray);
@ -2214,7 +2213,7 @@ void AMSControl::show_noams_mode(bool show, bool support_virtual_tray)
m_button_extrusion_cali->Show();
}
show?ExitNoneAMSMode() : EnterNoneAMSMode();
show?ExitNoneAMSMode() : EnterNoneAMSMode(support_vt_load);
}
void AMSControl::show_vams(bool show)
@ -2244,6 +2243,10 @@ void AMSControl::update_vams_kn_value(AmsTray tray)
m_vams_info.n = tray.n;
m_vams_lib->m_info.k = tray.k;
m_vams_lib->m_info.n = tray.n;
m_vams_info.material_name = tray.get_display_filament_type();
m_vams_info.material_colour = tray.get_color();
m_vams_lib->m_info.material_name = tray.get_display_filament_type();
m_vams_lib->m_info.material_colour = tray.get_color();
m_vams_lib->Refresh();
}
@ -2392,26 +2395,56 @@ void AMSControl::SwitchAms(std::string ams_id)
// update buttons
}
void AMSControl::SetFilamentStep(int item_idx, bool isload)
void AMSControl::SetFilamentStep(int item_idx, FilamentStepType f_type)
{
if (item_idx == FilamentStep::STEP_IDLE && isload) {
if (item_idx == FilamentStep::STEP_IDLE) {
m_simplebook_right->SetSelection(0);
m_filament_load_step->Idle();
return;
}
if (item_idx == FilamentStep::STEP_IDLE && !isload) {
m_filament_unload_step->Idle();
m_filament_vt_load_step->Idle();
return;
}
if (item_idx >= 0 && isload && item_idx < FilamentStep::STEP_COUNT) {
m_simplebook_right->SetSelection(1);
m_filament_load_step->SelectItem(item_idx - 1);
}
if (item_idx >= 0 && !isload && item_idx < FilamentStep::STEP_COUNT) {
m_simplebook_right->SetSelection(2);
m_filament_unload_step->SelectItem(item_idx - 1);
if (f_type == FilamentStepType::STEP_TYPE_LOAD) {
if (item_idx > 0 && item_idx < FilamentStep::STEP_COUNT) {
m_simplebook_right->SetSelection(1);
m_filament_load_step->SelectItem(item_idx - 1);
} else {
m_filament_load_step->Idle();
}
} else if (f_type == FilamentStepType::STEP_TYPE_UNLOAD) {
if (item_idx > 0 && item_idx < FilamentStep::STEP_COUNT) {
m_simplebook_right->SetSelection(2);
m_filament_unload_step->SelectItem(item_idx - 1);
}
else {
m_filament_unload_step->Idle();
}
} else if (f_type == FilamentStepType::STEP_TYPE_VT_LOAD) {
m_simplebook_right->SetSelection(3);
if (item_idx == STEP_HEAT_NOZZLE) {
m_filament_vt_load_step->SelectItem(0);
}
else if (item_idx == STEP_FEED_FILAMENT) {
m_filament_vt_load_step->SelectItem(1);
}
else if (item_idx == STEP_CONFIRM_EXTRUDED) {
m_filament_vt_load_step->SelectItem(2);
}
else if (item_idx == STEP_PURGE_OLD_FILAMENT) {
m_filament_vt_load_step->SelectItem(3);
}
else {
m_filament_vt_load_step->Idle();
}
} else {
if (item_idx > 0 && item_idx < FilamentStep::STEP_COUNT) {
m_simplebook_right->SetSelection(1);
m_filament_load_step->SelectItem(item_idx - 1);
}
else {
m_filament_load_step->Idle();
}
}
}
@ -2459,6 +2492,15 @@ bool AMSControl::Enable(bool enable)
return wxWindow::Enable(enable);
}
void AMSControl::SetExtruder(bool on_off, wxColour col)
{
if (!on_off) {
m_extruder->TurnOff();
} else {
m_extruder->TurnOn(col);
}
}
void AMSControl::SetAmsStep(std::string ams_id, std::string canid, AMSPassRoadType type, AMSPassRoadSTEP step)
{
AmsCansWindow *cans = nullptr;
@ -2476,26 +2518,22 @@ void AMSControl::SetAmsStep(std::string ams_id, std::string canid, AMSPassRoadTy
if (cans == nullptr) return;
if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_NONE) {
if (ams_id == m_current_ams) { m_extruder->TurnOff(); }
cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_NONE);
}
type = AMSPassRoadType::AMS_ROAD_TYPE_LOAD;
if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP1) {
if (ams_id == m_current_ams) { m_extruder->TurnOff(); }
cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_1);
cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_2);
}
if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP2) {
if (ams_id == m_current_ams) { m_extruder->TurnOn(GetCanColour(ams_id, canid)); }
cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_NONE);
cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_1);
cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_2);
}
if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP3) {
if (ams_id == m_current_ams) { m_extruder->TurnOn(GetCanColour(ams_id, canid)); }
cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_1);
cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_2);
cans->amsCans->SetAmsStep(canid, type, AMSPassRoadSTEP::AMS_ROAD_STEP_3);
}
for (auto i = 0; i < m_ams_info.size(); i++) {
@ -2504,14 +2542,6 @@ void AMSControl::SetAmsStep(std::string ams_id, std::string canid, AMSPassRoadTy
m_ams_info[i].current_can_id = canid;
}
}
if (type == AMSPassRoadType::AMS_ROAD_TYPE_LOAD) {
SetActionState(AMSAction::AMS_ACTION_LOAD);
}
if (type == AMSPassRoadType::AMS_ROAD_TYPE_UNLOAD) {
SetActionState(AMSAction::AMS_ACTION_UNLOAD);
}
}
void AMSControl::on_filament_load(wxCommandEvent &event)

View file

@ -35,6 +35,13 @@
namespace Slic3r { namespace GUI {
enum ActionButton {
ACTION_BTN_CALI = 0,
ACTION_BTN_LOAD = 1,
ACTION_BTN_UNLOAD = 2,
ACTION_BTN_COUNT = 3
};
enum class AMSRoadMode : int {
AMS_ROAD_MODE_LEFT,
AMS_ROAD_MODE_LEFT_RIGHT,
@ -95,9 +102,17 @@ enum FilamentStep {
STEP_PULL_CURR_FILAMENT,
STEP_PUSH_NEW_FILAMENT,
STEP_PURGE_OLD_FILAMENT,
STEP_FEED_FILAMENT,
STEP_CONFIRM_EXTRUDED,
STEP_COUNT,
};
enum FilamentStepType {
STEP_TYPE_LOAD = 0,
STEP_TYPE_UNLOAD = 1,
STEP_TYPE_VT_LOAD = 2,
};
#define AMS_ITEM_CUBE_SIZE wxSize(FromDIP(14), FromDIP(14))
#define AMS_ITEM_SIZE wxSize(FromDIP(82), FromDIP(27))
#define AMS_ITEM_HUMIDITY_SIZE wxSize(FromDIP(120), FromDIP(27))
@ -495,6 +510,7 @@ protected:
::StepIndicator *m_filament_load_step = {nullptr};
::StepIndicator *m_filament_unload_step = {nullptr};
::StepIndicator *m_filament_vt_load_step = {nullptr};
Button *m_button_extruder_feed = {nullptr};
Button *m_button_extruder_back = {nullptr};
@ -515,8 +531,8 @@ public:
wxColour GetCanColour(std::string amsid, std::string canid);
bool m_is_none_ams_mode{false};
void SetActionState(AMSAction action, bool support_virtual_tray = true);
void EnterNoneAMSMode();
void SetActionState(bool button_status[]);
void EnterNoneAMSMode(bool support_vt_load = false);
void ExitNoneAMSMode();
void EnterCalibrationMode(bool read_to_calibration);
@ -528,7 +544,7 @@ public:
void PlayRridLoading(wxString amsid, wxString canid);
void StopRridLoading(wxString amsid, wxString canid);
void SetFilamentStep(int item_idx, bool isload = true);
void SetFilamentStep(int item_idx, FilamentStepType f_type);
void ShowFilamentTip(bool hasams = true);
void SetHumidity(std::string amsid, int humidity);
@ -536,6 +552,7 @@ public:
void CreateAms();
void UpdateAms(std::vector<AMSinfo> info, bool keep_selection = true, bool has_extrusion_cali = true);
void AddAms(AMSinfo info, bool refresh = true);
void SetExtruder(bool on_off, wxColour col);
void SetAmsStep(std::string ams_id, std::string canid, AMSPassRoadType type, AMSPassRoadSTEP step);
void SwitchAms(std::string ams_id);
@ -549,7 +566,7 @@ public:
void on_clibration_cancel_click(wxMouseEvent &event);
void Reset();
void show_noams_mode(bool show, bool support_virtual_tray);
void show_noams_mode(bool show, bool support_virtual_tray, bool support_vt_load = false);
void show_vams(bool show);
void show_vams_kn_value(bool show);
void update_vams_kn_value(AmsTray tray);

View file

@ -3,9 +3,13 @@
#include <wx/dcgraph.h>
#ifdef __WXGTK__
#include <gtk/gtk.h>
#endif
wxDEFINE_EVENT(EVT_DISMISS, wxCommandEvent);
BEGIN_EVENT_TABLE(DropDown, wxPopupTransientWindow)
BEGIN_EVENT_TABLE(DropDown, PopupWindow)
EVT_LEFT_DOWN(DropDown::mouseDown)
EVT_LEFT_UP(DropDown::mouseReleased)
@ -50,7 +54,7 @@ DropDown::DropDown(wxWindow * parent,
void DropDown::Create(wxWindow * parent,
long style)
{
wxPopupTransientWindow::Create(parent, wxPU_CONTAINS_CONTROLS);
PopupWindow::Create(parent, wxPU_CONTAINS_CONTROLS);
SetBackgroundStyle(wxBG_STYLE_PAINT);
SetBackgroundColour(*wxWHITE);
state_handler.attach({&border_color, &text_color, &selector_border_color, &selector_background_color});
@ -62,7 +66,7 @@ void DropDown::Create(wxWindow * parent,
// BBS set default font
SetFont(Label::Body_14);
#ifdef __WXOSX__
// wxPopupTransientWindow releases mouse on idle, which may cause various problems,
// PopupWindow releases mouse on idle, which may cause various problems,
// such as losting mouse move, and dismissing soon on first LEFT_DOWN event.
Bind(wxEVT_IDLE, [] (wxIdleEvent & evt) {});
#endif
@ -343,6 +347,10 @@ void DropDown::messureSize()
szContent.y *= std::min((size_t)15, texts.size());
szContent.y += texts.size() > 15 ? rowSize.y / 2 : 0;
wxWindow::SetSize(szContent);
#ifdef __WXGTK__
// Gtk has a wrapper window for popup widget
gtk_window_resize (GTK_WINDOW (m_widget), szContent.x, szContent.y);
#endif
need_sync = false;
}
@ -417,11 +425,12 @@ void DropDown::mouseMove(wxMouseEvent &event)
wxPoint pt = event.GetPosition();
if (pressedDown) {
wxPoint pt2 = offset + pt - dragStart;
dragStart = pt;
wxSize size = GetSize();
dragStart = pt;
if (pt2.y > 0)
pt2.y = 0;
else if (pt2.y + rowSize.y * texts.size() < GetSize().y)
pt2.y = GetSize().y - rowSize.y * texts.size();
else if (pt2.y + rowSize.y * int(texts.size()) < size.y)
pt2.y = size.y - rowSize.y * int(texts.size());
if (pt2.y != offset.y) {
offset = pt2;
hover_item = -1; // moved
@ -443,11 +452,12 @@ void DropDown::mouseMove(wxMouseEvent &event)
void DropDown::mouseWheelMoved(wxMouseEvent &event)
{
auto delta = event.GetWheelRotation();
wxPoint pt2 = offset + wxPoint{0, delta};
wxSize size = GetSize();
wxPoint pt2 = offset + wxPoint{0, delta};
if (pt2.y > 0)
pt2.y = 0;
else if (pt2.y + rowSize.y * texts.size() < GetSize().y)
pt2.y = GetSize().y - rowSize.y * texts.size();
else if (pt2.y + rowSize.y * int(texts.size()) < size.y)
pt2.y = size.y - rowSize.y * int(texts.size());
if (pt2.y != offset.y) {
offset = pt2;
} else {

View file

@ -4,6 +4,7 @@
#include <wx/stattext.h>
#include "../wxExtensions.hpp"
#include "StateHandler.hpp"
#include "PopupWindow.hpp"
#define DD_NO_CHECK_ICON 0x0001
#define DD_NO_TEXT 0x0002
@ -11,7 +12,7 @@
wxDECLARE_EVENT(EVT_DISMISS, wxCommandEvent);
class DropDown : public wxPopupTransientWindow
class DropDown : public PopupWindow
{
std::vector<wxString> & texts;
std::vector<wxBitmap> & icons;

View file

@ -2,6 +2,7 @@
#include "Label.hpp"
#include "../BitmapCache.hpp"
#include "../I18N.hpp"
#include "../GUI_App.hpp"
#include <wx/simplebook.h>
#include <wx/dcgraph.h>
@ -44,44 +45,26 @@ void Fan::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSi
//auto m_bitmap_pointer = ScalableBitmap(this, "fan_pointer", FromDIP(25));
//m_img_pointer = m_bitmap_pointer.bmp().ConvertToImage();
/*m_bitmap_scale_0 = ScalableBitmap(this, "fan_dash_board_level_0", FromDIP(13));
m_bitmap_scale_1 = ScalableBitmap(this, "fan_dash_board_level_1", FromDIP(13));
m_bitmap_scale_2 = ScalableBitmap(this, "fan_dash_board_level_2", FromDIP(13));
m_bitmap_scale_3 = ScalableBitmap(this, "fan_dash_board_level_3", FromDIP(10));
m_bitmap_scale_4 = ScalableBitmap(this, "fan_dash_board_level_4", FromDIP(5));
m_bitmap_scale_5 = ScalableBitmap(this, "fan_dash_board_level_5", FromDIP(5));
m_bitmap_scale_6 = ScalableBitmap(this, "fan_dash_board_level_6", FromDIP(10));
m_bitmap_scale_7 = ScalableBitmap(this, "fan_dash_board_level_7", FromDIP(13));
m_bitmap_scale_8 = ScalableBitmap(this, "fan_dash_board_level_8", FromDIP(13));
m_bitmap_scale_9 = ScalableBitmap(this, "fan_dash_board_level_9", FromDIP(13));*/
m_bitmap_bk = ScalableBitmap(this, "fan_dash_bk", FromDIP(80));
for (auto i = 0; i <= 10; i++) {
auto a = wxString::Format("fan_scale_%d", i);
#ifdef __APPLE__
auto m_bitmap_scale = ScalableBitmap(this, wxString::Format("fan_scale_%d", i).ToStdString(), FromDIP(60));
m_bitmap_scales.push_back(m_bitmap_scale);
#else
auto m_bitmap_scale = ScalableBitmap(this, wxString::Format("fan_scale_%d", i).ToStdString(), FromDIP(46));
m_bitmap_scales.push_back(m_bitmap_scale);
#endif
}
/* m_bitmap_scale_0 = ScalableBitmap(this, "fan_scale_0", FromDIP(60));
m_bitmap_scale_1 = ScalableBitmap(this, "fan_scale_1", FromDIP(60));
m_bitmap_scale_2 = ScalableBitmap(this, "fan_scale_2", FromDIP(60));
m_bitmap_scale_3 = ScalableBitmap(this, "fan_scale_3", FromDIP(60));
m_bitmap_scale_4 = ScalableBitmap(this, "fan_scale_4", FromDIP(60));
m_bitmap_scale_5 = ScalableBitmap(this, "fan_scale_5", FromDIP(60));
m_bitmap_scale_6 = ScalableBitmap(this, "fan_scale_6", FromDIP(60));
m_bitmap_scale_7 = ScalableBitmap(this, "fan_scale_7", FromDIP(60));
m_bitmap_scale_8 = ScalableBitmap(this, "fan_scale_8", FromDIP(60));
m_bitmap_scale_9 = ScalableBitmap(this, "fan_scale_9", FromDIP(60));
m_bitmap_scale_10 = ScalableBitmap(this, "fan_scale_10", FromDIP(60));*/
#ifdef __APPLE__
SetMinSize(wxSize(FromDIP(94), FromDIP(81) + FromDIP(6)));
SetMaxSize(wxSize(FromDIP(94), FromDIP(81) + FromDIP(6)));
#else
//#ifdef __APPLE__
// SetMinSize(wxSize(FromDIP(100), FromDIP(100) + FromDIP(6)));
// SetMaxSize(wxSize(FromDIP(100), FromDIP(100) + FromDIP(6)));
//#else
SetMinSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
SetMaxSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
#endif // __APPLE__
//#endif // __APPLE__
Bind(wxEVT_PAINT, &Fan::paintEvent, this);
}
@ -155,13 +138,13 @@ void Fan::doRender(wxDC& dc)
//fan val
dc.SetTextForeground(DRAW_TEXT_COLOUR);
dc.SetFont(::Label::Head_14);
dc.SetFont(::Label::Head_13);
auto speeds = wxString::Format("%d%%", m_current_speeds * 10);
dc.DrawText(speeds, (size.x - dc.GetTextExtent(speeds).x) / 2, size.y - dc.GetTextExtent(speeds).y - FromDIP(10));
dc.DrawText(speeds, (size.x - dc.GetTextExtent(speeds).x) / 2 + FromDIP(2), size.y - dc.GetTextExtent(speeds).y - FromDIP(5));
//rpm
dc.SetFont(::Label::Body_13);
dc.DrawText(rpm, (size.x - dc.GetTextExtent(rpm).x) / 2, size.y - dc.GetTextExtent(rpm).y);
//dc.SetFont(::Label::Body_13);
//dc.DrawText(rpm, (size.x - dc.GetTextExtent(rpm).x) / 2, size.y - dc.GetTextExtent(rpm).y);
}
void Fan::msw_rescale() {
@ -303,9 +286,9 @@ void FanOperate::doRender(wxDC& dc)
//txt
dc.SetFont(::Label::Body_12);
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour(0x898989)));
wxString text = wxString::Format("%d%%", m_current_speeds * 10);
wxString text = wxString::Format("%d%%", 10);
wxSize text_size = dc.GetTextExtent(text);
dc.DrawText(text, wxPoint(left_fir + (left_fir- text_size.x) / 2, (size.y- text_size.y) / 2 + 2));
dc.DrawText(text, wxPoint(left_fir + (left_fir- text_size.x) / 2, (size.y- text_size.y) / 2));
}
void FanOperate::msw_rescale() {
@ -411,15 +394,16 @@ void FanControl::command_control_fan()
{
if (m_current_speed < 0 || m_current_speed > 10) { return; }
int speed = floor(m_current_speed * float(25.5));
m_obj->command_control_fan_val(m_type, speed);
post_event(wxCommandEvent(EVT_FAN_CHANGED));
if (m_update_already) {
m_obj->command_control_fan_val(m_type, speed);
post_event(wxCommandEvent(EVT_FAN_CHANGED));
}
}
void FanControl::on_swith_fan(wxMouseEvent& evt)
{
int speed = 0;
if (m_switch_fan) {
speed = 0;
m_switch_button->SetBitmap(m_bitmap_toggle_off->bmp());
m_switch_fan = false;
}
@ -427,7 +411,7 @@ void FanControl::on_swith_fan(wxMouseEvent& evt)
speed = 255;
m_switch_button->SetBitmap(m_bitmap_toggle_on->bmp());
m_switch_fan = true;
}
}
set_fan_speed(speed);
command_control_fan();
@ -446,6 +430,7 @@ void FanControl::on_swith_fan(bool on)
void FanControl::set_machine_obj(MachineObject* obj)
{
m_update_already = true;
m_obj = obj;
}
@ -498,7 +483,7 @@ void FanControl::post_event(wxCommandEvent&& event)
Description:FanControlPopup
**************************************************/
FanControlPopup::FanControlPopup(wxWindow* parent)
:wxPopupTransientWindow(parent, wxBORDER_NONE)
:PopupWindow(parent, wxBORDER_NONE)
{
this->SetSizeHints(wxDefaultSize, wxDefaultSize);
@ -542,20 +527,37 @@ FanControlPopup::FanControlPopup(wxWindow* parent)
Bind(wxEVT_LEFT_DOWN, &FanControlPopup::on_left_down, this);
#endif
#ifdef __WXOSX__
Bind(wxEVT_IDLE, [](wxIdleEvent& evt) {});
#endif
Bind(wxEVT_SHOW, &FanControlPopup::on_show, this);
SetBackgroundColour(*wxWHITE);
}
void FanControlPopup::update_show_mode(bool support_cham_fun)
{
if (support_cham_fun && !m_is_suppt_cham_fun) {
m_cham_fan->Show();
m_line_bottom->Show();
Layout();
Fit();
}
if (!support_cham_fun && m_is_suppt_cham_fun) {
m_cham_fan->Hide();
m_line_bottom->Hide();
Layout();
Fit();
}
m_is_suppt_cham_fun = support_cham_fun;
}
void FanControlPopup::update_fan_data(MachineObject::FanType type, MachineObject* obj)
{
bool is_suppt_cham_fun = obj->is_function_supported(PrinterFunction::FUNC_CHAMBER_FAN);
if (is_suppt_cham_fun) {
m_cham_fan->Show();
m_line_bottom->Show();
}
else {
m_cham_fan->Hide();
m_line_bottom->Hide();
}
m_is_suppt_cham_fun = obj->is_function_supported(PrinterFunction::FUNC_CHAMBER_FAN);
update_show_mode(m_is_suppt_cham_fun);
if (type == MachineObject::FanType::COOLING_FAN && obj->cooling_fan_speed >= 0) {
m_part_fan->set_fan_speed(obj->cooling_fan_speed);
@ -576,15 +578,30 @@ void FanControlPopup::update_fan_data(MachineObject::FanType type, MachineObject
Bind(EVT_FAN_CHANGED, [this](wxCommandEvent& e) {
post_event(e.GetInt(), e.GetString());
});
Layout();
Fit();
}
void FanControlPopup::on_left_down(wxMouseEvent& evt)
{
auto mouse_pos = ClientToScreen(evt.GetPosition());
auto win_pos = m_part_fan->m_switch_button->ClientToScreen(wxPoint(0, 0));
auto size = m_part_fan->m_switch_button->GetSize();
if (mouse_pos.x > win_pos.x && mouse_pos.x < (win_pos.x + m_part_fan->m_switch_button->GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + m_part_fan->m_switch_button->GetSize().y)) {
m_part_fan->on_swith_fan(evt);
}
win_pos = m_aux_fan->m_switch_button->ClientToScreen(wxPoint(0, 0));
size = m_aux_fan->m_switch_button->GetSize();
if (mouse_pos.x > win_pos.x && mouse_pos.x < (win_pos.x + m_aux_fan->m_switch_button->GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + m_aux_fan->m_switch_button->GetSize().y)) {
m_aux_fan->on_swith_fan(evt);
}
win_pos = m_cham_fan->m_switch_button->ClientToScreen(wxPoint(0, 0));
size = m_cham_fan->m_switch_button->GetSize();
if (mouse_pos.x > win_pos.x && mouse_pos.x < (win_pos.x + m_cham_fan->m_switch_button->GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + m_cham_fan->m_switch_button->GetSize().y)) {
m_cham_fan->on_swith_fan(evt);
}
auto part_tag_pos = m_part_fan->ScreenToClient(mouse_pos);
evt.SetPosition(part_tag_pos);
m_part_fan->on_left_down(evt);
@ -601,7 +618,9 @@ void FanControlPopup::on_left_down(wxMouseEvent& evt)
void FanControlPopup::OnDismiss()
{
m_part_fan->update_obj_state(false);
m_aux_fan->update_obj_state(false);
m_cham_fan->update_obj_state(false);
}
void FanControlPopup::post_event(int fan_type, wxString speed)
@ -616,7 +635,12 @@ void FanControlPopup::post_event(int fan_type, wxString speed)
bool FanControlPopup::ProcessLeftDown(wxMouseEvent& event)
{
return wxPopupTransientWindow::ProcessLeftDown(event);
return PopupWindow::ProcessLeftDown(event);
}
void FanControlPopup::on_show(wxShowEvent& evt)
{
wxGetApp().UpdateDarkUIWin(this);
}
void FanControlPopup::paintEvent(wxPaintEvent& evt)

View file

@ -5,6 +5,7 @@
#include "StaticBox.hpp"
#include "StepCtrl.hpp"
#include "Button.hpp"
#include "PopupWindow.hpp"
#include "../DeviceManager.hpp"
#include "slic3r/GUI/Event.hpp"
#include <wx/simplebook.h>
@ -112,15 +113,17 @@ protected:
MachineObject::FanType m_type;
MachineObject* m_obj;
wxStaticText* m_static_name{ nullptr };
wxStaticBitmap* m_switch_button{ nullptr };
ScalableBitmap* m_bitmap_toggle_off{ nullptr };
ScalableBitmap* m_bitmap_toggle_on{ nullptr };
Fan* m_fan{ nullptr };
FanOperate* m_fan_operate{ nullptr };
bool m_switch_fan{ false };
bool m_update_already{false};
int m_current_speed{0};
public:
wxStaticBitmap* m_switch_button{ nullptr };
void update_obj_state(bool stat) {m_update_already = stat;};
void command_control_fan();
void set_machine_obj(MachineObject* obj);
void set_type(MachineObject::FanType type);
@ -137,7 +140,7 @@ public:
/*************************************************
Description:FanControlPopup
**************************************************/
class FanControlPopup : public wxPopupTransientWindow
class FanControlPopup : public PopupWindow
{
public:
FanControlPopup(wxWindow* parent);
@ -150,12 +153,15 @@ private:
FanControl* m_cham_fan;
wxWindow* m_line_top;
wxWindow* m_line_bottom;
bool m_is_suppt_cham_fun{true};
public:
void update_show_mode(bool support_cham_fun);
void update_fan_data(MachineObject::FanType type, MachineObject* obj);
void on_left_down(wxMouseEvent& evt);
void paintEvent(wxPaintEvent& evt);
void post_event(int fan_type, wxString speed);
void on_show(wxShowEvent& evt);
virtual void OnDismiss() wxOVERRIDE;
virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE;
};

View file

@ -312,7 +312,7 @@ void FanSwitchButton::render(wxDC& dc)
dc.SetTextForeground(text_color.colorForStates(states));
pt.x = (size.x - dc.GetTextExtent(speed).x) / 2;
pt.y -= FromDIP(5);
pt.y += FromDIP(1);
dc.DrawText(speed, pt);
}

View file

@ -116,16 +116,20 @@ public:
// Find the last word to chop off.
size_t lastSpace = posEnd;
while (lastSpace != size_t(-1)) {
while (lastSpace > 0) {
auto c = line[lastSpace];
if (c == ' ' || c > 0x4E00)
if (c == ' ')
break;
if (c > 0x4E00) {
if (lastSpace != posEnd)
++lastSpace;
break;
}
--lastSpace;
}
if (lastSpace == size_t(-1)) {
if (lastSpace == 0) {
// No spaces, so can't wrap.
DoOutputLine(line);
break;
lastSpace = posEnd;
}
// Output the part that fits.
@ -225,7 +229,7 @@ Label::Label(wxWindow *parent, wxFont const &font, wxString const &text, long st
{
this->font = font;
SetFont(font);
SetForegroundColour(*wxBLACK);
SetForegroundColour(wxColour("#262E30"));
SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent));
SetForegroundColour("#262E30");
if (style & LB_PROPAGATE_MOUSE_EVENT) {

View file

@ -0,0 +1,37 @@
#include "PopupWindow.hpp"
static wxWindow *GetTopParent(wxWindow *pWindow)
{
wxWindow *pWin = pWindow;
while (pWin->GetParent()) {
pWin = pWin->GetParent();
if (auto top = dynamic_cast<wxNonOwnedWindow*>(pWin))
return top;
}
return pWin;
}
bool PopupWindow::Create(wxWindow *parent, int style)
{
if (!wxPopupTransientWindow::Create(parent, style))
return false;
#ifdef __WXGTK__
GetTopParent(parent)->Bind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this);
#endif
return true;
}
PopupWindow::~PopupWindow()
{
#ifdef __WXGTK__
GetTopParent(this)->Unbind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this);
#endif
}
#ifdef __WXGTK__
void PopupWindow::topWindowActiavate(wxActivateEvent &event)
{
event.Skip();
if (!event.GetActive() && IsShown()) DismissAndNotify();
}
#endif

View file

@ -0,0 +1,24 @@
#ifndef slic3r_GUI_PopupWindow_hpp_
#define slic3r_GUI_PopupWindow_hpp_
#include <wx/popupwin.h>
class PopupWindow : public wxPopupTransientWindow
{
public:
PopupWindow() {}
~PopupWindow();
PopupWindow(wxWindow *parent, int style = wxBORDER_NONE)
{ Create(parent, style); }
bool Create(wxWindow *parent, int flags = wxBORDER_NONE);
private:
#ifdef __WXGTK__
void topWindowActiavate(wxActivateEvent &event);
#endif
};
#endif // !slic3r_GUI_PopupWindow_hpp_

View file

@ -608,6 +608,8 @@ bool ProgressDialog::Pulse(const wxString &newmsg, bool *skip)
return m_state != Canceled;
}
bool ProgressDialog::WasCanceled() const { return m_state == Canceled; }
bool ProgressDialog::DoBeforeUpdate(bool *skip)
{
// we have to yield because not only we want to update the display but

View file

@ -36,6 +36,7 @@ public:
virtual bool Update(int value, const wxString &newmsg = wxEmptyString, bool *skip = NULL);
virtual bool Pulse(const wxString &newmsg = wxEmptyString, bool *skip = NULL);
bool WasCanceled() const;
virtual void Resume();

View file

@ -6,9 +6,9 @@ BEGIN_EVENT_TABLE(RoundedRectangle, wxPanel)
EVT_PAINT(RoundedRectangle::OnPaint)
END_EVENT_TABLE()
RoundedRectangle::RoundedRectangle(wxWindow *parent, wxColour col, wxPoint pos, wxSize size, double radius, int type)
: wxWindow(parent, wxID_ANY, pos, size, wxBORDER_NONE)
{
RoundedRectangle::RoundedRectangle(wxWindow *parent, wxColour col, wxPoint pos, wxSize size, double radius, int type)
: wxWindow(parent, wxID_ANY, pos, size, wxBORDER_NONE)
{
SetBackgroundColour(wxColour(255,255,255));
m_type = type;
m_color = col;
@ -26,9 +26,10 @@ void RoundedRectangle::OnPaint(wxPaintEvent &evt)
}
//draw RoundedRectangle only board
if (m_type == 1) {
if (m_type == 1) {
wxPaintDC dc(this);
dc.SetPen(m_color);
dc.SetPen(m_color);
dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
dc.DrawRoundedRectangle(0, 0, GetSize().GetWidth(), GetSize().GetHeight(), m_radius);
}
}

View file

@ -6,12 +6,12 @@
wxBEGIN_EVENT_TABLE(SidePopup,wxPopupTransientWindow)
wxBEGIN_EVENT_TABLE(SidePopup,PopupWindow)
EVT_PAINT(SidePopup::paintEvent)
wxEND_EVENT_TABLE()
SidePopup::SidePopup(wxWindow* parent)
:wxPopupTransientWindow(parent,
:PopupWindow(parent,
wxBORDER_NONE |
wxPU_CONTAINS_CONTROLS)
{
@ -28,16 +28,16 @@ SidePopup::~SidePopup()
void SidePopup::OnDismiss()
{
Slic3r::GUI::wxGetApp().set_side_menu_popup_status(false);
wxPopupTransientWindow::OnDismiss();
PopupWindow::OnDismiss();
}
bool SidePopup::ProcessLeftDown(wxMouseEvent& event)
{
return wxPopupTransientWindow::ProcessLeftDown(event);
return PopupWindow::ProcessLeftDown(event);
}
bool SidePopup::Show( bool show )
{
return wxPopupTransientWindow::Show(show);
return PopupWindow::Show(show);
}
void SidePopup::Popup(wxWindow* focus)
@ -66,7 +66,7 @@ void SidePopup::Popup(wxWindow* focus)
Position(pos, {0, focus->GetSize().y + 12});
}
Slic3r::GUI::wxGetApp().set_side_menu_popup_status(true);
wxPopupTransientWindow::Popup();
PopupWindow::Popup();
}
void SidePopup::Create()

View file

@ -9,8 +9,9 @@
#include "../wxExtensions.hpp"
#include "StateHandler.hpp"
#include "SideButton.hpp"
#include "PopupWindow.hpp"
class SidePopup : public wxPopupTransientWindow
class SidePopup : public PopupWindow
{
private:
std::vector<SideButton*> btn_list;

View file

@ -142,8 +142,26 @@ void SideTools::doRender(wxDC &dc)
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(*wxWHITE);
auto sizet = dc.GetTextExtent(_L("No printer"));
dc.DrawText(_L("No printer"), wxPoint(left, (size.y - sizet.y) / 2));
wxString no_printer_str = _L("No printer");
auto sizet = dc.GetTextExtent(no_printer_str);
auto left_add_bitmap = size.x - FromDIP(30) - m_wifi_none_img.GetBmpSize().x - m_none_add_img.GetBmpSize().x;
auto size_width = left_add_bitmap - left;
if (sizet.x > size_width) {
wxString temp_str = wxEmptyString;
for (auto i = 0; i < no_printer_str.Len(); i++) {
if (dc.GetTextExtent(L("...") + temp_str).x < size_width) {
temp_str += no_printer_str[i];
}
else {
break;
}
}
no_printer_str = temp_str + L("...");
}
dc.DrawText(no_printer_str, wxPoint(left, (size.y - sizet.y) / 2));
left = size.x - FromDIP(30) - m_wifi_none_img.GetBmpSize().x;
dc.DrawBitmap(m_none_add_img.bmp(), left, (size.y - m_none_add_img.GetBmpSize().y) / 2);

View file

@ -106,7 +106,7 @@ void SpinInput::SetTextColor(StateColor const &color)
void SpinInput::SetSize(wxSize const &size)
{
wxWindow::SetSize(size);
StaticBox::SetSize(size);
Rescale();
}
@ -204,11 +204,11 @@ void SpinInput::messureSize()
int h = textSize.y + 8;
if (size.y < h) {
size.y = h;
SetSize(size);
SetMinSize(size);
} else {
textSize.y = size.y * 14 / 24;
}
wxSize minSize = size;
minSize.x = GetMinWidth();
StaticBox::SetSize(size);
SetMinSize(size);
wxSize btnSize = {14, (size.y - 4) / 2};
btnSize.x = btnSize.x * btnSize.y / 10;
wxClientDC dc(this);

View file

@ -141,6 +141,8 @@ void StaticBox::render(wxDC& dc)
}
wxSize size = GetSize();
if (size.x <= 0 || size.y <= 0)
return;
wxMemoryDC memdc;
wxBitmap bmp(size.x, size.y);
memdc.SelectObject(bmp);

View file

@ -100,10 +100,18 @@ void SwitchButton::Rescale()
}
for (int i = 0; i < 2; ++i) {
wxMemoryDC memdc(&dc);
#ifdef __WXMSW__
wxBitmap bmp(trackSize.x, trackSize.y);
memdc.SelectObject(bmp);
memdc.SetBackground(wxBrush(GetBackgroundColour()));
memdc.Clear();
#else
wxImage image(trackSize);
image.InitAlpha();
memset(image.GetAlpha(), 0, trackSize.GetWidth() * trackSize.GetHeight());
wxBitmap bmp(std::move(image));
memdc.SelectObject(bmp);
#endif
memdc.SetFont(dc.GetFont());
auto state = i == 0 ? StateColor::Enabled : (StateColor::Checked | StateColor::Enabled);
{

View file

@ -1,5 +1,6 @@
#include "TempInput.hpp"
#include "Label.hpp"
#include "PopupWindow.hpp"
#include "../I18N.hpp"
#include <wx/dcgraph.h>
#include "../GUI.hpp"
@ -190,7 +191,7 @@ void TempInput::Warning(bool warn, WarningType type)
if (warning_mode) {
if (wdialog == nullptr) {
wdialog = new wxPopupTransientWindow(this);
wdialog = new PopupWindow(this);
wdialog->SetBackgroundColour(wxColour(0xFFFFFF));
wdialog->SetSizeHints(wxDefaultSize, wxDefaultSize);

View file

@ -13,7 +13,7 @@
#endif
#ifdef __WIN32__
#include "../WebView2.h"
#include <WebView2.h>
#elif defined __linux__
#include <gtk/gtk.h>
#define WEBKIT_API
@ -35,6 +35,48 @@ webkit_javascript_result_unref (WebKitJavascriptResult *js_result);
}
#endif
#ifdef __WIN32__
class WebViewEdge : public wxWebViewEdge
{
public:
bool SetUserAgent(const wxString &userAgent)
{
ICoreWebView2 *webView2 = (ICoreWebView2 *) GetNativeBackend();
if (webView2) {
ICoreWebView2Settings *settings;
HRESULT hr = webView2->get_Settings(&settings);
if (hr == S_OK) {
ICoreWebView2Settings2 *settings2;
hr = settings->QueryInterface(&settings2);
if (hr == S_OK) {
settings2->put_UserAgent(userAgent.wc_str());
settings2->Release();
return true;
}
}
return false;
}
pendingUserAgent = userAgent;
return true;
}
void DoGetClientSize(int *x, int *y) const override
{
if (!pendingUserAgent.empty()) {
auto thiz = const_cast<WebViewEdge *>(this);
auto userAgent = std::move(thiz->pendingUserAgent);
thiz->pendingUserAgent.clear();
thiz->SetUserAgent(userAgent);
}
wxWebViewEdge::DoGetClientSize(x, y);
};
private:
wxString pendingUserAgent;
};
#endif
class FakeWebView : public wxWebView
{
virtual bool Create(wxWindow* parent, wxWindowID id, const wxString& url, const wxPoint& pos, const wxSize& size, long style, const wxString& name) override { return false; }
@ -108,7 +150,11 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
if (!url2.empty()) { url2 = wxURI(url2).BuildURI(); }
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": " << url2.ToUTF8();
#ifdef __WIN32__
wxWebView* webView = new WebViewEdge;
#else
auto webView = wxWebView::New();
#endif
if (webView) {
webView->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
#ifdef __WIN32__
@ -206,32 +252,9 @@ bool WebView::RunScript(wxWebView *webView, wxString const &javascript)
void WebView::RecreateAll()
{
#ifdef __WXMSW__
auto webviews = g_webviews;
std::vector<wxWindow*> parents;
std::vector<wxString> urls;
for (auto web : webviews) {
parents.push_back(web->GetParent());
urls.push_back(web->GetCurrentURL());
delete web;
}
assert(g_webviews.empty());
for (int i = 0; i < parents.size(); ++i) {
auto webView = CreateWebView(parents[i], urls[i]);
if (webView) {
wxCommandEvent evt(EVT_WEBVIEW_RECREATED);
evt.SetEventObject(webView);
wxPostEvent(parents[i], evt);
}
}
#else
for (auto webView : g_webviews) {
webView->SetUserAgent(wxString::Format("BBL-Slicer/v%s (%s) Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)", SLIC3R_VERSION,
Slic3r::GUI::wxGetApp().dark_mode() ? "dark" : "light"));
webView->Reload();
wxCommandEvent evt(EVT_WEBVIEW_RECREATED);
evt.SetEventObject(webView);
wxPostEvent(webView->GetParent(), evt);
}
#endif
}

View file

@ -3,8 +3,6 @@
#include <wx/webview.h>
wxDECLARE_EVENT(EVT_WEBVIEW_RECREATED, wxCommandEvent);
class WebView
{
public: