Louvre
v1.2.1-2
C++ library for Wayland compositors
|
#include <LSurfaceView.h>
View for displaying surfaces. More...
View for displaying surfaces.
The LSurfaceView class can be used to display client surfaces on a scene. By default, it inherits the damage, input, translucent, and opaque regions, as well as the surface position from the LSurface.
To override any of these properties, you can use these specific methods:
An LSurface can have multiple views, but only views with the primary() property set to true will clear its damage when requestNextFrame() is called and also send LSurface::sendOutputEnterEvent() and LSurface::sendOutputLeaveEvent() to its client. Use the setPrimary() method to set the primary property of a view.
Public Member Functions | |
LSurfaceView (LSurface *surface, LView *parent=nullptr) | |
LSurfaceView class constructor. More... | |
~LSurfaceView () | |
LSurfaceView class destructor. More... | |
LSurface * | surface () const |
Get the LSurface associated with the view. More... | |
virtual bool | primary () const |
Check if the view is a primary view. More... | |
virtual void | setPrimary (bool primary) |
Set the view as a primary view. More... | |
virtual bool | customPosEnabled () const |
Check if custom position is enabled for the view. More... | |
virtual void | enableCustomPos (bool enable) |
Enable or disable custom position for the view. More... | |
virtual bool | customInputRegionEnabled () const |
Check if custom input region is enabled for the view. More... | |
virtual void | enableCustomInputRegion (bool enabled) |
Enable or disable custom input region for the view. More... | |
void | setCustomPos (const LPoint &pos) |
Set a custom position for the view. More... | |
virtual void | setCustomPos (Int32 x, Int32 y) |
Set a custom position for the view. More... | |
virtual const LPoint & | customPos () const |
Get the custom position set for the view. More... | |
virtual void | setCustomInputRegion (const LRegion *region) |
Set a custom input region for the view. More... | |
virtual const LRegion * | customInputRegion () const |
Get the custom input region set for the view. More... | |
virtual void | enableCustomTranslucentRegion (bool enabled) |
Enable or disable the custom translucent region for the view. More... | |
virtual bool | customTranslucentRegionEnabled () const |
Check if the custom translucent region is enabled for the view. More... | |
virtual void | setCustomTranslucentRegion (const LRegion *region) |
Set a custom translucent region for the view. More... | |
const LRectF & | srcRect () const |
Gets the source rect of the surface, equivalent to LSurface::srcRect(). More... | |
virtual bool | nativeMapped () const override |
Tells whether the view should be rendered. More... | |
virtual const LPoint & | nativePos () const override |
Get the position of the view without any transformations applied. More... | |
virtual const LSize & | nativeSize () const override |
Get the size of the view without any transformations applied. More... | |
virtual Float32 | bufferScale () const override |
Get the scale of the view buffer content. More... | |
virtual void | enteredOutput (LOutput *output) override |
Indicate that the view is visible on the given output. More... | |
virtual void | leftOutput (LOutput *output) override |
Indicate that the view is no longer visible on the given output. More... | |
virtual const std::vector< LOutput * > & | outputs () const override |
Get a vector of output pointers on which the view is currently visible. More... | |
virtual bool | isRenderable () const override |
Check if the view is itself renderable. More... | |
virtual void | requestNextFrame (LOutput *output) override |
Notify that the view has been rendered on the given output. More... | |
virtual const LRegion * | damage () const override |
Get the region within the view rect that needs to be repainted. More... | |
virtual const LRegion * | translucentRegion () const override |
Returns the translucent region within the view rectangle. More... | |
virtual const LRegion * | opaqueRegion () const override |
Returns the opaque region within the view rectangle. More... | |
virtual const LRegion * | inputRegion () const override |
Region within the view rect that can receive input events (when the inputEnabled() property is enabled). More... | |
virtual void | paintEvent (const PaintEventParams ¶ms) override |
Request to paint a region of the view to the current framebuffer. More... | |
Public Member Functions inherited from LView | |
LView (UInt32 type, LView *parent=nullptr) | |
Construct an LView object. More... | |
virtual | ~LView () |
Destructor for the LView class. More... | |
void | damageAll () |
Forces a complete repaint of the view in the next rendering frame. More... | |
LScene * | scene () const |
Get the scene in which this view is currently embedded. More... | |
LSceneView * | parentSceneView () const |
Get the LSceneView in which this view is currently embedded. More... | |
UInt32 | type () const |
Get the identifier for the type of view. More... | |
void | repaint () |
Schedule a repaint for all outputs where this view is currently visible. More... | |
LView * | parent () const |
Get the parent of the view. More... | |
void | setParent (LView *view) |
Set the new parent for the view and insert it at the end of its children list. More... | |
void | insertAfter (LView *prev, bool switchParent=true) |
Insert the view after the 'prev' view. More... | |
std::list< LView * > & | children () const |
Get the list of child views. More... | |
bool | parentOffsetEnabled () const |
Check if the parent's offset is applied to the view position. More... | |
void | enableParentOffset (bool enabled) |
Enable or disable the parent's offset for the view position. More... | |
const LPoint & | pos () const |
Get the current position of the view with applied transformations. More... | |
const LSize & | size () const |
Get the current size of the view with applied transformations. More... | |
bool | clippingEnabled () const |
Check if the view is currently being clipped to the clippingRect() property. More... | |
void | enableClipping (bool enabled) |
Enable or disable clipping of the view to the clippingRect() property. More... | |
const LRect & | clippingRect () const |
Get the current clipping rectangle defined by the clippingRect() property. More... | |
void | setClippingRect (const LRect &rect) |
Set the clipping rectangle for the view using the clippingRect() property. More... | |
bool | parentClippingEnabled () const |
Check if the view clipping to the current parent view rect is enabled. More... | |
void | enableParentClipping (bool enabled) |
Enable or disable clipping of the view to the current parent view rect. More... | |
bool | inputEnabled () const |
Check if the view receives pointer and touch events. More... | |
void | enableInput (bool enabled) |
Enable or disable pointer and touch events for the view. More... | |
bool | scalingEnabled () const |
Check if scaling is enabled for the view's size. More... | |
void | enableScaling (bool enabled) |
Enable or disable scaling for the view's size. More... | |
bool | parentScalingEnabled () const |
Check if the size and position are scaled by the parent scaling vector. More... | |
void | enableParentScaling (bool enabled) |
Enable or disable scaling of the size and position by the parent's scaling vector. More... | |
const LSizeF & | scalingVector (bool forceIgnoreParent=false) const |
Get the scaling vector for the view's size. More... | |
void | setScalingVector (const LSizeF &scalingVector) |
Set the scaling vector for the view's size. More... | |
bool | visible () const |
Check if the view is marked as visible. More... | |
void | setVisible (bool visible) |
Toggle the view visibility. More... | |
bool | mapped () const |
Check if the view should be rendered, taking into consideration several conditions. More... | |
Float32 | opacity (bool forceIgnoreParent=false) const |
Get the current view opacity. More... | |
void | setOpacity (Float32 opacity) |
Set the view opacity. More... | |
bool | parentOpacityEnabled () const |
Check if the view's opacity is multiplied by its parent's opacity. More... | |
void | enableParentOpacity (bool enabled) |
Enable or disable the view's opacity being multiplied by its parent's opacity. More... | |
bool | forceRequestNextFrameEnabled () const |
Check if the requestNextFrame() is enabled. More... | |
void | enableForceRequestNextFrame (bool enabled) const |
Enable or disable the requestNextFrame() to be called always. More... | |
void | setBlendFunc (GLenum sRGBFactor, GLenum dRGBFactor, GLenum sAlphaFactor, GLenum dAlphaFactor) |
Set the alpha blending function for the view. More... | |
void | enableAutoBlendFunc (bool enabled) |
Enable or disable automatic blend function adjustment. More... | |
bool | autoBlendFuncEnabled () const |
Check whether the automatic blend function adjustment is enabled. More... | |
void | setColorFactor (Float32 r, Float32 g, Float32 b, Float32 a) |
Set the color factor. More... | |
const LRGBAF & | colorFactor () |
Get the color factor. More... | |
bool | pointerIsOver () const |
Checks if the pointer/cursor is inside the view's input region. More... | |
void | enableBlockPointer (bool enabled) |
Enable or disable blocking of pointer or touch events to views behind the view's input region. More... | |
bool | blockPointerEnabled () const |
Checks if blocking of pointer or touch events to views behind the view's input region is enabled. More... | |
LBox | boundingBox () const |
Get the bounding box of the view and all its mapped children. More... | |
virtual void | pointerEnterEvent (const LPoint &localPos) |
Handle the pointer enter event within the view. More... | |
virtual void | pointerMoveEvent (const LPoint &localPos) |
Handle the pointer move event within the view. More... | |
virtual void | pointerLeaveEvent () |
Handle the pointer leave event within the view. More... | |
virtual void | pointerButtonEvent (LPointer::Button button, LPointer::ButtonState state) |
Handle the pointer button event within the view. More... | |
virtual void | pointerAxisEvent (Float64 axisX, Float64 axisY, Int32 discreteX, Int32 discreteY, UInt32 source) |
Handle the pointer axis event within the view. More... | |
virtual void | keyModifiersEvent (UInt32 depressed, UInt32 latched, UInt32 locked, UInt32 group) |
Handle the key modifiers event within the view. More... | |
virtual void | keyEvent (UInt32 keyCode, UInt32 keyState) |
Handle the key event within the view. More... | |
Public Member Functions inherited from LObject | |
LObject ()=default | |
Constructor of the LObject class. More... | |
~LObject () | |
Destructor of the LObject class. More... | |
std::shared_ptr< const bool > | isAlive () const |
Object's liveness status. More... | |
Additional Inherited Members | |
Public Types inherited from LView | |
enum | Type : UInt32 |
Types of views included with Louvre. More... | |
Static Public Member Functions inherited from LObject | |
static LCompositor * | compositor () |
Quick access to the global compositor instance. More... | |
static LSeat * | seat () |
Quick access to the global seat instance. More... | |
static LCursor * | cursor () |
Quick access to the global cursor instance. More... | |
LSurfaceView | ( | LSurface * | surface, |
LView * | parent = nullptr |
||
) |
LSurfaceView class constructor.
~LSurfaceView | ( | ) |
LSurfaceView class destructor.
LSurface * surface | ( | ) | const |
|
virtual |
Check if the view is a primary view.
Only primary views will clear their damage when requestNextFrame() is called. The default value is true.
|
virtual |
Set the view as a primary view.
Only primary views will clear their damage when requestNextFrame() is called.
primary | True to set the view as a primary view, false otherwise. |
|
virtual |
Check if custom position is enabled for the view.
If enabled, nativePos() will return the position set with setCustomPos() instead of the surface position. The default value is false.
|
virtual |
Enable or disable custom position for the view.
If enabled, nativePos() will return the position set with setCustomPos() instead of the surface position.
enable | True to enable custom position, false to disable. |
|
virtual |
Check if custom input region is enabled for the view.
If enabled, inputRegion() will return the input region set with setCustomInputRegion() instead of the surface input region. The default value is false.
|
virtual |
Enable or disable custom input region for the view.
If enabled, inputRegion() will return the input region set with setCustomInputRegion() instead of the surface input region.
enabled | True to enable custom input region, false to disable. |
void setCustomPos | ( | const LPoint & | pos | ) |
Set a custom position for the view.
This method allows you to set a custom position for the view, overriding the surface position.
pos | The custom position as an LPoint object. |
Set a custom position for the view.
This method allows you to set a custom position for the view, overriding the surface position.
x | The X coordinate of the custom position. |
y | The Y coordinate of the custom position. |
|
virtual |
Get the custom position set for the view.
|
virtual |
Set a custom input region for the view.
This method allows you to set a custom input region for the view, overriding the surface input region.
region | Pointer to the custom input region as an LRegion object. |
|
virtual |
Get the custom input region set for the view.
|
virtual |
Enable or disable the custom translucent region for the view.
If enabled, the view will use the custom translucent region set with setCustomTranslucentRegion() instead of the surface translucent region.
enabled | True to enable the custom translucent region, false to disable. |
|
virtual |
Check if the custom translucent region is enabled for the view.
|
virtual |
Set a custom translucent region for the view.
This method allows you to set a custom translucent region for the view, overriding the surface translucent region.
region | Pointer to the custom translucent region as an LRegion object. |
const LRectF & srcRect | ( | ) | const |
Gets the source rect of the surface, equivalent to LSurface::srcRect().
|
overridevirtual |
|
overridevirtual |
Get the position of the view without any transformations applied.
Must return the position of the view in surface coordinates.
Implements LView.
|
overridevirtual |
Get the size of the view without any transformations applied.
Must return the size of the view in surface coordinates.
Implements LView.
|
overridevirtual |
Get the scale of the view buffer content.
This property is primarily used by views that contain a buffer like for example the LSceneView, LSurfaceView and LTextureView types.
Implements LView.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Get a vector of output pointers on which the view is currently visible.
Must return a vector of output pointers where the view is currently visible. Use the enteredOutput() and leftOutput() methods to update the vector.
Implements LView.
|
overridevirtual |
Check if the view is itself renderable.
This property indicates whether the view is capable of rendering its content (check paintEvent()). For example, all view types included in Louvre are renderable, except for LLayerView, which serves as a container for other views but does not produce any output by itself.
true
if the view is renderable; otherwise, false
. Implements LView.
|
overridevirtual |
Notify that the view has been rendered on the given output.
This method is called by LScene and should be used to clear the previous view damage or update its content. If forceRequestNextFrameEnabled() is true
, this method is always called.
output | The LOutput on which the view is rendered. |
Implements LView.
|
overridevirtual |
Get the region within the view rect that needs to be repainted.
The region rects are specified in surface coordinates within the view, without any scaling, clipping, or offset transformations applied. The damage may be cleared after requestNextFrame() is called. If nullptr
is returned, the entire view rect will be considered damaged. If the view has no damage, simply pass an empty LRegion (not nullptr
).
nullptr
if the entire view rect is damaged. Implements LView.
|
overridevirtual |
Returns the translucent region within the view rectangle.
The region rects are specified in surface coordinates within the view, without any scaling, clipping, or offset transformations.
If nullptr
is returned, the entire view rect will be considered translucent.
Implements LView.
|
overridevirtual |
Returns the opaque region within the view rectangle.
The region rects are specified in surface coordinates within the view, without any scaling, clipping, or offset transformations.
If nullptr
is returned, the inverse of the translucent region will be considered opaque.
Implements LView.
|
overridevirtual |
Region within the view rect that can receive input events (when the inputEnabled() property is enabled).
The region rects are specified in surface coordinates within the view, without any scaling, clipping, or offset transformations.
If nullptr
is returned, the entire view rect will receive input.
Implements LView.
|
overridevirtual |
Request to paint a region of the view to the current framebuffer.
This method is used by LSceneView to request the view to paint a specified region on the current framebuffer. The painting is performed using the provided LPainter object.
Implements LView.