removed gwinImageNext() since the image box widget now automatically takes care of animated images
This commit is contained in:
parent
bd8620fb93
commit
cb28adcfba
2 changed files with 36 additions and 34 deletions
|
@ -32,7 +32,8 @@
|
||||||
// An image window
|
// An image window
|
||||||
typedef struct GImageObject {
|
typedef struct GImageObject {
|
||||||
GWindowObject g;
|
GWindowObject g;
|
||||||
gdispImage image;
|
gdispImage image; // The image itself
|
||||||
|
GTimer timer; // Timer used for animated images
|
||||||
} GImageObject;
|
} GImageObject;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -104,26 +105,6 @@ bool_t gwinImageOpenMemory(GHandle gh, const void* memory);
|
||||||
*/
|
*/
|
||||||
gdispImageError gwinImageCache(GHandle gh);
|
gdispImageError gwinImageCache(GHandle gh);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Prepare for the next frame/page in the image file.
|
|
||||||
* @return A time in milliseconds to keep displaying the current frame before trying to draw
|
|
||||||
* the next frame. Watch out for the special values TIME_IMMEDIATE and TIME_INFINITE.
|
|
||||||
*
|
|
||||||
* @param[in] gh The widget handle (must be an image box handle)
|
|
||||||
*
|
|
||||||
* @pre gwinImageOpenXxx() must have returned successfully.
|
|
||||||
*
|
|
||||||
* @note It will return TIME_IMMEDIATE if the first frame/page hasn't been drawn or if the next frame
|
|
||||||
* should be drawn immediately.
|
|
||||||
* @note It will return TIME_INFINITE if another image frame doesn't exist or an error has occurred.
|
|
||||||
* @note Images that support multiple pages (eg TIFF files) will return TIME_IMMEDIATE between pages
|
|
||||||
* and then TIME_INFINITE when there are no more pages.
|
|
||||||
* @note An image that displays a looped animation will never return TIME_INFINITE unless it
|
|
||||||
* gets an error.
|
|
||||||
*/
|
|
||||||
delaytime_t gwinImageNext(GHandle gh);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -88,6 +88,27 @@ static const gwinVMT imageVMT = {
|
||||||
0, // The after-clear routine
|
0, // The after-clear routine
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This is the callback for the automated redraw for animated images
|
||||||
|
static void _animatedRedraw(void* gh) {
|
||||||
|
// draw pending frame
|
||||||
|
_redraw((GHandle)gh);
|
||||||
|
|
||||||
|
// read the delay for the next frame and set the timer
|
||||||
|
gtimerStart(&(widget((GHandle)gh)->timer), _animatedRedraw, (void*)gh, FALSE, gdispImageNext(&(widget((GHandle)gh)->image)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for an animated image
|
||||||
|
static bool_t _checkAnimated(GHandle gh) {
|
||||||
|
if (widget(gh)->image.flags & GDISP_IMAGE_FLG_ANIMATED) {
|
||||||
|
gtimerInit(&(widget(gh)->timer));
|
||||||
|
gtimerStart(&(widget(gh)->timer), _animatedRedraw, (void*)gh, FALSE, gdispImageNext(&(widget(gh)->image)));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
GHandle gwinImageCreate(GImageObject *gobj, GWindowInit *pInit) {
|
GHandle gwinImageCreate(GImageObject *gobj, GWindowInit *pInit) {
|
||||||
if (!(gobj = (GImageObject *)_gwindowCreate(&gobj->g, pInit, &imageVMT, 0)))
|
if (!(gobj = (GImageObject *)_gwindowCreate(&gobj->g, pInit, &imageVMT, 0)))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -116,8 +137,11 @@ bool_t gwinImageOpenMemory(GHandle gh, const void* memory) {
|
||||||
#if GDISP_NEED_CLIP
|
#if GDISP_NEED_CLIP
|
||||||
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
|
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
|
||||||
#endif
|
#endif
|
||||||
_redraw(gh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!_checkAnimated(gh))
|
||||||
|
_redraw(gh);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,8 +162,11 @@ bool_t gwinImageOpenFile(GHandle gh, const char* filename) {
|
||||||
#if GDISP_NEED_CLIP
|
#if GDISP_NEED_CLIP
|
||||||
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
|
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
|
||||||
#endif
|
#endif
|
||||||
_redraw(gh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!_checkAnimated(gh))
|
||||||
|
_redraw(gh);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -161,8 +188,11 @@ bool_t gwinImageOpenStream(GHandle gh, void *streamPtr) {
|
||||||
#if GDISP_NEED_CLIP
|
#if GDISP_NEED_CLIP
|
||||||
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
|
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
|
||||||
#endif
|
#endif
|
||||||
_redraw(gh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!_checkAnimated(gh))
|
||||||
|
_redraw(gh);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -171,14 +201,5 @@ gdispImageError gwinImageCache(GHandle gh) {
|
||||||
return gdispImageCache(&widget(gh)->image);
|
return gdispImageCache(&widget(gh)->image);
|
||||||
}
|
}
|
||||||
|
|
||||||
delaytime_t gwinImageNext(GHandle gh) {
|
|
||||||
delaytime_t delay;
|
|
||||||
|
|
||||||
delay = gdispImageNext(&widget(gh)->image);
|
|
||||||
_redraw(gh);
|
|
||||||
|
|
||||||
return delay;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // GFX_USE_GWIN && GWIN_NEED_IMAGE
|
#endif // GFX_USE_GWIN && GWIN_NEED_IMAGE
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
Loading…
Add table
Reference in a new issue