From e2f2ed41720c73170c0e08f8650394d253cae973 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 5 Oct 2021 11:05:20 +0200 Subject: [PATCH] Fix for #6218 - Button tooltip in the way Use wxRichTooltip instead of wxTooltip for buttons on the bottom of a sidebar --- src/slic3r/GUI/Plater.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 90dce0a13..4726884fe 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "libslic3r/libslic3r.h" #include "libslic3r/Format/STL.hpp" @@ -611,6 +612,7 @@ 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) @@ -622,6 +624,7 @@ struct Sidebar::priv ~priv(); void show_preset_comboboxes(); + void show_rich_tip(const wxString& tooltip, wxButton* btn); }; Sidebar::priv::~priv() @@ -650,6 +653,17 @@ void Sidebar::priv::show_preset_comboboxes() scrolled->Refresh(); } +void Sidebar::priv::show_rich_tip(const wxString& tooltip, wxButton* btn) +{ + if (tooltip.IsEmpty()) + return; + wxRichToolTip tip(tooltip, ""); + tip.SetIcon(wxICON_NONE); + tip.SetTitleFont(wxGetApp().normal_font()); + tip.SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + tip.SetTimeout(1200); + tip.ShowFor(btn); +} // Sidebar / public @@ -784,7 +798,11 @@ Sidebar::Sidebar(Plater *parent) #endif //__APPLE__ ScalableBitmap bmp = ScalableBitmap(this, icon_name, bmp_px_cnt); *btn = new ScalableButton(this, wxID_ANY, bmp, "", wxBU_EXACTFIT); - (*btn)->SetToolTip(tooltip); + + (*btn)->Bind(wxEVT_ENTER_WINDOW, [tooltip, btn, this](wxMouseEvent& event) { + p->show_rich_tip(tooltip, *btn); + event.Skip(); + }); (*btn)->Hide(); }; @@ -843,6 +861,11 @@ Sidebar::Sidebar(Plater *parent) p->plater->reslice(); p->plater->select_view_3D("Preview"); }); + + p->btn_reslice->Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent& event) { + p->show_rich_tip(p->btn_reslice_tip, p->btn_reslice); + event.Skip(); + }); 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); }); @@ -970,7 +993,7 @@ 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"); - p->btn_reslice->SetToolTip(tooltip); + p->btn_reslice_tip = tooltip; } void Sidebar::msw_rescale()