more menu changes

This commit is contained in:
kkoenig1@optonline.com
2022-06-11 15:13:11 +02:00
committed by Raphael Coeffic
parent fe7d425ced
commit c5175f7061
4 changed files with 12 additions and 61 deletions
+1 -52
View File
@@ -81,14 +81,7 @@ void Button::checkEvents()
}
lv_style_t style_btn;
LvglWidgetFactory textButtonFactory = LvglWidgetFactory(
[](lv_obj_t *parent) {
return lv_btn_create(parent);
},
[] (LvglWidgetFactory *factory) {
});
LvglWidgetFactory textButtonFactory = {lv_btn_create, nullptr};
TextButton::TextButton(FormGroup* parent, const rect_t& rect, std::string text,
std::function<uint8_t(void)> pressHandler,
@@ -125,50 +118,6 @@ TextButton::TextButton(FormGroup* parent, const rect_t& rect, std::string text,
lv_obj_set_style_text_color(label, makeLvColor(COLOR_THEME_PRIMARY2), LV_PART_MAIN | LV_STATE_FOCUSED);
}
TextButton::~TextButton()
{
}
void TextButton::paint(BitmapBuffer * dc)
{
// auto textColor = getTextFlags();
// auto bgColor = COLOR_THEME_SECONDARY2;
// if (bgColorHandler) {
// bgColor = bgColorHandler();
// } else if (checked()) {
// bgColor = COLOR_THEME_ACTIVE;
// } else if (hasFocus()) {
// bgColor = COLOR_THEME_FOCUS;
// textColor = COLOR_THEME_PRIMARY2;
// }
// if (checked()) {
// if (hasFocus()) {
// dc->drawSolidRect(0, 0, rect.w, rect.h, 2, COLOR_THEME_FOCUS);
// dc->drawSolidFilledRect(3, 3, rect.w - 6, rect.h - 6, bgColor);
// } else {
// dc->drawSolidFilledRect(0, 0, rect.w, rect.h, bgColor);
// }
// }
// else {
// dc->drawSolidFilledRect(0, 0, rect.w, rect.h, bgColor);
// if (windowFlags & BUTTON_BACKGROUND) {
// if (hasFocus()) {
// textColor = COLOR_THEME_PRIMARY2;
// }
// } else if (hasFocus()) {
// dc->drawSolidRect(0, 0, rect.w, rect.h, 2, COLOR_THEME_FOCUS);
// }
// else {
// dc->drawSolidRect(0, 0, rect.w, rect.h, 1, COLOR_THEME_SECONDARY2);
// }
// }
// dc->drawText(rect.w / 2, 1 + (rect.h - getFontHeight(textFlags)) / 2,
// text.c_str(), CENTERED | textColor);
}
void IconButton::paint(BitmapBuffer * dc)
{
dc->drawBitmap(0, 0, theme->getIcon(icon, checked() ? STATE_PRESSED : STATE_DEFAULT));
-6
View File
@@ -88,8 +88,6 @@ class Button: public FormField
};
extern void my_btn_event_cb(lv_event_t * e);
class TextButton: public Button
{
public:
@@ -97,7 +95,6 @@ class TextButton: public Button
std::function<uint8_t(void)> pressHandler = nullptr,
WindowFlags windowFlags = BUTTON_BACKGROUND | OPAQUE,
LcdFlags textFlags = 0);
~TextButton();
#if defined(DEBUG_WINDOWS)
std::string getName() const override
@@ -111,7 +108,6 @@ class TextButton: public Button
if (value != text) {
text = std::move(value);
lv_label_set_text(label, text.c_str());
invalidate();
}
}
@@ -120,8 +116,6 @@ class TextButton: public Button
bgColorHandler = std::move(handler);
}
void paint(BitmapBuffer* dc) override;
protected:
lv_obj_t * label = nullptr;
+9 -2
View File
@@ -92,11 +92,17 @@ int MenuBody::rangeCheck(int index)
void MenuBody::setIndex(int index)
{
if (index < (int)lines.size()) {
selectedIndex = index;
lv_obj_t *btn = lv_obj_get_child(lvobj, selectedIndex);
if (btn != nullptr) {
lv_obj_clear_state(btn, LV_STATE_CHECKED);
}
selectedIndex = index;
btn = lv_obj_get_child(lvobj, selectedIndex);
if (btn != nullptr) {
lv_obj_add_state(btn, LV_STATE_CHECKED);
lv_obj_scroll_to_view(btn, LV_ANIM_ON);
}
}
}
@@ -263,6 +269,7 @@ MenuWindowContent::MenuWindowContent(Menu* parent) :
body(this, {0, 0, width(), height()})
{
body.setFocus(SET_FOCUS_DEFAULT);
lv_obj_set_style_bg_opa(lvobj, LV_OPA_100, LV_PART_MAIN);
}
void MenuWindowContent::paint(BitmapBuffer * dc)
+2 -1
View File
@@ -53,11 +53,12 @@ class MenuToolbar: public FormGroup {
choice(choice),
menu(menu)
{
lv_obj_set_style_bg_opa(lvobj, LV_OPA_100, LV_PART_MAIN);
}
void paint(BitmapBuffer * dc) override
{
dc->clear(COLOR_THEME_SECONDARY3);
// dc->clear(COLOR_THEME_SECONDARY3);
}
#if defined(HARDWARE_KEYS)