MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / PiuStyleDraw

Function PiuStyleDraw

modules/piu/All/piuStyle.c:326–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326void PiuStyleDraw(PiuStyle* self, xsSlot* string, PiuView* view, PiuRectangle bounds, PiuBoolean ellipsis, PiuState state)
327{
328 PiuFont* font = (*self)->font;
329 PiuCoordinate x = bounds->x;
330 PiuCoordinate y = bounds->y;
331 PiuCoordinate dx = bounds->width;
332 PiuCoordinate dy = bounds->height;
333 PiuMargins margins = &((*self)->margins);
334 PiuCoordinate du = 0, dv;
335 PiuColorRecord color;
336 switch ((*self)->horizontal) {
337 case piuCenter:
338 du = PiuStyleGetWidth(self, string);
339 if (ellipsis && (dx < du)) {
340 x += margins->left;
341 dx -= margins->left + margins->right;
342 }
343 else {
344#ifdef piuPC
345 x += margins->left + ((dx - du) / 2);
346#else
347 x += margins->left + ((dx - du) >> 1);
348#endif
349 dx = 0;
350 }
351 break;
352 case piuLeft:
353 x += margins->left;
354 if (ellipsis) {
355 du = PiuStyleGetWidth(self, string);
356 if (dx < du)
357 dx -= margins->left + margins->right;
358 else
359 dx = 0;
360 }
361 else
362 dx = 0;
363 break;
364 case piuRight:
365 du = PiuStyleGetWidth(self, string);
366 if (ellipsis && (dx < du)) {
367 x += margins->left;
368 dx -= margins->left + margins->right;
369 }
370 else {
371 x += dx - du + margins->left;
372 dx = 0;
373 }
374 break;
375 }
376 switch ((*self)->vertical) {
377 case piuMiddle:
378 dv = margins->top + PiuFontGetHeight(font) + margins->bottom;
379#ifdef piuPC
380 y += margins->top + ((dy - dv) / 2);
381#else
382 y += margins->top + ((dy - dv) >> 1);
383#endif

Callers 3

PiuPort_drawLabelFunction · 0.85
PiuPort_drawStyleFunction · 0.85
PiuLabelDrawFunction · 0.85

Calls 6

PiuStyleGetWidthFunction · 0.85
PiuColorsBlendFunction · 0.85
PiuFontGetHeightFunction · 0.50
PiuViewPushColorFunction · 0.50
PiuViewDrawStringFunction · 0.50
PiuViewPopColorFunction · 0.50

Tested by

no test coverage detected