5#include "fifechan/widgets/tooltip.hpp"
12#include "fifechan/graphics.hpp"
65 mModifierState = modifierState;
68 mHoverTimer += deltaMs;
71 bool const altPressed = (mModifierState & 0x100) != 0;
72 mIsExtended = mSpec.modifierBehavior.enabled && altPressed;
81 mCurrentContent.clear();
86 generateNormalContent();
89 generateExtendedContent();
95 return mCurrentContent;
103 void Tooltip::generateNormalContent()
106 mCurrentContent = mSpec.
content(mWidgetId);
108 mCurrentContent.clear();
112 void Tooltip::generateExtendedContent()
114 if (!mSpec.modifierBehavior.modifiedContent) {
118 std::string modified = mSpec.modifierBehavior.modifiedContent(mWidgetId);
123 if (!mCurrentContent.empty() && !modified.empty()) {
124 if (modified.rfind(mCurrentContent, 0) == 0) {
125 modified.erase(0, mCurrentContent.size());
126 while (!modified.empty() && (modified.front() ==
'\n' || modified.front() ==
'\r')) {
127 modified.erase(modified.begin());
132 if (mCurrentContent.empty()) {
133 mCurrentContent = modified;
134 }
else if (!modified.empty()) {
135 mCurrentContent = mCurrentContent +
"\n" + modified;
141 if (!mIsHovering || mHoverTimer < mSpec.delayMs) {
145 if (mCurrentContent.empty()) {
174 if (!mIsHovering || mHoverTimer < mSpec.delayMs) {
void draw(Graphics *graphics) override
Draws the widget.
Rectangle getChildrenArea() override
Gets the area of the widget occupied by the widget's children.
virtual void setOpaque(bool opaque)
Sets the container to be opaque or not.
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
virtual void setColor(Color const &color)=0
Sets the color to use when drawing.
virtual void drawRectangle(Rectangle const &rectangle)=0
Draws a simple, non-filled rectangle with a one pixel width.
virtual void fillRectangle(Rectangle const &rectangle)=0
Draws a filled rectangle.
Represents a rectangular area (X, Y, Width, Height).
Used replacement tokens by configure_file():