flipperzero-firmware/applications/gui/canvas.h

45 lines
821 B
C
Raw Normal View History

#pragma once
#include <stdint.h>
2020-10-15 15:56:47 +00:00
#include <u8g2.h>
2020-10-15 15:05:28 +00:00
typedef enum {
ColorWhite = 0x00,
ColorBlack = 0x01,
} Color;
2020-10-15 15:05:28 +00:00
typedef const uint8_t* Font;
typedef struct {
Font primary;
Font secondary;
} Fonts;
2020-10-15 15:56:47 +00:00
struct _CanvasApi;
typedef struct _CanvasApi CanvasApi;
// Canvas is private but we need its declaration here
typedef struct {
u8g2_t fb;
uint8_t offset_x;
uint8_t offset_y;
uint8_t width;
uint8_t height;
} Canvas;
struct _CanvasApi {
2020-10-15 15:05:28 +00:00
Canvas canvas;
Fonts* fonts;
uint8_t (*width)(CanvasApi* canvas);
uint8_t (*height)(CanvasApi* canvas);
2020-10-15 15:05:28 +00:00
void (*clear)(CanvasApi* canvas);
2020-10-15 15:56:47 +00:00
void (*set_color)(CanvasApi* canvas, Color color);
void (*set_font)(CanvasApi* canvas, Font font);
2020-10-15 15:05:28 +00:00
void (*draw_str)(CanvasApi* canvas, uint8_t x, uint8_t y, const char* str);
2020-10-15 15:56:47 +00:00
};