Landtiger LPC1768 C BigLib 1
A self made, custom C library for the LandTiger board.
 
Loading...
Searching...
No Matches
glcd_processor.h File Reference
#include "glcd_types.h"
#include "types.h"

Go to the source code of this file.

Enumerations

enum  __ProcessingMode { MD_DRAW_BBOX = 0x1 , MD_DELETE = 0x2 , MD_BBOX = 0x4 , MD_DELETE_FAST = 0x8 }
 

Functions

bool __LCD_PROC_DoProcessObject (const LCD_Obj *const obj, LCD_BBox *out_bbox, u8 mode)
 

Enumeration Type Documentation

◆ __ProcessingMode

Enumerator
MD_DRAW_BBOX 
MD_DELETE 
MD_BBOX 
MD_DELETE_FAST 

Definition at line 9 of file glcd_processor.h.

10{
11 MD_DRAW_BBOX = 0x1,
12 MD_DELETE = 0x2,
13 MD_BBOX = 0x4,
14 MD_DELETE_FAST = 0x8,
__ProcessingMode
@ MD_DELETE
@ MD_DRAW_BBOX
@ MD_DELETE_FAST
@ MD_BBOX

Function Documentation

◆ __LCD_PROC_DoProcessObject()

bool __LCD_PROC_DoProcessObject ( const LCD_Obj *const  obj,
LCD_BBox out_bbox,
u8  mode 
)

Definition at line 642 of file glcd_processor.c.

643{
644 if (!obj || !obj->comps || obj->comps_size == 0)
645 return false;
646
647 bool res = true;
648 LCD_Component *comp;
649 for (u16 i = 0; i < obj->comps_size && res; i++)
650 {
651 comp = &obj->comps[i];
652 switch (comp->type)
653 {
654 case LCD_COMP_LINE:
655 // Cannot delete faster, skipping MD_FAST check
656 res = process_line(comp->object.line, &comp->cached_bbox, mode);
657 break;
658 case LCD_COMP_RECT:
659 // Cannot delete faster, skipping MD_FAST check
660 res = process_rect(comp->object.rect, comp->pos, &comp->cached_bbox, mode);
661 break;
662 case LCD_COMP_CIRCLE:
663 // Maybe can delete faster?
664 res = process_circle(comp->object.circle, &comp->cached_bbox, mode);
665 break;
666 case LCD_COMP_IMAGE: {
667 if (IS_MODE(mode, MD_DELETE))
668 {
669 res = process_rect(
670 &(LCD_Rect){
671 .width = comp->object.image->width,
672 .height = comp->object.image->height,
673 .fill_color = LCDCurrentBGColor,
674 .edge_color = LCDCurrentBGColor,
675 },
676 comp->pos, NULL, MD_DELETE);
677 }
678 else
679 res = process_img_rle(comp->object.image, comp->pos, &comp->cached_bbox, MD_DRAW_BBOX);
680 break;
681 }
682 case LCD_COMP_TEXT:
683 if (IS_MODE(mode, MD_DELETE | MD_DELETE_FAST))
684 {
685 // If we're deleting in fast mode, we don't delete char by char, but we simply paint
686 // the whole text's bounding box (i.e. a rectangle) with the background color. Faster?
687 LCD_BBox bbox;
688 if (!(res = process_text(comp->object.text, comp->pos, &bbox, MD_BBOX)))
689 break;
690
691 res = process_rect(
692 &(LCD_Rect){
693 .width = abs(bbox.top_left.x - bbox.bottom_right.x),
694 .height = abs(bbox.top_left.y - bbox.bottom_right.y),
695 },
696 comp->pos, NULL, MD_DELETE);
697 break;
698 }
699 else
700 res = process_text(comp->object.text, comp->pos, &comp->cached_bbox, mode);
701 break;
702 case LCD_COMP_BUTTON: {
703 if (IS_MODE(mode, MD_DELETE))
704 res = delete_button(comp->object.button, comp->pos);
705 else
706 res = process_button(comp->object.button, comp->pos, &comp->cached_bbox, mode);
707 break;
708 }
709 }
710 }
711
712 if (!res)
713 return false;
714
715 // If we need to calculate the bounding box of the object, we need to calculate the union of all
716 // the bounding boxes of the components. This is needed to determine the actual dimensions of the
717 // object, so that the caller can use them to position it correctly.
718 if (out_bbox && IS_MODE(mode, MD_BBOX | MD_DRAW_BBOX))
719 *out_bbox = get_union_bbox(obj->comps, obj->comps_size);
720
721 return true;
722}
_PRIVATE bool process_rect(const LCD_Rect *const rect, LCD_Coordinate pos, LCD_BBox *out_bbox, u8 mode)
_DECL_EXTERNALLY LCD_Color LCDCurrentBGColor
_PRIVATE bool process_text(const LCD_Text *const text, LCD_Coordinate pos, LCD_BBox *out_bbox, u8 mode)
Prints the string onto the screen, or calculates its dimensions without the overhead of printing.
_PRIVATE bool delete_button(const LCD_Button *const button, LCD_Coordinate pos)
_PRIVATE LCD_BBox get_union_bbox(LCD_Component *comps, u16 comps_sz)
_PRIVATE bool process_button(const LCD_Button *const button, LCD_Coordinate pos, LCD_BBox *out_bbox, u8 mode)
#define IS_MODE(mode, flag)
_PRIVATE bool process_img_rle(const LCD_Image *const img, LCD_Coordinate pos, LCD_BBox *out_bbox, u8 mode)
_PRIVATE bool process_line(const LCD_Line *const line, LCD_BBox *out_bbox, u8 mode)
_PRIVATE bool process_circle(const LCD_Circle *const circle, LCD_BBox *out_bbox, u8 mode)
@ LCD_COMP_RECT
Definition glcd_types.h:159
@ LCD_COMP_BUTTON
Definition glcd_types.h:163
@ LCD_COMP_IMAGE
Definition glcd_types.h:161
@ LCD_COMP_CIRCLE
Definition glcd_types.h:160
@ LCD_COMP_TEXT
Definition glcd_types.h:162
@ LCD_COMP_LINE
Definition glcd_types.h:158
LCD_Coordinate top_left
Definition glcd_types.h:62
LCD_Coordinate bottom_right
Definition glcd_types.h:62
Used to store a drawable component of any type.
Definition glcd_types.h:168
LCD_Circle * circle
Definition glcd_types.h:175
LCD_Coordinate pos
Definition glcd_types.h:170
LCD_Text * text
Definition glcd_types.h:177
LCD_Button * button
Definition glcd_types.h:178
LCD_Line * line
Definition glcd_types.h:173
LCD_ComponentType type
Definition glcd_types.h:169
LCD_Rect * rect
Definition glcd_types.h:174
union LCD_Component::@0 object
LCD_Image * image
Definition glcd_types.h:176
LCD_BBox cached_bbox
Definition glcd_types.h:171
u8 comps_size
Definition glcd_types.h:192
LCD_Component * comps
Definition glcd_types.h:191
uint16_t u16
Definition types.h:7