Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
ThemePreviewPicker Class Reference

#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

Detailed Description

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.

Member Typedef Documentation

◆ HoverChanged

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.

Parameters
layerthe layer under the pointer, or NoRole.
global_posthe pointer in global coordinates; null for NoRole reports from resetHover().

◆ Render

using ThemePreviewPicker::Render = std::function<QImage()>

Renders the owner's key image at the owner's current size.

◆ TextHeight

using ThemePreviewPicker::TextHeight = std::function<int()>

Tallest line height of the key fonts, in image pixels; called after Render.

Constructor & Destructor Documentation

◆ ThemePreviewPicker()

ThemePreviewPicker::ThemePreviewPicker ( QWidget * owner,
Render render,
TextHeight text_height )
Parameters
ownerthe sample; gets mouse tracking and the cursor.
renderrenders the key image of owner.
text_heighttallest line height of the key fonts.

Member Function Documentation

◆ hover()

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()).

Returns
false when picking is off, so the owner passes the event on.

◆ invalidate()

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.

◆ isEnabled()

bool ThemePreviewPicker::isEnabled ( ) const
inline

Whether picking is on.

◆ isPickClick()

bool ThemePreviewPicker::isPickClick ( const QMouseEvent * event) const

Whether event is a click that picks: picking on, left button.

◆ layerAt()

ThemePreviewPick::Layer ThemePreviewPicker::layerAt ( const QPoint & pos)

ThemePreviewPick::layerAt() on the key image; token NoRole when off.

◆ layersAt()

QList< ThemePreviewPick::Layer > ThemePreviewPicker::layersAt ( const QPoint & pos)

ThemePreviewPick::layersAt() on the key image; empty when off.

◆ resetHover()

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.

◆ setEnabled()

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.

◆ setHoverChanged()

void ThemePreviewPicker::setHoverChanged ( HoverChanged hover_changed)

Sets the function called when the hovered layer changes; may be empty.


The documentation for this class was generated from the following files: