mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 08:25:35 +00:00
GUI: Implemented link tooltips for RichTextWidget
This commit is contained in:
parent
125d3dfa69
commit
2b35c7997f
@ -546,13 +546,15 @@ void GuiManager::runLoop() {
|
||||
&& systemMillisNowForTooltipCheck - _lastMousePosition.time > (uint32)kTooltipDelay
|
||||
&& !activeDialog->isDragging()) {
|
||||
Widget *wdg = activeDialog->findWidget(_lastMousePosition.x, _lastMousePosition.y);
|
||||
if (wdg && wdg->hasTooltip() && !(wdg->getFlags() & WIDGET_PRESSED)
|
||||
if (wdg && (wdg->hasTooltip() || (wdg->getFlags() & WIDGET_DYN_TOOLTIP)) && !(wdg->getFlags() & WIDGET_PRESSED)
|
||||
&& (_lastTooltipShown.wdg != wdg || systemMillisNowForTooltipCheck - _lastTooltipShown.time > (uint32)kTooltipSameWidgetDelay)) {
|
||||
_lastTooltipShown.time = systemMillisNowForTooltipCheck;
|
||||
_lastTooltipShown.wdg = wdg;
|
||||
_lastTooltipShown.x = _lastMousePosition.x;
|
||||
_lastTooltipShown.y = _lastMousePosition.y;
|
||||
if (wdg->getType() != kEditTextWidget || activeDialog->getFocusWidget() != wdg) {
|
||||
if (wdg->getFlags() & WIDGET_DYN_TOOLTIP)
|
||||
wdg->handleTooltipUpdate(_lastMousePosition.x- activeDialog->_x - wdg->getRelX(), _lastMousePosition.y - activeDialog->_y - wdg->getRelY());
|
||||
Tooltip *tooltip = new Tooltip();
|
||||
tooltip->setup(activeDialog, wdg, _lastMousePosition.x, _lastMousePosition.y);
|
||||
tooltip->runModal();
|
||||
|
@ -104,6 +104,7 @@ public:
|
||||
virtual Common::Rect getClipRect() const;
|
||||
|
||||
virtual void handleMouseWheel(int x, int y, int direction) {};
|
||||
virtual void handleTooltipUpdate(int x, int y) {};
|
||||
protected:
|
||||
virtual void releaseFocus() = 0;
|
||||
};
|
||||
|
13
gui/widget.h
13
gui/widget.h
@ -57,7 +57,8 @@ enum {
|
||||
// The PopUpWidget for example does not want this behavior, since the
|
||||
// mouse down will open up a new dialog which silently eats the mouse
|
||||
// up event for its own purposes.
|
||||
WIDGET_IGNORE_DRAG = 1 << 10
|
||||
WIDGET_IGNORE_DRAG = 1 << 10,
|
||||
WIDGET_DYN_TOOLTIP = 1 << 11, // Widgets updates tooltip by coordinates
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -203,7 +204,7 @@ protected:
|
||||
Common::U32String _label;
|
||||
Graphics::TextAlign _align;
|
||||
ThemeEngine::FontStyle _font;
|
||||
ThemeEngine::FontColor _fontColor;
|
||||
ThemeEngine::FontColor _fontColor;
|
||||
bool _useEllipsis;
|
||||
|
||||
public:
|
||||
@ -217,7 +218,7 @@ public:
|
||||
void setAlign(Graphics::TextAlign align);
|
||||
Graphics::TextAlign getAlign() const { return _align; }
|
||||
void readLabel() { read(_label); }
|
||||
void setFontColor(ThemeEngine::FontColor color);
|
||||
void setFontColor(ThemeEngine::FontColor color);
|
||||
|
||||
protected:
|
||||
void drawWidget() override;
|
||||
@ -323,7 +324,7 @@ protected:
|
||||
class CheckboxWidget : public ButtonWidget {
|
||||
protected:
|
||||
bool _state;
|
||||
bool _overrideText;
|
||||
bool _overrideText;
|
||||
int _spacing;
|
||||
public:
|
||||
CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, bool scale, const Common::U32String &label, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0, uint8 hotkey = 0);
|
||||
@ -338,8 +339,8 @@ public:
|
||||
void toggleState() { setState(!_state); }
|
||||
bool getState() const { return _state; }
|
||||
|
||||
void setOverride(bool enable);
|
||||
|
||||
void setOverride(bool enable);
|
||||
|
||||
protected:
|
||||
void drawWidget() override;
|
||||
};
|
||||
|
@ -71,7 +71,7 @@ RichTextWidget::RichTextWidget(GuiObject *boss, const Common::String &name, cons
|
||||
}
|
||||
|
||||
void RichTextWidget::init() {
|
||||
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG);
|
||||
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_TRACK_MOUSE | WIDGET_DYN_TOOLTIP);
|
||||
|
||||
_type = kRichTextWidget;
|
||||
|
||||
@ -93,6 +93,15 @@ void RichTextWidget::handleMouseWheel(int x, int y, int direction) {
|
||||
_verticalScroll->handleMouseWheel(x, y, direction);
|
||||
}
|
||||
|
||||
void RichTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
|
||||
warning("M: %s", _txtWnd->getMouseLink(x + _x + _scrolledX, y + _y + _scrolledY).encode().c_str());
|
||||
}
|
||||
|
||||
void RichTextWidget::handleTooltipUpdate(int x, int y) {
|
||||
_tooltip = _txtWnd->getMouseLink(x + _x + _scrolledX, y + _y + _scrolledY);
|
||||
//warning("t: %s", _tooltip.encode().c_str());
|
||||
}
|
||||
|
||||
void RichTextWidget::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||
Widget::handleCommand(sender, cmd, data);
|
||||
switch (cmd) {
|
||||
|
@ -58,6 +58,8 @@ public:
|
||||
|
||||
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
|
||||
void handleMouseWheel(int x, int y, int direction) override;
|
||||
void handleMouseDown(int x, int y, int button, int clickCount) override;
|
||||
void handleTooltipUpdate(int x, int y) override;
|
||||
|
||||
void markAsDirty() override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user