zori_widget.c 749 B

123456789101112131415161718192021222324252627
  1. #include "zori.h"
  2. #include "zori_widget.h"
  3. #include "draw.h"
  4. /* Draws a widget's frame based on it's style. If the background bitmap is set
  5. * then that is used, otherwise, the background color is used, including a border
  6. * if needed. */
  7. void zori_widget_draw_background(struct zori_widget * widget) {
  8. float dx, dy, dw, dh;
  9. struct zori_style * style = &widget->style;
  10. zori_bitmap * background = style->back.image;
  11. dx = rebox_x(&widget->box);
  12. dy = rebox_y(&widget->box);
  13. dw = rebox_w(&widget->box);
  14. dh = rebox_h(&widget->box);
  15. if (background) {
  16. image_blitscale9(background, dx, dy, dw, dh, -1, -1);
  17. } else {
  18. draw_frame(dx, dy, dw, dh, 3, style->border.color, style->back.color);
  19. }
  20. }