FIX: something

Change-Id: I2923786337f97f4297b0444522c620891aa2ad90
Jira: STUDIO-9725 filament menu delete icon
Jira: STUDIO-9785 StaticGroup border color
Jira: STUDIO-9716 update badge icon
Jira: STUDIO-9815 click printer/bed panel for combobox
Jira: STUDIO-9867 label with for single noozle
Jira: STUDIO-9739 ams page up/down
(cherry picked from commit 1cde0b844a97f3420db4999927f05a833b92b0fb)
This commit is contained in:
chunmao.guo
2025-01-15 15:40:27 +08:00
committed by Noisyfox
parent 5c2281bb07
commit d626c38ae7
12 changed files with 113 additions and 37 deletions

View File

@@ -765,9 +765,9 @@ static void generic_exception_handle()
std::terminate();
//throw;
} catch (const std::exception& ex) {
wxLogError(format_wxstr(_L("OrcaSlicer got an unhandled exception: %1%"), ex.what()));
BOOST_LOG_TRIVIAL(error) << boost::format("Uncaught exception: %1%") % ex.what();
flush_logs();
wxLogError(format_wxstr(_L("OrcaSlicer got an unhandled exception: %1%"), ex.what()));
throw;
}
//#endif

View File

@@ -1481,7 +1481,7 @@ void MenuFactory::create_filament_action_menu(bool init, int active_filament_men
if (init) {
append_menu_item(
menu, wxID_ANY, _L("Delete"), _L("Delete this filament"), [](wxCommandEvent&) {
plater()->sidebar().delete_filament(-2); }, "menu_delete", nullptr,
plater()->sidebar().delete_filament(-2); }, "", nullptr,
[]() { return plater()->sidebar().combos_filament().size() > 1; }, m_parent);
}

View File

@@ -237,7 +237,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
m_remote_proto = 0;
m_model_download_support = false;
}
Enable(obj && obj->is_connected() && obj->m_push_count > 0);
Enable(obj && obj->is_info_ready() && obj->m_push_count > 0);
if (machine == m_machine) {
if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && (m_local_proto || m_remote_proto))) {
auto fs = m_image_grid->GetFileSystem();

View File

@@ -171,7 +171,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
m_remote_proto = 0;
m_device_busy = false;
}
Enable(obj && obj->is_connected() && obj->m_push_count > 0);
Enable(obj && obj->is_info_ready() && obj->m_push_count > 0);
if (machine == m_machine) {
if (m_last_state == MEDIASTATE_IDLE && IsEnabled())
Play();

View File

@@ -352,12 +352,14 @@ struct ExtruderGroup : StaticGroup
ExtruderGroup(wxWindow * parent, int index, wxString const &title);
wxStaticBoxSizer *sizer = nullptr;
ScalableButton * btn_edit = nullptr;
ComboBox * combo_nozzle = nullptr;
ComboBox * combo_flow = nullptr;
AMSPreview * ams[4] = {nullptr};
wxStaticText *ams_not_installed_msg{nullptr};
ScalableButton *up_down_btn{nullptr};
ScalableButton * btn_up{nullptr};
ScalableButton * btn_down{nullptr};
wxBoxSizer *hsizer_ams { nullptr };
bool is_upward{false};
int page_cur{0};
int page_num{3};
int ams_n4 = 0;
int ams_n1 = 0;
@@ -375,7 +377,9 @@ struct ExtruderGroup : StaticGroup
{
if (btn_edit)
btn_edit->msw_rescale();
combo_nozzle->Rescale();
btn_up->msw_rescale();
btn_down->msw_rescale();
combo_flow->Rescale();
}
};
@@ -911,22 +915,22 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
: StaticGroup(parent, wxID_ANY, title)
{
SetFont(Label::Body_10);
SetForegroundColour("#909090");
ShowBadge(true);
// Nozzle
wxStaticText *label_nozzle = new wxStaticText(this, wxID_ANY, _L("Flow"));
label_nozzle->SetFont(Label::Body_14);
label_nozzle->SetForegroundColour("#262E30");
auto combo_nozzle = new ComboBox(this, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY);
combo_nozzle->GetDropDown().SetUseContentWidth(true);
combo_nozzle->Bind(wxEVT_COMBOBOX, [this, index, combo_nozzle](wxCommandEvent &evt) {
wxStaticText *label_flow = new wxStaticText(this, wxID_ANY, _L("Flow"));
label_flow->SetFont(Label::Body_14);
label_flow->SetForegroundColour("#262E30");
if (index >= 0) label_flow->SetMinSize({FromDIP(80), -1});
auto combo_flow = new ComboBox(this, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY);
combo_flow->GetDropDown().SetUseContentWidth(true);
combo_flow->Bind(wxEVT_COMBOBOX, [this, index, combo_flow](wxCommandEvent &evt) {
auto printer_tab = dynamic_cast<TabPrinter *>(wxGetApp().get_tab(Preset::TYPE_PRINTER));
printer_tab->set_extruder_volume_type(index, NozzleVolumeType(intptr_t(combo_nozzle->GetClientData(evt.GetInt()))));
printer_tab->set_extruder_volume_type(index, NozzleVolumeType(intptr_t(combo_flow->GetClientData(evt.GetInt()))));
if (GUI::wxGetApp().plater())
GUI::wxGetApp().plater()->update_machine_sync_status();
});
this->combo_nozzle = combo_nozzle;
this->combo_flow = combo_flow;
// AMS
wxStaticText *label_ams = new wxStaticText(this, wxID_ANY, _L("AMS"));
@@ -946,7 +950,7 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
});
auto hovered = std::make_shared<wxWindow *>();
for (wxWindow *w : std::initializer_list<wxWindow *>{this, label_nozzle, combo_nozzle, btn_edit, label_ams}) {
for (wxWindow *w : std::initializer_list<wxWindow *>{this, label_flow, combo_flow, btn_edit, label_ams}) {
w->Bind(wxEVT_ENTER_WINDOW, [w, hovered, this](wxMouseEvent &evt) { *hovered = w; btn_edit->SetBitmap_("edit"); });
w->Bind(wxEVT_LEAVE_WINDOW, [w, hovered, this](wxMouseEvent &evt) { if (*hovered == w) { btn_edit->SetBitmap_("dot"); *hovered = nullptr; } });
}
@@ -969,15 +973,25 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
if (btn_edit)
hsizer_ams->Add(btn_edit, 0, wxLEFT | wxALIGN_CENTER, FromDIP(2));
up_down_btn = new ScalableButton(this, wxID_ANY, "dot");
up_down_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this, index](auto &evt) {
is_upward = !is_upward;
btn_up = new ScalableButton(this, wxID_ANY, "page_up", "", {-1, FromDIP(14)});
btn_up->SetBackgroundColour(*wxWHITE);
btn_up->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this, index](auto &evt) {
if (page_cur > 0)
--page_cur;
update_ams();
});
btn_down = new ScalableButton(this, wxID_ANY, "page_down", "", {-1, FromDIP(14)});
btn_down->SetBackgroundColour(*wxWHITE);
btn_down->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this, index](auto &evt) {
if (page_cur + 1 < page_num)
++page_cur;
update_ams();
});
wxBoxSizer * hsizer_nozzle = new wxBoxSizer(wxHORIZONTAL);
hsizer_nozzle->Add(label_nozzle, 2, wxALIGN_CENTER);
hsizer_nozzle->Add(combo_nozzle, 3, wxEXPAND);
hsizer_nozzle->Add(label_flow, 2, wxALIGN_CENTER);
hsizer_nozzle->Add(combo_flow, 3, wxEXPAND);
if (index < 0) {
label_ams->Hide();
ams_not_installed_msg->Hide();
@@ -999,8 +1013,8 @@ void ExtruderGroup::update_ams()
{
int display_capacity = 8;
if (ams_n4 * 4 + ams_n1 * 2 <= 8)
is_upward = false;
//if (ams_n4 * 4 + ams_n1 * 2 <= 8)
// is_upward = false;
std::vector<wxColour> colors = {
wxColour(255, 110, 100),
@@ -1009,7 +1023,7 @@ void ExtruderGroup::update_ams()
wxColour(170, 111, 252)
};
bool display_front_ams = !is_upward;
bool display_front_ams = false; //!is_upward;
size_t i = 0;
for (; i < ams_n4 && i < 4; ++i) {
display_capacity -= 4;
@@ -1051,7 +1065,7 @@ void ExtruderGroup::update_ams()
if (i == 0) {
ams_not_installed_msg->Show();
up_down_btn->Hide();
btn_up->Hide();
for (AMSPreview *a : ams) {
a->Close();
}
@@ -1059,12 +1073,15 @@ void ExtruderGroup::update_ams()
ams_not_installed_msg->Hide();
for (; i < 4; ++i) { ams[i]->Close(); }
if (display_capacity < 0) {
up_down_btn->Show();
btn_up->Show();
} else {
up_down_btn->Hide();
btn_up->Hide();
}
}
btn_up->Show(page_cur > 0);
btn_down->Show(page_cur + 1 < page_num);
while (hsizer_ams->GetItemCount() > 2)
hsizer_ams->Remove(2);
if (ams_not_installed_msg->IsShown()) {
@@ -1076,9 +1093,19 @@ void ExtruderGroup::update_ams()
if (ams[i]->IsShown())
hsizer_ams->Add(this->ams[i], 0, wxLEFT, FromDIP(4));
}
if (up_down_btn->IsShown()) {
if (btn_up->IsShown() || btn_down->IsShown()) {
hsizer_ams->AddStretchSpacer(1);
hsizer_ams->Add(up_down_btn, 0, wxALIGN_CENTER);
if (btn_up->IsShown() && btn_down->IsShown()) {
auto vsizer_btn = new wxBoxSizer(wxVERTICAL);
auto size = btn_up->GetSize();
vsizer_btn->Add(btn_up, 0);
vsizer_btn->Add(btn_down, 0);
hsizer_ams->Add(vsizer_btn, 0, wxALIGN_CENTER | wxLEFT, FromDIP(2));
} else if (btn_up->IsShown()) {
hsizer_ams->Add(btn_up, 0, wxALIGN_CENTER | wxLEFT, FromDIP(2));
} else {
hsizer_ams->Add(btn_down, 0, wxALIGN_CENTER | wxLEFT, FromDIP(2));
}
}
sizer->Layout();
@@ -1160,7 +1187,7 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj)
auto clear_all_sync_status = [this]() {
panel_printer_preset->ShowBadge(false);
panel_printer_bed->ShowBadge(false);
left_extruder->ShowBadge(false);
//left_extruder->ShowBadge(false);
right_extruder->ShowBadge(false);
single_extruder->ShowBadge(false);
};
@@ -1413,6 +1440,9 @@ Sidebar::Sidebar(Plater *parent)
p->panel_printer_preset->SetCornerRadius(8);
p->panel_printer_preset->SetBorderColor(wxColour("#CECECE"));
p->panel_printer_preset->SetMinSize(PRINTER_PANEL_SIZE_SMALL);
p->panel_printer_preset->Bind(wxEVT_LEFT_DOWN, [this](auto & evt) {
p->combo_printer->wxEvtHandler::ProcessEvent(evt);
});
ScalableButton *edit_btn = new ScalableButton(p->panel_printer_preset, wxID_ANY, "dot");
edit_btn->SetToolTip(_L("Click to edit preset"));
@@ -1426,6 +1456,10 @@ Sidebar::Sidebar(Plater *parent)
ScalableBitmap bitmap_printer(p->panel_printer_preset, "printer_placeholder", 48);
p->image_printer = new wxStaticBitmap(p->panel_printer_preset, wxID_ANY, bitmap_printer.bmp(), wxDefaultPosition, PRINTER_THUMBNAIL_SIZE, 0);
p->image_printer->Bind(wxEVT_LEFT_DOWN, [this](auto &evt) {
p->combo_printer->wxEvtHandler::ProcessEvent(evt);
});
PlaterPresetComboBox *combo_printer = new PlaterPresetComboBox(p->panel_printer_preset, Preset::TYPE_PRINTER);
combo_printer->SetWindowStyle(combo_printer->GetWindowStyle() & ~wxALIGN_MASK | wxALIGN_CENTER_HORIZONTAL);
combo_printer->SetBorderWidth(0);
@@ -1453,6 +1487,9 @@ Sidebar::Sidebar(Plater *parent)
p->panel_printer_bed->SetCornerRadius(8);
p->panel_printer_bed->SetBorderColor(wxColour("#CECECE"));
p->panel_printer_bed->SetMinSize(PRINTER_PANEL_SIZE_SMALL);
p->panel_printer_bed->Bind(wxEVT_LEFT_DOWN, [this](auto &evt) {
p->combo_printer_bed->wxEvtHandler::ProcessEvent(evt);
});
ScalableButton *wiki_bed = new ScalableButton(p->panel_printer_bed, wxID_ANY, "dot");
wiki_bed->Bind(wxEVT_BUTTON, [](wxCommandEvent) {
@@ -1461,6 +1498,9 @@ Sidebar::Sidebar(Plater *parent)
ScalableBitmap bitmap_bed(p->panel_printer_bed, "printer_placeholder", 32);
p->image_printer_bed = new wxStaticBitmap(p->panel_printer_bed, wxID_ANY, bitmap_bed.bmp(), wxDefaultPosition, wxDefaultSize, 0);
p->image_printer_bed->Bind(wxEVT_LEFT_DOWN, [this](auto &evt) {
p->combo_printer_bed->wxEvtHandler::ProcessEvent(evt);
});
p->combo_printer_bed = new ComboBox(p->panel_printer_bed, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY | wxALIGN_CENTER_HORIZONTAL);
p->combo_printer_bed->SetBorderWidth(0);

View File

@@ -192,7 +192,9 @@ void PresetComboBox::update_selection()
* there is no presets added to the list.
* So, select last combobox item ("Add/Remove preset")
*/
validate_selection();
//validate_selection();
if (m_last_selected == INT_MAX)
m_last_selected == 1;
SetSelection(m_last_selected);
#ifdef __WXMSW__

View File

@@ -23,7 +23,7 @@ StaticBox::StaticBox()
{
border_color = StateColor(
std::make_pair(0xF0F0F1, (int) StateColor::Disabled),
std::make_pair(0x303A3C, (int) StateColor::Normal));
std::make_pair(0xCECECE, (int) StateColor::Normal));
}
StaticBox::StaticBox(wxWindow* parent,

View File

@@ -3,6 +3,8 @@
StaticGroup::StaticGroup(wxWindow *parent, wxWindowID id, const wxString &label)
: wxStaticBox(parent, id, label)
{
SetBackgroundColour(*wxWHITE);
SetForegroundColour("#CECECE");
#ifdef __WXMSW__
Bind(wxEVT_PAINT, &StaticGroup::OnPaint, this);
#else
@@ -30,4 +32,29 @@ void StaticGroup::OnPaint(wxPaintEvent &evt)
}
}
void StaticGroup::PaintForeground(wxDC &dc, const struct tagRECT &rc)
{
wxStaticBox::PaintForeground(dc, rc);
auto mdc = dynamic_cast<wxMemoryDC *>(&dc);
auto image = mdc->GetSelectedBitmap().ConvertToImage();
// Found border coords
int top = 0;
int left = 0;
int right = rc.right - 1;
int bottom = rc.bottom - 1;
auto blue = GetBackgroundColour().Blue();
while (image.GetBlue(0, top) == blue) ++top;
while (image.GetBlue(left, top) != blue) ++left; // --left; // fix start
while (image.GetBlue(right, top) != blue) --right; ++right;
while (image.GetBlue(0, bottom) == blue) --bottom;
// Draw border with foreground color
wxPoint polygon[] = { {left, top}, {0, top}, {0, bottom}, {rc.right - 1, bottom}, {rc.right - 1, top}, {right, top} };
dc.SetPen(wxPen(GetForegroundColour(), 1));
for (int i = 1; i < 6; ++i) {
if (i == 4) // fix bottom right corner
++polygon[i - 1].y;
dc.DrawLine(polygon[i - 1], polygon[i]);
}
}
#endif

View File

@@ -16,6 +16,7 @@ public:
private:
#ifdef __WXMSW__
void OnPaint(wxPaintEvent &evt);
void PaintForeground(wxDC &dc, const struct tagRECT &rc) override;
#endif
private: