wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ICPreviewPopup Class Reference

Frameless tooltip-like widget showing a rendered preview of an IC's sub-circuit. More...

#include <ICPreviewPopup.h>

Inheritance diagram for ICPreviewPopup:
[legend]

Public Member Functions

void cancelHide ()
 Cancels a pending show/hide.
 ICPreviewPopup (QWidget *parent=nullptr)
 Constructs the popup as a frameless, non-activating child of parent.
bool isShowActiveFor (const IC *ic) const
ICpendingIC () const
 Returns the IC currently pending display (may be null).
void scheduleHide ()
void showForIC (IC *ic, const QPoint &screenPos)
void updatePendingPos (const QPoint &screenPos)

Static Public Member Functions

static QPoint clampedPopupPos (const QPoint &cursorPos, const QSize &popupSize, const QRect &availableGeometry)

Static Public Attributes

static constexpr int MaxElementCount = 500
static constexpr int MaxHeight = 350
static constexpr int MaxWidth = 500
 Maximum preview dimensions in pixels.

Protected Member Functions

void enterEvent (QEnterEvent *event) override
void leaveEvent (QEvent *event) override

Detailed Description

Frameless tooltip-like widget showing a rendered preview of an IC's sub-circuit.

Displayed on hover over an IC element. The preview is rendered from the IC's internal elements and connections into a QPixmap at reduced scale. The popup is dismissed with a short delay (300ms) when the mouse leaves either the IC or the popup itself.

Definition at line 26 of file ICPreviewPopup.h.

Constructor & Destructor Documentation

◆ ICPreviewPopup()

ICPreviewPopup::ICPreviewPopup ( QWidget * parent = nullptr)
explicit

Constructs the popup as a frameless, non-activating child of parent.

Definition at line 16 of file ICPreviewPopup.cpp.

Member Function Documentation

◆ cancelHide()

void ICPreviewPopup::cancelHide ( )

Cancels a pending show/hide.

Definition at line 167 of file ICPreviewPopup.cpp.

Referenced by enterEvent(), and showForIC().

◆ clampedPopupPos()

QPoint ICPreviewPopup::clampedPopupPos ( const QPoint & cursorPos,
const QSize & popupSize,
const QRect & availableGeometry )
static

Top-left at which a popup of popupSize should appear for a cursor at cursorPos: offset down-right, then clamped so it stays within availableGeometry on every side. Pure (no screen lookup) so it is testable.

Definition at line 149 of file ICPreviewPopup.cpp.

◆ enterEvent()

void ICPreviewPopup::enterEvent ( QEnterEvent * event)
overrideprotected
Reimplemented from base class. Cancels a scheduled hide when the cursor enters the popup itself.

Definition at line 190 of file ICPreviewPopup.cpp.

References cancelHide().

◆ isShowActiveFor()

bool ICPreviewPopup::isShowActiveFor ( const IC * ic) const

True while a show is pending (timer running) or the popup is already visible for ic. Used by hover-move to tell "already armed" from "needs re-arming" (e.g. after the cursor passed over a port).

Definition at line 185 of file ICPreviewPopup.cpp.

◆ leaveEvent()

void ICPreviewPopup::leaveEvent ( QEvent * event)
overrideprotected
Reimplemented from base class. Schedules a hide when the cursor leaves the popup.

Definition at line 196 of file ICPreviewPopup.cpp.

References scheduleHide().

◆ pendingIC()

IC * ICPreviewPopup::pendingIC ( ) const

Returns the IC currently pending display (may be null).

Definition at line 180 of file ICPreviewPopup.cpp.

◆ scheduleHide()

void ICPreviewPopup::scheduleHide ( )

Starts a delayed hide (300ms). If showForIC() is called before the timer fires, the hide is cancelled.

Definition at line 161 of file ICPreviewPopup.cpp.

Referenced by leaveEvent().

◆ showForIC()

void ICPreviewPopup::showForIC ( IC * ic,
const QPoint & screenPos )

Schedules the popup to appear near screenPos with the preview of ic after a 1-second hover delay. If the popup is already visible (e.g. the cursor moved quickly from another IC), the update is applied immediately.

Definition at line 78 of file ICPreviewPopup.cpp.

References cancelHide(), and Settings::icPreviewDisabled().

◆ updatePendingPos()

void ICPreviewPopup::updatePendingPos ( const QPoint & screenPos)

Updates the position the popup will appear at when the show timer fires. No effect if the popup is already visible. Use this on hover-move so the popup tracks the cursor during the show delay.

Definition at line 173 of file ICPreviewPopup.cpp.

Member Data Documentation

◆ MaxElementCount

int ICPreviewPopup::MaxElementCount = 500
staticconstexpr

Maximum number of internal elements before we skip generating a preview. Empirically chosen: circuits above this size render in >16 ms on a mid-range laptop, making the 1-second hover delay feel unresponsive.

Definition at line 38 of file ICPreviewPopup.h.

Referenced by ICRenderer::generatePreviewPixmap().

◆ MaxHeight

int ICPreviewPopup::MaxHeight = 350
staticconstexpr

Definition at line 33 of file ICPreviewPopup.h.

Referenced by ICRenderer::generatePreviewPixmap().

◆ MaxWidth

int ICPreviewPopup::MaxWidth = 500
staticconstexpr

Maximum preview dimensions in pixels.

Definition at line 32 of file ICPreviewPopup.h.

Referenced by ICRenderer::generatePreviewPixmap().


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