Helpers
app.ui.qt.widgets.preview.layer_bbox.helpersLow-level bbox helper math for hit-testing and clamping.
These helpers are intentionally primitive operations reused by higher-level interaction and widget facade logic.
See Also
DragMode— describes the resize handle selected by hit-testingfind_bbox_at_pos— locates boxes under the pointer
Layer: Presentation. Context: Contains concrete Qt presentation components and supporting utilities.
get_drag_mode_for_rect_at_pos(rect: QRect, pos: QPoint) -> DragMode
Identify the resize handle nearest to a pointer position.
| PARAMETER | DESCRIPTION |
|---|---|
rect
|
Bounding rectangle whose handles are hit-tested.
TYPE:
|
pos
|
Pointer position in the same widget coordinate space.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DragMode
|
Matching handle mode, or |
clamp_rect_to_pixmap(rect: QRect, pixmap_rect: QRect) -> QRect
Clamp a rectangle to the pixmap bounds.
| PARAMETER | DESCRIPTION |
|---|---|
rect
|
Rectangle to keep inside the displayed image area.
TYPE:
|
pixmap_rect
|
Bounds of the displayed image.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QRect
|
Normalized rectangle shifted back within the image bounds. |
apply_clamped_drag_deltas(mode: DragMode, pr: QRect, x1: int, x2: int, y1: int, y2: int, dx: int, dy: int) -> QRect
Apply clamped drag deltas.
| PARAMETER | DESCRIPTION |
|---|---|
mode
|
Active handle being dragged.
TYPE:
|
pr
|
Rectangle limiting the resulting coordinates.
TYPE:
|
x1
|
Starting left coordinate.
TYPE:
|
x2
|
Starting right coordinate.
TYPE:
|
y1
|
Starting top coordinate.
TYPE:
|
y2
|
Starting bottom coordinate.
TYPE:
|
dx
|
Horizontal pointer displacement from drag start.
TYPE:
|
dy
|
Vertical pointer displacement from drag start.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QRect
|
Normalized rectangle after moving the selected edge or corner, clamped to |
clamp_point_to_rect(point: QPoint, r: QRect) -> QPoint
Clamp a point to the rectangle bounds.
| PARAMETER | DESCRIPTION |
|---|---|
point
|
Point to constrain.
TYPE:
|
r
|
Rectangle defining the allowed coordinate range.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QPoint
|
Point with x and y independently clamped to |