Louvre  v2.12.0-1
C++ library for Wayland compositors
Public Types | Public Member Functions | List of all members
LScene Class Reference

Scene. More...

+ Inheritance diagram for LScene:

Public Types

enum  EventOptions : UInt8
 Custom options for input event handlers. More...
 
enum  InputFilter : UInt8
 Input filter flags used by viewAt(). More...
 

Public Member Functions

 LScene ()
 Constructor for LScene. More...
 
 ~LScene ()
 Destructor for LScene. More...
 
void enableAutoRepaint (bool enabled) noexcept
 Enables or disables automatic repainting of child views. More...
 
bool autoRepaintEnabled () const noexcept
 Checks if automatic repainting of child views is currently enabled. More...
 
const std::vector< LView * > & pointerFocus () const
 Vector of views with pointer focus. More...
 
const std::vector< LView * > & keyboardFocus () const
 Vector of views with keyboard focus. More...
 
const std::vector< LSceneTouchPoint * > & touchPoints () const
 Vector of active touch points managed within the scene. More...
 
LSceneTouchPointfindTouchPoint (Int32 id) const
 Searches for a touch point within the scene by its ID. More...
 
void handleInitializeGL (LOutput *output)
 Handle the OpenGL initialization for an LOutput. More...
 
void handlePaintGL (LOutput *output)
 Handle the OpenGL painting for an LOutput. More...
 
void handleMoveGL (LOutput *output)
 Handle the OpenGL movement for an LOutput. More...
 
void handleResizeGL (LOutput *output)
 Handle the OpenGL resizing for an LOutput. More...
 
void handleUninitializeGL (LOutput *output)
 Handle the OpenGL uninitialization for an LOutput. More...
 
void handlePointerMoveEvent (const LPointerMoveEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle pointer movement event. More...
 
void handlePointerButtonEvent (const LPointerButtonEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle pointer button event. More...
 
void handlePointerScrollEvent (const LPointerScrollEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle pointer scroll event. More...
 
void handlePointerSwipeBeginEvent (const LPointerSwipeBeginEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle pointer swipe begin event. More...
 
void handlePointerSwipeUpdateEvent (const LPointerSwipeUpdateEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle pointer swipe update event. More...
 
void handlePointerSwipeEndEvent (const LPointerSwipeEndEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle pointer swipe end event. More...
 
void handlePointerPinchBeginEvent (const LPointerPinchBeginEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle pointer pinch begin event. More...
 
void handlePointerPinchUpdateEvent (const LPointerPinchUpdateEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle pointer pinch update event. More...
 
void handlePointerPinchEndEvent (const LPointerPinchEndEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle pointer pinch end event. More...
 
void handlePointerHoldBeginEvent (const LPointerHoldBeginEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle pointer hold begin event. More...
 
void handlePointerHoldEndEvent (const LPointerHoldEndEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle pointer hold end event. More...
 
void handleKeyboardKeyEvent (const LKeyboardKeyEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle keyboard key event. More...
 
void handleTouchDownEvent (const LTouchDownEvent &event, const LPointF &globalPos, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle touch down event. More...
 
void handleTouchMoveEvent (const LTouchMoveEvent &event, const LPointF &globalPos, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle touch move event. More...
 
void handleTouchUpEvent (const LTouchUpEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle touch up event. More...
 
void handleTouchFrameEvent (const LTouchFrameEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle touch frame event. More...
 
void handleTouchCancelEvent (const LTouchCancelEvent &event, LBitset< EventOptions > options=WaylandEvents|PointerConstraints|AuxFunc)
 Handle touch cancel event. More...
 
LSceneViewmainView () const
 Retrieve the main (root) view of the scene. More...
 
LViewviewAt (const LPoint &pos, LView::Type type=LView::UndefinedType, LBitset< InputFilter > filter=FilterDisabled)
 Retrieve the view located at the specified position. More...
 
- Public Member Functions inherited from LObject
 LObject (const LObject &) noexcept
 Copy constructor. More...
 
LObjectoperator= (const LObject &) noexcept
 Assignment operator (each object has its own individual LWeak reference count). More...
 
void setUserData (UIntPtr data) const noexcept
 Store an unsigned integer value/pointer. More...
 
UIntPtr userData () const noexcept
 Retrieves the stored unsigned integer value/pointer. More...
 

Additional Inherited Members

- Protected Member Functions inherited from LObject
 LObject () noexcept=default
 Constructor of the LObject class. More...
 
virtual ~LObject () noexcept
 Destructor of the LObject class. More...
 
void notifyDestruction () noexcept
 Notifies the object destruction. More...
 

Detailed Description

Scene.

The LScene class is an optional utility that significantly simplifies rendering.
It encompasses a primary LSceneView which can host multiple children and even nested scenes.
A single LScene can drive multiple outputs and also manage Wayland input events, while also providing per-view input events.
You might opt to leverage LScene for rendering instead of relying solely on the basic rendering functions from the LPainter class or your custom OpenGL shaders.

LScene achieves high efficiency by rendering only damaged regions and avoiding rendering content obscured by opaque areas.

Alternatively, you can still use your own OpenGL shaders or LPainter functions for rendering, either in conjunction with LScene or independently.
These approaches can be applied before or after handlePaintGL() is called, or by creating custom LViews that override the LView::paintEvent() virtual method.

Rendering

For proper rendering with LScene, you need to "plug" the following methods into each LOutput you intend to manage:

Warning
Make sure to "plug" the scene to all the output events mentioned earlier. Failing to do so may result in scene initialization issues and memory leaks.

For example, like this:

#include <LOutput.h>
class YourCustomOutput : public LOutput
{
...
void initializeGL(LOutput *output) override
{
scene->handleInitializeGL(output);
}
void paintGL(LOutput *output) override
{
scene->handlePaintGL(output);
}
void moveGL(LOutput *output) override
{
scene->handleMoveGL(output);
}
void resizeGL(LOutput *output) override
{
scene->handleResizeGL(output);
}
void uninitializeGL(LOutput *output) override
{
scene->handleUninitializeGL(output);
}
};

Input Events

Similar to rendering, you can integrate LScene into LPointer, LKeyboard and LTouch for managing input events.

See also
EventOptions

Member Enumeration Documentation

◆ EventOptions

Custom options for input event handlers.

Enumerator
OptionsDisabled 

All options disabled, input events will only be dispatched to views acordingly.

WaylandEvents 

Input events will be dispatched to client surfaces acordingly.

PointerConstraints 

The scene will constraint the cursor within surfaces when allowed clients require it.

AuxFunc 

Auxiliary functionality of the default Louvre implementation, such as exiting the compositor when Ctrl + Shift + Esc is pressed, will be handled.

◆ InputFilter

Input filter flags used by viewAt().

See also
viewAt()
Enumerator
FilterDisabled 

All views will be considered.

Pointer 

Views with pointer events enabled will be considered.

Keyboard 

Views with keyboard events enabled will be considered.

Touch 

Views with touch events enabled will be considered.

Constructor & Destructor Documentation

◆ LScene()

LScene ( )

Constructor for LScene.

◆ ~LScene()

~LScene ( )

Destructor for LScene.

Member Function Documentation

◆ enableAutoRepaint()

void enableAutoRepaint ( bool  enabled)
noexcept

Enables or disables automatic repainting of child views.

When disabled, LOutput::repaint() requests from child views will be ignored.

This can be useful when modifying views during an LOutput::paintGL() event to prevent the output from immediately scheduling a new repaint.

Enabled by default.

◆ autoRepaintEnabled()

bool autoRepaintEnabled ( ) const
noexcept

Checks if automatic repainting of child views is currently enabled.

See also
enableAutoRepaint

◆ pointerFocus()

const std::vector< LView * > & pointerFocus ( ) const

Vector of views with pointer focus.

This vector contains views that have pointer events enabled and whose input region intersects with the current pointer position.

The vector is ordered with the topmost views first and the bottommost views last.
Views with the property LView::blockInputEnabled() disabled allow views behind them to also receive pointer events, which is why multiple views can be in focus at the same time.

◆ keyboardFocus()

const std::vector< LView * > & keyboardFocus ( ) const

Vector of views with keyboard focus.

Views with keyboard focus are simply those whose LView::keyboardEventsEnabled() property is enabled.

◆ touchPoints()

const std::vector< LSceneTouchPoint * > & touchPoints ( ) const

Vector of active touch points managed within the scene.

◆ findTouchPoint()

LSceneTouchPoint * findTouchPoint ( Int32  id) const

Searches for a touch point within the scene by its ID.

Parameters
idThe ID of the touch point to search for.
Returns
A pointer to the touch point if found, nullptr otherwise.

◆ handleInitializeGL()

void handleInitializeGL ( LOutput output)

Handle the OpenGL initialization for an LOutput.

This method should be integrated into LOutput::initializeGL() to properly handle OpenGL initialization for the associated output.

Parameters
outputThe LOutput instance to handle OpenGL initialization for.

◆ handlePaintGL()

void handlePaintGL ( LOutput output)

Handle the OpenGL painting for an LOutput.

This method should be integrated into LOutput::paintGL() to properly handle OpenGL painting for the associated output.

Parameters
outputThe LOutput instance to handle OpenGL painting for.

◆ handleMoveGL()

void handleMoveGL ( LOutput output)

Handle the OpenGL movement for an LOutput.

This method should be integrated into LOutput::moveGL() to properly handle OpenGL movement for the associated output.

Parameters
outputThe LOutput instance to handle OpenGL movement for.

◆ handleResizeGL()

void handleResizeGL ( LOutput output)

Handle the OpenGL resizing for an LOutput.

This method should be integrated into LOutput::resizeGL() to properly handle OpenGL resizing for the associated output.

Parameters
outputThe LOutput instance to handle OpenGL resizing for.

◆ handleUninitializeGL()

void handleUninitializeGL ( LOutput output)

Handle the OpenGL uninitialization for an LOutput.

This method should be integrated into LOutput::uninitializeGL() to properly handle OpenGL uninitialization for the associated output.

Parameters
outputThe LOutput instance to handle OpenGL uninitialization for.

◆ handlePointerMoveEvent()

void handlePointerMoveEvent ( const LPointerMoveEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle pointer movement event.

This method should be integrated into LPointer::pointerMoveEvent() to effectively manage pointer movement events.

Parameters
eventThe pointer move event to handle.
optionsCustom event options.
See also
EventOptions.

◆ handlePointerButtonEvent()

void handlePointerButtonEvent ( const LPointerButtonEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle pointer button event.

This method should be integrated into LPointer::pointerButtonEvent() to handle pointer button events.

Parameters
eventThe pointer button event to handle.

◆ handlePointerScrollEvent()

void handlePointerScrollEvent ( const LPointerScrollEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle pointer scroll event.

This method should be integrated into LPointer::pointerScrollEvent() to manage pointer scroll events.

Parameters
eventThe pointer scroll event to handle.

◆ handlePointerSwipeBeginEvent()

void handlePointerSwipeBeginEvent ( const LPointerSwipeBeginEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle pointer swipe begin event.

This method should be integrated into LPointer::pointerSwipeBeginEvent() to manage pointer swipe begin events.

Parameters
eventThe pointer swipe begin event to handle.

◆ handlePointerSwipeUpdateEvent()

void handlePointerSwipeUpdateEvent ( const LPointerSwipeUpdateEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle pointer swipe update event.

This method should be integrated into LPointer::pointerSwipeUpdateEvent() to manage pointer swipe update events.

Parameters
eventThe pointer swipe update event to handle.

◆ handlePointerSwipeEndEvent()

void handlePointerSwipeEndEvent ( const LPointerSwipeEndEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle pointer swipe end event.

This method should be integrated into LPointer::pointerSwipeEndEvent() to manage pointer swipe end events.

Parameters
eventThe pointer swipe end event to handle.

◆ handlePointerPinchBeginEvent()

void handlePointerPinchBeginEvent ( const LPointerPinchBeginEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle pointer pinch begin event.

This method should be integrated into LPointer::pointerPinchBeginEvent() to manage pointer pinch begin events.

Parameters
eventThe pointer pinch begin event to handle.

◆ handlePointerPinchUpdateEvent()

void handlePointerPinchUpdateEvent ( const LPointerPinchUpdateEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle pointer pinch update event.

This method should be integrated into LPointer::pointerPinchUpdateEvent() to manage pointer pinch update events.

Parameters
eventThe pointer pinch update event to handle.

◆ handlePointerPinchEndEvent()

void handlePointerPinchEndEvent ( const LPointerPinchEndEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle pointer pinch end event.

This method should be integrated into LPointer::pointerPinchEndEvent() to manage pointer pinch end events.

Parameters
eventThe pointer pinch end event to handle.

◆ handlePointerHoldBeginEvent()

void handlePointerHoldBeginEvent ( const LPointerHoldBeginEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle pointer hold begin event.

This method should be integrated into LPointer::pointerHoldBeginEvent() to manage pointer hold begin events.

Parameters
eventThe pointer hold begin event to handle.

◆ handlePointerHoldEndEvent()

void handlePointerHoldEndEvent ( const LPointerHoldEndEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle pointer hold end event.

This method should be integrated into LPointer::pointerHoldEndEvent() to manage pointer hold end events.

Parameters
eventThe pointer hold end event to handle.

◆ handleKeyboardKeyEvent()

void handleKeyboardKeyEvent ( const LKeyboardKeyEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle keyboard key event.

This method should be integrated into LKeyboard::keyEvent() to handle key events.

◆ handleTouchDownEvent()

void handleTouchDownEvent ( const LTouchDownEvent event,
const LPointF globalPos,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle touch down event.

This method should be integrated into LTouch::touchDownEvent() to manage touch down events.

Parameters
eventThe touch down event to handle.
globalPosThe event position transformed to global coordinates.

◆ handleTouchMoveEvent()

void handleTouchMoveEvent ( const LTouchMoveEvent event,
const LPointF globalPos,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle touch move event.

This method should be integrated into LTouch::touchMoveEvent() to manage touch move events.

Parameters
eventThe touch move event to handle.
globalPosThe event position transformed to global coordinates.

◆ handleTouchUpEvent()

void handleTouchUpEvent ( const LTouchUpEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle touch up event.

This method should be integrated into LTouch::touchUpEvent() to manage touch up events.

Parameters
eventThe touch up event to handle.

◆ handleTouchFrameEvent()

void handleTouchFrameEvent ( const LTouchFrameEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle touch frame event.

This method should be integrated into LTouch::touchFrameEvent() to manage touch frame events.

Parameters
eventThe touch frame event to handle.

◆ handleTouchCancelEvent()

void handleTouchCancelEvent ( const LTouchCancelEvent event,
LBitset< EventOptions options = WaylandEvents | PointerConstraints | AuxFunc 
)

Handle touch cancel event.

This method should be integrated into LTouch::touchCancelEvent() to manage touch cancel events.

Parameters
eventThe touch cancel event to handle.

◆ mainView()

LSceneView * mainView ( ) const

Retrieve the main (root) view of the scene.

This method returns the main LSceneView associated with the LScene.

Returns
A pointer to the main LSceneView of the scene.

◆ viewAt()

LView * viewAt ( const LPoint pos,
LView::Type  type = LView::UndefinedType,
LBitset< InputFilter filter = FilterDisabled 
)

Retrieve the view located at the specified position.

This method returns the first LView whose input region intersects the given position.

Parameters
posThe position to query.
typeThe type of view to search for. Passing LView::Type::Undefined disables the type filter.
filterAdditional flags for searching only views with pointer, keyboard and/or touch events enabled.
Returns
A pointer to the LView at the specified position, or nullptr if no view is found.