diff --git a/radio/src/gui/colorlcd/CMakeLists.txt b/radio/src/gui/colorlcd/CMakeLists.txt index b9a0a36a6..80d8dcb53 100644 --- a/radio/src/gui/colorlcd/CMakeLists.txt +++ b/radio/src/gui/colorlcd/CMakeLists.txt @@ -172,9 +172,11 @@ add_gui_src(mixer_edit.cpp) add_gui_src(output_edit.cpp) add_gui_src(input_mix_group.cpp) add_gui_src(input_mix_button.cpp) -add_gui_src(lvgl_widgets/input_mix_line.c) add_gui_src(channel_bar.cpp) +add_gui_src(lvgl_widgets/input_mix_line.c) +add_gui_src(lvgl_widgets/input_mix_group.c) + if(HARDWARE_TOUCH) add_gui_src(keyboard_curve.cpp) endif() diff --git a/radio/src/gui/colorlcd/channel_bar.cpp b/radio/src/gui/colorlcd/channel_bar.cpp index bbc6d6569..0971404f7 100644 --- a/radio/src/gui/colorlcd/channel_bar.cpp +++ b/radio/src/gui/colorlcd/channel_bar.cpp @@ -64,8 +64,10 @@ void MixerChannelBar::paint(BitmapBuffer * dc) FONT(XS) | COLOR_THEME_SECONDARY1, 0, nullptr, "%"); } - // Draw middle bar - dc->drawSolidVerticalLine(width() / 2, 0, height(), COLOR_THEME_SECONDARY1); + if (drawMiddleBar) { + // Draw middle bar + dc->drawSolidVerticalLine(width() / 2, 0, height(), COLOR_THEME_SECONDARY1); + } } void MixerChannelBar::checkEvents() diff --git a/radio/src/gui/colorlcd/channel_bar.h b/radio/src/gui/colorlcd/channel_bar.h index 08067a4dd..f013c2b7c 100644 --- a/radio/src/gui/colorlcd/channel_bar.h +++ b/radio/src/gui/colorlcd/channel_bar.h @@ -49,10 +49,13 @@ class MixerChannelBar : public ChannelBar public: using ChannelBar::ChannelBar; + void setDrawMiddleBar(bool enable) { drawMiddleBar = enable; } + void paint(BitmapBuffer* dc) override; void checkEvents() override; protected: + bool drawMiddleBar = true; int value = 0; }; diff --git a/radio/src/gui/colorlcd/input_mix_group.cpp b/radio/src/gui/colorlcd/input_mix_group.cpp index 68d701d6c..c191ec7c1 100644 --- a/radio/src/gui/colorlcd/input_mix_group.cpp +++ b/radio/src/gui/colorlcd/input_mix_group.cpp @@ -22,6 +22,8 @@ #include "input_mix_group.h" #include "channel_bar.h" +#include "lvgl_widgets/input_mix_group.h" + #include "opentx.h" #include @@ -35,16 +37,8 @@ static const lv_coord_t row_dsc[] = { }; InputMixGroup::InputMixGroup(Window* parent, mixsrc_t idx) : - Window(parent, rect_t{}), idx(idx) + Window(parent, rect_t{}, 0, 0, input_mix_group_create), idx(idx) { - lv_obj_set_style_bg_opa(lvobj, LV_OPA_100, 0); - lv_obj_set_style_radius(lvobj, lv_dpx(16), 0); - lv_obj_set_style_pad_hor(lvobj, lv_dpx(8), 0); - lv_obj_set_style_pad_ver(lvobj, lv_dpx(8), 0); - - lv_obj_set_width(lvobj, lv_pct(100)); - lv_obj_set_height(lvobj, LV_SIZE_CONTENT); - lv_obj_set_layout(lvobj, LV_LAYOUT_GRID); lv_obj_set_grid_dsc_array(lvobj, col_dsc, row_dsc); @@ -71,12 +65,11 @@ void InputMixGroup::addMixerMonitor(uint8_t channel) { rect_t r{ 0, 0, 100, 14 }; auto mon = new MixerChannelBar(this, r, channel); + mon->setDrawMiddleBar(false); lv_obj_t* mon_obj = mon->getLvObj(); lv_obj_set_parent(mon_obj, line_container); - lv_obj_set_style_border_width(mon_obj, lv_dpx(1), 0); - lv_obj_set_style_border_color(mon_obj, makeLvColor(COLOR_THEME_SECONDARY1), 0); - lv_obj_set_style_radius(mon_obj, lv_dpx(8), 0); + lv_obj_set_style_translate_x(mon_obj, -lv_dpx(8), 0); } void InputMixGroup::addLine(Window* line, const uint8_t* symbol) diff --git a/radio/src/gui/colorlcd/lvgl_widgets/input_mix_group.c b/radio/src/gui/colorlcd/lvgl_widgets/input_mix_group.c new file mode 100644 index 000000000..d91e74118 --- /dev/null +++ b/radio/src/gui/colorlcd/lvgl_widgets/input_mix_group.c @@ -0,0 +1,35 @@ +/* + * Copyright (C) EdgeTX + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "input_mix_group.h" + +#define MY_CLASS &input_mix_group_class + +const lv_obj_class_t input_mix_group_class = { + .width_def = LV_PCT(100), + .height_def = LV_SIZE_CONTENT, + .editable = LV_OBJ_CLASS_EDITABLE_FALSE, + .group_def = LV_OBJ_CLASS_GROUP_DEF_FALSE, + .instance_size = sizeof(lv_obj_t), + .base_class = &lv_obj_class, +}; + +lv_obj_t* input_mix_group_create(lv_obj_t* parent) +{ + LV_LOG_INFO("begin"); + lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent); + lv_obj_class_init_obj(obj); + return obj; +} diff --git a/radio/src/gui/colorlcd/lvgl_widgets/input_mix_group.h b/radio/src/gui/colorlcd/lvgl_widgets/input_mix_group.h new file mode 100644 index 000000000..e11d4bd0e --- /dev/null +++ b/radio/src/gui/colorlcd/lvgl_widgets/input_mix_group.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) EdgeTX + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef INPUT_MIX_GROUP_H +#define INPUT_MIX_GROUP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern const lv_obj_class_t input_mix_group_class; +lv_obj_t* input_mix_group_create(lv_obj_t* parent); + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/radio/src/gui/colorlcd/model_mixes.cpp b/radio/src/gui/colorlcd/model_mixes.cpp index 7a2eb8e50..6f073c9ae 100644 --- a/radio/src/gui/colorlcd/model_mixes.cpp +++ b/radio/src/gui/colorlcd/model_mixes.cpp @@ -185,7 +185,7 @@ class MixLineButton : public InputMixButton static void mix_draw_mplex(lv_event_t* e) { auto obj = (lv_obj_t*)lv_event_get_user_data(e); - if (!obj || (lv_obj_get_index(obj) == 0)) return; + if (!obj || (lv_obj_get_index(obj) <= 1)) return; auto btn = (MixLineButton*)lv_obj_get_user_data(obj); if (!btn) return; diff --git a/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp b/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp index 478cd6b9a..fe48f5848 100644 --- a/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp +++ b/radio/src/gui/colorlcd/themes/etx_lv_theme.cpp @@ -8,7 +8,11 @@ *********************/ #include "etx_lv_theme.h" #include "../colors.h" +#include "font.h" + +#include "libopenui_config.h" #include "lvgl_widgets/input_mix_line.h" +#include "lvgl_widgets/input_mix_group.h" extern lv_color_t makeLvColor(uint32_t colorFlags); @@ -802,6 +806,12 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_add_style(obj, &styles.focus_border, LV_STATE_FOCUSED); } #endif + else if(lv_obj_check_type(obj, &input_mix_group_class)) { + lv_obj_add_style(obj, &styles.line_btn, 0); + lv_obj_add_style(obj, &styles.pad_small, 0); + lv_obj_set_style_text_color(obj, makeLvColor(COLOR_THEME_SECONDARY1), 0); + lv_obj_set_style_text_font(obj, getFont(FONT(BOLD)), 0); + } #if LV_USE_LINE else if(lv_obj_check_type(obj, &lv_line_class)) { diff --git a/radio/src/targets/horus/libopenui_config.h b/radio/src/targets/horus/libopenui_config.h index ce19330f6..2e3c013ac 100644 --- a/radio/src/targets/horus/libopenui_config.h +++ b/radio/src/targets/horus/libopenui_config.h @@ -31,7 +31,7 @@ enum FontIndex { FONT_STD_INDEX, -#if !defined(BOLD) +#if !defined(BOOT) FONT_BOLD_INDEX, FONT_XXS_INDEX, FONT_XS_INDEX, diff --git a/radio/src/targets/nv14/libopenui_config.h b/radio/src/targets/nv14/libopenui_config.h index b75c6c97a..4240af8a8 100644 --- a/radio/src/targets/nv14/libopenui_config.h +++ b/radio/src/targets/nv14/libopenui_config.h @@ -31,7 +31,7 @@ enum FontIndex { FONT_STD_INDEX, -#if !defined(BOLD) +#if !defined(BOOT) FONT_BOLD_INDEX, FONT_XXS_INDEX, FONT_XS_INDEX,