A semi-transparent overlay widget used to dim the background content.
More...
#include <overlay_widget.h>
|
| qreal | GetOpacity () const |
| | Gets the current opacity of the overlay.
|
| |
| | OverlayWidget (QWidget *parent=nullptr) |
| | Constructs an OverlayWidget. Sets necessary widget attributes for transparency and event handling. Installs an event filter on the parent to track resize events. Attempts to find a Navbar child in the parent to exclude its area.
|
| |
| void | SetOpacity (qreal opacity) |
| | Sets the opacity of the overlay. Triggers a repaint of the widget.
|
| |
| void | UpdateGeometry (const QRect &rect) |
| | Updates the geometry of the overlay widget. Typically called when the parent widget resizes.
|
| |
|
| bool | eventFilter (QObject *watched, QEvent *event) override |
| | Filters events from the parent widget. Specifically, watches for Resize events on the parent to call UpdateGeometry().
|
| |
| void | paintEvent (QPaintEvent *event) override |
| | Overridden paint event handler. Draws the semi-transparent overlay. Fills the widget's area with a black color whose alpha is determined by opacity_. Excludes the exclude_rect_ area from being painted using clipping.
|
| |
|
| qreal | opacity |
| | Property controlling the opacity of the overlay (0.0 = transparent, 1.0 = fully opaque black). Animatable.
|
| |
|
| QRect | exclude_rect_ |
| | Rectangle defining an area (e.g., Navbar) to be excluded from the dimming effect.
|
| |
| qreal | opacity_ |
| | Current opacity level of the overlay (0.0 to 1.0).
|
| |
A semi-transparent overlay widget used to dim the background content.
This widget is typically placed over another widget (its parent) to create a dimming effect, often used when a modal dialog or sidebar is shown. It can exclude a specific rectangular area (like a navigation bar) from being dimmed. The opacity of the overlay can be animated. It automatically resizes to match its parent widget.
◆ OverlayWidget()
| OverlayWidget::OverlayWidget |
( |
QWidget * | parent = nullptr | ) |
|
|
explicit |
Constructs an OverlayWidget. Sets necessary widget attributes for transparency and event handling. Installs an event filter on the parent to track resize events. Attempts to find a Navbar child in the parent to exclude its area.
- Parameters
-
| parent | The parent widget over which the overlay will be displayed. |
◆ eventFilter()
| bool OverlayWidget::eventFilter |
( |
QObject * | watched, |
|
|
QEvent * | event ) |
|
overrideprotected |
Filters events from the parent widget. Specifically, watches for Resize events on the parent to call UpdateGeometry().
- Parameters
-
| watched | The object that generated the event. |
| event | The event being processed. |
- Returns
- True if the event was handled, false otherwise.
◆ GetOpacity()
| qreal OverlayWidget::GetOpacity |
( |
| ) |
const |
|
inline |
Gets the current opacity of the overlay.
- Returns
- The current opacity value (0.0 to 1.0).
◆ paintEvent()
| void OverlayWidget::paintEvent |
( |
QPaintEvent * | event | ) |
|
|
overrideprotected |
Overridden paint event handler. Draws the semi-transparent overlay. Fills the widget's area with a black color whose alpha is determined by opacity_. Excludes the exclude_rect_ area from being painted using clipping.
- Parameters
-
◆ SetOpacity()
| void OverlayWidget::SetOpacity |
( |
qreal | opacity | ) |
|
Sets the opacity of the overlay. Triggers a repaint of the widget.
- Parameters
-
| opacity | The desired opacity (0.0 to 1.0). |
◆ UpdateGeometry()
| void OverlayWidget::UpdateGeometry |
( |
const QRect & | rect | ) |
|
Updates the geometry of the overlay widget. Typically called when the parent widget resizes.
- Parameters
-
| rect | The new geometry rectangle, usually matching the parent's bounds. |
◆ exclude_rect_
| QRect OverlayWidget::exclude_rect_ |
|
private |
Rectangle defining an area (e.g., Navbar) to be excluded from the dimming effect.
◆ opacity_
| qreal OverlayWidget::opacity_ |
|
private |
Current opacity level of the overlay (0.0 to 1.0).
◆ opacity
| qreal OverlayWidget::opacity |
|
readwrite |
Property controlling the opacity of the overlay (0.0 = transparent, 1.0 = fully opaque black). Animatable.
The documentation for this class was generated from the following files: