|
Wireshark 5.1.0
The Wireshark network protocol analyzer
|
#include <theme_preview_pick.h>
Public Types | |
| using | Render = std::function<QImage()> |
| using | TextHeight = std::function<int()> |
| using | HoverChanged = std::function<void(const ThemePreviewPick::Layer &layer, const QPoint &global_pos)> |
Public Member Functions | |
| ThemePreviewPicker (QWidget *owner, Render render, TextHeight text_height) | |
| void | setEnabled (bool enabled) |
| bool | isEnabled () const |
| void | invalidate () |
| void | setHoverChanged (HoverChanged hover_changed) |
| void | resetHover () |
| ThemePreviewPick::Layer | layerAt (const QPoint &pos) |
| QList< ThemePreviewPick::Layer > | layersAt (const QPoint &pos) |
| bool | hover (const QPoint &pos) |
| bool | isPickClick (const QMouseEvent *event) const |
Pick state of one Theme Designer sample: the cached key image, the hand cursor and the lookups. Each sample owns one and keeps only what differs between samples: how its key image is rendered and how tall its key fonts are.
The key image is rendered on demand and kept until invalidate() is called or the owner's size changes. Owners call invalidate() when something that shapes the key render changes (fonts, visible content), not on color changes: the key render has its own fixed key colors.
| using ThemePreviewPicker::HoverChanged = std::function<void(const ThemePreviewPick::Layer &layer, const QPoint &global_pos)> |
Called on every mouse move over a color, and once with a NoRole layer when the pointer leaves all colors, the sample, or picking goes off.
| layer | the layer under the pointer, or NoRole. |
| global_pos | the pointer in global coordinates; null for NoRole reports from resetHover(). |
| using ThemePreviewPicker::Render = std::function<QImage()> |
Renders the owner's key image at the owner's current size.
| using ThemePreviewPicker::TextHeight = std::function<int()> |
Tallest line height of the key fonts, in image pixels; called after Render.
| ThemePreviewPicker::ThemePreviewPicker | ( | QWidget * | owner, |
| Render | render, | ||
| TextHeight | text_height ) |
| owner | the sample; gets mouse tracking and the cursor. |
| render | renders the key image of owner. |
| text_height | tallest line height of the key fonts. |
| bool ThemePreviewPicker::hover | ( | const QPoint & | pos | ) |
Mouse move handling: a hand cursor over a pickable spot, else the arrow. Reports the layer under the pointer to the hover function (see setHoverChanged()).
| void ThemePreviewPicker::invalidate | ( | ) |
Marks the key image stale; the next lookup renders it again. Also resetHover(), as the spot under the pointer may now be another color.
|
inline |
Whether picking is on.
| bool ThemePreviewPicker::isPickClick | ( | const QMouseEvent * | event | ) | const |
Whether event is a click that picks: picking on, left button.
| ThemePreviewPick::Layer ThemePreviewPicker::layerAt | ( | const QPoint & | pos | ) |
ThemePreviewPick::layerAt() on the key image; token NoRole when off.
| QList< ThemePreviewPick::Layer > ThemePreviewPicker::layersAt | ( | const QPoint & | pos | ) |
ThemePreviewPick::layersAt() on the key image; empty when off.
| void ThemePreviewPicker::resetHover | ( | ) |
Forgets the hover. When the last move was over a color, the hover function gets a NoRole layer, so the owner can hide what it shows; the next mouse move reports the layer again.
| void ThemePreviewPicker::setEnabled | ( | bool | enabled | ) |
Turns picking on or off. Off (the default) turns mouse tracking off, restores the arrow cursor and drops the key image.
| void ThemePreviewPicker::setHoverChanged | ( | HoverChanged | hover_changed | ) |
Sets the function called when the hovered layer changes; may be empty.