@@ -798,12 +798,21 @@ class WindowManager::Tooltip
798798 const glFont* font;
799799 std::vector<std::string> lines;
800800 unsigned width = 0 , height = 0 ;
801+ unsigned short maxWidth;
801802
802803public:
803804 Tooltip (const ctrlBaseTooltip* showingCtrl, const std::string& text, unsigned short maxWidth)
804- : showingCtrl(showingCtrl), font(NormalFont),
805- lines (font->GetWrapInfo (text, maxWidth, maxWidth).CreateSingleStrings(text))
805+ : showingCtrl(showingCtrl), font(NormalFont), maxWidth(maxWidth)
806806 {
807+ setText (text);
808+ }
809+
810+ auto getShowingCtrl () const { return showingCtrl; }
811+ auto getWidth () const { return width; }
812+
813+ void setText (const std::string& text)
814+ {
815+ lines = font->GetWrapInfo (text, maxWidth, maxWidth).CreateSingleStrings (text);
807816 if (lines.empty ())
808817 return ;
809818 width = 0 ;
@@ -813,9 +822,6 @@ class WindowManager::Tooltip
813822 height = lines.size () * font->getHeight () + BORDER_SIZE * 2 ;
814823 }
815824
816- auto getShowingCtrl () const { return showingCtrl; }
817- auto getWidth () const { return width; }
818-
819825 void draw (DrawPoint pos) const
820826 {
821827 Window::DrawRectangle (Rect (pos, width, height), 0x9F000000 );
@@ -829,7 +835,7 @@ class WindowManager::Tooltip
829835 }
830836};
831837
832- void WindowManager::SetToolTip (const ctrlBaseTooltip* ttw, const std::string& tooltip)
838+ void WindowManager::SetToolTip (const ctrlBaseTooltip* ttw, const std::string& tooltip, bool updateCurrent )
833839{
834840 // Max width of tooltip
835841 constexpr unsigned short MAX_TOOLTIP_WIDTH = 260 ;
@@ -838,6 +844,10 @@ void WindowManager::SetToolTip(const ctrlBaseTooltip* ttw, const std::string& to
838844 {
839845 if (curTooltip && (!ttw || curTooltip->getShowingCtrl () == ttw))
840846 curTooltip.reset ();
847+ } else if (updateCurrent)
848+ {
849+ if (curTooltip && curTooltip->getShowingCtrl () == ttw)
850+ curTooltip->setText (tooltip);
841851 } else
842852 curTooltip = std::make_unique<Tooltip>(ttw, tooltip, MAX_TOOLTIP_WIDTH );
843853}
0 commit comments