Fixes
This commit is contained in:
parent
df29f89977
commit
ed03347331
@ -381,10 +381,10 @@ void WidgetManager::showScreen(uint8_t screenId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WidgetManager::handleButtonAction(const WidgetConfig& cfg, lv_obj_t* target) {
|
void WidgetManager::handleButtonAction(const WidgetConfig& cfg, lv_obj_t* target) {
|
||||||
if (cfg.type != WidgetType::BUTTON) return;
|
ESP_LOGI(TAG, "handleButtonAction: button=%d action=%d targetScreen=%d type=%d",
|
||||||
|
cfg.id, static_cast<int>(cfg.action), cfg.targetScreen, static_cast<int>(cfg.type));
|
||||||
|
|
||||||
ESP_LOGI(TAG, "handleButtonAction: button=%d action=%d targetScreen=%d",
|
if (cfg.type != WidgetType::BUTTON) return;
|
||||||
cfg.id, static_cast<int>(cfg.action), cfg.targetScreen);
|
|
||||||
|
|
||||||
onUserActivity();
|
onUserActivity();
|
||||||
|
|
||||||
|
|||||||
@ -4,28 +4,27 @@
|
|||||||
|
|
||||||
static const char* TAG = "ButtonWidget";
|
static const char* TAG = "ButtonWidget";
|
||||||
|
|
||||||
// Free function instead of static member
|
|
||||||
static void button_event_cb(lv_event_t* e) {
|
|
||||||
ESP_LOGI(TAG, "button_event_cb called");
|
|
||||||
}
|
|
||||||
|
|
||||||
ButtonWidget::ButtonWidget(const WidgetConfig& config)
|
ButtonWidget::ButtonWidget(const WidgetConfig& config)
|
||||||
: Widget(config)
|
: Widget(config)
|
||||||
, label_(nullptr)
|
, label_(nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonWidget::~ButtonWidget() {
|
ButtonWidget::~ButtonWidget() {
|
||||||
// Remove event callback BEFORE the base class destructor deletes the object
|
// Remove event callback BEFORE the base class destructor deletes the object
|
||||||
if (obj_) {
|
if (obj_) {
|
||||||
lv_obj_remove_event_cb(obj_, button_event_cb);
|
lv_obj_remove_event_cb(obj_, clickCallback);
|
||||||
}
|
}
|
||||||
label_ = nullptr;
|
label_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget::clickCallback(lv_event_t* e) {
|
void ButtonWidget::clickCallback(lv_event_t* e) {
|
||||||
// Not used currently
|
ESP_LOGI(TAG, "clickCallback called");
|
||||||
(void)e;
|
ButtonWidget* widget = static_cast<ButtonWidget*>(lv_event_get_user_data(e));
|
||||||
|
if (!widget) return;
|
||||||
|
lv_obj_t* target = static_cast<lv_obj_t*>(lv_event_get_target(e));
|
||||||
|
WidgetManager::instance().handleButtonAction(widget->getConfig(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_obj_t* ButtonWidget::create(lv_obj_t* parent) {
|
lv_obj_t* ButtonWidget::create(lv_obj_t* parent) {
|
||||||
@ -35,7 +34,7 @@ lv_obj_t* ButtonWidget::create(lv_obj_t* parent) {
|
|||||||
config_.height > 0 ? config_.height : 50);
|
config_.height > 0 ? config_.height : 50);
|
||||||
|
|
||||||
// Test: free function callback
|
// Test: free function callback
|
||||||
lv_obj_add_event_cb(obj_, button_event_cb, LV_EVENT_CLICKED, NULL);
|
lv_obj_add_event_cb(obj_, clickCallback, LV_EVENT_CLICKED, this);
|
||||||
|
|
||||||
label_ = lv_label_create(obj_);
|
label_ = lv_label_create(obj_);
|
||||||
lv_label_set_text(label_, config_.text);
|
lv_label_set_text(label_, config_.text);
|
||||||
|
|||||||
@ -61,6 +61,7 @@ void Widget::applyCommonStyle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Widget::applyShadowStyle() {
|
void Widget::applyShadowStyle() {
|
||||||
|
return;
|
||||||
if (obj_ == nullptr || !config_.shadow.enabled) return;
|
if (obj_ == nullptr || !config_.shadow.enabled) return;
|
||||||
|
|
||||||
lv_obj_set_style_shadow_color(obj_, lv_color_make(
|
lv_obj_set_style_shadow_color(obj_, lv_color_make(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user