Tooltip
The ControlTooltip plugin provides a user interface control that enables the display of contextual tooltips for other interface elements. It allows customization of tooltip appearance, including position offset, radius, and color. Tooltips can be defined both statically (with custom text) and dynamically (using callback functions), giving developers flexibility in tailoring their behavior and content.
#include <interface/tooltip/include/TellusimControlTooltip.h>
Example
// create tooltip
ControlTooltip tooltip(&root);
tooltip.addTooltip(button_0, "Button 0");
tooltip.addTooltip(button_1, "Button 1");
tooltip.addTooltip(dialog, ControlTooltip::TextCallback([](Control control, Vector2f *position, float32_t *height) -> String {
*height = control.getHeight();
position->set(control.getOffsetX() + control.getWidth() / 2.0f, control.getOffsetY());
return String::format("Position: %.0f %.0f\nSize: %.0fx%.0f", control.getPositionX(), control.getPositionY(), control.getWidth(), control.getHeight());
}));
tooltip.addTooltip(button_2, ControlTooltip::DrawCallback([](Control control, CanvasMesh mesh, Vector2f *position, float32_t *height) -> String {
mesh.setMode(CanvasElement::ModeGradient);
mesh.setRect(Rect(0.0f, 128.0f, 0.0f, 128.0f));
mesh.setGradientStyle(GradientStyle(0.5f, Vector2f(0.5f), Color::magenta, Color::zero));
return String::format("Offset: %.0f %.0f", control.getOffsetX(), control.getOffsetY());
}));