GUI: Icons and IconsAnimation refactoring. Switch assets to new Icon Api (#566)
* GUI: Icons and IconsAnimation refactoring. Switch assets to new Icon API. * Gui: icon and animation draw now do not accept null pointer * Format Sources * Fix no debug build * Furi: stricter checks in memmgr
This commit is contained in:
@@ -1,75 +1,13 @@
|
||||
#include "icon_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
Icon* icon_alloc(const IconData* data) {
|
||||
Icon* icon = furi_alloc(sizeof(Icon));
|
||||
icon->data = data;
|
||||
return icon;
|
||||
uint8_t icon_get_width(const Icon* instance) {
|
||||
return instance->width;
|
||||
}
|
||||
|
||||
void icon_free(Icon* icon) {
|
||||
furi_assert(icon);
|
||||
free(icon);
|
||||
uint8_t icon_get_height(const Icon* instance) {
|
||||
return instance->height;
|
||||
}
|
||||
|
||||
const uint8_t* icon_get_data(Icon* icon) {
|
||||
furi_assert(icon);
|
||||
if(icon->tick) {
|
||||
uint32_t now = osKernelGetTickCount();
|
||||
if(now < icon->tick) {
|
||||
icon->tick = now;
|
||||
icon_next_frame(icon);
|
||||
} else if(now - icon->tick > osKernelGetTickFreq() / icon->data->frame_rate) {
|
||||
icon->tick = now;
|
||||
icon_next_frame(icon);
|
||||
}
|
||||
}
|
||||
return icon->data->frames[icon->frame];
|
||||
}
|
||||
|
||||
void icon_next_frame(Icon* icon) {
|
||||
furi_assert(icon);
|
||||
icon->frame = (icon->frame + 1) % icon->data->frame_count;
|
||||
}
|
||||
|
||||
uint8_t icon_get_width(Icon* icon) {
|
||||
furi_assert(icon);
|
||||
return icon->data->width;
|
||||
}
|
||||
|
||||
uint8_t icon_get_height(Icon* icon) {
|
||||
furi_assert(icon);
|
||||
return icon->data->height;
|
||||
}
|
||||
|
||||
bool icon_is_animated(Icon* icon) {
|
||||
furi_assert(icon);
|
||||
return icon->data->frame_count > 1;
|
||||
}
|
||||
|
||||
bool icon_is_animating(Icon* icon) {
|
||||
furi_assert(icon);
|
||||
return icon->tick > 0;
|
||||
}
|
||||
|
||||
void icon_start_animation(Icon* icon) {
|
||||
furi_assert(icon);
|
||||
icon->tick = osKernelGetTickCount();
|
||||
}
|
||||
|
||||
void icon_stop_animation(Icon* icon) {
|
||||
furi_assert(icon);
|
||||
icon->tick = 0;
|
||||
icon->frame = 0;
|
||||
}
|
||||
|
||||
uint8_t icon_get_current_frame(Icon* icon) {
|
||||
furi_assert(icon);
|
||||
return icon->frame;
|
||||
}
|
||||
|
||||
bool icon_is_last_frame(Icon* icon) {
|
||||
furi_assert(icon);
|
||||
return icon->data->frame_count - icon->frame <= 1;
|
||||
const uint8_t* icon_get_data(const Icon* instance) {
|
||||
return instance->frames[0];
|
||||
}
|
Reference in New Issue
Block a user