Move event handlers to unnamed namespace
This commit is contained in:
parent
c6026aa617
commit
6cfb45e280
|
@ -2,23 +2,25 @@
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Widgets;
|
using namespace Pinetime::Applications::Widgets;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void upBtnEventHandler(lv_obj_t* obj, lv_event_t event) {
|
||||||
|
auto* widget = static_cast<Counter*>(obj->user_data);
|
||||||
|
if (event == LV_EVENT_SHORT_CLICKED || event == LV_EVENT_LONG_PRESSED_REPEAT) {
|
||||||
|
widget->Increment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void downBtnEventHandler(lv_obj_t* obj, lv_event_t event) {
|
||||||
|
auto* widget = static_cast<Counter*>(obj->user_data);
|
||||||
|
if (event == LV_EVENT_SHORT_CLICKED || event == LV_EVENT_LONG_PRESSED_REPEAT) {
|
||||||
|
widget->Decrement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Counter::Counter(int min, int max) : min {min}, max {max} {
|
Counter::Counter(int min, int max) : min {min}, max {max} {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Counter::upBtnEventHandler(lv_obj_t* obj, lv_event_t event) {
|
|
||||||
auto* widget = static_cast<Counter*>(obj->user_data);
|
|
||||||
if (event == LV_EVENT_SHORT_CLICKED || event == LV_EVENT_LONG_PRESSED_REPEAT) {
|
|
||||||
widget->Increment();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Counter::downBtnEventHandler(lv_obj_t* obj, lv_event_t event) {
|
|
||||||
auto* widget = static_cast<Counter*>(obj->user_data);
|
|
||||||
if (event == LV_EVENT_SHORT_CLICKED || event == LV_EVENT_LONG_PRESSED_REPEAT) {
|
|
||||||
widget->Decrement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Counter::Increment() {
|
void Counter::Increment() {
|
||||||
value++;
|
value++;
|
||||||
if (value > max) {
|
if (value > max) {
|
||||||
|
|
|
@ -9,8 +9,6 @@ namespace Pinetime {
|
||||||
Counter(int min, int max);
|
Counter(int min, int max);
|
||||||
|
|
||||||
void Create();
|
void Create();
|
||||||
static void upBtnEventHandler(lv_obj_t* obj, lv_event_t event);
|
|
||||||
static void downBtnEventHandler(lv_obj_t* obj, lv_event_t event);
|
|
||||||
void Increment();
|
void Increment();
|
||||||
void Decrement();
|
void Decrement();
|
||||||
void SetValue(int newValue);
|
void SetValue(int newValue);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user