cleanup and fixes for widgets
This commit is contained in:
parent
bb047b4a5f
commit
eed990217f
@ -0,0 +1,9 @@
|
||||
#include "spacer.h"
|
||||
#include "widgets.h"
|
||||
|
||||
lv_obj_t* spacer(lv_obj_t* parent, lv_coord_t width, lv_coord_t height) {
|
||||
lv_obj_t* spacer = lv_obj_create(parent);
|
||||
lv_obj_set_size(spacer, width, height);
|
||||
lv_obj_set_style_bg_invisible(spacer);
|
||||
return spacer;
|
||||
}
|
||||
13
components/nanobake/src/apps/services/gui/widgets/spacer.h
Normal file
13
components/nanobake/src/apps/services/gui/widgets/spacer.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
lv_obj_t* spacer(lv_obj_t* parent, lv_coord_t width, lv_coord_t height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@ -26,9 +26,12 @@ void toolbar(lv_obj_t* parent, lv_coord_t offset_y, const AppManifest* manifest)
|
||||
lv_img_set_src(close_button_image, LV_SYMBOL_CLOSE);
|
||||
lv_obj_align(close_button_image, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
// Need spacer to avoid button press glitch animation
|
||||
spacer(toolbar, 2, 1);
|
||||
|
||||
lv_obj_t* label_container = lv_obj_create(toolbar);
|
||||
lv_obj_set_style_no_padding(label_container);
|
||||
lv_obj_set_height(label_container, LV_PCT(100));
|
||||
lv_obj_set_height(label_container, LV_PCT(100)); // 2% less due to 4px translate (it's not great, but it works)
|
||||
lv_obj_set_flex_grow(label_container, 1);
|
||||
|
||||
lv_obj_t* label = lv_label_create(label_container);
|
||||
|
||||
@ -7,7 +7,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define TOP_BAR_ICON_SIZE 18
|
||||
#define TOP_BAR_HEIGHT (TOP_BAR_ICON_SIZE + 2)
|
||||
#define TOP_BAR_HEIGHT (TOP_BAR_ICON_SIZE + 4) // 4 extra pixels for border and outline
|
||||
|
||||
void top_bar(lv_obj_t* parent);
|
||||
|
||||
|
||||
@ -5,6 +5,11 @@ void lv_obj_set_style_bg_blacken(lv_obj_t* obj) {
|
||||
lv_obj_set_style_border_color(obj, lv_color_black(), 0);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_invisible(lv_obj_t* obj) {
|
||||
lv_obj_set_style_bg_opa(obj, 0, 0);
|
||||
lv_obj_set_style_border_opa(obj, 0, 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);
|
||||
|
||||
@ -2,12 +2,14 @@
|
||||
|
||||
#include "top_bar.h"
|
||||
#include "toolbar.h"
|
||||
#include "spacer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void lv_obj_set_style_bg_blacken(lv_obj_t* obj);
|
||||
void lv_obj_set_style_bg_invisible(lv_obj_t* obj);
|
||||
void lv_obj_set_style_no_padding(lv_obj_t* obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user