implemented basic top bar
This commit is contained in:
parent
e0fc80ca64
commit
f6c547ad45
13
COPYRIGHT.md
Normal file
13
COPYRIGHT.md
Normal file
@ -0,0 +1,13 @@
|
||||
### Flipper Zero Firmware
|
||||
Website: https://github.com/flipperdevices/flipperzero-firmware/
|
||||
License: GPL v3.0
|
||||
https://github.com/flipperdevices/flipperzero-firmware/blob/dev/LICENSE
|
||||
|
||||
### Google Fonts
|
||||
Website: https://fonts.google.com/icons
|
||||
License: Apache License, version 2.0
|
||||
https://fonts.google.com/attribution
|
||||
|
||||
### Components
|
||||
See `/components` for the respective projects and their licenses.
|
||||
|
||||
@ -4,6 +4,7 @@ idf_component_register(
|
||||
"src/apps/services/desktop"
|
||||
"src/apps/services/loader"
|
||||
"src/apps/services/gui"
|
||||
"src/apps/services/gui/widgets"
|
||||
INCLUDE_DIRS "src"
|
||||
REQUIRES esp_lvgl_port esp_lcd esp_lcd_touch driver mlib cmsis_core furi nvs_flash spiffs fatfs
|
||||
)
|
||||
|
||||
BIN
components/nanobake/assets/wifi-off.png
Normal file
BIN
components/nanobake/assets/wifi-off.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 274 B |
BIN
components/nanobake/assets/wifi-on.png
Normal file
BIN
components/nanobake/assets/wifi-on.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 224 B |
@ -1,6 +1,7 @@
|
||||
#include "check.h"
|
||||
#include "gui_i.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
#include "apps/services/gui/widgets/widgets.h"
|
||||
|
||||
static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
||||
/*
|
||||
@ -151,15 +152,29 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
||||
}
|
||||
|
||||
static bool gui_redraw_window(Gui* gui) {
|
||||
/*
|
||||
canvas_frame_set(gui->lvgl_parent, GUI_WINDOW_X, GUI_WINDOW_Y, GUI_WINDOW_WIDTH, GUI_WINDOW_HEIGHT);
|
||||
ViewPort* view_port = gui_view_port_find_enabled(gui->layers[GuiLayerWindow]);
|
||||
if(view_port) {
|
||||
view_port_draw(view_port, gui->lvgl_parent);
|
||||
if (view_port) {
|
||||
lv_obj_set_style_bg_blacken(gui->lvgl_parent);
|
||||
|
||||
lv_obj_t* vertical_container = lv_obj_create(gui->lvgl_parent);
|
||||
lv_obj_set_size(vertical_container, LV_PCT(100), LV_PCT(100));
|
||||
lv_obj_set_flex_flow(vertical_container, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_style_no_padding(vertical_container);
|
||||
lv_obj_set_style_bg_blacken(vertical_container);
|
||||
|
||||
top_bar(vertical_container);
|
||||
|
||||
lv_obj_t* window_parent = lv_obj_create(vertical_container);
|
||||
lv_obj_set_width(window_parent, LV_PCT(100));
|
||||
lv_obj_set_flex_grow(window_parent, 1);
|
||||
lv_obj_set_style_no_padding(vertical_container);
|
||||
lv_obj_set_style_bg_blacken(vertical_container);
|
||||
|
||||
view_port_draw(view_port, window_parent);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool gui_redraw_desktop(Gui* gui) {
|
||||
@ -191,7 +206,6 @@ void gui_redraw(Gui* gui) {
|
||||
|
||||
furi_check(lvgl_port_lock(100));
|
||||
lv_obj_clean(gui->lvgl_parent);
|
||||
lvgl_port_unlock();
|
||||
|
||||
gui_redraw_desktop(gui);
|
||||
if (!gui_redraw_fs(gui)) {
|
||||
@ -201,5 +215,7 @@ void gui_redraw(Gui* gui) {
|
||||
gui_redraw_status_bar(gui, false);
|
||||
}
|
||||
|
||||
lvgl_port_unlock();
|
||||
|
||||
gui_unlock(gui);
|
||||
}
|
||||
|
||||
@ -89,10 +89,8 @@ void view_port_draw(ViewPort* view_port, lv_obj_t* parent) {
|
||||
furi_check(view_port->gui);
|
||||
|
||||
if (view_port->draw_callback) {
|
||||
furi_check(lvgl_port_lock(100)); // TODO: fail safely
|
||||
lv_obj_clean(parent);
|
||||
view_port->draw_callback(parent, view_port->draw_callback_context);
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
|
||||
furi_mutex_release(view_port->mutex);
|
||||
|
||||
26
components/nanobake/src/apps/services/gui/widgets/top_bar.c
Normal file
26
components/nanobake/src/apps/services/gui/widgets/top_bar.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include "top_bar.h"
|
||||
#include "widgets.h"
|
||||
|
||||
void top_bar(lv_obj_t* parent) {
|
||||
lv_obj_t* topbar_container = lv_obj_create(parent);
|
||||
lv_obj_set_width(topbar_container, LV_PCT(100));
|
||||
lv_obj_set_height(topbar_container, TOP_BAR_HEIGHT);
|
||||
lv_obj_set_style_no_padding(topbar_container);
|
||||
lv_obj_set_style_bg_blacken(topbar_container);
|
||||
lv_obj_center(topbar_container);
|
||||
lv_obj_set_flex_flow(topbar_container, LV_FLEX_FLOW_ROW);
|
||||
|
||||
lv_obj_t* spacer = lv_obj_create(topbar_container);
|
||||
lv_obj_set_height(spacer, LV_PCT(100));
|
||||
lv_obj_set_style_no_padding(spacer);
|
||||
lv_obj_set_style_bg_blacken(spacer);
|
||||
lv_obj_set_flex_grow(spacer, 1);
|
||||
|
||||
lv_obj_t* wifi = lv_img_create(topbar_container);
|
||||
lv_obj_set_size(wifi, TOP_BAR_ICON_SIZE, TOP_BAR_ICON_SIZE);
|
||||
lv_obj_set_style_no_padding(wifi);
|
||||
lv_obj_set_style_bg_blacken(wifi);
|
||||
lv_obj_set_style_img_recolor(wifi, lv_color_white(), 0);
|
||||
lv_obj_set_style_img_recolor_opa(wifi, 255, 0);
|
||||
lv_img_set_src(wifi, "A:/assets/wifi-off.png");
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
#define TOP_BAR_ICON_SIZE 18
|
||||
#define TOP_BAR_HEIGHT (TOP_BAR_ICON_SIZE + 2)
|
||||
|
||||
void top_bar(lv_obj_t* parent);
|
||||
11
components/nanobake/src/apps/services/gui/widgets/widgets.c
Normal file
11
components/nanobake/src/apps/services/gui/widgets/widgets.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "widgets.h"
|
||||
|
||||
void lv_obj_set_style_bg_blacken(lv_obj_t* obj) {
|
||||
lv_obj_set_style_bg_color(obj, lv_color_black(), 0);
|
||||
lv_obj_set_style_border_color(obj, lv_color_black(), 0);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_no_padding(lv_obj_t* obj) {
|
||||
lv_obj_set_style_pad_all(obj, LV_STATE_DEFAULT, 0);
|
||||
lv_obj_set_style_pad_gap(obj, LV_STATE_DEFAULT, 0);
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "top_bar.h"
|
||||
|
||||
void lv_obj_set_style_bg_blacken(lv_obj_t* obj);
|
||||
void lv_obj_set_style_no_padding(lv_obj_t* obj);
|
||||
@ -136,9 +136,18 @@ static void loader_start_app_with_manifest(
|
||||
loader->app_data.view_port = view_port;
|
||||
view_port_draw_callback_set(view_port, manifest->on_show, NULL);
|
||||
|
||||
FURI_RECORD_TRANSACTION(RECORD_GUI, Gui*, gui, {
|
||||
gui_add_view_port(gui, view_port, GuiLayerFullscreen); // TODO: layer type
|
||||
})
|
||||
switch (manifest->type) {
|
||||
case AppTypeService:
|
||||
furi_crash("service apps cannot have an on_show implementation");
|
||||
case AppTypeSystem:
|
||||
case AppTypeUser:
|
||||
FURI_RECORD_TRANSACTION(RECORD_GUI, Gui*, gui, {
|
||||
gui_add_view_port(gui, view_port, GuiLayerWindow);
|
||||
})
|
||||
break;
|
||||
default:
|
||||
furi_crash("viewport not implemented for app type");
|
||||
}
|
||||
} else {
|
||||
loader->app_data.view_port = NULL;
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "check.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
#include "graphics_i.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
#define TAG "lvgl"
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#include "nanobake.h"
|
||||
#include "app_i.h"
|
||||
#include "app_manifest_registry.h"
|
||||
#include "devices_i.h"
|
||||
#include "furi.h"
|
||||
@ -52,5 +51,4 @@ __attribute__((unused)) extern void nanobake_start(Config* _Nonnull config) {
|
||||
register_apps(config);
|
||||
|
||||
start_services();
|
||||
// TODO: option to await starting services?
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ esp_err_t nb_partitions_init() {
|
||||
esp_vfs_spiffs_conf_t assets_spiffs = {
|
||||
.base_path = MOUNT_POINT_ASSETS,
|
||||
.partition_label = NULL,
|
||||
.max_files = 4,
|
||||
.max_files = 100,
|
||||
.format_if_mount_failed = false
|
||||
};
|
||||
|
||||
@ -54,7 +54,7 @@ esp_err_t nb_partitions_init() {
|
||||
esp_vfs_spiffs_conf_t config_spiffs = {
|
||||
.base_path = MOUNT_POINT_CONFIG,
|
||||
.partition_label = "config",
|
||||
.max_files = 2,
|
||||
.max_files = 100,
|
||||
.format_if_mount_failed = false
|
||||
};
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
#include "apps/services/loader/loader.h"
|
||||
|
||||
static void on_button_click(lv_event_t _Nonnull* event) {
|
||||
UNUSED(event);
|
||||
|
||||
FURI_RECORD_TRANSACTION(RECORD_LOADER, Loader*, loader, {
|
||||
loader_start_app_nonblocking(loader, "systeminfo", NULL);
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user