Microchip® Advanced Software Framework

win.c File Reference

Graphical Window system.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <stdint.h>
#include <stdlib.h>
#include <win.h>
#include <membag.h>
#include "conf_win.h"

Data Structures

struct  win_event_queue
 Event queue control struct. More...
 
struct  win_window
 Window control data. More...
 

Functions

bool win_compute_clipping (const struct win_window *win, const struct win_area *dirty_area, struct win_clip_region *clip)
 Compute clipping region in absolute coords from window and dirty area. More...
 
bool win_compute_intersection (struct win_clip_region *clip, const struct win_area *area)
 Compute the intersection of clipping region and area. More...
 
void win_compute_union (struct win_area *area, const struct win_area *merge)
 Compute the smallest square containing two areas. More...
 
struct win_windowwin_create (struct win_window *parent, const struct win_attributes *attributes)
 Create a window and return its pointer. More...
 
void win_destroy (struct win_window *win)
 Destroy a window, its contents and children to free up memory. More...
 
struct win_areawin_get_area (const struct win_window *win)
 Get a pointer to the window area struct. More...
 
struct win_attributeswin_get_attributes (const struct win_window *win)
 Get a pointer to the window attribute struct. More...
 
void * win_get_custom_data (const struct win_window *win)
 Get window custom data. More...
 
struct win_windowwin_get_parent (const struct win_window *win)
 Get pointer to parent window, or NULL for root window. More...
 
struct win_windowwin_get_root (void)
 Get pointer to root window, i.e. More...
 
void win_grab_pointer (struct win_window *win)
 Set pointer focus window or NULL, i.e. More...
 
void win_hide (struct win_window *win)
 Hide window, clear it from screen if it was visible. More...
 
void win_inflate_area (struct win_area *area, int16_t size)
 Expands a given area in all directions by a given amount. More...
 
void win_init (void)
 Initialize window system, set up root window, hook into touch driver. More...
 
bool win_is_inside_area (const struct win_area *area, const struct win_point *point)
 Check if point is inside area. More...
 
bool win_is_inside_clip (const struct win_clip_region *clip, const struct win_point *point)
 Check if point is inside clipping region. More...
 
bool win_is_inside_window (const struct win_window *win, const struct win_point *point)
 Check if global point is inside window. More...
 
void win_lower (struct win_window *win)
 Lower window to bottom of all its siblings. More...
 
static void win_process_command_event (struct win_command_event *cevent)
 Process a command event. More...
 
void win_process_events (void)
 Process all pending events from the internal queue. More...
 
static void win_process_keyboard_event (struct win_keyboard_event *kevent)
 Process a keyboard event. More...
 
void win_queue_command_event (const struct win_command_event *event)
 Add a command event to the internal event queue. More...
 
void win_queue_keyboard_event (const struct win_keyboard_event *event)
 Add a keyboard event to the internal event queue. More...
 
void win_queue_pointer_event (const struct win_pointer_event *event)
 Add a pointer event to the internal event queue. More...
 
void win_raise (struct win_window *win)
 Raise window to top of all its siblings. More...
 
void win_redraw (struct win_window *win)
 Redraw window and its contents, if visible. More...
 
void win_reparent (struct win_window *child, struct win_window *new_parent)
 Change a window's parent. More...
 
void win_reset_root_geometry (void)
 Reset root window geometry to fullscreen. More...
 
void win_set_area (struct win_window *win, const struct win_area *new_area, win_attribute_mask_t attribute_mask)
 Update window position and/or size. More...
 
void win_set_attributes (struct win_window *win, const struct win_attributes *new_attributes, win_attribute_mask_t attribute_mask)
 Update window attributes specified in attribute mask. More...
 
void win_set_keyboard_focus (struct win_window *win)
 Set keyboard focus window or NULL, i.e., receiver of keyboard events. More...
 
void win_show (struct win_window *win)
 Show window, draw it to screen if parent is visible. More...
 
void win_translate_win_to_root (struct win_window const *start_win, struct win_point *return_pos)
 Compute window position on root window. More...
 
Internal functions
Note
Due to circular references, these functions need private prototypes.
static bool win_is_visible (const struct win_window *win)
 Check if window and all parents, grand parents, etc. More...
 
static void win_draw (struct win_window *win, const struct win_area *dirty_area)
 Draw window, all its siblings and parents within dirty area. More...
 
static void win_draw_parent (struct win_window *child, const struct win_area *dirty_area)
 Draw parent window, with all child windows, within dirty area. More...
 
static void win_draw_contents (struct win_window *win, const struct win_clip_region *clip)
 Draw window background and contents, including children, within clip. More...
 
static void win_draw_child (struct win_window *child, const struct win_clip_region *parent_clip)
 Draw child window, with automatic translation of parent's clip region. More...
 
static bool win_translate_area_to_parent (struct win_area *area, const struct win_window *parent)
 Translate an area to coordinates relative to parent's origin. More...
 
static void win_destroy_children (struct win_window *win)
 Destroy child windows, freeing allocated memory. More...
 
static void win_unlink (struct win_window *win)
 Remove window from parent's linked list. More...
 
static void win_add_top_child (struct win_window *parent, struct win_window *child)
 Add window as first child in parent's linked list. More...
 
static void win_process_pointer_event (struct win_pointer_event *event)
 Helper function for processing pointer events. More...
 
static bool win_handle_pointer_event (struct win_window *win, const struct win_pointer_event *event, const struct win_point *pos)
 Handle pointer event in the window at the pointer coordinates. More...
 
static bool win_handle_event (struct win_window *win, enum win_event_type type, const void *data)
 Call window's event handler, if one is set. More...
 
static void win_queue_event (const struct win_event *event)
 Add an event to the internal queue. More...
 
static void win_pop_front_event (void)
 Remove front event from internal queue. More...
 
static bool win_are_events_pending (void)
 Check if internal queue has pending events. More...
 

Variables

Internal variables
static struct win_window win_root
 Root window, i.e. More...
 
static struct win_event win_event_queue_buffer [WIN_EVENT_QUEUE_SIZE]
 Event queue data buffer. More...
 
static struct win_event_queue win_event_queue
 Window event queue. More...
 
static uint32_t win_num_dropped_events
 Diagnostic value counting number of dropped events due to event queue full. More...
 
static struct win_windowwin_pointer_grabber
 Current pointer grabbing window, or NULL. More...
 
static struct win_windowwin_keyboard_focus
 Current keyboard focus, or NULL. More...
 
static struct win_point win_last_pointer_pos
 Stores last pointer event position, in absolute coordinates. More...
 
static struct gfx_bitmap win_root_background
 Frame background bitmap. More...