diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.cpp b/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.cpp index bbb3d57..8f10dd6 100644 --- a/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.cpp +++ b/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.cpp @@ -1,26 +1,20 @@ +#include "BrightnessSlider.hpp" #include "DisplaySettings.hpp" -#include "Slider.hpp" using namespace UI::Page; DisplaySettings::DisplaySettings(std::shared_ptr aDisplay) : Base(UI::ID::Pages::DisplaySettings), mDisplay(aDisplay), - mBrightnessSlider( - AddElement(std::make_unique( - [this](auto aNewBrightness) { - mDisplay->setBrightness(aNewBrightness); - }, - 0, 255))) { + mBrightnessSlider(AddElement(std::make_unique(mDisplay))) { SetBgColor(Color::GREY); - auto usableWidth = GetContentWidth(); - mBrightnessSlider->SetWidth(usableWidth - (usableWidth * 0.20f)); - mBrightnessSlider->SetHeight(lv_pct(10)); + mBrightnessSlider->SetWidth(GetContentWidth()); + mBrightnessSlider->SetHeight(50); mBrightnessSlider->AlignTo(this, LV_ALIGN_TOP_MID); } void DisplaySettings::OnShow() { - mBrightnessSlider->SetValue(mDisplay->getBrightness()); + }; void DisplaySettings::OnHide(){ diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.hpp b/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.hpp index 7d73962..4467292 100644 --- a/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.hpp +++ b/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.hpp @@ -3,7 +3,7 @@ #include "PageBase.hpp" namespace UI::Widget { -class Slider; +class BrightnessSlider; } namespace UI::Page { @@ -18,6 +18,6 @@ public: private: std::shared_ptr mDisplay; - Widget::Slider *mBrightnessSlider; + Widget::BrightnessSlider *mBrightnessSlider; }; } // namespace UI::Page diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.cpp b/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.cpp index d617110..086d6a2 100644 --- a/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.cpp +++ b/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.cpp @@ -1,6 +1,7 @@ #include "SettingsPage.hpp" #include "BackgroundScreen.hpp" #include "Button.hpp" +#include "Slider.hpp" #include "Colors.hpp" #include "DisplaySettings.hpp" #include "PopUpScreen.hpp" @@ -30,8 +31,7 @@ void SettingsPage::PushDisplaySettings() { } void SettingsPage::AddSlider() { - auto fakeSlider = std::make_unique( - lv_slider_create(UI::Screen::BackgroundScreen::getLvInstance())); + auto fakeSlider = std::make_unique([](auto data){}); fakeSlider->SetHeight(lv_pct(10)); fakeSlider->SetWidth(GetContentWidth()); if (sliders.empty()) { diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/widget/BrightnessSlider.cpp b/Platformio/OmoteUI/UIs/BasicRefactored/widget/BrightnessSlider.cpp new file mode 100644 index 0000000..72e9003 --- /dev/null +++ b/Platformio/OmoteUI/UIs/BasicRefactored/widget/BrightnessSlider.cpp @@ -0,0 +1,33 @@ +#include "BrightnessSlider.hpp" +#include "Label.hpp" +#include "Slider.hpp" + +using namespace UI::Widget; + + +BrightnessSlider::BrightnessSlider(std::shared_ptr aDisplay): Base(ID::Widgets::BrightnessSlider), + mDisplay(aDisplay), + mSlider(AddElement(std::make_unique( + [this](auto aNewBrightness){ + mDisplay->setBrightness(aNewBrightness); + },0,255))), + mLabel(AddElement(std::make_unique