|
PatchworkOS
|
Drawable. More...
Data Structures | |
| struct | drawable_t |
| Drawable structure. More... | |
Enumerations | |
| enum | align_t { ALIGN_CENTER = 0 , ALIGN_MAX = 1 , ALIGN_MIN = 2 } |
| Alignment type. More... | |
| enum | direction_t { DIRECTION_VERTICAL , DIRECTION_HORIZONTAL , DIRECTION_DIAGONAL } |
| Direction type. More... | |
Functions | |
| void | draw_rect (drawable_t *draw, const rect_t *rect, pixel_t pixel) |
| Draw a filled rectangle. | |
| void | draw_polygon (drawable_t *draw, const point_t *points, uint64_t pointCount, pixel_t pixel) |
| Draw a filled polygon. | |
| void | draw_line (drawable_t *draw, const point_t *start, const point_t *end, pixel_t pixel, uint32_t thickness) |
| Draw a line between two points. | |
| void | draw_frame (drawable_t *draw, const rect_t *rect, uint64_t width, pixel_t foreground, pixel_t background) |
| Draw a skeuomorphic frame. | |
| void | draw_dashed_outline (drawable_t *draw, const rect_t *rect, pixel_t pixel, uint32_t length, int32_t width) |
| Draw a dashed outline just inside the given rectangle. | |
| void | draw_bezel (drawable_t *draw, const rect_t *rect, uint64_t width, pixel_t pixel) |
| Draw a filled border bezel just inside the given rectangle. | |
| void | draw_gradient (drawable_t *draw, const rect_t *rect, pixel_t start, pixel_t end, direction_t direction, bool shouldAddNoise) |
| Draw a gradient filled rectangle. | |
| void | draw_transfer (drawable_t *dest, drawable_t *src, const rect_t *destRect, const point_t *srcPoint) |
| Transfer pixels from one drawable to another. | |
| void | draw_transfer_blend (drawable_t *dest, drawable_t *src, const rect_t *destRect, const point_t *srcPoint) |
| Transfer pixels from one drawable to another with alpha blending. | |
| void | draw_image (drawable_t *draw, image_t *image, const rect_t *destRect, const point_t *srcPoint) |
| Draw an image,. | |
| void | draw_image_blend (drawable_t *draw, image_t *image, const rect_t *destRect, const point_t *srcPoint) |
| Draw an image with alpha blending. | |
| void | draw_string (drawable_t *draw, const font_t *font, const point_t *point, pixel_t pixel, const char *string, uint64_t length) |
| Draw a string. | |
| void | draw_text (drawable_t *draw, const rect_t *rect, const font_t *font, align_t xAlign, align_t yAlign, pixel_t pixel, const char *text) |
| Draw text to a drawable. | |
| void | draw_text_multiline (drawable_t *draw, const rect_t *rect, const font_t *font, align_t xAlign, align_t yAlign, pixel_t pixel, const char *text) |
| Draw multiline text to a drawable. | |
| void | draw_ridge (drawable_t *draw, const rect_t *rect, uint64_t width, pixel_t foreground, pixel_t background) |
| Draw a ridge effect. | |
| void | draw_separator (drawable_t *draw, const rect_t *rect, pixel_t highlight, pixel_t shadow, direction_t direction) |
| Draw a separator line. | |
| void | draw_invalidate (drawable_t *draw, const rect_t *rect) |
| Invalidate a rectangle in the drawable. | |
Drawable.
A drawable implements a generic system for drawing operations to a pixel buffer.
| enum align_t |
Alignment type.
| Enumerator | |
|---|---|
| ALIGN_CENTER | |
| ALIGN_MAX | |
| ALIGN_MIN | |
Definition at line 47 of file drawable.h.
| enum direction_t |
Direction type.
| Enumerator | |
|---|---|
| DIRECTION_VERTICAL | |
| DIRECTION_HORIZONTAL | |
| DIRECTION_DIAGONAL | |
Definition at line 58 of file drawable.h.
| void draw_bezel | ( | drawable_t * | draw, |
| const rect_t * | rect, | ||
| uint64_t | width, | ||
| pixel_t | pixel | ||
| ) |
Draw a filled border bezel just inside the given rectangle.
Will fit the rectangle to the drawable's content rectangle.
| draw | The drawable to draw to. |
| rect | The rectangle to draw the bezel around. |
| width | The width of the bezel. |
| pixel | The pixel color to draw with. |
Definition at line 339 of file drawable.c.
References rect_t::bottom, drawable_t::contentRect, draw_rect(), rect_t::left, NULL, RECT_FIT, rect_t::right, and rect_t::top.
Referenced by button_draw(), and field_edge_draw().
| void draw_dashed_outline | ( | drawable_t * | draw, |
| const rect_t * | rect, | ||
| pixel_t | pixel, | ||
| uint32_t | length, | ||
| int32_t | width | ||
| ) |
Draw a dashed outline just inside the given rectangle.
Will fit the rectangle to the drawable's content rectangle.
| draw | The drawable to draw to. |
| rect | The rectangle to draw the outline inside. |
| pixel | The pixel color to draw with. |
| length | The length of the dashes. |
| width | The width of the outline. |
Definition at line 259 of file drawable.c.
References rect_t::bottom, drawable_t::buffer, drawable_t::contentRect, draw_invalidate(), rect_t::left, NULL, RECT_FIT, RECT_HEIGHT, RECT_WIDTH, rect_t::right, drawable_t::stride, rect_t::top, x, and y.
Referenced by button_draw().
| void draw_frame | ( | drawable_t * | draw, |
| const rect_t * | rect, | ||
| uint64_t | width, | ||
| pixel_t | foreground, | ||
| pixel_t | background | ||
| ) |
Draw a skeuomorphic frame.
Will draw a frame with the given width, using the foreground color for the top and left sides, and the background color for the bottom and right sides.
Will fit the rectangle to the drawable's content rectangle.
| draw | The drawable to draw to. |
| rect | The rectangle to draw the frame around. |
| width | The width of the frame. |
| foreground | The pixel color for the top and left sides. |
| background | The pixel color for the bottom and right sides. |
Definition at line 204 of file drawable.c.
References rect_t::bottom, drawable_t::buffer, drawable_t::contentRect, draw_invalidate(), draw_rect(), rect_t::left, NULL, RECT_FIT, rect_t::right, drawable_t::stride, rect_t::top, x, and y.
Referenced by block_draw(), button_draw(), draw_ridge(), field_edge_draw(), label_procedure(), startmenu_procedure(), window_deco_draw_titlebar(), and window_deco_redraw().
| void draw_gradient | ( | drawable_t * | draw, |
| const rect_t * | rect, | ||
| pixel_t | start, | ||
| pixel_t | end, | ||
| direction_t | direction, | ||
| bool | shouldAddNoise | ||
| ) |
Draw a gradient filled rectangle.
Will fit the rectangle to the drawable's content rectangle.
| draw | The drawable to draw to. |
| rect | The rectangle to draw. |
| start | The starting pixel color. |
| end | The ending pixel color. |
| direction | The direction of the gradient. |
| shouldAddNoise | Whether to add noise to the gradient to reduce banding. |
Definition at line 382 of file drawable.c.
References rect_t::bottom, drawable_t::buffer, CLAMP, drawable_t::contentRect, DIRECTION_DIAGONAL, DIRECTION_HORIZONTAL, DIRECTION_VERTICAL, draw_invalidate(), rect_t::left, NULL, PIXEL_ARGB, PIXEL_BLUE, PIXEL_GREEN, PIXEL_RED, rand(), RECT_FIT, RECT_HEIGHT, RECT_WIDTH, rect_t::right, start(), drawable_t::stride, rect_t::top, x, and y.
Referenced by startmenu_procedure(), and window_deco_draw_titlebar().
| void draw_image | ( | drawable_t * | draw, |
| image_t * | image, | ||
| const rect_t * | destRect, | ||
| const point_t * | srcPoint | ||
| ) |
Draw an image,.
| draw | The drawable to draw to. |
| image | The image to draw. |
| destRect | The rectangle that will be filled in the drawable. |
| srcPoint | The top-left point in the image to copy from. |
Definition at line 545 of file drawable.c.
References draw_transfer(), image, and image_draw().
Referenced by procedure().
| void draw_image_blend | ( | drawable_t * | draw, |
| image_t * | image, | ||
| const rect_t * | destRect, | ||
| const point_t * | srcPoint | ||
| ) |
Draw an image with alpha blending.
| draw | The drawable to draw to. |
| image | The image to draw. |
| destRect | The rectangle that will be filled in the drawable. |
| srcPoint | The top-left point in the image to copy from. |
Definition at line 550 of file drawable.c.
References draw_transfer_blend(), image, and image_draw().
Referenced by button_draw().
| void draw_invalidate | ( | drawable_t * | draw, |
| const rect_t * | rect | ||
| ) |
Invalidate a rectangle in the drawable.
Marks the given rectangle as invalid, so that it will be updated on the next flush.
Flushing is handled by each element or other system using the drawable, not the drawable itself.
| draw | The drawable. |
| rect | The rectangle to invalidate, or NULL to invalidate the entire content rectangle. |
Definition at line 1062 of file drawable.c.
References drawable_t::contentRect, drawable_t::invalidRect, NULL, RECT_AREA, and RECT_EXPAND_TO_CONTAIN.
Referenced by draw_dashed_outline(), draw_frame(), draw_gradient(), draw_rect(), draw_separator(), draw_string(), draw_text_multiline(), draw_transfer(), and draw_transfer_blend().
| void draw_line | ( | drawable_t * | draw, |
| const point_t * | start, | ||
| const point_t * | end, | ||
| pixel_t | pixel, | ||
| uint32_t | thickness | ||
| ) |
Draw a line between two points.
Will clip the line to fit within the drawable's content rectangle.
| draw | The drawable to draw to. |
| start | The starting point of the line, inclusive. |
| end | The ending point of the line, inclusive. |
| pixel | The pixel color to draw with. |
| thickness | The thickness of the line, must be at least 1. |
Definition at line 179 of file drawable.c.
References atan2(), rect_t::bottom, CLAMP, drawable_t::contentRect, cos(), draw_polygon(), rect_t::left, M_PI_2, NULL, rect_t::right, sin(), start(), rect_t::top, point_t::x, and point_t::y.
| void draw_polygon | ( | drawable_t * | draw, |
| const point_t * | points, | ||
| uint64_t | pointCount, | ||
| pixel_t | pixel | ||
| ) |
Draw a filled polygon.
Will clip the polygon to fit within the drawable's content rectangle.
| draw | The drawable to draw to. |
| points | The points of the polygon. |
| pointCount | The number of points in the polygon, must be at least 3. |
| pixel | The pixel color to fill with. |
Definition at line 48 of file drawable.c.
References rect_t::bottom, drawable_t::buffer, drawable_t::contentRect, edge_compare(), INT64_MAX, INT64_MIN, edge_t::invSlope, rect_t::left, MAX, MIN, NULL, PIXEL_ALPHA, PIXEL_ARGB, PIXEL_BLEND, PIXEL_BLUE, PIXEL_GREEN, PIXEL_RED, polygon_contains(), qsort(), rect_t::right, drawable_t::stride, point_t::x, edge_t::x, x, point_t::y, y, edge_t::yMax, and edge_t::yMin.
Referenced by draw_hand(), draw_line(), and draw_marker().
| void draw_rect | ( | drawable_t * | draw, |
| const rect_t * | rect, | ||
| pixel_t | pixel | ||
| ) |
Draw a filled rectangle.
Will fit the rectangle to the drawable's content rectangle.
| draw | The drawable to draw to. |
| rect | The rectangle to draw. |
| pixel | The pixel color to fill with. |
Definition at line 7 of file drawable.c.
References rect_t::bottom, drawable_t::buffer, drawable_t::contentRect, draw_invalidate(), rect_t::left, memset32(), NULL, RECT_FIT, RECT_WIDTH, drawable_t::stride, rect_t::top, and y.
Referenced by block_draw(), button_draw(), draw_bezel(), draw_frame(), draw_separator(), label_procedure(), popup_procedure(), procedure(), start_press_space_draw(), startmenu_procedure(), taskbar_procedure(), terminal_char_draw(), terminal_clear(), terminal_scroll(), and window_deco_redraw().
| void draw_ridge | ( | drawable_t * | draw, |
| const rect_t * | rect, | ||
| uint64_t | width, | ||
| pixel_t | foreground, | ||
| pixel_t | background | ||
| ) |
Draw a ridge effect.
Will draw a inverted frame inside another frame inside the given rectangle, creating a ridge effect.
| draw | The drawable to draw to. |
| rect | The rectangle to draw the ridge effect within. |
| width | The total width of the ridge effect. |
| foreground | The pixel color for the top and left sides of the outer frame and the bottom and right sides of the inner frame. |
| background | The pixel color for the bottom and right sides of the outer frame and the top and left sides of the inner frame. |
Definition at line 994 of file drawable.c.
References draw_frame(), NULL, and RECT_SHRINK.
Referenced by side_panel_draw().
| void draw_separator | ( | drawable_t * | draw, |
| const rect_t * | rect, | ||
| pixel_t | highlight, | ||
| pixel_t | shadow, | ||
| direction_t | direction | ||
| ) |
Draw a separator line.
Will draw a separator line within the given rectangle, either horizontally or vertically.
| draw | The drawable to draw to. |
| rect | The rectangle to draw the separator within. |
| highlight | The pixel color for the highlight side of the separator (top or left). |
| shadow | The pixel color for the shadow side of the separator (bottom or right). |
| direction | The direction of the separator line. |
Definition at line 1008 of file drawable.c.
References rect_t::bottom, drawable_t::contentRect, DIRECTION_HORIZONTAL, DIRECTION_VERTICAL, draw_invalidate(), draw_rect(), rect_t::left, NULL, RECT_FIT, RECT_HEIGHT, RECT_WIDTH, rect_t::right, and rect_t::top.
Referenced by taskbar_procedure().
| void draw_string | ( | drawable_t * | draw, |
| const font_t * | font, | ||
| const point_t * | point, | ||
| pixel_t | pixel, | ||
| const char * | string, | ||
| uint64_t | length | ||
| ) |
Draw a string.
Will not draw a background, only the glyphs of the string.
| draw | The drawable to draw to. |
| font | The font to use. If NULL, the default font for the display will be used. |
| point | The top-left point to start drawing the string at. |
| pixel | The pixel color to draw with. |
| string | The string to draw, null-termination is ignored. |
| length | The length of the string to draw. |
Definition at line 591 of file drawable.c.
References grf_glyph_t::advanceX, grf_t::ascender, grf_t::buffer, grf_t::descender, drawable_t::disp, draw_grf_char(), draw_invalidate(), font_default(), font_kerning_offset(), font_width(), grf_t::glyphOffsets, font_t::grf, GRF_NONE, NULL, RECT_INIT_DIM, point_t::x, and point_t::y.
Referenced by draw_text(), draw_text_multiline(), and terminal_char_draw().
| void draw_text | ( | drawable_t * | draw, |
| const rect_t * | rect, | ||
| const font_t * | font, | ||
| align_t | xAlign, | ||
| align_t | yAlign, | ||
| pixel_t | pixel, | ||
| const char * | text | ||
| ) |
Draw text to a drawable.
Will clip the text to fit within the rectangle, adding an ellipsis (...) if the text is too long.
| draw | The drawable to draw to. |
| rect | The rectangle to draw the text within. |
| font | The font to use. If NULL, the default font for the display will be used. |
| xAlign | The horizontal alignment of the text within the rectangle. |
| yAlign | The vertical alignment of the text within the rectangle. |
| pixel | The pixel color to draw with. |
| text | The text to draw, null-terminated. |
Definition at line 669 of file drawable.c.
References ALIGN_CENTER, ALIGN_MAX, ALIGN_MIN, grf_t::ascender, grf_t::descender, drawable_t::disp, draw_calculate_aligned_text_pos(), draw_string(), font_default(), font_kerning_offset(), font_width(), font_t::grf, rect_t::left, MAX, NULL, RECT_HEIGHT, RECT_WIDTH, strlen(), rect_t::top, point_t::x, and point_t::y.
Referenced by button_draw(), label_procedure(), side_panel_draw(), start_press_space_draw(), start_tetris_draw(), and window_deco_draw_titlebar().
| void draw_text_multiline | ( | drawable_t * | draw, |
| const rect_t * | rect, | ||
| const font_t * | font, | ||
| align_t | xAlign, | ||
| align_t | yAlign, | ||
| pixel_t | pixel, | ||
| const char * | text | ||
| ) |
Draw multiline text to a drawable.
Will wrap lines to fit within the rectangle. Newlines (\n) are also supported.
| draw | The drawable to draw to. |
| rect | The rectangle to draw the text within. |
| font | The font to use. If NULL, the default font for the display will be used. |
| xAlign | The horizontal alignment of the text within the rectangle. |
| yAlign | The vertical alignment of the text within the rectangle. |
| pixel | The pixel color to draw with. |
| text | The text to draw, null-terminated. |
Definition at line 814 of file drawable.c.
References grf_glyph_t::advanceX, ALIGN_CENTER, ALIGN_MAX, ALIGN_MIN, grf_t::ascender, rect_t::bottom, grf_t::buffer, drawable_t::contentRect, grf_t::descender, drawable_t::disp, draw_invalidate(), draw_string(), font_default(), font_kerning_offset(), font_width(), grf_t::glyphOffsets, font_t::grf, GRF_NONE, rect_t::left, MAX, NULL, RECT_FIT, RECT_HEIGHT, RECT_WIDTH, rect_t::top, and point_t::x.
Referenced by popup_procedure().
| void draw_transfer | ( | drawable_t * | dest, |
| drawable_t * | src, | ||
| const rect_t * | destRect, | ||
| const point_t * | srcPoint | ||
| ) |
Transfer pixels from one drawable to another.
| dest | The destination drawable. |
| src | The source drawable. |
| destRect | The rectangle that will be filled in the destination. |
| srcPoint | The top-left point in the source drawable to copy from. |
Definition at line 462 of file drawable.c.
References drawable_t::buffer, drawable_t::contentRect, draw_invalidate(), rect_t::left, memcpy(), memmove(), NULL, RECT_HEIGHT, RECT_WIDTH, drawable_t::stride, rect_t::top, point_t::x, point_t::y, and y.
Referenced by draw_image(), and terminal_scroll().
| void draw_transfer_blend | ( | drawable_t * | dest, |
| drawable_t * | src, | ||
| const rect_t * | destRect, | ||
| const point_t * | srcPoint | ||
| ) |
Transfer pixels from one drawable to another with alpha blending.
| dest | The destination drawable. |
| src | The source drawable. |
| destRect | The rectangle that will be filled in the destination. |
| srcPoint | The top-left point in the source drawable to copy from. |
Definition at line 507 of file drawable.c.
References drawable_t::buffer, drawable_t::contentRect, draw_invalidate(), rect_t::left, NULL, PIXEL_BLEND, RECT_HEIGHT, RECT_WIDTH, drawable_t::stride, rect_t::top, point_t::x, x, point_t::y, and y.
Referenced by draw_image_blend().