more menu changes
This commit is contained in:
committed by
Raphael Coeffic
parent
fe7d425ced
commit
c5175f7061
+1
-52
@@ -81,14 +81,7 @@ void Button::checkEvents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
lv_style_t style_btn;
|
lv_style_t style_btn;
|
||||||
|
LvglWidgetFactory textButtonFactory = {lv_btn_create, nullptr};
|
||||||
|
|
||||||
LvglWidgetFactory textButtonFactory = LvglWidgetFactory(
|
|
||||||
[](lv_obj_t *parent) {
|
|
||||||
return lv_btn_create(parent);
|
|
||||||
},
|
|
||||||
[] (LvglWidgetFactory *factory) {
|
|
||||||
});
|
|
||||||
|
|
||||||
TextButton::TextButton(FormGroup* parent, const rect_t& rect, std::string text,
|
TextButton::TextButton(FormGroup* parent, const rect_t& rect, std::string text,
|
||||||
std::function<uint8_t(void)> pressHandler,
|
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);
|
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)
|
void IconButton::paint(BitmapBuffer * dc)
|
||||||
{
|
{
|
||||||
dc->drawBitmap(0, 0, theme->getIcon(icon, checked() ? STATE_PRESSED : STATE_DEFAULT));
|
dc->drawBitmap(0, 0, theme->getIcon(icon, checked() ? STATE_PRESSED : STATE_DEFAULT));
|
||||||
|
|||||||
-6
@@ -88,8 +88,6 @@ class Button: public FormField
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern void my_btn_event_cb(lv_event_t * e);
|
|
||||||
|
|
||||||
class TextButton: public Button
|
class TextButton: public Button
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -97,7 +95,6 @@ class TextButton: public Button
|
|||||||
std::function<uint8_t(void)> pressHandler = nullptr,
|
std::function<uint8_t(void)> pressHandler = nullptr,
|
||||||
WindowFlags windowFlags = BUTTON_BACKGROUND | OPAQUE,
|
WindowFlags windowFlags = BUTTON_BACKGROUND | OPAQUE,
|
||||||
LcdFlags textFlags = 0);
|
LcdFlags textFlags = 0);
|
||||||
~TextButton();
|
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() const override
|
std::string getName() const override
|
||||||
@@ -111,7 +108,6 @@ class TextButton: public Button
|
|||||||
if (value != text) {
|
if (value != text) {
|
||||||
text = std::move(value);
|
text = std::move(value);
|
||||||
lv_label_set_text(label, text.c_str());
|
lv_label_set_text(label, text.c_str());
|
||||||
invalidate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,8 +116,6 @@ class TextButton: public Button
|
|||||||
bgColorHandler = std::move(handler);
|
bgColorHandler = std::move(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint(BitmapBuffer* dc) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
lv_obj_t * label = nullptr;
|
lv_obj_t * label = nullptr;
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -92,11 +92,17 @@ int MenuBody::rangeCheck(int index)
|
|||||||
void MenuBody::setIndex(int index)
|
void MenuBody::setIndex(int index)
|
||||||
{
|
{
|
||||||
if (index < (int)lines.size()) {
|
if (index < (int)lines.size()) {
|
||||||
selectedIndex = index;
|
|
||||||
|
|
||||||
lv_obj_t *btn = lv_obj_get_child(lvobj, selectedIndex);
|
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) {
|
if (btn != nullptr) {
|
||||||
lv_obj_add_state(btn, LV_STATE_CHECKED);
|
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(this, {0, 0, width(), height()})
|
||||||
{
|
{
|
||||||
body.setFocus(SET_FOCUS_DEFAULT);
|
body.setFocus(SET_FOCUS_DEFAULT);
|
||||||
|
lv_obj_set_style_bg_opa(lvobj, LV_OPA_100, LV_PART_MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuWindowContent::paint(BitmapBuffer * dc)
|
void MenuWindowContent::paint(BitmapBuffer * dc)
|
||||||
|
|||||||
+2
-1
@@ -53,11 +53,12 @@ class MenuToolbar: public FormGroup {
|
|||||||
choice(choice),
|
choice(choice),
|
||||||
menu(menu)
|
menu(menu)
|
||||||
{
|
{
|
||||||
|
lv_obj_set_style_bg_opa(lvobj, LV_OPA_100, LV_PART_MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint(BitmapBuffer * dc) override
|
void paint(BitmapBuffer * dc) override
|
||||||
{
|
{
|
||||||
dc->clear(COLOR_THEME_SECONDARY3);
|
// dc->clear(COLOR_THEME_SECONDARY3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
|
|||||||
Reference in New Issue
Block a user