|
wiRedPanda
Logic Circuit Simulator
|
Frameless tooltip-like widget showing a rendered preview of an IC's sub-circuit. More...
#include <ICPreviewPopup.h>
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 |
| IC * | pendingIC () 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 |
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.
|
explicit |
Constructs the popup as a frameless, non-activating child of parent.
Definition at line 16 of file ICPreviewPopup.cpp.
| void ICPreviewPopup::cancelHide | ( | ) |
Cancels a pending show/hide.
Definition at line 167 of file ICPreviewPopup.cpp.
Referenced by enterEvent(), and showForIC().
|
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.
|
overrideprotected |
Definition at line 190 of file ICPreviewPopup.cpp.
References cancelHide().
| 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.
|
overrideprotected |
Definition at line 196 of file ICPreviewPopup.cpp.
References scheduleHide().
| IC * ICPreviewPopup::pendingIC | ( | ) | const |
Returns the IC currently pending display (may be null).
Definition at line 180 of file ICPreviewPopup.cpp.
| 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().
| 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().
| 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.
|
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().
|
staticconstexpr |
Definition at line 33 of file ICPreviewPopup.h.
Referenced by ICRenderer::generatePreviewPixmap().
|
staticconstexpr |
Maximum preview dimensions in pixels.
Definition at line 32 of file ICPreviewPopup.h.
Referenced by ICRenderer::generatePreviewPixmap().