OMOTE/Platformio/OmoteUI/core/UIElement.hpp
Matthew Colvin 1cc65594a9 Added concept of Background Screen that allows for construction of pages before knowing the final parent.
This will allow for easy creation of "pages" that can be layed out internally and passed to different screens and cleaned up when screens are cleaned up by the screen manager

add set width and height to base elements that allow for easy resizing

Create a settings page and make it red.
Test adding 2 tabs with the Page

this currently does not do anything fantastic on simulator but it sets a strong foundation for managing multiple pages
2023-09-22 19:59:24 -05:00

47 lines
No EOL
1 KiB
C++

#pragma once
#include "UIElementIds.hpp"
#include "lvgl.h"
namespace UI {
class UIElement {
public:
UIElement(lv_obj_t *aLvglSelf, const ID aId = ID());
virtual void SetBgColor(lv_color_t value,
lv_style_selector_t selector = LV_PART_MAIN);
void SetVisiblity(bool aVisibility);
bool IsVisible();
virtual void SetWidth(uint16_t aWidth);
virtual void SetHeight(uint16_t aHeight);
int16_t GetWidth();
int16_t GetHeight();
virtual void AddElement(UIElement *anElement);
ID GetID() { return mId; };
protected:
/// @brief get Lvgl object refernce to use in LVGL APIs
/// @return lvgl object a
lv_obj_t *LvglSelf() { return mLvglSelf; }
/// @brief Show Element
virtual void Show();
/// @brief Hide Element
virtual void Hide();
/// @brief Override in child class to run something after element is shown
virtual void OnShow() = 0;
/// @brief Override in child class to run something after element is hidden
virtual void OnHide() = 0;
private:
lv_obj_t *mLvglSelf;
const ID mId;
};
} // namespace UI