-
Notifications
You must be signed in to change notification settings - Fork 1
User Interface
The widgets used in the UI, as buttons, texts, checkboxes, input fields, etc. are to be found at /firmware/common/ui_widget.cpp
MOST menues (excluding the OPTIONS and DEBUG menues, which are actually apps) and pop-up boxes (yes/no, yes/cancel, ok) are defined in /firmware/application/ui_navigation.cpp
The Options menu is actually an "app" defined at /firmware/application/apps/ui_settings.cpp
The Debug menu is defined at /firmware/application/apps/ui_debug.cpp
You can readily inspect the creation of each menu through the add_items() function, setting number of columns, etc. You will learn that menus are created as an instancing of BtGridView class.
On a side-note, I found a touchscreen sensitivity threshold parameter, which also may be of serious use, in the event of a low quality chinese touchscreen... see inside /firmware/application/touch.hpp
Line 215.
The BtnGridView class in charge of generating and processing the buttons based menu is Located at /firmware/application/ui/ui_btngrid.cpp
. It expects a list of menu_items. As a reference, each Menu item defined as:
struct GridItem {
std::string text;
ui::Color color;
const Bitmap* bitmap;
std::function<void(void)> on_select;
};
The BtnGridView Class exposes:
- The
add_items();
accepting a menu items list of grid Items. - The number of columns used on the grid with
set_max_rows(int rows)
(default: 3) - A default highlighted button with
set_highlighted(int_32_t new_value)
- Returns the number of rows you set with above
int rows();
- Can clear the whole list with
void clear();
INTERESTING NOTE: The button grid can paginate: It will show pagination arrows at a the bottom of the screen, if there are more buttons than the space available.
Each menu button is instanced from NewButton object (defined in ui_widget.cpp).
Input Widgets (and NewButton) can be navigated through either cursor keys, wheel jog, and touch events.