Skip to content

Commit

Permalink
bigger click area for macro hide/unhide.
Browse files Browse the repository at this point in the history
  • Loading branch information
ballaswag committed Dec 23, 2023
1 parent 01daaed commit 04075ef
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
10 changes: 5 additions & 5 deletions assets/zbolt/load_filament_img.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#define LV_ATTRIBUTE_MEM_ALIGN
#endif

#ifndef LV_ATTRIBUTE_IMG_EXTRUDE_IMG
#define LV_ATTRIBUTE_IMG_EXTRUDE_IMG
#ifndef LV_ATTRIBUTE_IMG_LOAD_FILAMENT_IMG
#define LV_ATTRIBUTE_IMG_LOAD_FILAMENT_IMG
#endif

const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_EXTRUDE_IMG uint8_t extrude_img_map[] = {
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_LOAD_FILAMENT_IMG uint8_t load_filament_img_map[] = {
#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8
/*Pixel format: Alpha 8 bit, Red: 3 bit, Green: 3 bit, Blue: 2 bit*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down Expand Up @@ -291,12 +291,12 @@ const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_EXTRUDE_I
#endif
};

const lv_img_dsc_t extrude_img = {
const lv_img_dsc_t load_filament_img = {
.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA,
.header.always_zero = 0,
.header.reserved = 0,
.header.w = 64,
.header.h = 64,
.data_size = 4096 * LV_IMG_PX_SIZE_ALPHA_BYTE,
.data = extrude_img_map,
.data = load_filament_img_map,
};
10 changes: 5 additions & 5 deletions assets/zbolt/unload_filament_img.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#define LV_ATTRIBUTE_MEM_ALIGN
#endif

#ifndef LV_ATTRIBUTE_IMG_RETRACT_IMG
#define LV_ATTRIBUTE_IMG_RETRACT_IMG
#ifndef LV_ATTRIBUTE_IMG_UNLOAD_FILAMENT_IMG
#define LV_ATTRIBUTE_IMG_UNLOAD_FILAMENT_IMG
#endif

const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_RETRACT_IMG uint8_t retract_img_map[] = {
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_UNLOAD_FILAMENT_IMG uint8_t unload_filament_img_map[] = {
#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8
/*Pixel format: Alpha 8 bit, Red: 3 bit, Green: 3 bit, Blue: 2 bit*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down Expand Up @@ -291,12 +291,12 @@ const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_RETRACT_I
#endif
};

const lv_img_dsc_t retract_img = {
const lv_img_dsc_t unload_filament_img = {
.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA,
.header.always_zero = 0,
.header.reserved = 0,
.header.w = 64,
.header.h = 64,
.data_size = 4096 * LV_IMG_PX_SIZE_ALPHA_BYTE,
.data = retract_img_map,
.data = unload_filament_img_map,
};
18 changes: 11 additions & 7 deletions src/macro_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ MacroItem::MacroItem(KWebSocketClient &c,
, cont(lv_obj_create(parent))
, top_cont(lv_obj_create(cont))
, macro_label(lv_label_create(top_cont))
, hide_show(lv_label_create(top_cont))
, hide_show_cont(lv_obj_create(top_cont))
, hide_show(lv_label_create(hide_show_cont))
, kb(keyboard)
, hidden(hide)
, always_visible(false)
Expand All @@ -33,10 +34,12 @@ MacroItem::MacroItem(KWebSocketClient &c,
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP);
lv_obj_set_flex_align(cont, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);

lv_obj_set_style_border_side(cont, LV_BORDER_SIDE_LEFT | LV_BORDER_SIDE_RIGHT | LV_BORDER_SIDE_TOP,
LV_PART_MAIN);
lv_obj_set_style_border_side(cont, LV_BORDER_SIDE_TOP, LV_PART_MAIN);

lv_obj_set_style_border_width(cont, 2, 0);
lv_obj_clear_flag(hide_show_cont, LV_OBJ_FLAG_SCROLLABLE);

lv_obj_center(hide_show);

if (hidden) {
lv_label_set_text(hide_show, " " LV_SYMBOL_EYE_OPEN " ");
Expand All @@ -46,9 +49,10 @@ MacroItem::MacroItem(KWebSocketClient &c,
lv_obj_set_style_text_color(hide_show, lv_color_white(), LV_PART_MAIN);
}

lv_obj_align(hide_show, LV_ALIGN_LEFT_MID, 0, 0);
lv_obj_add_flag(hide_show, LV_OBJ_FLAG_CLICKABLE);
lv_obj_add_event_cb(hide_show, &MacroItem::_handle_hide_show, LV_EVENT_CLICKED, this);
lv_obj_align(hide_show_cont, LV_ALIGN_LEFT_MID, 0, 0);
lv_obj_set_size(hide_show_cont, 60, LV_PCT(100));
lv_obj_add_flag(hide_show_cont, LV_OBJ_FLAG_CLICKABLE);
lv_obj_add_event_cb(hide_show_cont, &MacroItem::_handle_hide_show, LV_EVENT_CLICKED, this);

lv_label_set_text(macro_label, macro_name.c_str());
lv_obj_align(macro_label, LV_ALIGN_LEFT_MID, 65, 0);
Expand Down Expand Up @@ -153,7 +157,7 @@ void MacroItem::handle_send_macro(lv_event_t *e) {
void MacroItem::handle_hide_show(lv_event_t *e) {
lv_event_code_t code = lv_event_get_code(e);
if (code == LV_EVENT_CLICKED) {
spdlog::debug("macro item hide/show");
spdlog::trace("macro item hide/show");
std::string key = fmt::format("macros.settings.{}", lv_label_get_text(macro_label));

json h = {
Expand Down
1 change: 1 addition & 0 deletions src/macro_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class MacroItem {
lv_obj_t *cont;
lv_obj_t *top_cont;
lv_obj_t *macro_label;
lv_obj_t *hide_show_cont;
lv_obj_t *hide_show;
lv_obj_t *kb;
bool hidden;
Expand Down
2 changes: 1 addition & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ namespace KUtils {
std::smatch matches;
std::string default_value = "";

spdlog::debug("macro: {}, param; {}, rest: {}", macro_name, param_name, rest);
spdlog::trace("macro: {}, param; {}, rest: {}", macro_name, param_name, rest);

if (std::regex_search(rest, matches, default_value_regex)) {
default_value = matches.str(1);
Expand Down

0 comments on commit 04075ef

Please sign in to comment.