2021-03-12 16:19:43 +01:00
|
|
|
//---
|
|
|
|
// JustUI.jfkeys: Row of function keys
|
|
|
|
//---
|
|
|
|
|
|
|
|
#ifndef _J_JFKEYS
|
|
|
|
#define _J_JFKEYS
|
|
|
|
|
|
|
|
#include <justui/defs.h>
|
|
|
|
#include <justui/jwidget.h>
|
|
|
|
|
|
|
|
#include <gint/display.h>
|
2024-03-24 11:05:10 +01:00
|
|
|
#include <gint/config.h>
|
2021-03-12 16:19:43 +01:00
|
|
|
|
|
|
|
/* jfkeys: Functions keys indicating functions for the F1..F6 keys
|
|
|
|
|
|
|
|
This widget is the typical function key bar with a slightly different
|
|
|
|
design. There are four types of keys, with conventional guidelines:
|
|
|
|
|
|
|
|
* MENU KEYS are used for functions that open menus or navigate between tabs
|
|
|
|
on a same application. The name comes from their primary usage in the
|
2021-05-12 15:24:12 +02:00
|
|
|
system apps. Navigation functions should be easily reversible and fairly
|
2021-03-12 16:19:43 +01:00
|
|
|
failproof. Menu keys are black rectangular keys with a chipped corner.
|
|
|
|
|
|
|
|
* ENTRY KEYS are used for catalog entries such as the leaves of PRGM's many
|
|
|
|
nested input menus. They represent entries to be chosen from. Entry keys
|
|
|
|
are black rectangular keys.
|
|
|
|
|
|
|
|
* ACTION KEYS are used for generic safe and unsafe actions. Action keys are
|
|
|
|
black round keys.
|
|
|
|
|
|
|
|
* SPECIAL KEYS are used for special functions, such as scrolling to the next
|
|
|
|
set of functions keys when there are several pages, important functions
|
2021-05-12 15:24:12 +02:00
|
|
|
that should catch attention, or particularly unsafe actions. They are
|
|
|
|
round white keys.
|
2021-03-12 16:19:43 +01:00
|
|
|
|
2024-03-24 11:05:10 +01:00
|
|
|
The more flexible option to draw the keys is dynamically with text. In that
|
|
|
|
case each key are specified with a strings that combines a type and name:
|
2021-03-12 16:19:43 +01:00
|
|
|
|
|
|
|
* "/NAME" for a menu key;
|
|
|
|
* ".NAME" for an entry key;
|
|
|
|
* "@NAME" for an action key;
|
|
|
|
" "#NAME" for a special key.
|
|
|
|
|
2021-05-12 15:24:12 +02:00
|
|
|
The names are separated by semicolons, eg. "/F1;;/F3;.F4;@F5;#F6". Several
|
2021-03-12 16:19:43 +01:00
|
|
|
sets of function keys can be defined if separated by a '|' character. For
|
|
|
|
instance, "/F1;#F2|/F1" represents a function bar where the F2
|
2021-05-12 15:24:12 +02:00
|
|
|
function can be hidden by switching from level 0 to level 1.
|
2021-03-12 16:19:43 +01:00
|
|
|
|
2024-03-24 11:05:10 +01:00
|
|
|
The other option is to draw the keys with an image. This is most useful at
|
|
|
|
small resolutions where hand-drawn keys often look better. On the fx-9860G
|
|
|
|
with its 128x64 resolution, the convention is that the image is 128x8, and
|
|
|
|
key #i is positioned at x = 21i+2 with width 19. The equivalent of "|"-
|
|
|
|
separated levels is allowed by stacking up rows of keys (in which case the
|
|
|
|
image is of height 9n-1 for n rows). */
|
2021-03-12 16:19:43 +01:00
|
|
|
typedef struct {
|
|
|
|
jwidget widget;
|
|
|
|
int8_t level;
|
|
|
|
|
2024-03-24 11:05:10 +01:00
|
|
|
/* Image version; if specified this overrides all text parameters */
|
|
|
|
|
2021-03-12 16:19:43 +01:00
|
|
|
bopti_image_t const *img;
|
|
|
|
|
2024-03-24 11:05:10 +01:00
|
|
|
/* Text version */
|
|
|
|
|
2021-03-12 16:19:43 +01:00
|
|
|
char const *labels;
|
2022-06-21 10:19:10 +02:00
|
|
|
char const *overrides[6];
|
2022-08-29 14:49:15 +02:00
|
|
|
|
|
|
|
int bg_color, bg_special_color;
|
|
|
|
int text_color, text_special_color;
|
|
|
|
|
|
|
|
font_t const *font;
|
2021-03-12 16:19:43 +01:00
|
|
|
|
|
|
|
} jfkeys;
|
|
|
|
|
2024-03-24 11:05:10 +01:00
|
|
|
/* jfkeys_create2(): Create a set of function keys
|
2021-03-12 16:19:43 +01:00
|
|
|
|
2024-03-24 11:05:10 +01:00
|
|
|
Both the image and text specification are provided; one of them should
|
|
|
|
generally be NULL (if both are non-NULL, the image takes precedence). For
|
|
|
|
historical reasons the name fkeys_create() is a one-argument version with
|
|
|
|
either the text or image depending on the platform. */
|
|
|
|
jfkeys *jfkeys_create2(
|
|
|
|
bopti_image_t const *img, char const *labels, void *parent);
|
2021-03-12 16:19:43 +01:00
|
|
|
|
2024-03-24 11:05:10 +01:00
|
|
|
/* jfkeys_set2(): Replace the definition of function keys
|
2021-03-12 16:19:43 +01:00
|
|
|
This will also reset the level to 0. */
|
2024-03-24 11:05:10 +01:00
|
|
|
void jfkeys_set2(jfkeys *keys, bopti_image_t const *img, char const *labels);
|
|
|
|
|
|
|
|
/* Deprecated platform-specific shortcuts */
|
|
|
|
#if GINT_RENDER_MONO
|
|
|
|
# define jfkeys_create(img, parent) jfkeys_create2(img, NULL, parent)
|
|
|
|
# define jfkeys_set(keys, img) jfkeys_set2(keys, img, NULL)
|
|
|
|
#elif GINT_RENDER_RGB
|
|
|
|
# define jfkeys_create(labels, parent) jfkeys_create2(NULL, labels, parent)
|
|
|
|
# define jfkeys_set(keys, labels) jfkeys_set2(keys, NULL, labels)
|
2021-03-12 16:19:43 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* jfkeys_level(): Return the current function key level */
|
|
|
|
int jfkeys_level(jfkeys *keys);
|
|
|
|
|
|
|
|
/* jfkeys_set_level(): Set the function key level */
|
|
|
|
void jfkeys_set_level(jfkeys *keys, int level);
|
|
|
|
|
2021-05-23 11:56:11 +02:00
|
|
|
/* The following functions are available only on fx-CG 50 and are no-ops on
|
2022-08-29 14:49:15 +02:00
|
|
|
fx-9860G (you can't generate a good image for a tiny key). */
|
2021-05-23 11:56:11 +02:00
|
|
|
|
|
|
|
/* fkeys_override(): Get the override for a key */
|
|
|
|
char const *jfkeys_override(jfkeys *keys, int key);
|
|
|
|
|
2022-08-29 14:49:15 +02:00
|
|
|
/* jfkeys_set_override(): Override the value of a single key on all levels
|
2021-05-23 11:56:11 +02:00
|
|
|
This functions sets the override on the specified key, which replaces the
|
|
|
|
label for that key on all levels. This is useful to conditionally show
|
|
|
|
functions. */
|
|
|
|
void jfkeys_set_override(jfkeys *keys, int key, char const *override);
|
|
|
|
|
2022-08-29 14:49:15 +02:00
|
|
|
/* jfkeys_set_color(): Change the key and text colors
|
|
|
|
* bg is the background color for MENU, ENTRY and ACTION keys (default
|
|
|
|
C_BLACK), and the border color for SPECIAL keys.
|
|
|
|
* bg_special is the background color for SPECIAL keys (default C_WHITE).
|
|
|
|
* text is the text color for MENU, ENTRY and ACTION keys (default C_WHITE).
|
|
|
|
* text_special is the text color for SPECIAL keys (default C_BLACK). */
|
|
|
|
void jfkeys_set_color(jfkeys *keys, int bg, int bg_special, int text,
|
|
|
|
int text_special);
|
|
|
|
void jfkeys_set_font(jfkeys *keys, font_t const *font);
|
|
|
|
|
2021-03-12 16:19:43 +01:00
|
|
|
#endif /* _J_JFKEYS */
|