19#include <winpr/assert.h>
21#include <rdtk/config.h>
25#include "rdtk_label.h"
27int rdtk_label_draw(rdtkSurface* surface, uint16_t nXDst, uint16_t nYDst, uint16_t nWidth,
28 uint16_t nHeight, WINPR_ATTR_UNUSED rdtkLabel* label,
const char* text,
29 WINPR_ATTR_UNUSED uint16_t hAlign, WINPR_ATTR_UNUSED uint16_t vAlign)
33 uint16_t textWidth = 0;
34 uint16_t textHeight = 0;
36 WINPR_ASSERT(surface);
38 rdtkEngine* engine = surface->engine;
39 rdtkFont* font = engine->font;
41 rdtk_font_text_draw_size(font, &textWidth, &textHeight, text);
43 if ((textWidth > 0) && (textHeight > 0))
48 if (textWidth < nWidth)
49 offsetX = ((nWidth - textWidth) / 2);
51 if (textHeight < nHeight)
52 offsetY = ((nHeight - textHeight) / 2);
54 rdtk_font_draw_text(surface, nXDst + offsetX, nYDst + offsetY, font, text);
60rdtkLabel* rdtk_label_new(rdtkEngine* engine)
63 rdtkLabel* label = (rdtkLabel*)calloc(1,
sizeof(rdtkLabel));
68 label->engine = engine;
73void rdtk_label_free(rdtkLabel* label)
78int rdtk_label_engine_init(rdtkEngine* engine)
83 engine->label = rdtk_label_new(engine);
89int rdtk_label_engine_uninit(rdtkEngine* engine)
94 rdtk_label_free(engine->label);