5#include "fifechan/widgets/tooltip.hpp"
13#include "fifechan/graphics.hpp"
66 mModifierState = modifierState;
69 mHoverTimer += deltaMs;
72 bool const altPressed = (mModifierState & 0x100) != 0;
73 mIsExtended = mSpec.modifierBehavior.enabled && altPressed;
82 mCurrentContent.clear();
87 generateNormalContent();
90 generateExtendedContent();
96 return mCurrentContent;
104 void Tooltip::generateNormalContent()
107 mCurrentContent = mSpec.
content(mWidgetId);
109 mCurrentContent.clear();
113 void Tooltip::generateExtendedContent()
115 if (!mSpec.modifierBehavior.modifiedContent) {
119 std::string modified = mSpec.modifierBehavior.modifiedContent(mWidgetId);
124 if (!mCurrentContent.empty() && !modified.empty()) {
125 if (modified.starts_with(mCurrentContent)) {
126 modified.erase(0, mCurrentContent.size());
127 while (!modified.empty() && (modified.front() ==
'\n' || modified.front() ==
'\r')) {
128 modified.erase(modified.begin());
133 if (mCurrentContent.empty()) {
134 mCurrentContent = modified;
135 }
else if (!modified.empty()) {
136 mCurrentContent = mCurrentContent +
"\n" + modified;
142 if (!mIsHovering || mHoverTimer < mSpec.delayMs) {
146 if (mCurrentContent.empty()) {
175 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():