// imgBtn.h  -- ImageButton widget API
#ifndef IMGBTN_H
#define IMGBTN_H

#include "../../../libs/kpunch/libdvx/dvxWgt.h"

typedef struct {
    WidgetT *(*create)(WidgetT *parent, uint8_t *data, int32_t w, int32_t h, int32_t pitch);
    WidgetT *(*fromFile)(WidgetT *parent, const char *path);
    void     (*setData)(WidgetT *w, uint8_t *data, int32_t imgW, int32_t imgH, int32_t pitch);
    void     (*loadFile)(WidgetT *w, const char *path);
} ImageButtonApiT;

static inline const ImageButtonApiT *dvxImageButtonApi(void) {
    static const ImageButtonApiT *sApi;
    if (!sApi) { sApi = (const ImageButtonApiT *)wgtGetApi("imagebutton"); }
    return sApi;
}

#define wgtImageButton(parent, data, w, h, pitch)          dvxImageButtonApi()->create(parent, data, w, h, pitch)
#define wgtImageButtonFromFile(parent, path)               dvxImageButtonApi()->fromFile(parent, path)
#define wgtImageButtonSetData(w, data, imgW, imgH, pitch)  dvxImageButtonApi()->setData(w, data, imgW, imgH, pitch)
#define wgtImageButtonLoadFile(w, path)                    dvxImageButtonApi()->loadFile(w, path)

#endif // IMGBTN_H
