Inputs, Mixers: various tweaks & fixes

This commit is contained in:
Raphael Coeffic
2022-06-11 15:38:08 +02:00
committed by Raphael Coeffic
parent 46c4095cd2
commit 5a0fe2101c
10 changed files with 95 additions and 18 deletions
+3 -1
View File
@@ -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()
+4 -2
View File
@@ -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()
+3
View File
@@ -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;
};
+5 -12
View File
@@ -22,6 +22,8 @@
#include "input_mix_group.h"
#include "channel_bar.h"
#include "lvgl_widgets/input_mix_group.h"
#include "opentx.h"
#include <algorithm>
@@ -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)
@@ -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;
}
@@ -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 <lvgl/lvgl.h>
#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
+1 -1
View File
@@ -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;
@@ -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)) {
+1 -1
View File
@@ -31,7 +31,7 @@
enum FontIndex
{
FONT_STD_INDEX,
#if !defined(BOLD)
#if !defined(BOOT)
FONT_BOLD_INDEX,
FONT_XXS_INDEX,
FONT_XS_INDEX,
+1 -1
View File
@@ -31,7 +31,7 @@
enum FontIndex
{
FONT_STD_INDEX,
#if !defined(BOLD)
#if !defined(BOOT)
FONT_BOLD_INDEX,
FONT_XXS_INDEX,
FONT_XS_INDEX,