Skip to content

Commit

Permalink
GUI: Allow tooltips to be changed after widget creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Schickel committed Jun 20, 2012
1 parent 72ea449 commit 80ae9d7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gui/Tooltip.cpp
Expand Up @@ -37,7 +37,7 @@ Tooltip::Tooltip() :
}

void Tooltip::setup(Dialog *parent, Widget *widget, int x, int y) {
assert(widget->getTooltip());
assert(widget->hasTooltip());

_maxWidth = g_gui.xmlEval()->getVar("Globals.Tooltip.MaxWidth", 100);
_xdelta = g_gui.xmlEval()->getVar("Globals.Tooltip.XDelta", 0);
Expand Down
2 changes: 1 addition & 1 deletion gui/gui-manager.cpp
Expand Up @@ -381,7 +381,7 @@ void GuiManager::runLoop() {

if (tooltipCheck && _lastMousePosition.time + kTooltipDelay < _system->getMillis()) {
Widget *wdg = activeDialog->findWidget(_lastMousePosition.x, _lastMousePosition.y);
if (wdg && wdg->getTooltip() && !(wdg->getFlags() & WIDGET_PRESSED)) {
if (wdg && wdg->hasTooltip() && !(wdg->getFlags() & WIDGET_PRESSED)) {
Tooltip *tooltip = new Tooltip();
tooltip->setup(activeDialog, wdg, _lastMousePosition.x, _lastMousePosition.y);
tooltip->runModal();
Expand Down
6 changes: 4 additions & 2 deletions gui/widget.h
Expand Up @@ -88,7 +88,7 @@ class Widget : public GuiObject {
uint16 _id;
bool _hasFocus;
ThemeEngine::WidgetStateInfo _state;
const char *_tooltip;
Common::String _tooltip;

private:
uint16 _flags;
Expand Down Expand Up @@ -142,7 +142,9 @@ class Widget : public GuiObject {
uint8 parseHotkey(const Common::String &label);
Common::String cleanupHotkey(const Common::String &label);

const char *getTooltip() const { return _tooltip; }
bool hasTooltip() const { return !_tooltip.empty(); }
const Common::String &getTooltip() const { return _tooltip; }
void setTooltip(const Common::String &tooltip) { _tooltip = tooltip; }

protected:
void updateState(int oldFlags, int newFlags);
Expand Down

0 comments on commit 80ae9d7

Please sign in to comment.