跳转至

blocks:\n

    • Image initialization and drawing
    • Animated image sequences
    • Menu setup and navigation
    • Menu with indicators and animations
    • Progress bar creation and updates
    • Complex multi-widget UIs
    • Batch drawing optimization

* *

Pages Tab\n

*

    • Widget_UserGuide (comprehensive usage guide)
    • Graphics_Widget_Examples (11+ practical examples)
    • Graphics_Widget_Documentation (this page)

* *

Design Patterns\n

*

Initialize → Configure → Render\n

*

  • All widgets follow this pattern:

* *

\n
* 1. Initialize with base properties (Init function)\n
* 2. Configure visual/behavioral properties (ops->set_property)\n
* 3. Render (ops->immediate_draw or equivalent)\n
* 

* *

Operation Tables\n

*

  • Polymorphic behavior through function pointer tables enables:
    • Multiple implementations per widget type
    • Compile-time or runtime selection
    • Future extensibility

* *

Caller Ownership\n

*

    • All structures stack/static allocated
    • Caller owns: display device, bitmap data, item arrays
    • Widgets reference, don't copy data
    • Ensures deterministic memory usage

* *

Widget Best Practices

*

Initialization\n

*

    • Call *_Init() for all widgets before using
    • Initialize in order: dependencies first
    • Keep structures valid for entire usage lifetime

* *

Drawing Order

*

    • Use deferred mode for multiple widgets
    • Minimize update calls in tight loops

* *

Animation\n

*

    • Use 4-8 frames for UI feedback
    • Use 16+ frames for smooth transitions
    • Choose delays based on HAL tick resolution (25-50ms typical)

* *

Error Handling

*

    • Always check return values from add_item() - may fail if full
    • Always check return values from set_property() - property may not exist
    • Validate coordinates before drawing (device->ops->setPixel may fail)

* *

Documentation Maintenance\n

*

  • When modifying widget code:

* * 1. Update ```

Filename: blocks:\n


Updated on 2026-02-03 at 13:21:55 +0000