示例#1
0
guiObject_t *GUI_CreateImageOffset(guiImage_t *image, u16 x, u16 y, u16 width, u16 height, u16 x_off, u16 y_off, const char *file,
    void (*CallBack)(guiObject_t *obj, s8 press_type, const void *data), const void *cb_data)
{
    struct guiObject *obj = (guiObject_t *)image;
    struct guiBox    *box;
    CLEAR_OBJ(image);

    box = &obj->box;

    image->file = file;
    image->x_off = x_off;
    image->y_off = y_off;
    image->callback = CallBack;
    image->cb_data = cb_data;
    image->crc = Crc(file, strlen(file));

    box->x = x;
    box->y = y;
    box->width = width;
    box->height = height;

    obj->Type = Image;
    OBJ_SET_TRANSPARENT(obj, LCD_ImageIsTransparent(file));
    OBJ_SET_SELECTABLE(obj, CallBack ? 1 :0);
    connect_object(obj);

    return obj;

}
示例#2
0
void GUI_ChangeImage(struct guiImage *image, const char *file, u16 x_off, u16 y_off)
{
    guiObject_t *obj = (guiObject_t *)image;
    //Use a CRC for comparison because the filename may change without the pointer changing
    u32 crc = Crc(file, strlen(file));
    if (image->file != file || image->crc != crc || image->x_off != x_off || image->y_off != y_off) {
        image->crc = crc;
        image->file = file;
        image->x_off = x_off;
        image->y_off = y_off;
        OBJ_SET_TRANSPARENT(obj, LCD_ImageIsTransparent(file));
        OBJ_SET_DIRTY(obj, 1);
    }
}
示例#3
0
void _GUI_ChangeImage(struct guiImage *image, const char *file, u16 x_off, u16 y_off, u8 replace)
{
    guiObject_t *obj = (guiObject_t *)image;
    //Use a CRC for comparison because the filename may change without the pointer changing
    u32 crc = Crc(file, strlen(file));
    if (image->file != file || image->crc != crc || image->x_off != x_off || image->y_off != y_off) {
        if (replace) {
            // draw background where the old picture was bigger
            struct guiBox *box = &obj->box;
            u16 w, h;
            LCD_ImageDimensions(file, &w, &h);
            if (h < box->height) GUI_DrawBackground(box->x, box->y + h, box->width, box->height - h);    // remove lower left part of old image
            if (w < box->width) GUI_DrawBackground(box->x + w, box->y, box->width - w, h < box->height ? h : box->height);    // remove upper right part of old image
            box->width = w;
            box->height = h;
        }
        image->crc = crc;
        image->file = file;
        image->x_off = x_off;
        image->y_off = y_off;
        OBJ_SET_TRANSPARENT(obj, LCD_ImageIsTransparent(file));
        OBJ_SET_DIRTY(obj, 1);
    }
}