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