Follow-up e2f2ed4172 and 80844ca337 - Allow RichToolTips just under MSW

This commit is contained in:
YuSanka 2021-10-05 16:45:54 +02:00
parent 091f946340
commit 9e2fa3cd4d

View File

@ -609,7 +609,6 @@ struct Sidebar::priv
wxButton *btn_export_gcode; wxButton *btn_export_gcode;
wxButton *btn_reslice; wxButton *btn_reslice;
wxString btn_reslice_tip;
ScalableButton *btn_send_gcode; ScalableButton *btn_send_gcode;
//ScalableButton *btn_eject_device; //ScalableButton *btn_eject_device;
ScalableButton* btn_export_gcode_removable; //exports to removable drives (appears only if removable drive is connected) ScalableButton* btn_export_gcode_removable; //exports to removable drives (appears only if removable drive is connected)
@ -621,7 +620,11 @@ struct Sidebar::priv
~priv(); ~priv();
void show_preset_comboboxes(); void show_preset_comboboxes();
#ifdef _WIN32
wxString btn_reslice_tip;
void show_rich_tip(const wxString& tooltip, wxButton* btn); void show_rich_tip(const wxString& tooltip, wxButton* btn);
#endif
}; };
Sidebar::priv::~priv() Sidebar::priv::~priv()
@ -650,6 +653,7 @@ void Sidebar::priv::show_preset_comboboxes()
scrolled->Refresh(); scrolled->Refresh();
} }
#ifdef _WIN32
void Sidebar::priv::show_rich_tip(const wxString& tooltip, wxButton* btn) void Sidebar::priv::show_rich_tip(const wxString& tooltip, wxButton* btn)
{ {
if (tooltip.IsEmpty()) if (tooltip.IsEmpty())
@ -662,6 +666,7 @@ void Sidebar::priv::show_rich_tip(const wxString& tooltip, wxButton* btn)
tip.SetTimeout(1200); tip.SetTimeout(1200);
tip.ShowFor(btn); tip.ShowFor(btn);
} }
#endif
// Sidebar / public // Sidebar / public
@ -797,10 +802,14 @@ Sidebar::Sidebar(Plater *parent)
ScalableBitmap bmp = ScalableBitmap(this, icon_name, bmp_px_cnt); ScalableBitmap bmp = ScalableBitmap(this, icon_name, bmp_px_cnt);
*btn = new ScalableButton(this, wxID_ANY, bmp, "", wxBU_EXACTFIT); *btn = new ScalableButton(this, wxID_ANY, bmp, "", wxBU_EXACTFIT);
#ifdef _WIN32
(*btn)->Bind(wxEVT_ENTER_WINDOW, [tooltip, btn, this](wxMouseEvent& event) { (*btn)->Bind(wxEVT_ENTER_WINDOW, [tooltip, btn, this](wxMouseEvent& event) {
p->show_rich_tip(tooltip, *btn); p->show_rich_tip(tooltip, *btn);
event.Skip(); event.Skip();
}); });
#else
(*btn)->SetToolTip(tooltip);
#endif // _WIN32
(*btn)->Hide(); (*btn)->Hide();
}; };
@ -860,10 +869,13 @@ Sidebar::Sidebar(Plater *parent)
p->plater->select_view_3D("Preview"); p->plater->select_view_3D("Preview");
}); });
#ifdef _WIN32
p->btn_reslice->Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent& event) { p->btn_reslice->Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent& event) {
p->show_rich_tip(p->btn_reslice_tip, p->btn_reslice); p->show_rich_tip(p->btn_reslice_tip, p->btn_reslice);
event.Skip(); event.Skip();
}); });
#endif // _WIN32
p->btn_send_gcode->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { p->plater->send_gcode(); }); p->btn_send_gcode->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { p->plater->send_gcode(); });
// p->btn_eject_device->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { p->plater->eject_drive(); }); // p->btn_eject_device->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { p->plater->eject_drive(); });
p->btn_export_gcode_removable->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { p->plater->export_gcode(true); }); p->btn_export_gcode_removable->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { p->plater->export_gcode(true); });
@ -991,7 +1003,11 @@ void Sidebar::update_reslice_btn_tooltip() const
wxString tooltip = wxString("Slice") + " [" + GUI::shortkey_ctrl_prefix() + "R]"; wxString tooltip = wxString("Slice") + " [" + GUI::shortkey_ctrl_prefix() + "R]";
if (m_mode != comSimple) if (m_mode != comSimple)
tooltip += wxString("\n") + _L("Hold Shift to Slice & Export G-code"); tooltip += wxString("\n") + _L("Hold Shift to Slice & Export G-code");
#ifdef _WIN32
p->btn_reslice_tip = tooltip; p->btn_reslice_tip = tooltip;
#else
p->btn_reslice->SetToolTip(tooltip);
#endif
} }
void Sidebar::msw_rescale() void Sidebar::msw_rescale()