- All widgets must inherit from
NanoSubWidgetand implementonNanoDisplay()method as the primary entry point for its rendering logic. - Widgets must use DPF events (.eg.
MouseEvent,MotionEvent,ScrollEvent, orKeyboardEvent) for all user interactions. - Standard
onMouse,onMotionandonKeyboardevent callbacks are overridden and passed to internalEventHandlerclasses.
The goal of the library is to emulate plugdata GUI objects and styling.
- Objects are organized in (sub-)patches. These can be several layers deep and should be able to overlap other objects.
- Global theme colors are used for standard colors and overridden from the plugin UI init. Each object can have its own additional color settings for object specific elements.
- Objects should have the same configuration, UI and UX as plugdata graphics as much as possible.
The library strictly separates interaction logic from rendering:
- Handlers:
ExtraEventHandlers.hppcontains specialized logic classes (e.g.,PDSliderEventHandler) that manage internal state, value scaling, and drag physics. - Widgets: UI classes (e.g.,
PDKnob) inherit from bothPDWidgetand a specific handler. This bridges NanoVG drawing logic with standardized interaction behavior.
PDMainpatchandPDSubpatchare the primary organizational containers. They manage astd::vector<PDWidget*> managedChildrenand manually forward mouse/keyboard events to them.- This manual propagation allows patches to handle Pure Data's specific layering and overlapping requirements, which differ from DPF's default mouse capturing.
PDSubpatchobjects can be nested multiple layers deep. Their size causes all sub-objects and sub-patches to be intersected. 1
- Currently this requires a patched DPF to work properly. Some other feature requests are also still open.
- Since DPF's standard coordinate system is relative,
PDWidgetoverloadscontains()and providesgetScreenPos(). - It walks up the parent chain to calculate absolute screen positions. This ensures that hit detection remains accurate regardless of how deeply a widget is nested within sub-patches.
Common.hppacts as the "Source of Truth" for the library's visual identity, containing globalColors,Corners, andBorderstructs.- Shared utility functions for drawing (e.g.,
drawRoundedRect) and color interpolation ensure visual consistency across all objects.
- To minimize duplication, complex widgets use composition over inheritance.
PDLabelis employed as an internal sub-component for objects that require text display, whilePDDragNumprovides the foundation forPDFloatandPDNumberobjects.- Parameter values are normalized before rendering to maintain consistent behavior across different scales and ranges.