OMOTE/Platformio/OmoteUI/core/UIElement.cpp
MatthewColvin dfbfd7a6a8 Add visiblity API for UIElements
Add ability for Screen Manager to display screens
and retain others underneath in a stack fasion.
2023-09-16 21:43:07 -05:00

36 lines
725 B
C++

#include "UIElement.hpp"
namespace UI {
UIElement::UIElement(lv_obj_t *aLvglSelf, ID aId)
: mLvglSelf(aLvglSelf), mId(aId) {
mLvglSelf->user_data = this;
}
bool UIElement::IsVisible() { return lv_obj_is_visible(mLvglSelf); }
void UIElement::SetVisiblity(bool aVisible) {
if (aVisible == IsVisible()) {
return;
}
if (aVisible) {
Show();
} else {
Hide();
}
}
void UIElement::SetBgColor(lv_color_t aColor, lv_style_selector_t aStyle) {
lv_obj_set_style_bg_color(mLvglSelf, aColor, aStyle);
};
void UIElement::Show() {
lv_obj_clear_flag(mLvglSelf, LV_OBJ_FLAG_HIDDEN);
OnShow();
}
void UIElement::Hide() {
lv_obj_add_flag(mLvglSelf, LV_OBJ_FLAG_HIDDEN);
OnHide();
}
} // namespace UI