custom components - JamJar00/JUI GitHub Wiki

Building custom components in JUI is very easy and will instantly allow your component to be used with any other components or menus.

Reference

typedef struct component_t {
    uint8_t flags;
    void (*draw_func) (struct component_t* component, rectangle_t rect);
    void (*selected_func) (struct component_t* component);
    style_t style;
    void* contents;
} component_t;

flags holds a number of options that JUI will use when drawing and interacting with your component:

  • COMPONENT_SELECTABLE indicates this component can be selected in menus. Functionality not implemented yet

draw_func is the function that will be invoked to draw this component within the rectangle specified.

selected_func is the function that will be invoked when the user clicks on this menu item. assign this to be NULL if selection is not needed.

style is the style the component will be drawn with.

components is a space for a pointer to whatever contents your component will contain.

Implementation

When drawing your component the menu will invoke the draw_func with the rectangle of where the component should be drawn. Your component does not need to draw the style as this will be done by the menu however if it is a container component it will need to draw the child component's style.

⚠️ **GitHub.com Fallback** ⚠️