The desktop application handles launching of additional applications. More...
|
Data Structures | |
| struct | app_desktop |
| Desktop context. More... | |
| struct | app_config |
| Application metadata. More... | |
Defines | |
| #define | DESKTOP_REGISTER_APP(icon, text, start_task) { .icon_name = icon, .icon_text=text,.task=start_task } |
| Convenience macro for registering applications. | |
Functions | |
| static void | app_desktop_enable (void) |
| Enable desktop. | |
| static void | app_desktop_disable (void) |
| Disable desktop. | |
| static bool | app_desktop_is_enabled (void) |
| Check if desktop is enabled. | |
| void | app_desktop_restart (void) |
| Restart desktop. | |
| static void | get_icon_pos (uint8_t iconnum, gfx_coord_t *x, gfx_coord_t *y) |
| Helper function to get icon position. | |
| static void | draw_icon_text (const char text[], gfx_coord_t center_x, gfx_coord_t center_y) |
| Helper function for drawing icon text. | |
| static bool | app_desktop_handler (struct win_window *win, enum win_event_type type, void const *data) |
| Event handler for desktop window. | |
| static void | load_desktop (struct workqueue_task *task) |
| Load desktop. | |
| void | app_desktop_setup (void) |
| Setup desktop. | |
Variables | |
| static struct app_desktop | the_app_desktop |
| Statically allocated desktop context. | |
| struct app_config | apps [DESKTOP_APP_COUNT] |
| Desktop application menu items. | |
Application menu configuration | |
|
| |
| #define | DESKTOP_NUM_APPS_PER_COLUMN 4 |
| Number of apps per column. | |
| #define | DESKTOP_NUM_APPS_PER_ROW 3 |
| Number of apps per row. | |
| #define | DESKTOP_APP_COUNT |
| Total number of apps. | |
Color scheme | |
|
| |
| #define | DESKTOP_BACKGROUND_COLOR GFX_COLOR(0, 0, 0) |
| Desktop background color. | |
| #define | DESKTOP_ICON_TEXT_COLOR GFX_COLOR(255, 255, 255) |
| Text color for icons. | |
| #define | DESKTOP_POPUP_BORDER_COLOR GFX_COLOR(255, 42, 42) |
| Desktop pop-up border color. | |
Icon configuration | |
|
| |
| #define | DESKTOP_ICON_NAME_SIZE 9 |
| Size of string for icon name. | |
| #define | DESKTOP_ICON_TEXT_SIZE 11 |
| Size of string for text below each icon. | |
| #define | DESKTOP_ICON_SPACING_X 80 |
| Size of application launch icon and text. | |
| #define | DESKTOP_ICON_SPACING_Y 80 |
| Size of application launch icon and text. | |
| #define | DESKTOP_ICON_POS_X 11 |
| X position of icon. | |
| #define | DESKTOP_ICON_POS_Y 7 |
| Y position of icon. | |
| #define | DESKTOP_ICON_SIZE_X 57 |
| Width of icon. | |
| #define | DESKTOP_ICON_SIZE_Y 57 |
| Height of icon. | |
| #define | DESKTOP_ICON_TEXT_X (DESKTOP_ICON_SPACING_X / 2) |
| Position for text describing each icon. | |
| #define | DESKTOP_ICON_TEXT_Y |
| Position for text describing each icon. | |
Pop-up size and position configuration | |
|
| |
| #define | DESKTOP_POPUP_PADDING 20 |
| Position from display edge to start of pop-up box. | |
| #define | DESKTOP_POPUP_HEIGHT (gfx_font_get_height(&sysfont) * 5) |
| Height of pop-up box. | |
| #define | DESKTOP_POPUP_WIDTH |
| Width of pop-up box. | |
| #define | DESKTOP_POPUP_POS_X DESKTOP_POPUP_PADDING |
| X position of pop-up box. | |
| #define | DESKTOP_POPUP_POS_Y |
| Y position of pop-up box. | |
Default exit-button appearance | |
|
| |
| #define | APP_EXIT_BUTTON_SIZE_X 40 |
| Common application exit button size. | |
| #define | APP_EXIT_BUTTON_SIZE_Y 40 |
| Common application exit button size. | |
| #define | APP_EXIT_BUTTON_POS_X (gfx_get_width() - APP_EXIT_BUTTON_SIZE_X) |
| Common application exit button position. | |
| #define | APP_EXIT_BUTTON_POS_Y (gfx_get_height() - APP_EXIT_BUTTON_SIZE_Y) |
| Common application exit button position. | |
| #define | APP_EXIT_BUTTON_TEXT "X" |
| Common application exit button text. | |
The desktop application handles launching of additional applications.
Icons and names for the individual applications which have been registered are displayed as an on-screen menu. The user can launch the applications with pointer presses on their respective icons.
The desktop is implemented on the root window, without any additional windows on top, to ensure minimal memory usage and event handling when applications are launched.
| #define APP_EXIT_BUTTON_POS_X (gfx_get_width() - APP_EXIT_BUTTON_SIZE_X) |
Common application exit button position.
Definition at line 74 of file app_desktop.h.
Referenced by app_memgame_launch(), and app_tank_launch().
| #define APP_EXIT_BUTTON_POS_Y (gfx_get_height() - APP_EXIT_BUTTON_SIZE_Y) |
Common application exit button position.
Definition at line 76 of file app_desktop.h.
Referenced by app_memgame_launch(), and app_tank_launch().
| #define APP_EXIT_BUTTON_SIZE_X 40 |
Common application exit button size.
Definition at line 70 of file app_desktop.h.
Referenced by app_memgame_launch(), and app_tank_launch().
| #define APP_EXIT_BUTTON_SIZE_Y 40 |
Common application exit button size.
Definition at line 72 of file app_desktop.h.
Referenced by app_memgame_launch(), and app_tank_launch().
| #define APP_EXIT_BUTTON_TEXT "X" |
Common application exit button text.
Definition at line 78 of file app_desktop.h.
Referenced by app_memgame_launch(), and app_tank_launch().
| #define DESKTOP_APP_COUNT |
Total number of apps.
Definition at line 83 of file app_desktop.c.
Referenced by app_desktop_handler().
| #define DESKTOP_BACKGROUND_COLOR GFX_COLOR(0, 0, 0) |
Desktop background color.
Definition at line 95 of file app_desktop.c.
Referenced by app_desktop_handler(), and load_desktop().
| #define DESKTOP_ICON_NAME_SIZE 9 |
Size of string for icon name.
Definition at line 110 of file app_desktop.c.
| #define DESKTOP_ICON_POS_X 11 |
| #define DESKTOP_ICON_POS_Y 7 |
| #define DESKTOP_ICON_SIZE_X 57 |
| #define DESKTOP_ICON_SIZE_Y 57 |
| #define DESKTOP_ICON_SPACING_X 80 |
Size of application launch icon and text.
Definition at line 114 of file app_desktop.c.
Referenced by app_desktop_handler(), and get_icon_pos().
| #define DESKTOP_ICON_SPACING_Y 80 |
Size of application launch icon and text.
Definition at line 116 of file app_desktop.c.
Referenced by app_desktop_handler(), and get_icon_pos().
| #define DESKTOP_ICON_TEXT_COLOR GFX_COLOR(255, 255, 255) |
Text color for icons.
Definition at line 97 of file app_desktop.c.
Referenced by app_desktop_handler(), and draw_icon_text().
| #define DESKTOP_ICON_TEXT_SIZE 11 |
Size of string for text below each icon.
Definition at line 112 of file app_desktop.c.
| #define DESKTOP_ICON_TEXT_X (DESKTOP_ICON_SPACING_X / 2) |
Position for text describing each icon.
Definition at line 126 of file app_desktop.c.
Referenced by load_desktop().
| #define DESKTOP_ICON_TEXT_Y |
((DESKTOP_ICON_POS_Y + \ DESKTOP_ICON_SIZE_Y + DESKTOP_ICON_SPACING_Y) / 2)
Position for text describing each icon.
Definition at line 128 of file app_desktop.c.
Referenced by load_desktop().
| #define DESKTOP_NUM_APPS_PER_COLUMN 4 |
Number of apps per column.
Definition at line 79 of file app_desktop.c.
Referenced by app_desktop_handler(), and get_icon_pos().
| #define DESKTOP_NUM_APPS_PER_ROW 3 |
Number of apps per row.
Definition at line 81 of file app_desktop.c.
| #define DESKTOP_POPUP_BORDER_COLOR GFX_COLOR(255, 42, 42) |
Desktop pop-up border color.
Definition at line 99 of file app_desktop.c.
| #define DESKTOP_POPUP_HEIGHT (gfx_font_get_height(&sysfont) * 5) |
Height of pop-up box.
Definition at line 142 of file app_desktop.c.
| #define DESKTOP_POPUP_PADDING 20 |
Position from display edge to start of pop-up box.
Definition at line 140 of file app_desktop.c.
| #define DESKTOP_POPUP_POS_X DESKTOP_POPUP_PADDING |
X position of pop-up box.
Definition at line 147 of file app_desktop.c.
| #define DESKTOP_POPUP_POS_Y |
((gfx_get_height() / 2) - \ (DESKTOP_POPUP_HEIGHT / 2))
Y position of pop-up box.
Definition at line 149 of file app_desktop.c.
| #define DESKTOP_POPUP_WIDTH |
(gfx_get_width() - 2 * \ DESKTOP_POPUP_PADDING)
Width of pop-up box.
Definition at line 144 of file app_desktop.c.
| #define DESKTOP_REGISTER_APP | ( | icon, | |||
| text, | |||||
| start_task | ) | { .icon_name = icon, .icon_text=text,.task=start_task } |
Convenience macro for registering applications.
Definition at line 155 of file app_desktop.c.
| static void app_desktop_disable | ( | void | ) | [static] |
Disable desktop.
This function disables the event handling in the desktop window to ensure that the desktop does not slow down another running application.
Definition at line 239 of file app_desktop.c.
References app_desktop::desktop_enabled, and the_app_desktop.
Referenced by app_desktop_handler(), and load_desktop().
| static void app_desktop_enable | ( | void | ) | [static] |
Enable desktop.
This function enables the event handling in the desktop window.
Definition at line 228 of file app_desktop.c.
References app_desktop::desktop_enabled, and the_app_desktop.
Referenced by load_desktop().
| static bool app_desktop_handler | ( | struct win_window * | win, | |
| enum win_event_type | type, | |||
| void const * | data | |||
| ) | [static] |
Event handler for desktop window.
Handles all events received by the desktop application window. Only pointer events require handling in this application: These are used to select and launch applications if the desktop is enabled.
| win | Pointer to window receiving the event | |
| type | Indicates type of event | |
| data | Event type-specific data |
Definition at line 345 of file app_desktop.c.
References app_desktop_disable(), app_desktop_is_enabled(), app_desktop::application_launcher_task, dbg_error, DESKTOP_APP_COUNT, DESKTOP_BACKGROUND_COLOR, DESKTOP_ICON_SPACING_X, DESKTOP_ICON_SPACING_Y, DESKTOP_ICON_TEXT_COLOR, DESKTOP_NUM_APPS_PER_COLUMN, gfx_draw_rect, main_workqueue, app_config::task, the_app_desktop, WIN_EVENT_POINTER, WIN_POINTER_PRESS, WIN_POINTER_RELEASE, workqueue_add_task(), and workqueue_task_set_work_func().
| static bool app_desktop_is_enabled | ( | void | ) | [static] |
Check if desktop is enabled.
Definition at line 249 of file app_desktop.c.
References app_desktop::desktop_enabled, and the_app_desktop.
Referenced by app_desktop_handler().
| void app_desktop_restart | ( | void | ) |
Restart desktop.
Restarts the desktop when an application has finished execution by scheduling a task to the main_workqueue to start loading the desktop with load_desktop.
Launched applications must call this before exiting for the desktop to reappear.
Referenced by app_clock_frame_command_handler(), app_files_frame_command_handler(), app_fonts_frame_command_handler(), app_fonts_load_worker(), app_memgame_launch(), app_tank_launch(), calc_frame_command_handler(), memgame_draw_piece(), memgame_handle_command_event(), slide_launch_helper(), slide_window_handler(), tank_frame_handler(), tank_loader(), and widget_frame_command_handler().
| void app_desktop_setup | ( | void | ) |
Setup desktop.
Allocates the desktop application window and initializes the workqueue tasks.
This function should be called from the main function to set up the desktop for first use.
If CONFIG_FS_TSFS is defined, the File loader utility is initialized to prepare for loading of application icons.
If CONFIG_WIN_USE_TOUCH is defined, this function will enqueue the touch calibration on the main workqueue. When calibration is finished, or if touch is not enabled, it will schedule a task with load_desktop for loading the desktop.
| static void draw_icon_text | ( | const char | text[], | |
| gfx_coord_t | center_x, | |||
| gfx_coord_t | center_y | |||
| ) | [static] |
Helper function for drawing icon text.
Draws text that is centered on the specified coordinates regardless of the length of the string.
| text | The string to draw | |
| center_x | Center X coordinate of string | |
| center_y | Center Y coordinate of string |
Definition at line 296 of file app_desktop.c.
References DESKTOP_ICON_TEXT_COLOR, GFX_COLOR_TRANSPARENT, gfx_draw_string(), gfx_get_string_bounding_box(), and sysfont.
Referenced by load_desktop().
| static void get_icon_pos | ( | uint8_t | iconnum, | |
| gfx_coord_t * | x, | |||
| gfx_coord_t * | y | |||
| ) | [static] |
Helper function to get icon position.
Returns the X and Y coordinates of a specific icon.
| iconnum | Icon number of which to find position |
| x | Returned X coordinate of icon | |
| y | Returned Y coordinate of icon |
Definition at line 280 of file app_desktop.c.
References DESKTOP_ICON_SPACING_X, DESKTOP_ICON_SPACING_Y, and DESKTOP_NUM_APPS_PER_COLUMN.
Referenced by load_desktop().
| static void load_desktop | ( | struct workqueue_task * | task | ) | [static] |
Load desktop.
This task worker function draws the desktop. It is scheduled at startup with the app_desktop_setup function, and by exiting applications with app_desktop_restart.
The function loops through all the registered applications in apps and draws their respective icon text before drawing a shaded rectangle in place of its icon.
Definition at line 519 of file app_desktop.c.
References app_desktop_disable(), app_desktop_enable(), ARRAY_LEN, DESKTOP_BACKGROUND_COLOR, DESKTOP_ICON_POS_X, DESKTOP_ICON_POS_Y, DESKTOP_ICON_SIZE_X, DESKTOP_ICON_SIZE_Y, DESKTOP_ICON_TEXT_X, DESKTOP_ICON_TEXT_Y, draw_icon_text(), get_icon_pos(), gfx_color(), gfx_draw_filled_rect, gfx_get_height(), gfx_get_width(), gfx_set_clipping(), strlen(), win_get_root(), and win_redraw().
| struct app_config apps[DESKTOP_APP_COUNT] |
{
DESKTOP_REGISTER_APP("i_calc", "Calc", app_calc_launch),
DESKTOP_REGISTER_APP("i_sett", "Widget", app_widget_launch),
DESKTOP_REGISTER_APP("i_clock", "Clock", app_clock_launch),
DESKTOP_REGISTER_APP("", "", NULL),
DESKTOP_REGISTER_APP("", "", NULL),
DESKTOP_REGISTER_APP("", "", NULL),
DESKTOP_REGISTER_APP("", "", NULL),
DESKTOP_REGISTER_APP("", "", NULL),
DESKTOP_REGISTER_APP("", "", NULL),
DESKTOP_REGISTER_APP("", "", NULL),
DESKTOP_REGISTER_APP("", "", NULL),
}
Desktop application menu items.
This array contains the data for all the applications to be shown on the desktop. They will be listed in the order that they are registered here.
Definition at line 194 of file app_desktop.c.
struct app_desktop the_app_desktop [static] |
Statically allocated desktop context.
Definition at line 169 of file app_desktop.c.
Referenced by app_desktop_disable(), app_desktop_enable(), app_desktop_handler(), and app_desktop_is_enabled().
1.6.3