From 2ebea6c269f9679b467a632029ba0675c0032bbf Mon Sep 17 00:00:00 2001 From: tallbl0nde <40382856+tallbl0nde@users.noreply.github.com> Date: Sun, 25 Jul 2021 17:36:49 +0930 Subject: [PATCH] Update Aether and UI --- Application/include/Application.hpp | 13 +- .../include/ui/element/ButtonPicker.hpp | 6 +- Application/include/ui/element/GridItem.hpp | 18 +-- Application/include/ui/element/Image.hpp | 31 +++-- Application/include/ui/element/NumberBox.hpp | 8 +- .../include/ui/element/RoundButton.hpp | 8 +- .../include/ui/element/ScrollableGrid.hpp | 4 +- Application/include/ui/element/Slider.hpp | 8 +- Application/include/ui/element/TextBox.hpp | 8 +- Application/include/ui/element/VSlider.hpp | 8 +- .../include/ui/element/listitem/AlbumSong.hpp | 4 +- .../include/ui/element/listitem/Artist.hpp | 4 +- .../include/ui/element/listitem/File.hpp | 4 +- .../include/ui/element/listitem/Item.hpp | 39 ++---- .../include/ui/element/listitem/More.hpp | 4 +- .../include/ui/element/listitem/Playlist.hpp | 4 +- .../include/ui/element/listitem/Song.hpp | 4 +- .../include/ui/overlay/ComboPicker.hpp | 4 +- Application/include/ui/overlay/Equalizer.hpp | 5 +- Application/include/ui/screen/Fullscreen.hpp | 2 +- Application/include/utils/Splash.hpp | 4 +- Application/libs/Aether | 2 +- Application/source/Application.cpp | 50 +++---- Application/source/Sysmodule.cpp | 2 +- Application/source/Updater.cpp | 2 +- .../source/db/migrations/7_AddAudioFormat.cpp | 2 +- Application/source/ui/Theme.cpp | 10 +- .../source/ui/element/ButtonPicker.cpp | 12 +- Application/source/ui/element/GridItem.cpp | 126 ++++++++---------- .../source/ui/element/HorizontalList.cpp | 6 +- Application/source/ui/element/Image.cpp | 31 ++++- Application/source/ui/element/MenuButton.cpp | 18 +-- Application/source/ui/element/NumberBox.cpp | 22 +-- Application/source/ui/element/Player.cpp | 34 ++--- Application/source/ui/element/RoundButton.cpp | 14 +- .../source/ui/element/ScrollableGrid.cpp | 27 ++-- Application/source/ui/element/SideButton.cpp | 18 +-- Application/source/ui/element/Slider.cpp | 31 +++-- Application/source/ui/element/TextBox.cpp | 22 +-- Application/source/ui/element/VSlider.cpp | 35 +++-- .../source/ui/element/listitem/AlbumSong.cpp | 32 +++-- .../source/ui/element/listitem/Artist.cpp | 28 ++-- .../source/ui/element/listitem/File.cpp | 28 ++-- .../source/ui/element/listitem/Item.cpp | 93 ++++--------- .../source/ui/element/listitem/More.cpp | 7 +- .../source/ui/element/listitem/Playlist.cpp | 45 ++++--- .../source/ui/element/listitem/Song.cpp | 40 ++++-- Application/source/ui/frame/Album.cpp | 24 ++-- Application/source/ui/frame/AlbumInfo.cpp | 6 +- Application/source/ui/frame/Albums.cpp | 20 +-- Application/source/ui/frame/Artist.cpp | 20 +-- Application/source/ui/frame/ArtistInfo.cpp | 4 +- Application/source/ui/frame/Artists.cpp | 14 +- Application/source/ui/frame/Playlist.cpp | 26 ++-- Application/source/ui/frame/PlaylistInfo.cpp | 6 +- Application/source/ui/frame/Playlists.cpp | 20 +-- Application/source/ui/frame/Queue.cpp | 22 +-- Application/source/ui/frame/Search.cpp | 50 +++---- Application/source/ui/frame/Songs.cpp | 16 +-- .../source/ui/frame/settings/About.cpp | 2 +- .../source/ui/frame/settings/AppAdvanced.cpp | 8 +- .../ui/frame/settings/AppAppearance.cpp | 6 +- .../source/ui/frame/settings/AppGeneral.cpp | 6 +- .../source/ui/frame/settings/AppSearch.cpp | 10 +- .../source/ui/frame/settings/Frame.cpp | 4 +- .../source/ui/frame/settings/SysGeneral.cpp | 10 +- .../source/ui/overlay/AddToPlaylist.cpp | 6 +- Application/source/ui/overlay/ComboPicker.cpp | 30 ++--- Application/source/ui/overlay/Equalizer.cpp | 44 ++---- Application/source/ui/overlay/FileBrowser.cpp | 4 +- Application/source/ui/overlay/ItemMenu.cpp | 6 +- Application/source/ui/overlay/NewPlaylist.cpp | 8 +- Application/source/ui/overlay/ProgressBox.cpp | 4 +- Application/source/ui/overlay/SortBy.cpp | 4 +- Application/source/ui/screen/Fullscreen.cpp | 54 ++++---- Application/source/ui/screen/Home.cpp | 26 ++-- Application/source/ui/screen/Settings.cpp | 20 +-- Application/source/ui/screen/Splash.cpp | 4 +- Application/source/ui/screen/Update.cpp | 2 +- Application/source/utils/Curl.cpp | 2 +- Application/source/utils/Splash.cpp | 48 ++++--- Overlay/source/gui/Error.cpp | 2 +- 82 files changed, 705 insertions(+), 760 deletions(-) diff --git a/Application/include/Application.hpp b/Application/include/Application.hpp index 8710797..71c9eeb 100644 --- a/Application/include/Application.hpp +++ b/Application/include/Application.hpp @@ -28,8 +28,8 @@ namespace Main { // and objects used through the app class Application { private: - // Display object used for rendering - Aether::Display * display; + // Aether window used for UI + Aether::Window * window; // Screens of the app ScreenID screenID; @@ -63,7 +63,7 @@ namespace Main { // Constructor inits Aether, screens + other objects Application(); - // Wrappers for display functions + // Wrappers for window functions void setHoldDelay(int); void setHighlightAnimation(std::function); @@ -75,7 +75,6 @@ namespace Main { void setScreen(ScreenID); void pushScreen(); void popScreen(); - void dropScreen(); void updateScreenTheme(); // Helper functions for database @@ -96,9 +95,9 @@ namespace Main { // Returns theme pointer Theme * theme(); - // Handles display loop + // Handles window loop void run(); - // Call to stop display loop (set true to force close) + // Call to stop window loop (set true to force close) void exit(const bool); // Destructor frees memory and quits Aether @@ -106,4 +105,4 @@ namespace Main { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/ButtonPicker.hpp b/Application/include/ui/element/ButtonPicker.hpp index 394d899..c9df830 100644 --- a/Application/include/ui/element/ButtonPicker.hpp +++ b/Application/include/ui/element/ButtonPicker.hpp @@ -24,8 +24,8 @@ namespace CustomElm { // Override to intercept button press and update containing button bool handleEvent(Aether::InputEvent *); void setSelected(bool); - SDL_Texture * renderHighlight(); - SDL_Texture * renderSelection(); + Aether::Drawable * renderHighlight(); + Aether::Drawable * renderSelection(); // Get the currently 'chosen' button Aether::Button selectedButton(); @@ -39,4 +39,4 @@ namespace CustomElm { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/GridItem.hpp b/Application/include/ui/element/GridItem.hpp index 041bcab..bf6dfa8 100644 --- a/Application/include/ui/element/GridItem.hpp +++ b/Application/include/ui/element/GridItem.hpp @@ -4,13 +4,7 @@ #include "Aether/Aether.hpp" namespace CustomElm { - class GridItem : public Aether::Element { - enum RenderingStatus { - Waiting, // Not rendering and no textures - InProgress, // Rendering but no textures - Done // Rendered and textures done - }; - + class GridItem : public Aether::AsyncItem { private: // Artist image Aether::Image * image; @@ -24,11 +18,11 @@ namespace CustomElm { std::function moreCallback; bool callMore; - // Status of threaded elements - RenderingStatus isRendering; - // Positions items after rendering - void positionItems(); + void positionElements(); + + // Helper to update text elements + void processText(Aether::Text * &, std::function); public: // Constructor sets up elements and takes path to image @@ -59,4 +53,4 @@ namespace CustomElm { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/Image.hpp b/Application/include/ui/element/Image.hpp index b62425a..9785724 100644 --- a/Application/include/ui/element/Image.hpp +++ b/Application/include/ui/element/Image.hpp @@ -3,18 +3,33 @@ #include "Aether/Aether.hpp" -// Extends Aether::Texture to allow Image creation from an SDL_Surface -// It thus is created with RenderType::OnCreate namespace CustomElm { - class Image : public Aether::Texture { + // Class extending Aether's element providing a basic Image implementation + // in order to allow instantiation from a drawable. + class Image : public Aether::Element { private: - // Does nothing but is required to be instantiated - void generateSurface(); + // Colour to tint image with + Aether::Colour colour_; + + // Drawable to render + Aether::Drawable * drawable; public: - // Constructor takes x, y, and surface pointer - Image(int, int, SDL_Surface *); + // Constructs a new image element using the provided drawable. + Image(int x, int y, Aether::Drawable * drawable); + + // Return the colour of the image. + Aether::Colour colour(); + + // Set the colour of the image. + void setColour(const Aether::Colour &); + + // Render the image. + void render(); + + // Delete the drawable. + ~Image(); }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/NumberBox.hpp b/Application/include/ui/element/NumberBox.hpp index 6b98226..97cc4cf 100644 --- a/Application/include/ui/element/NumberBox.hpp +++ b/Application/include/ui/element/NumberBox.hpp @@ -49,10 +49,10 @@ namespace CustomElm { int value(); // Custom highlight/select graphics - SDL_Texture * renderHighlightBG(); - SDL_Texture * renderHighlight(); - SDL_Texture * renderSelection(); + Aether::Drawable * renderHighlightBG(); + Aether::Drawable * renderHighlight(); + Aether::Drawable * renderSelection(); }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/RoundButton.hpp b/Application/include/ui/element/RoundButton.hpp index 5e4c619..299f155 100644 --- a/Application/include/ui/element/RoundButton.hpp +++ b/Application/include/ui/element/RoundButton.hpp @@ -29,10 +29,10 @@ namespace CustomElm { void setH(int); // Override rendering selection and highlight to make it round - SDL_Texture * renderHighlightBG(); - SDL_Texture * renderHighlight(); - SDL_Texture * renderSelection(); + Aether::Drawable * renderHighlightBG(); + Aether::Drawable * renderHighlight(); + Aether::Drawable * renderSelection(); }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/ScrollableGrid.hpp b/Application/include/ui/element/ScrollableGrid.hpp index 934a0be..22be9bf 100644 --- a/Application/include/ui/element/ScrollableGrid.hpp +++ b/Application/include/ui/element/ScrollableGrid.hpp @@ -18,7 +18,7 @@ namespace CustomElm { int scrollVelocity; int scrollPos; int maxScrollPos; - SDL_Texture * scrollBar; + Aether::Drawable * scrollBar; Aether::Colour scrollBarColour; bool showScrollBar_; int touchY; @@ -59,4 +59,4 @@ namespace CustomElm { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/Slider.hpp b/Application/include/ui/element/Slider.hpp index 041c66f..b7097f6 100644 --- a/Application/include/ui/element/Slider.hpp +++ b/Application/include/ui/element/Slider.hpp @@ -41,10 +41,10 @@ namespace CustomElm { void setBarH(int); // We only highlight around the knob! - SDL_Texture * renderHighlightBG(); - SDL_Texture * renderHighlight(); - SDL_Texture * renderSelection(); + Aether::Drawable * renderHighlightBG(); + Aether::Drawable * renderHighlight(); + Aether::Drawable * renderSelection(); }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/TextBox.hpp b/Application/include/ui/element/TextBox.hpp index d57727a..5cdddb1 100644 --- a/Application/include/ui/element/TextBox.hpp +++ b/Application/include/ui/element/TextBox.hpp @@ -44,10 +44,10 @@ namespace CustomElm { std::string string(); // Custom highlight/select graphics - SDL_Texture * renderHighlightBG(); - SDL_Texture * renderHighlight(); - SDL_Texture * renderSelection(); + Aether::Drawable * renderHighlightBG(); + Aether::Drawable * renderHighlight(); + Aether::Drawable * renderSelection(); }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/VSlider.hpp b/Application/include/ui/element/VSlider.hpp index 173a845..d53b488 100644 --- a/Application/include/ui/element/VSlider.hpp +++ b/Application/include/ui/element/VSlider.hpp @@ -33,10 +33,10 @@ namespace CustomElm { void setKnobColour(const Aether::Colour &); // Override to only highlight the knob - SDL_Texture * renderHighlightBG(); - SDL_Texture * renderHighlight(); - SDL_Texture * renderSelection(); + Aether::Drawable * renderHighlightBG(); + Aether::Drawable * renderHighlight(); + Aether::Drawable * renderSelection(); }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/listitem/AlbumSong.hpp b/Application/include/ui/element/listitem/AlbumSong.hpp index fd637ff..a5f0a3c 100644 --- a/Application/include/ui/element/listitem/AlbumSong.hpp +++ b/Application/include/ui/element/listitem/AlbumSong.hpp @@ -11,7 +11,7 @@ namespace CustomElm::ListItem { Aether::Text * title; Aether::Text * artist; Aether::Text * length; - void positionItems(); + void positionElements(); public: // Constructor sets up elements @@ -27,4 +27,4 @@ namespace CustomElm::ListItem { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/listitem/Artist.hpp b/Application/include/ui/element/listitem/Artist.hpp index f729d3a..684f281 100644 --- a/Application/include/ui/element/listitem/Artist.hpp +++ b/Application/include/ui/element/listitem/Artist.hpp @@ -10,7 +10,7 @@ namespace CustomElm::ListItem { // Elements Aether::Image * image; Aether::Text * name; - void positionItems(); + void positionElements(); public: // Constructor accepts path to image @@ -25,4 +25,4 @@ namespace CustomElm::ListItem { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/listitem/File.hpp b/Application/include/ui/element/listitem/File.hpp index 904a3e0..f5ea76a 100644 --- a/Application/include/ui/element/listitem/File.hpp +++ b/Application/include/ui/element/listitem/File.hpp @@ -11,7 +11,7 @@ namespace CustomElm::ListItem { // Elements Aether::Image * icon; Aether::Text * name; - void positionItems(); + void positionElements(); public: // Constructor takes name, if directory and callback @@ -26,4 +26,4 @@ namespace CustomElm::ListItem { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/listitem/Item.hpp b/Application/include/ui/element/listitem/Item.hpp index 1977143..591f0b0 100644 --- a/Application/include/ui/element/listitem/Item.hpp +++ b/Application/include/ui/element/listitem/Item.hpp @@ -4,33 +4,18 @@ #include "Aether/Aether.hpp" namespace CustomElm::ListItem { - // Item extends a base Aether::Element in order to provide automatic 'deferring' - // functionality for items in a list. It does this by having a variable which - // keeps track of when all it's textures are rendered. - class Item : public Aether::Element { + // Item extends a base Aether::AsyncItem to show a line either side of + // the element. + class Item : public Aether::AsyncItem { private: - // Status of texture rendering - enum class Status { - Waiting, // Not rendering and outside of threshold - InProgress, // Rendering all children textures - Done // Textures are visible and within threshold - }; - Status renderStatus; - // Static line texture used to separate all items (instead of having multiple) - static SDL_Texture * line; - Aether::Colour lineColour; - - // Vector of child textures to watch - std::vector textures; + static Aether::Drawable * line; - // Children must implement this function which positions items - // once they have all finished rendering - virtual void positionItems() = 0; + // Note: positionElements() isn't defined by this class! protected: - // Mark a texture to be watched (also adds as child) - void watchTexture(Aether::Texture *); + // Helper to update text + void processText(Aether::Text * &, std::function); public: // The constructor will create a line texture if one isn't present @@ -38,17 +23,11 @@ namespace CustomElm::ListItem { Item(int = 100); // Set colour to tint line with - void setLineColour(Aether::Colour); - - // Check and update texture rendering things - void update(uint32_t); + void setLineColour(const Aether::Colour &); // Render lines before children void render(); - - // Call positionItems on width change - void setW(int); }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/listitem/More.hpp b/Application/include/ui/element/listitem/More.hpp index 1abfcb0..deca75e 100644 --- a/Application/include/ui/element/listitem/More.hpp +++ b/Application/include/ui/element/listitem/More.hpp @@ -11,6 +11,8 @@ namespace CustomElm::ListItem { std::function moreCallback; bool touchedMore; + // Note: positionElements() isn't defined by this class! + protected: //'More' image (child should position it) Aether::Image * more; @@ -31,4 +33,4 @@ namespace CustomElm::ListItem { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/listitem/Playlist.hpp b/Application/include/ui/element/listitem/Playlist.hpp index 139144f..ac61abd 100644 --- a/Application/include/ui/element/listitem/Playlist.hpp +++ b/Application/include/ui/element/listitem/Playlist.hpp @@ -10,7 +10,7 @@ namespace CustomElm::ListItem { Aether::Image * image; Aether::Text * name; Aether::Text * songs; - void positionItems(); + void positionElements(); public: // Constructor sets up elements (takes path to image) @@ -27,4 +27,4 @@ namespace CustomElm::ListItem { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/element/listitem/Song.hpp b/Application/include/ui/element/listitem/Song.hpp index 55020b7..47bdc8b 100644 --- a/Application/include/ui/element/listitem/Song.hpp +++ b/Application/include/ui/element/listitem/Song.hpp @@ -12,7 +12,7 @@ namespace CustomElm::ListItem { Aether::Text * artist; Aether::Text * album; Aether::Text * length; - void positionItems(); + void positionElements(); public: // Constructor sets up elements @@ -27,4 +27,4 @@ namespace CustomElm::ListItem { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/overlay/ComboPicker.hpp b/Application/include/ui/overlay/ComboPicker.hpp index e903909..cc53cb3 100644 --- a/Application/include/ui/overlay/ComboPicker.hpp +++ b/Application/include/ui/overlay/ComboPicker.hpp @@ -24,7 +24,7 @@ namespace CustomOvl { Aether::Text * title; Aether::Rectangle * topR; Aether::Rectangle * bottomR; - Aether::Controls * ctrl; + Aether::ControlBar * ctrl; Aether::Text * tip; Aether::BorderButton * ok; @@ -56,4 +56,4 @@ namespace CustomOvl { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/overlay/Equalizer.hpp b/Application/include/ui/overlay/Equalizer.hpp index a47c868..6c418f7 100644 --- a/Application/include/ui/overlay/Equalizer.hpp +++ b/Application/include/ui/overlay/Equalizer.hpp @@ -12,8 +12,7 @@ namespace CustomOvl { std::array sliders; std::array sliderIndexes; - Aether::ControlItem * reset, * apply, * back, * ok; - Aether::Controls * ctrl; // Pointer to controls + Aether::ControlBar * ctrl; // Pointer to controls Aether::List * list; // Pointer to list Aether::Rectangle * rect; // Pointer to main rectangle Aether::Rectangle * top; // Pointer to top rectangle @@ -54,4 +53,4 @@ namespace CustomOvl { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/ui/screen/Fullscreen.hpp b/Application/include/ui/screen/Fullscreen.hpp index f968be0..48fbc34 100644 --- a/Application/include/ui/screen/Fullscreen.hpp +++ b/Application/include/ui/screen/Fullscreen.hpp @@ -98,4 +98,4 @@ namespace Screen { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/include/utils/Splash.hpp b/Application/include/utils/Splash.hpp index 417a1cf..e73b25f 100644 --- a/Application/include/utils/Splash.hpp +++ b/Application/include/utils/Splash.hpp @@ -19,10 +19,10 @@ namespace Utils::Splash { Aether::Colour changeLightness(Aether::Colour, int); // Returns the above struct filled with colours for the given image - Palette getPaletteForSurface(SDL_Surface *); + Palette getPaletteForDrawable(Aether::Drawable *); // Return a colour interpolated between the two provided colours at the given position (0 - 1) Aether::Colour interpolateColours(const Aether::Colour &, const Aether::Colour &, double); }; -#endif \ No newline at end of file +#endif diff --git a/Application/libs/Aether b/Application/libs/Aether index cb1cefd..91536eb 160000 --- a/Application/libs/Aether +++ b/Application/libs/Aether @@ -1 +1 @@ -Subproject commit cb1cefd2c6ce4fac2ccb03532c1760651e9e01d2 +Subproject commit 91536eba79cd3111d32e3667c16aea6bba65ae36 diff --git a/Application/source/Application.cpp b/Application/source/Application.cpp index 5e21a1f..3d74a1d 100644 --- a/Application/source/Application.cpp +++ b/Application/source/Application.cpp @@ -39,16 +39,22 @@ namespace Main { this->sysThread = std::async(std::launch::async, &Sysmodule::process, this->sysmodule_); // Create Aether instance - Aether::ThreadPool::setMaxThreads(8); - this->display = new Aether::Display(); - this->display->setBackgroundColour(0, 0, 0); - this->display->setFont("romfs:/Quicksand.ttf"); - this->display->setFontSpacing(0.9); - this->display->setHighlightColours(Aether::Colour{255, 255, 255, 0}, this->theme_->selected()); + this->window = new Aether::Window("TriPlayer", 1280, 720, [](const std::string msg, const bool important) { + if (important) { + Log::writeError("[AETHER] " + msg); + } else { + Log::writeInfo("[AETHER] " + msg); + } + }); + this->window->setBackgroundColour(Aether::Colour{0, 0, 0, 0}); + this->window->setFont("romfs:/Quicksand.ttf"); + this->window->setFontSpacing(0.9); this->setHighlightAnimation(nullptr); - this->display->setFadeIn(); - this->display->setFadeOut(); - // this->display->setShowFPS(true); + this->window->setHighlightBackground(Aether::Colour{255, 255, 255, 0}); + this->window->setHighlightOverlay(this->theme_->selected()); + this->window->setFadeIn(true); + this->window->setFadeOut(true); + this->window->showDebugInfo(true); this->exitPrompt = nullptr; // Setup screens @@ -85,7 +91,7 @@ namespace Main { this->exitPrompt->close(); }); this->exitPrompt->addRightButton("Common.Exit"_lang, [this]() { - this->display->exit(); + this->window->exit(); }); this->exitPrompt->setTextColour(this->theme_->accent()); Aether::Element * body = new Aether::Element(0, 0, 700); @@ -98,7 +104,7 @@ namespace Main { } void Application::setHoldDelay(int i) { - this->display->setHoldDelay(i); + this->window->setHoldDelay(i); } void Application::setHighlightAnimation(std::function f) { @@ -106,33 +112,29 @@ namespace Main { if (f == nullptr) { f = this->theme_->highlightFunc(); } - this->display->setHighlightAnimation(f); + this->window->setHighlightAnimation(f); } void Application::addOverlay(Aether::Overlay * o) { - this->display->addOverlay(o); + this->window->addOverlay(o); } void Application::setScreen(ScreenID s) { this->screenID = s; - this->display->setScreen(this->screens[static_cast(s)]); + this->window->showScreen(this->screens[static_cast(s)]); } void Application::pushScreen() { this->screenIDs.push(this->screenID); - this->display->pushScreen(); + this->window->pushScreen(); } void Application::popScreen() { - this->display->popScreen(); + this->window->popScreen(); this->screenID = this->screenIDs.top(); this->screenIDs.pop(); } - void Application::dropScreen() { - this->display->dropScreen(); - } - void Application::updateScreenTheme() { for (Screen::Screen * s : this->screens) { s->updateColours(); @@ -177,7 +179,7 @@ namespace Main { void Application::run() { // Do main loop - while (this->display->loop()) { + while (this->window->loop()) { } } @@ -190,7 +192,7 @@ namespace Main { // Otherwise just exit } else { - this->display->exit(); + this->window->exit(); } } @@ -221,7 +223,7 @@ namespace Main { delete this->exitPrompt; // Cleanup Aether after screens are deleted - delete this->display; + delete this->window; // Disconnect from sysmodule this->sysmodule_->exit(); @@ -236,4 +238,4 @@ namespace Main { // The database will be closed here as the wrapper goes out of scope } -}; \ No newline at end of file +}; diff --git a/Application/source/Sysmodule.cpp b/Application/source/Sysmodule.cpp index 9c32fa7..d037aaa 100644 --- a/Application/source/Sysmodule.cpp +++ b/Application/source/Sysmodule.cpp @@ -669,4 +669,4 @@ Sysmodule::~Sysmodule() { if (this->connected_) { TriPlayer::exit(); } -} \ No newline at end of file +} diff --git a/Application/source/Updater.cpp b/Application/source/Updater.cpp index 038f100..1eb7809 100644 --- a/Application/source/Updater.cpp +++ b/Application/source/Updater.cpp @@ -210,4 +210,4 @@ bool Updater::downloadUpdate(std::function callback) } return Utils::Curl::downloadToFile(this->downloadUrl, Path::App::UpdateFile, callback); -} \ No newline at end of file +} diff --git a/Application/source/db/migrations/7_AddAudioFormat.cpp b/Application/source/db/migrations/7_AddAudioFormat.cpp index ac146c7..d7ffa07 100644 --- a/Application/source/db/migrations/7_AddAudioFormat.cpp +++ b/Application/source/db/migrations/7_AddAudioFormat.cpp @@ -22,4 +22,4 @@ namespace Migration { return ""; }; -} \ No newline at end of file +} diff --git a/Application/source/ui/Theme.cpp b/Application/source/ui/Theme.cpp index acc2c95..c8929e8 100644 --- a/Application/source/ui/Theme.cpp +++ b/Application/source/ui/Theme.cpp @@ -155,10 +155,10 @@ std::function Theme::highlightFunc() { return [h1, h2](uint32_t t) { Aether::Colour col = {0, 0, 0, 0}; - col.r = h1.r + ((h2.r - h1.r) * (0.5 * sin(1.8 * std::numbers::pi * (t/1000.0)) + 0.5)); - col.g = h1.g + ((h2.g - h1.g) * (0.5 * sin(1.8 * std::numbers::pi * (t/1000.0)) + 0.5)); - col.b = h1.b + ((h2.b - h1.b) * (0.5 * sin(1.8 * std::numbers::pi * (t/1000.0)) + 0.5)); - col.a = h1.a + ((h2.a - h1.a) * (0.5 * sin(1.8 * std::numbers::pi * (t/1000.0)) + 0.5)); + col.setR(h1.r() + ((h2.r() - h1.r()) * (0.5 * sin(1.8 * std::numbers::pi * (t/1000.0)) + 0.5))); + col.setG(h1.g() + ((h2.g() - h1.g()) * (0.5 * sin(1.8 * std::numbers::pi * (t/1000.0)) + 0.5))); + col.setB(h1.b() + ((h2.b() - h1.b()) * (0.5 * sin(1.8 * std::numbers::pi * (t/1000.0)) + 0.5))); + col.setA(h1.a() + ((h2.a() - h1.a()) * (0.5 * sin(1.8 * std::numbers::pi * (t/1000.0)) + 0.5))); return col; }; -} \ No newline at end of file +} diff --git a/Application/source/ui/element/ButtonPicker.cpp b/Application/source/ui/element/ButtonPicker.cpp index ed3f7a9..c6776cd 100644 --- a/Application/source/ui/element/ButtonPicker.cpp +++ b/Application/source/ui/element/ButtonPicker.cpp @@ -68,17 +68,17 @@ namespace CustomElm { } } - SDL_Texture * ButtonPicker::renderHighlight() { + Aether::Drawable * ButtonPicker::renderHighlight() { // Only render if not selected if (this->selected()) { - return nullptr; + return new Aether::Drawable(); } - return SDLHelper::renderRoundRect(this->w() + 4, this->h() + 4, radius, this->hiSize); + return this->renderer->renderRoundRectTexture(this->w() + 4, this->h() + 4, radius, this->hiSize); } - SDL_Texture * ButtonPicker::renderSelection() { + Aether::Drawable * ButtonPicker::renderSelection() { // Hide selection - return nullptr; + return new Aether::Drawable(); } Aether::Button ButtonPicker::selectedButton() { @@ -99,4 +99,4 @@ namespace CustomElm { this->inactive = c; this->setSelected(this->selected()); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/GridItem.cpp b/Application/source/ui/element/GridItem.cpp index a0d4fd7..0c58b29 100644 --- a/Application/source/ui/element/GridItem.cpp +++ b/Application/source/ui/element/GridItem.cpp @@ -1,40 +1,36 @@ #include "ui/element/GridItem.hpp" // Font sizes -#define MAIN_FONT_SIZE 18 -#define SUB_FONT_SIZE 24 +#define MAIN_FONT_SIZE 24 +#define SUB_FONT_SIZE 18 // Dimensions #define IMAGE_SIZE 150 #define WIDTH 250 #define HEIGHT 230 -// Amount either side of screen to keep textures (in pixels) -#define TEX_THRESHOLD 2000 // Padding either side of name #define SIDE_PADDING 35 namespace CustomElm { - GridItem::GridItem(std::string path) : Element(0, 0, WIDTH, HEIGHT) { - this->image = new Aether::Image(this->x(), this->y(), path, 1, 1, Aether::RenderType::Deferred); + GridItem::GridItem(std::string path) : AsyncItem() { + // Need to call base so our overridden method isn't called + AsyncItem::setW(WIDTH); + AsyncItem::setH(HEIGHT); + + // Create elements + this->image = new Aether::Image(this->x(), this->y(), path, Aether::Render::Wait); this->addElement(this->image); - this->image->setHidden(true); - this->main = new Aether::Text(this->x(), this->y(), "", SUB_FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->main->setHidden(true); - this->main->setScrollSpeed(35); - this->main->setScrollWaitTime(500); - this->addElement(this->main); - this->sub = new Aether::Text(this->x(), this->y(), "", MAIN_FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->sub->setHidden(true); - this->sub->setScrollSpeed(35); - this->sub->setScrollWaitTime(500); - this->addElement(this->sub); - this->dots = new Aether::Image(this->x(), this->y(), "romfs:/icons/verticaldots.png", 1, 1, Aether::RenderType::Deferred); + this->addTexture(this->image); + + this->main = new Aether::Text(this->x(), this->y(), "", SUB_FONT_SIZE, Aether::Render::Wait); + this->sub = new Aether::Text(this->x(), this->y(), "", MAIN_FONT_SIZE, Aether::Render::Wait); + + this->dots = new Aether::Image(this->x(), this->y(), "romfs:/icons/verticaldots.png", Aether::Render::Wait); this->addElement(this->dots); - this->dots->setHidden(true); - this->isRendering = Waiting; + this->addTexture(this->dots); } void GridItem::setInactive() { - Element::setInactive(); + AsyncItem::setInactive(); this->callMore = false; } @@ -65,58 +61,34 @@ namespace CustomElm { } } - return Element::handleEvent(e); + return AsyncItem::handleEvent(e); } - void GridItem::update(uint32_t dt) { - Element::update(dt); + void GridItem::processText(Aether::Text * & text, std::function getNew) { + // Remove original + this->removeTexture(text); + this->removeElement(text); - // Scroll if this element is selected - if (this->highlighted() && !this->main->scroll()) { - this->main->setScroll(true); - this->sub->setScroll(true); - } else if (!this->highlighted() && this->main->scroll()) { - this->main->setScroll(false); - this->sub->setScroll(false); + // Get (and assign) new text object + text = getNew(); + + // Don't add if empty string + if (!text->string().empty()) { + this->addElement(text); + this->addTexture(text); } + } - switch (this->isRendering) { - case Waiting: - // Waiting to render - check position and start if within threshold - if (this->x() > -TEX_THRESHOLD && this->x() + this->w() < 1280 + TEX_THRESHOLD && this->y() + this->h() > -TEX_THRESHOLD && this->y() < 720 + TEX_THRESHOLD) { - this->image->startRendering(); - this->main->startRendering(); - this->sub->startRendering(); - this->dots->startRendering(); - this->isRendering = InProgress; - } - break; - - case InProgress: - // Check if all are ready and if so move show and change to done - if (this->image->textureReady() && this->main->textureReady() && this->sub->textureReady() && this->dots->textureReady()) { - this->positionItems(); - this->image->setHidden(false); - this->main->setHidden(false); - this->sub->setHidden(false); - this->dots->setHidden(false); - this->isRendering = Done; - } - - case Done: - // Check if move outside of threshold and if so remove texture to save memory - if (this->x() < -TEX_THRESHOLD || this->x() + this->w() > 1280 + TEX_THRESHOLD || this->y() + this->h() < -TEX_THRESHOLD || this->y() > 720 + TEX_THRESHOLD) { - this->image->destroyTexture(); - this->main->destroyTexture(); - this->sub->destroyTexture(); - this->dots->destroyTexture(); - this->image->setHidden(true); - this->main->setHidden(true); - this->sub->setHidden(true); - this->dots->setHidden(true); - this->isRendering = Waiting; - } - break; + void GridItem::update(uint32_t dt) { + AsyncItem::update(dt); + + // Scroll if this element is selected + if (this->highlighted() && !this->main->canScroll()) { + this->main->setCanScroll(true); + this->sub->setCanScroll(true); + } else if (!this->highlighted() && this->main->canScroll()) { + this->main->setCanScroll(false); + this->sub->setCanScroll(false); } } @@ -125,11 +97,21 @@ namespace CustomElm { } void GridItem::setMainString(std::string s) { - this->main->setString(s); + this->processText(this->main, [this, s]() -> Aether::Text * { + Aether::Text * t = new Aether::Text(this->x(), this->y(), s, MAIN_FONT_SIZE, Aether::Render::Wait); + t->setScrollPause(500); + t->setScrollSpeed(35); + return t; + }); } void GridItem::setSubString(std::string s) { - this->sub->setString(s); + this->processText(this->sub, [this, s]() -> Aether::Text * { + Aether::Text * t = new Aether::Text(this->x(), this->y(), s, SUB_FONT_SIZE, Aether::Render::Wait); + t->setScrollPause(500); + t->setScrollSpeed(35); + return t; + }); } void GridItem::setDotsColour(Aether::Colour c) { @@ -144,7 +126,7 @@ namespace CustomElm { this->sub->setColour(c); } - void GridItem::positionItems() { + void GridItem::positionElements() { this->image->setXY(this->x() + (this->w() - IMAGE_SIZE)/2, this->y() + 5); this->image->setWH(IMAGE_SIZE, IMAGE_SIZE); @@ -166,4 +148,4 @@ namespace CustomElm { this->dots->setXY(this->x() + this->w() - 20, this->sub->y() - 2 - (this->dots->h())/2); } -} \ No newline at end of file +} diff --git a/Application/source/ui/element/HorizontalList.cpp b/Application/source/ui/element/HorizontalList.cpp index 3b38b62..3058fa8 100644 --- a/Application/source/ui/element/HorizontalList.cpp +++ b/Application/source/ui/element/HorizontalList.cpp @@ -233,13 +233,13 @@ namespace CustomElm { void HorizontalList::render() { // Set clip rectangle to match position + size - SDLHelper::setClip(this->x(), this->y(), this->x() + this->w(), this->y() + this->h()); + this->renderer->setClipArea(this->x(), this->y(), this->x() + this->w(), this->y() + this->h()); // Render children Container::render(); // Remove clip rectangle - SDLHelper::resetClip(); + this->renderer->resetClipArea(); } void HorizontalList::setW(int w) { @@ -253,4 +253,4 @@ namespace CustomElm { this->children[i]->setH(this->h() - 2*Y_PADDING); } } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/Image.cpp b/Application/source/ui/element/Image.cpp index bd7e238..74d7422 100644 --- a/Application/source/ui/element/Image.cpp +++ b/Application/source/ui/element/Image.cpp @@ -1,13 +1,32 @@ #include "ui/element/Image.hpp" namespace CustomElm { - Image::Image(int x, int y, SDL_Surface * s) : Aether::Texture(x, y, Aether::RenderType::OnCreate){ - // Convert the surface immediately - this->surface = s; - this->convertSurface(); + Image::Image(int x, int y, Aether::Drawable * drawable) : Aether::Element(x, y, drawable->width(), drawable->height()) { + this->colour_ = Aether::Colour(255, 255, 255, 255); + this->drawable = drawable; + this->drawable->convertToTexture(); + this->drawable->setColour(this->colour_); } - void Image::generateSurface() { + Aether::Colour Image::colour() { + return this->colour_; + } + + void Image::setColour(const Aether::Colour & col) { + this->colour_ = col; + this->drawable->setColour(col); + } + + void Image::render() { + if (this->hidden()) { + return; + } + + this->drawable->render(this->x(), this->y(), this->w(), this->h()); + Element::render(); + } + Image::~Image() { + delete this->drawable; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/MenuButton.cpp b/Application/source/ui/element/MenuButton.cpp index 53fe5f4..cdaa35d 100644 --- a/Application/source/ui/element/MenuButton.cpp +++ b/Application/source/ui/element/MenuButton.cpp @@ -9,28 +9,28 @@ namespace CustomElm { MenuButton::MenuButton() : Element(0, 0, 100, HEIGHT) { this->icon = nullptr; this->text = new Aether::Text(this->x() + 55, this->y() + this->h()/2, "", 24); - this->text->setScroll(false); + this->text->setCanScroll(false); + this->text->setScrollPause(1000); this->text->setScrollSpeed(60); - this->text->setScrollWaitTime(1000); this->addElement(this->text); } void MenuButton::positionItems() { int maxW = (this->x() + this->w()) - this->text->x() - HEIGHT/4; - if (this->text->texW() > maxW) { + if (this->text->textureWidth() > maxW) { this->text->setW(maxW); } else { - this->text->setW(this->text->texW()); + this->text->setW(this->text->textureWidth()); } } void MenuButton::update(uint32_t dt) { Element::update(dt); - if (this->highlighted() && !this->text->scroll()) { - this->text->setScroll(true); - } else if (!this->highlighted() && this->text->scroll()) { - this->text->setScroll(false); + if (this->highlighted() && !this->text->canScroll()) { + this->text->setCanScroll(true); + } else if (!this->highlighted() && this->text->canScroll()) { + this->text->setCanScroll(false); } } @@ -62,4 +62,4 @@ namespace CustomElm { Element::setW(w); this->positionItems(); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/NumberBox.cpp b/Application/source/ui/element/NumberBox.cpp index 9b3be7b..e364eac 100644 --- a/Application/source/ui/element/NumberBox.cpp +++ b/Application/source/ui/element/NumberBox.cpp @@ -24,7 +24,7 @@ namespace CustomElm { this->conf.allowDecimal = true; // Set callback to open keyboard - this->setCallback([this]() { + this->onPress([this]() { this->openNumpad(); }); @@ -47,11 +47,11 @@ namespace CustomElm { // Position and cut off if too long this->text->setY(this->y() + (this->h() - this->text->h())/2); int wid = (this->rect->x() + this->rect->w()) - this->text->x() - PADDING; - if (this->text->texW() > wid) { - this->text->setMask(0, 0, wid, this->text->texH()); + if (this->text->textureWidth() > wid) { + this->text->setMask(0, 0, wid, this->text->textureHeight()); this->text->setW(wid); } else { - this->text->setMask(0, 0, this->text->texW(), this->text->texH()); + this->text->setMask(0, 0, this->text->textureWidth(), this->text->textureHeight()); } } @@ -92,16 +92,16 @@ namespace CustomElm { return std::stoi(this->text->string()); } - SDL_Texture * NumberBox::renderHighlightBG() { + Aether::Drawable * NumberBox::renderHighlightBG() { // No background - return nullptr; + return new Aether::Drawable(); } - SDL_Texture * NumberBox::renderHighlight() { - return SDLHelper::renderRoundRect(this->w() + 2*(this->hiSize), this->h() + 2*(this->hiSize), HI_CORNER_RAD, this->hiSize); + Aether::Drawable * NumberBox::renderHighlight() { + return this->renderer->renderRoundRectTexture(this->w() + 2*(this->hiSize), this->h() + 2*(this->hiSize), HI_CORNER_RAD, this->hiSize); } - SDL_Texture * NumberBox::renderSelection() { - return SDLHelper::renderFilledRoundRect(this->w(), this->h(), BOX_CORNER_RAD); + Aether::Drawable * NumberBox::renderSelection() { + return this->renderer->renderFilledRoundRectTexture(this->w(), this->h(), BOX_CORNER_RAD); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/Player.cpp b/Application/source/ui/element/Player.cpp index 38e5689..121bb65 100644 --- a/Application/source/ui/element/Player.cpp +++ b/Application/source/ui/element/Player.cpp @@ -24,9 +24,9 @@ namespace CustomElm { this->albumCover->setWH(110, 110); this->addElement(this->albumCover); this->trackName = new Aether::Text(140, 625, "", 24); - this->trackName->setScroll(true); + this->trackName->setCanScroll(true); + this->trackName->setScrollPause(1200); this->trackName->setScrollSpeed(35); - this->trackName->setScrollWaitTime(1200); this->addElement(this->trackName); this->trackArtist = new Aether::Text(140, 660, "", 18); this->addElement(this->trackArtist); @@ -60,10 +60,10 @@ namespace CustomElm { this->repeatContainer = new Aether::Container(760, 600, 100, 80); this->repeat = new Aether::Image(0, 0, "romfs:/icons/repeat.png"); this->repeatC = new CustomElm::RoundButton(790 - BTN_MAIN_SIZE/2, 640 - BTN_MAIN_SIZE/2, BTN_MAIN_SIZE); - this->repeatC->setCallback([this]() { - Aether::Colour c1 = this->repeat->getColour(); + this->repeatC->onPress([this]() { + Aether::Colour c1 = this->repeat->colour(); Aether::Colour c2 = this->accent; - if (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b && c1.a == c2.a) { + if (c1.r()== c2.r() && c1.g() == c2.g() && c1.b() == c2.b() && c1.a() == c2.a()) { this->repeatFunc(RepeatMode::Off); } else { this->repeatFunc(RepeatMode::One); @@ -75,7 +75,7 @@ namespace CustomElm { this->repeatOneContainer = new Aether::Container(760, 600, 100, 80); this->repeatOne = new Aether::Image(0, 0, "romfs:/icons/repeatone.png"); this->repeatOneC = new CustomElm::RoundButton(790 - BTN_MAIN_SIZE/2, 640 - BTN_MAIN_SIZE/2, BTN_MAIN_SIZE); - this->repeatOneC->setCallback([this]() { + this->repeatOneC->onPress([this]() { this->repeatFunc(RepeatMode::All); }); this->repeatOneC->setImage(this->repeatOne); @@ -282,23 +282,23 @@ namespace CustomElm { } void Player::setShuffleCallback(std::function f) { - this->shuffleC->setCallback(f); + this->shuffleC->onPress(f); } void Player::setPreviousCallback(std::function f) { - this->previousC->setCallback(f); + this->previousC->onPress(f); } void Player::setPauseCallback(std::function f) { - this->pauseC->setCallback(f); + this->pauseC->onPress(f); } void Player::setPlayCallback(std::function f) { - this->playC->setCallback(f); + this->playC->onPress(f); } void Player::setNextCallback(std::function f) { - this->nextC->setCallback(f); + this->nextC->onPress(f); } void Player::setRepeatCallback(std::function f) { @@ -306,29 +306,29 @@ namespace CustomElm { } void Player::setSeekCallback(std::function f) { - this->seekBar->setCallback([this, f]() { + this->seekBar->onPress([this, f]() { f(this->seekBar->value()); }); } void Player::setVolumeIconCallback(std::function f) { - this->volumeIconC->setCallback([this, f]() { + this->volumeIconC->onPress([this, f]() { f(false); }); - this->volumeIconMutedC->setCallback([this, f]() { + this->volumeIconMutedC->onPress([this, f]() { f(true); }); } void Player::setVolumeCallback(std::function f) { this->volumeFunc = f; - this->volume->setCallback([this]() { + this->volume->onPress([this]() { this->volumeFunc(this->volume->value()); }); } void Player::setFullscreenCallback(std::function f) { - this->fullscreenC->setCallback(f); + this->fullscreenC->onPress(f); } void Player::update(uint32_t dt) { @@ -342,4 +342,4 @@ namespace CustomElm { Container::update(dt); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/RoundButton.cpp b/Application/source/ui/element/RoundButton.cpp index 81e6f84..df326e5 100644 --- a/Application/source/ui/element/RoundButton.cpp +++ b/Application/source/ui/element/RoundButton.cpp @@ -34,15 +34,15 @@ namespace CustomElm { this->positionImage(); } - SDL_Texture * RoundButton::renderHighlightBG() { - return SDLHelper::renderFilledEllipse(this->w()/2, this->h()/2); + Aether::Drawable * RoundButton::renderHighlightBG() { + return this->renderer->renderFilledEllipseTexture(this->w()/2, this->h()/2); } - SDL_Texture * RoundButton::renderHighlight() { - return SDLHelper::renderEllipse(this->w()/2, this->h()/2, this->hiSize); + Aether::Drawable * RoundButton::renderHighlight() { + return this->renderer->renderEllipseTexture(this->w()/2, this->h()/2, this->hiSize); } - SDL_Texture * RoundButton::renderSelection() { - return SDLHelper::renderFilledEllipse(this->w()/2, this->h()/2); + Aether::Drawable * RoundButton::renderSelection() { + return this->renderer->renderFilledEllipseTexture(this->w()/2, this->h()/2); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/ScrollableGrid.cpp b/Application/source/ui/element/ScrollableGrid.cpp index 4f45209..abfe1a7 100644 --- a/Application/source/ui/element/ScrollableGrid.cpp +++ b/Application/source/ui/element/ScrollableGrid.cpp @@ -26,7 +26,7 @@ namespace CustomElm { this->scrollVelocity = 0; this->scrollPos = 0; this->maxScrollPos = 0; - this->scrollBar = nullptr; + this->scrollBar = new Aether::Drawable(); this->scrollBarColour = Aether::Colour{255, 255, 255, 255}; this->showScrollBar_ = true; this->touchY = std::numeric_limits::min(); @@ -106,8 +106,8 @@ namespace CustomElm { this->maxScrollPos -= this->h(); // Delete scroll bar due to new height - SDLHelper::destroyTexture(this->scrollBar); - this->scrollBar = nullptr; + delete this->scrollBar; + this->scrollBar = new Aether::Drawable(); } void ScrollableGrid::addElement(Aether::Element * e) { @@ -217,12 +217,12 @@ namespace CustomElm { } // Recreate scroll bar texture if needed - if (this->scrollBar == nullptr) { + if (this->scrollBar->type() == Aether::Drawable::Type::None) { int size = (0.8*this->h()) * (this->h()/(double)(this->h() + this->maxScrollPos/3)); if (size < MIN_SCROLLBAR_SIZE) { size = MIN_SCROLLBAR_SIZE; } - this->scrollBar = SDLHelper::renderFilledRoundRect(SCROLLBAR_WIDTH, size, SCROLLBAR_WIDTH/2); + this->scrollBar = this->renderer->renderFilledRoundRectTexture(SCROLLBAR_WIDTH, size, SCROLLBAR_WIDTH/2); } // If focused element is not completely inside list scroll to it @@ -240,16 +240,15 @@ namespace CustomElm { void ScrollableGrid::render() { // Set clip rectangle to match scrollable position + size - SDLHelper::setClip(this->x(), this->y(), this->x() + this->w(), this->y() + this->h()); + this->renderer->setClipArea(this->x(), this->y(), this->x() + this->w(), this->y() + this->h()); Container::render(); - SDLHelper::resetClip(); + this->renderer->resetClipArea(); // Draw scroll bar - if (this->maxScrollPos != 0 && this->showScrollBar_ && this->scrollBar != nullptr) { - int w, h; - SDLHelper::getDimensions(this->scrollBar, &w, &h); - int yPos = this->y() + PADDING/2 + (((float)this->scrollPos / this->maxScrollPos) * (this->h() - h - PADDING)); - SDLHelper::drawTexture(this->scrollBar, this->scrollBarColour, this->x() + this->w() - w, yPos); + if (this->maxScrollPos != 0 && this->showScrollBar_) { + this->scrollBar->setColour(this->scrollBarColour); + int yPos = this->y() + PADDING/2 + (((float)this->scrollPos / this->maxScrollPos) * (this->h() - this->scrollBar->height() - PADDING)); + this->scrollBar->render(this->x() + this->w() - this->scrollBar->width(), yPos); } } @@ -276,6 +275,6 @@ namespace CustomElm { } ScrollableGrid::~ScrollableGrid() { - SDLHelper::destroyTexture(this->scrollBar); + delete this->scrollBar; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/SideButton.cpp b/Application/source/ui/element/SideButton.cpp index 12fcc49..647cae6 100644 --- a/Application/source/ui/element/SideButton.cpp +++ b/Application/source/ui/element/SideButton.cpp @@ -7,9 +7,9 @@ namespace CustomElm { this->rect->setHidden(true); this->icon = nullptr; this->text = new Aether::Text(this->x() + 60, this->y() + this->h()/2, "", 26); - this->text->setScroll(false); + this->text->setCanScroll(false); + this->text->setScrollPause(1000); this->text->setScrollSpeed(60); - this->text->setScrollWaitTime(1000); this->addElement(this->text); this->isActive = false; } @@ -17,17 +17,17 @@ namespace CustomElm { void SideButton::update(uint32_t dt) { Element::update(dt); - if (this->highlighted() && !this->text->scroll()) { - this->text->setScroll(true); - } else if (!this->highlighted() && this->text->scroll()) { - this->text->setScroll(false); + if (this->highlighted() && !this->text->canScroll()) { + this->text->setCanScroll(true); + } else if (!this->highlighted() && this->text->canScroll()) { + this->text->setCanScroll(false); } } void SideButton::positionElements() { this->text->setX(this->icon ? this->x() + 60 : this->x() + 20); - this->text->setW(this->text->texW()); - if (this->text->texW() > (this->x() + this->w()) - this->text->x() - 10) { + this->text->setW(this->text->textureWidth()); + if (this->text->textureWidth() > (this->x() + this->w()) - this->text->x() - 10) { this->text->setW((this->x() + this->w()) - this->text->x() - 10); } this->text->setY(this->y() + (this->h() - this->text->h())/2); @@ -90,4 +90,4 @@ namespace CustomElm { Aether::Element::setW(w); this->positionElements(); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/Slider.cpp b/Application/source/ui/element/Slider.cpp index c0c36e0..53d207e 100644 --- a/Application/source/ui/element/Slider.cpp +++ b/Application/source/ui/element/Slider.cpp @@ -52,8 +52,8 @@ namespace CustomElm { } this->setSelected(false); moveHighlight(this); - if (this->callback() != nullptr) { - this->callback()(); + if (this->onPressFunc() != nullptr) { + this->onPressFunc()(); } b = true; @@ -78,8 +78,8 @@ namespace CustomElm { } else if (e->type() == Aether::EventType::ButtonReleased) { if (e->button() == Aether::Button::A && this->selected()) { this->setSelected(false); - if (this->callback() != nullptr) { - this->callback()(); + if (this->onPressFunc() != nullptr) { + this->onPressFunc()(); } b = true; } @@ -102,18 +102,17 @@ namespace CustomElm { } // Render selected/held layer - int w, h; if (this->selected()) { this->renderSelectionTexture(); - SDLHelper::getDimensions(this->selTex, &w, &h); - SDLHelper::drawTexture(this->selTex, this->selColour, this->knob->x() + (this->knob->xDiameter() - w)/2, this->knob->y() + (this->knob->yDiameter() - h)/2); + this->selTex->setColour(this->selColour); + this->selTex->render(this->knob->x() + (this->knob->xDiameter() - this->selTex->width())/2, this->knob->y() + (this->knob->yDiameter() - this->selTex->height())/2); } // Finally render highlight border if needed if (this->highlighted() && !this->isTouch) { this->renderHighlightTextures(); - SDLHelper::getDimensions(this->hiBorderTex, &w, &h); - SDLHelper::drawTexture(this->hiBorderTex, this->hiBorderColour, this->knob->x() + ((int)this->knob->xDiameter() - w)/2, this->knob->y() + ((int)this->knob->yDiameter() - h)/2); + this->hiBorderTex->setColour(this->hiBorderColour); + this->hiBorderTex->render(this->knob->x() + ((int)this->knob->xDiameter() - this->hiBorderTex->width())/2, this->knob->y() + ((int)this->knob->yDiameter() - this->hiBorderTex->height())/2); } } @@ -161,16 +160,16 @@ namespace CustomElm { this->bar->setY(this->y() + (this->h() - this->bar->h())/2); } - SDL_Texture * Slider::renderHighlightBG() { + Aether::Drawable * Slider::renderHighlightBG() { // No background needed - return nullptr; + return new Aether::Drawable(); } - SDL_Texture * Slider::renderHighlight() { - return SDLHelper::renderEllipse(this->knob->xDiameter()/2, this->knob->yDiameter()/2, this->hiSize); + Aether::Drawable * Slider::renderHighlight() { + return this->renderer->renderEllipseTexture(this->knob->xDiameter()/2, this->knob->yDiameter()/2, this->hiSize); } - SDL_Texture * Slider::renderSelection() { - return SDLHelper::renderFilledEllipse(this->knob->xDiameter()/2, this->knob->yDiameter()/2); + Aether::Drawable * Slider::renderSelection() { + return this->renderer->renderFilledEllipseTexture(this->knob->xDiameter()/2, this->knob->yDiameter()/2); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/TextBox.cpp b/Application/source/ui/element/TextBox.cpp index eea0076..0f72d52 100644 --- a/Application/source/ui/element/TextBox.cpp +++ b/Application/source/ui/element/TextBox.cpp @@ -23,7 +23,7 @@ namespace CustomElm { this->conf.showLine = false; // Set callback to open keyboard - this->setCallback([this]() { + this->onPress([this]() { this->openKeyboard(); }); @@ -46,11 +46,11 @@ namespace CustomElm { // Position and cut off if too long this->text->setY(this->y() + (this->h() - this->text->h())/2); int wid = (this->rect->x() + this->rect->w()) - this->text->x() - PADDING; - if (this->text->texW() > wid) { - this->text->setMask(0, 0, wid, this->text->texH()); + if (this->text->textureWidth() > wid) { + this->text->setMask(0, 0, wid, this->text->textureHeight()); this->text->setW(wid); } else { - this->text->setMask(0, 0, this->text->texW(), this->text->texH()); + this->text->setMask(0, 0, this->text->textureWidth(), this->text->textureHeight()); } } @@ -83,16 +83,16 @@ namespace CustomElm { return this->text->string(); } - SDL_Texture * TextBox::renderHighlightBG() { + Aether::Drawable * TextBox::renderHighlightBG() { // No background - return nullptr; + return new Aether::Drawable(); } - SDL_Texture * TextBox::renderHighlight() { - return SDLHelper::renderRoundRect(this->w() + 2*(this->hiSize), this->h() + 2*(this->hiSize), HI_CORNER_RAD, this->hiSize); + Aether::Drawable * TextBox::renderHighlight() { + return this->renderer->renderRoundRectTexture(this->w() + 2*(this->hiSize), this->h() + 2*(this->hiSize), HI_CORNER_RAD, this->hiSize); } - SDL_Texture * TextBox::renderSelection() { - return SDLHelper::renderFilledRoundRect(this->w(), this->h(), BOX_CORNER_RAD); + Aether::Drawable * TextBox::renderSelection() { + return this->renderer->renderFilledRoundRectTexture(this->w(), this->h(), BOX_CORNER_RAD); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/VSlider.cpp b/Application/source/ui/element/VSlider.cpp index 5c5f5ad..35f4bbf 100644 --- a/Application/source/ui/element/VSlider.cpp +++ b/Application/source/ui/element/VSlider.cpp @@ -44,8 +44,8 @@ namespace CustomElm { } this->setSelected(false); moveHighlight(this); - if (this->callback() != nullptr) { - this->callback()(); + if (this->onPressFunc() != nullptr) { + this->onPressFunc()(); } b = true; @@ -65,8 +65,8 @@ namespace CustomElm { } else if (e->type() == Aether::EventType::ButtonReleased) { if (e->button() == Aether::Button::A && this->selected()) { this->setSelected(false); - if (this->callback() != nullptr) { - this->callback()(); + if (this->onPressFunc() != nullptr) { + this->onPressFunc()(); } b = true; } @@ -89,18 +89,17 @@ namespace CustomElm { } // Render selected/held layer - int w, h; if (this->selected()) { this->renderSelectionTexture(); - SDLHelper::getDimensions(this->selTex, &w, &h); - SDLHelper::drawTexture(this->selTex, this->selColour, this->knob->x() + (this->knob->xDiameter() - w)/2, this->knob->y() + (this->knob->yDiameter() - h)/2); + this->selTex->setColour(this->selColour); + this->selTex->render(this->knob->x() + (this->knob->xDiameter() - this->selTex->width())/2, this->knob->y() + (this->knob->yDiameter() - this->selTex->height())/2); } // Finally render highlight border if needed if (this->highlighted() && !this->isTouch) { this->renderHighlightTextures(); - SDLHelper::getDimensions(this->hiBorderTex, &w, &h); - SDLHelper::drawTexture(this->hiBorderTex, this->hiBorderColour, this->knob->x() + ((int)this->knob->xDiameter() - w)/2, this->knob->y() + ((int)this->knob->yDiameter() - h)/2); + this->hiBorderTex->setColour(this->hiBorderColour); + this->hiBorderTex->render(this->knob->x() + ((int)this->knob->xDiameter() - this->hiBorderTex->width())/2, this->knob->y() + ((int)this->knob->yDiameter() - this->hiBorderTex->height())/2); } } @@ -110,10 +109,10 @@ namespace CustomElm { void VSlider::setValue(float val) { this->value_ = (val < 0.0 ? 0.0 : (val > 100.0 ? 100.0 : val)); - int h = this->barFg->texH() * (this->value_/100.0); + int h = this->barFg->textureHeight() * (this->value_/100.0); this->barFg->setY(this->barBg->y() + this->barBg->h() - h); this->barFg->setH(h); - this->barFg->setMask(0, this->barFg->texH() - h, this->barFg->texW(), h); + this->barFg->setMask(0, this->barFg->textureHeight() - h, this->barFg->textureWidth(), h); this->knob->setY(this->barBg->y() + this->barBg->h() - h - this->knob->yDiameter()/2); } @@ -133,16 +132,16 @@ namespace CustomElm { this->knob->setColour(c); } - SDL_Texture * VSlider::renderHighlightBG() { + Aether::Drawable * VSlider::renderHighlightBG() { // No background needed - return nullptr; + return new Aether::Drawable(); } - SDL_Texture * VSlider::renderHighlight() { - return SDLHelper::renderEllipse(this->knob->xDiameter()/2, this->knob->yDiameter()/2, this->hiSize); + Aether::Drawable * VSlider::renderHighlight() { + return this->renderer->renderEllipseTexture(this->knob->xDiameter()/2, this->knob->yDiameter()/2, this->hiSize); } - SDL_Texture * VSlider::renderSelection() { - return SDLHelper::renderFilledEllipse(this->knob->xDiameter()/2, this->knob->yDiameter()/2); + Aether::Drawable * VSlider::renderSelection() { + return this->renderer->renderFilledEllipseTexture(this->knob->xDiameter()/2, this->knob->yDiameter()/2); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/listitem/AlbumSong.cpp b/Application/source/ui/element/listitem/AlbumSong.cpp index 9820c0c..f3a7fe1 100644 --- a/Application/source/ui/element/listitem/AlbumSong.cpp +++ b/Application/source/ui/element/listitem/AlbumSong.cpp @@ -9,17 +9,13 @@ namespace CustomElm::ListItem { AlbumSong::AlbumSong() : More(HEIGHT) { - this->track = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->watchTexture(this->track); - this->title = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->watchTexture(this->title); - this->artist = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->watchTexture(this->artist); - this->length = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->watchTexture(this->length); + this->track = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::Render::Wait); + this->title = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::Render::Wait); + this->artist = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::Render::Wait); + this->length = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::Render::Wait); } - void AlbumSong::positionItems() { + void AlbumSong::positionElements() { this->track->setX(this->x() + 15); this->title->setX(this->x() + this->w() * 0.08); this->artist->setX(this->x() + this->w() * 0.6); @@ -44,19 +40,27 @@ namespace CustomElm::ListItem { } void AlbumSong::setTrackString(std::string s) { - this->track->setString(s); + this->processText(this->track, [s]() -> Aether::Text * { + return new Aether::Text(0, 0, s, FONT_SIZE, Aether::Render::Wait); + }); } void AlbumSong::setTitleString(std::string s) { - this->title->setString(s); + this->processText(this->title, [s]() -> Aether::Text * { + return new Aether::Text(0, 0, s, FONT_SIZE, Aether::Render::Wait); + }); } void AlbumSong::setArtistString(std::string s) { - this->artist->setString(s); + this->processText(this->artist, [s]() -> Aether::Text * { + return new Aether::Text(0, 0, s, FONT_SIZE, Aether::Render::Wait); + }); } void AlbumSong::setLengthString(std::string s) { - this->length->setString(s); + this->processText(this->length, [s]() -> Aether::Text * { + return new Aether::Text(0, 0, s, FONT_SIZE, Aether::Render::Wait); + }); } void AlbumSong::setTextColour(Aether::Colour c) { @@ -65,4 +69,4 @@ namespace CustomElm::ListItem { this->artist->setColour(c); this->length->setColour(c); } -} \ No newline at end of file +} diff --git a/Application/source/ui/element/listitem/Artist.cpp b/Application/source/ui/element/listitem/Artist.cpp index ae29bf7..9b6fd1e 100644 --- a/Application/source/ui/element/listitem/Artist.cpp +++ b/Application/source/ui/element/listitem/Artist.cpp @@ -9,15 +9,17 @@ namespace CustomElm::ListItem { Artist::Artist(const std::string & path) : Item(HEIGHT) { - this->image = new Aether::Image(0, 0, path, 1, 1, Aether::RenderType::Deferred); - this->watchTexture(this->image); - this->name = new Aether::Text(0, 0, "", FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); + this->image = new Aether::Image(0, 0, path, Aether::Render::Wait); + this->addElement(this->image); + this->addTexture(this->image); + this->name = new Aether::Text(0, 0, "", FONT_SIZE, Aether::Render::Wait); + this->name->setScrollPause(500); this->name->setScrollSpeed(35); - this->name->setScrollWaitTime(500); - this->watchTexture(this->name); + this->addElement(this->name); + this->addTexture(this->name); } - void Artist::positionItems() { + void Artist::positionElements() { this->image->setXY(this->x() + PADDING, this->y() + PADDING); this->image->setWH(HEIGHT - 2*PADDING, HEIGHT - 2*PADDING); this->name->setX(this->image->x() + this->image->w() + 2*PADDING); @@ -32,18 +34,20 @@ namespace CustomElm::ListItem { Item::update(dt); // Scroll if this element is selected - if (this->highlighted() && !this->name->scroll()) { - this->name->setScroll(true); - } else if (!this->highlighted() && this->name->scroll()) { - this->name->setScroll(false); + if (this->highlighted() && !this->name->canScroll()) { + this->name->setCanScroll(true); + } else if (!this->highlighted() && this->name->canScroll()) { + this->name->setCanScroll(false); } } void Artist::setName(const std::string & s) { - this->name->setString(s); + this->processText(this->name, [s]() -> Aether::Text * { + return new Aether::Text(0, 0, s, FONT_SIZE, Aether::Render::Wait); + }); } void Artist::setTextColour(Aether::Colour c) { this->name->setColour(c); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/listitem/File.cpp b/Application/source/ui/element/listitem/File.cpp index 50f8786..8a993e7 100644 --- a/Application/source/ui/element/listitem/File.cpp +++ b/Application/source/ui/element/listitem/File.cpp @@ -9,21 +9,23 @@ namespace CustomElm::ListItem { File::File(std::string s, bool b, std::function f) : Item(HEIGHT) { - this->icon = new Aether::Image(0, 0, (b ? "romfs:/icons/directory.png" : "romfs:/icons/file.png"), 1, 1, Aether::RenderType::Deferred); - this->watchTexture(this->icon); - this->name = new Aether::Text(0, 0, s, FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->watchTexture(this->name); - this->setCallback(f); + this->icon = new Aether::Image(0, 0, (b ? "romfs:/icons/directory.png" : "romfs:/icons/file.png"), Aether::Render::Wait); + this->addElement(this->icon); + this->addTexture(this->icon); + this->name = new Aether::Text(0, 0, s, FONT_SIZE, Aether::Render::Wait); + this->addElement(this->name); + this->addTexture(this->name); + this->onPress(f); } - void File::positionItems() { + void File::positionElements() { this->icon->setXY(this->x() + PADDING, this->y() + (this->h() - this->icon->h())/2); this->name->setXY(this->icon->x() + this->icon->w() + PADDING, this->y() + (this->h() - this->name->h())/2); int maxW = this->x() + this->w() - PADDING - this->name->x(); - if (this->name->texW() > maxW) { + if (this->name->textureWidth() > maxW) { this->name->setW(maxW); } else { - this->name->setW(this->name->texW()); + this->name->setW(this->name->textureWidth()); } } @@ -31,10 +33,10 @@ namespace CustomElm::ListItem { Item::update(dt); // Scroll if this element is selected - if (this->highlighted() && !this->name->scroll()) { - this->name->setScroll(true); - } else if (!this->highlighted() && this->name->scroll()) { - this->name->setScroll(false); + if (this->highlighted() && !this->name->canScroll()) { + this->name->setCanScroll(true); + } else if (!this->highlighted() && this->name->canScroll()) { + this->name->setCanScroll(false); } } @@ -45,4 +47,4 @@ namespace CustomElm::ListItem { void File::setTextColour(Aether::Colour c) { this->name->setColour(c); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/listitem/Item.cpp b/Application/source/ui/element/listitem/Item.cpp index 32ffc52..ee8278f 100644 --- a/Application/source/ui/element/listitem/Item.cpp +++ b/Application/source/ui/element/listitem/Item.cpp @@ -4,86 +4,43 @@ #define THRESHOLD 2000 namespace CustomElm::ListItem { - SDL_Texture * Item::line = nullptr; + Aether::Drawable * Item::line = new Aether::Drawable(); + + Item::Item(int h) : Aether::AsyncItem() { + this->setH(h); - Item::Item(int h) : Aether::Element(0, 0, 100, h) { // Create line texture if it doesn't exist - if (this->line == nullptr) { - this->line = SDLHelper::renderFilledRect(500, 1); + if (this->line->type() == Aether::Drawable::Type::None) { + this->line = this->renderer->renderFilledRectTexture(500, 1); } - - // Ensure other variables are initialized properly - this->lineColour = Aether::Colour{255, 255, 255, 0}; - this->renderStatus = Status::Waiting; - this->textures.clear(); - } - - void Item::watchTexture(Aether::Texture * t) { - t->setHidden(true); - this->textures.push_back(t); - this->addElement(t); - } - - void Item::setLineColour(Aether::Colour c) { - this->lineColour = c; } - void Item::update(uint32_t dt) { - // Update children - Element::update(dt); + void Item::processText(Aether::Text * & text, std::function getNew) { + // Remove original + this->removeTexture(text); + this->removeElement(text); - // Take action based on rendering status - switch (this->renderStatus) { - // Waiting to render - check position and start if within threshold - case Status::Waiting: - if (this->y() + this->h() > -THRESHOLD && this->y() < 720 + THRESHOLD) { - for (size_t i = 0; i < this->textures.size(); i++) { - this->textures[i]->startRendering(); - } - this->renderStatus = Status::InProgress; - } - break; + // Get (and assign) new text object + text = getNew(); - case Status::InProgress: - // Check if all are ready - for (size_t i = 0; i < this->textures.size(); i++) { - if (!this->textures[i]->textureReady()) { - return; - } - } - - // If they're all ready show and position - this->positionItems(); - for (size_t i = 0; i < this->textures.size(); i++) { - this->textures[i]->setHidden(false); - } - this->renderStatus = Status::Done; - - case Status::Done: - // Delete textures when outside of threshold to save memory - if (this->y() + this->h() < -THRESHOLD || this->y() > 720 + THRESHOLD) { - for (size_t i = 0; i < this->textures.size(); i++) { - this->textures[i]->destroyTexture(); - this->textures[i]->setHidden(true); - } - this->renderStatus = Status::Waiting; - } - break; + // Don't add if empty string + if (!text->string().empty()) { + this->addElement(text); + this->addTexture(text); } } + void Item::setLineColour(const Aether::Colour & c) { + this->line->setColour(c); + } + void Item::render() { // Render lines first so highlight will appear on top - if (this->renderStatus == Status::Done && this->isVisible()) { - SDLHelper::drawTexture(this->line, this->lineColour, this->x(), this->y(), this->w()); - SDLHelper::drawTexture(this->line, this->lineColour, this->x(), this->y() + this->h(), this->w()); + if (this->ready() && this->isVisible()) { + this->line->render(this->x(), this->y(), this->w()); + this->line->render(this->x(), this->y() + this->h(), this->w()); } - Element::render(); - } - - void Item::setW(int w) { - Element::setW(w); - this->positionItems(); + AsyncItem::render(); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/listitem/More.cpp b/Application/source/ui/element/listitem/More.cpp index 56095a1..f975fc2 100644 --- a/Application/source/ui/element/listitem/More.cpp +++ b/Application/source/ui/element/listitem/More.cpp @@ -6,8 +6,9 @@ namespace CustomElm::ListItem { More::More(int h) : Item(h) { this->moreCallback = nullptr; - this->more = new Aether::Image(0, 0, "romfs:/icons/verticaldots.png", 1, 1, Aether::RenderType::Deferred); - this->watchTexture(this->more); + this->more = new Aether::Image(0, 0, "romfs:/icons/verticaldots.png", Aether::Render::Wait); + this->addElement(this->more); + this->addTexture(this->more); this->touchedMore = false; } @@ -54,4 +55,4 @@ namespace CustomElm::ListItem { void More::setMoreColour(Aether::Colour c) { this->more->setColour(c); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/element/listitem/Playlist.cpp b/Application/source/ui/element/listitem/Playlist.cpp index 9e481c6..66bc812 100644 --- a/Application/source/ui/element/listitem/Playlist.cpp +++ b/Application/source/ui/element/listitem/Playlist.cpp @@ -10,41 +10,44 @@ namespace CustomElm::ListItem { Playlist::Playlist(const std::string & img) : More(HEIGHT) { - this->image = new Aether::Image(this->x() + PADDING, this->y() + PADDING, img, 1, 1, Aether::RenderType::Deferred); - this->watchTexture(this->image); - this->name = new Aether::Text(this->x(), this->y(), "", NAME_FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->name->setScroll(false); + this->image = new Aether::Image(this->x() + PADDING, this->y() + PADDING, img, Aether::Render::Wait); + this->addElement(this->image); + this->addTexture(this->image); + this->name = new Aether::Text(this->x(), this->y(), "", NAME_FONT_SIZE, Aether::Render::Wait); + this->name->setCanScroll(false); + this->name->setScrollPause(1000); this->name->setScrollSpeed(60); - this->name->setScrollWaitTime(1000); - this->watchTexture(this->name); - this->songs = new Aether::Text(this->x(), this->y(), "", SONGS_FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->watchTexture(this->songs); + this->addElement(this->name); + this->addTexture(this->name); + this->songs = new Aether::Text(this->x(), this->y(), "", SONGS_FONT_SIZE, Aether::Render::Wait); + this->addElement(this->songs); + this->addTexture(this->songs); } void Playlist::update(uint32_t dt) { More::update(dt); - if (this->highlighted() && !this->name->scroll()) { - this->name->setScroll(true); + if (this->highlighted() && !this->name->canScroll()) { + this->name->setCanScroll(true); - } else if (!this->highlighted() && this->name->scroll()) { - this->name->setScroll(false); + } else if (!this->highlighted() && this->name->canScroll()) { + this->name->setCanScroll(false); } } - void Playlist::positionItems() { + void Playlist::positionElements() { this->image->setWH(HEIGHT - 2*PADDING, HEIGHT - 2*PADDING); this->name->setX(this->image->x() + this->image->w() + 2*PADDING); this->name->setY(this->y() + 0.38*HEIGHT - this->name->h()/2); int maxW = (this->x() + this->w()) - this->name->x() - PADDING; - if (this->more->getColour().a != 0) { + if (this->more->colour().a() != 0) { maxW -= (this->x() + this->w()) - this->more->x(); } - if (this->name->texW() > maxW) { + if (this->name->textureWidth() > maxW) { this->name->setW(maxW); } else { - this->name->setW(this->name->texW()); + this->name->setW(this->name->textureWidth()); } this->songs->setX(this->name->x()); @@ -53,11 +56,15 @@ namespace CustomElm::ListItem { } void Playlist::setNameString(const std::string & s) { - this->name->setString(s); + this->processText(this->name, [s]() -> Aether::Text * { + return new Aether::Text(0, 0, s, NAME_FONT_SIZE, Aether::Render::Wait); + }); } void Playlist::setSongsString(const std::string & s) { - this->songs->setString(s); + this->processText(this->songs, [s]() -> Aether::Text * { + return new Aether::Text(0, 0, s, SONGS_FONT_SIZE, Aether::Render::Wait); + }); } void Playlist::setMutedTextColour(Aether::Colour c) { @@ -67,4 +74,4 @@ namespace CustomElm::ListItem { void Playlist::setTextColour(Aether::Colour c) { this->name->setColour(c); } -} \ No newline at end of file +} diff --git a/Application/source/ui/element/listitem/Song.cpp b/Application/source/ui/element/listitem/Song.cpp index 789cf58..f10bac8 100644 --- a/Application/source/ui/element/listitem/Song.cpp +++ b/Application/source/ui/element/listitem/Song.cpp @@ -9,17 +9,21 @@ namespace CustomElm::ListItem { Song::Song() : More(HEIGHT) { - this->title = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->watchTexture(this->title); - this->artist = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->watchTexture(this->artist); - this->album = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->watchTexture(this->album); - this->length = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::FontStyle::Regular, Aether::RenderType::Deferred); - this->watchTexture(this->length); + this->title = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::Render::Wait); + this->addElement(this->title); + this->addTexture(this->title); + this->artist = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::Render::Wait); + this->addElement(this->artist); + this->addTexture(this->artist); + this->album = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::Render::Wait); + this->addElement(this->album); + this->addTexture(this->album); + this->length = new Aether::Text(this->x(), this->y(), "", FONT_SIZE, Aether::Render::Wait); + this->addElement(this->length); + this->addTexture(this->length); } - void Song::positionItems() { + void Song::positionElements() { this->title->setX(this->x() + 15); this->artist->setX(this->x() + this->w() * 0.44); this->album->setX(this->x() + this->w() * 0.67); @@ -42,19 +46,27 @@ namespace CustomElm::ListItem { } void Song::setTitleString(std::string s) { - this->title->setString(s); + this->processText(this->title, [s]() -> Aether::Text * { + return new Aether::Text(0, 0, s, FONT_SIZE, Aether::Render::Wait); + }); } void Song::setArtistString(std::string s) { - this->artist->setString(s); + this->processText(this->artist, [s]() -> Aether::Text * { + return new Aether::Text(0, 0, s, FONT_SIZE, Aether::Render::Wait); + }); } void Song::setAlbumString(std::string s) { - this->album->setString(s); + this->processText(this->album, [s]() -> Aether::Text * { + return new Aether::Text(0, 0, s, FONT_SIZE, Aether::Render::Wait); + }); } void Song::setLengthString(std::string s) { - this->length->setString(s); + this->processText(this->length, [s]() -> Aether::Text * { + return new Aether::Text(0, 0, s, FONT_SIZE, Aether::Render::Wait); + }); } void Song::setTextColour(Aether::Colour c) { @@ -63,4 +75,4 @@ namespace CustomElm::ListItem { this->album->setColour(c); this->length->setColour(c); } -} \ No newline at end of file +} diff --git a/Application/source/ui/frame/Album.cpp b/Application/source/ui/frame/Album.cpp index 2bff43b..5336b81 100644 --- a/Application/source/ui/frame/Album.cpp +++ b/Application/source/ui/frame/Album.cpp @@ -130,7 +130,7 @@ namespace Frame { l->setLineColour(this->app->theme()->muted2()); l->setMoreColour(this->app->theme()->muted()); l->setTextColour(this->app->theme()->FG()); - l->setCallback([this, i]() { + l->onPress([this, i]() { this->playAlbum(i); }); l->setMoreCallback([this, i]() { @@ -175,7 +175,7 @@ namespace Frame { l->setLineColour(this->app->theme()->muted2()); l->setTextColour(this->app->theme()->FG()); ArtistID aID = m[i].ID; - l->setCallback([this, aID]() { + l->onPress([this, aID]() { this->changeFrame(Type::Artist, Action::Push, aID); this->artistsList->close(); }); @@ -197,7 +197,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this]() { + b->onPress([this]() { std::vector v = this->app->database()->getSongMetadataForAlbum(this->metadata.ID); for (size_t i = 0; i < v.size(); i++) { this->app->sysmodule()->sendAddToSubQueue(v[i].ID); @@ -212,7 +212,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this]() { + b->onPress([this]() { this->showAddToPlaylist([this](PlaylistID i) { if (i >= 0) { std::vector v = this->app->database()->getSongMetadataForAlbum(this->metadata.ID); @@ -233,7 +233,7 @@ namespace Frame { b->setTextColour(this->app->theme()->FG()); if (this->oneArtist) { b->setText("Common.GoToArtist"_lang); - b->setCallback([this]() { + b->onPress([this]() { ArtistID aID = this->app->database()->getArtistIDForName(this->metadata.artist); this->changeFrame(Type::Artist, Action::Push, aID); this->albumMenu->close(); @@ -241,7 +241,7 @@ namespace Frame { } else { b->setText("Common.ViewArtists"_lang); - b->setCallback([this]() { + b->onPress([this]() { this->createArtistsList(); this->albumMenu->close(); }); @@ -255,7 +255,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this]() { + b->onPress([this]() { this->changeFrame(Type::AlbumInfo, Action::Push, this->metadata.ID); this->albumMenu->close(); }); @@ -289,7 +289,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->app->sysmodule()->sendAddToSubQueue(this->songs[pos].ID); this->songMenu->close(); }); @@ -301,7 +301,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->showAddToPlaylist([this, pos](PlaylistID i) { if (i >= 0) { this->app->database()->addSongToPlaylist(i, this->songs[pos].ID); @@ -319,7 +319,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.GoToArtist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { ArtistID a = this->app->database()->getArtistIDForSong(this->songs[pos].ID); if (a >= 0) { this->changeFrame(Type::Artist, Action::Push, a); @@ -336,7 +336,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->changeFrame(Type::SongInfo, Action::Push, this->songs[pos].ID); this->songMenu->close(); }); @@ -356,4 +356,4 @@ namespace Frame { delete this->albumMenu; delete this->songMenu; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/AlbumInfo.cpp b/Application/source/ui/frame/AlbumInfo.cpp index 54ce2a6..ee2d856 100644 --- a/Application/source/ui/frame/AlbumInfo.cpp +++ b/Application/source/ui/frame/AlbumInfo.cpp @@ -404,7 +404,7 @@ namespace Frame { tmpImage->setWH(this->w()*0.18, this->w()*0.18); // Show error if image wasn't created - if (tmpImage->texW() == 0 || tmpImage->texH() == 0) { + if (tmpImage->textureWidth() == 0 || tmpImage->textureHeight() == 0) { this->createInfoOverlay("Common.Error.CorruptArt"_lang); delete tmpImage; @@ -431,7 +431,7 @@ namespace Frame { tmpImage->setWH(this->w()*0.18, this->w()*0.18); // Show error if image wasn't created - if (tmpImage->texW() == 0 || tmpImage->texH() == 0) { + if (tmpImage->textureWidth() == 0 || tmpImage->textureHeight() == 0) { this->createInfoOverlay("Common.Error.ReadImage"_lang); delete tmpImage; @@ -466,4 +466,4 @@ namespace Frame { delete this->msgbox; delete this->browser; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/Albums.cpp b/Application/source/ui/frame/Albums.cpp index eb2dd5d..f1d47c1 100644 --- a/Application/source/ui/frame/Albums.cpp +++ b/Application/source/ui/frame/Albums.cpp @@ -28,7 +28,7 @@ namespace Frame { this->bottomContainer->addElement(this->grid); // Create sort menu - this->sort->setCallback([this]() { + this->sort->onPress([this]() { this->app->addOverlay(this->sortMenu); }); std::vector sort = {{Database::SortBy::AlbumAsc, "Album.Sort.AlbumAsc"_lang}, @@ -65,7 +65,7 @@ namespace Frame { l->setLineColour(this->app->theme()->muted2()); l->setTextColour(this->app->theme()->FG()); ArtistID aID = m[i].ID; - l->setCallback([this, aID]() { + l->onPress([this, aID]() { this->changeFrame(Type::Artist, Action::Push, aID); this->artistsList->close(); }); @@ -91,7 +91,7 @@ namespace Frame { l->setTextColour(this->app->theme()->FG()); l->setMutedTextColour(this->app->theme()->muted()); AlbumID id = m[i].ID; - l->setCallback([this, id](){ + l->onPress([this, id](){ this->changeFrame(Type::Album, Action::Push, id); }); l->setMoreCallback([this, id]() { @@ -139,7 +139,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.Play"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, m]() { + b->onPress([this, m]() { std::vector v = this->app->database()->getSongMetadataForAlbum(m.ID); std::vector ids; for (size_t i = 0; i < v.size(); i++) { @@ -157,7 +157,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { std::vector v = this->app->database()->getSongMetadataForAlbum(id); for (size_t i = 0; i < v.size(); i++) { this->app->sysmodule()->sendAddToSubQueue(v[i].ID); @@ -172,7 +172,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->showAddToPlaylist([this, id](PlaylistID i) { if (i >= 0) { std::vector v = this->app->database()->getSongMetadataForAlbum(id); @@ -194,14 +194,14 @@ namespace Frame { if (m.artist != "Various Artists") { b->setText("Common.GoToArtist"_lang); ArtistID aID = this->app->database()->getArtistIDForName(m.artist); - b->setCallback([this, aID]() { + b->onPress([this, aID]() { this->changeFrame(Type::Artist, Action::Push, aID); this->albumMenu->close(); }); } else { b->setText("Common.ViewArtists"_lang); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->createArtistsList(id); this->albumMenu->close(); }); @@ -215,7 +215,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->changeFrame(Type::AlbumInfo, Action::Push, id); this->albumMenu->close(); }); @@ -231,4 +231,4 @@ namespace Frame { delete this->albumMenu; delete this->sortMenu; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/Artist.cpp b/Application/source/ui/frame/Artist.cpp index 979a966..687f9d1 100644 --- a/Application/source/ui/frame/Artist.cpp +++ b/Application/source/ui/frame/Artist.cpp @@ -102,7 +102,7 @@ namespace Frame { this->createList(Database::SortBy::AlbumAsc); // Create sort menu - this->sort->setCallback([this]() { + this->sort->onPress([this]() { this->app->addOverlay(this->sortMenu); }); std::vector sort = {{Database::SortBy::AlbumAsc, "Artist.Sort.AlbumAsc"_lang}, @@ -142,7 +142,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { std::vector v = this->app->database()->getSongMetadataForArtist(id); for (size_t i = 0; i < v.size(); i++) { this->app->sysmodule()->sendAddToSubQueue(v[i].ID); @@ -157,7 +157,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->showAddToPlaylist([this, id](PlaylistID i) { if (i >= 0) { std::vector v = this->app->database()->getSongMetadataForArtist(id); @@ -177,7 +177,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->changeFrame(Type::ArtistInfo, Action::Push, id); this->artistMenu->close(); }); @@ -217,7 +217,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Artist.PlayAlbum"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, m]() { + b->onPress([this, m]() { std::vector v = this->app->database()->getSongMetadataForAlbum(m.ID); std::vector ids; for (size_t i = 0; i < v.size(); i++) { @@ -235,7 +235,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Artist.AddAlbumToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { std::vector v = this->app->database()->getSongMetadataForAlbum(id); for (size_t i = 0; i < v.size(); i++) { this->app->sysmodule()->sendAddToSubQueue(v[i].ID); @@ -250,7 +250,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Artist.AddAlbumToPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->showAddToPlaylist([this, id](PlaylistID i) { if (i >= 0) { std::vector v = this->app->database()->getSongMetadataForAlbum(id); @@ -270,7 +270,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->changeFrame(Type::AlbumInfo, Action::Push, id); this->albumMenu->close(); }); @@ -298,7 +298,7 @@ namespace Frame { l->setTextColour(this->app->theme()->FG()); l->setMutedTextColour(this->app->theme()->muted()); AlbumID id = md[i].ID; - l->setCallback([this, id](){ + l->onPress([this, id](){ this->changeFrame(Type::Album, Action::Push, id); }); l->setMoreCallback([this, id]() { @@ -318,4 +318,4 @@ namespace Frame { delete this->artistMenu; delete this->sortMenu; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/ArtistInfo.cpp b/Application/source/ui/frame/ArtistInfo.cpp index a9c516b..aa873c3 100644 --- a/Application/source/ui/frame/ArtistInfo.cpp +++ b/Application/source/ui/frame/ArtistInfo.cpp @@ -368,7 +368,7 @@ namespace Frame { tmpImage->setWH(this->w()*0.18, this->w()*0.18); // Show error if image wasn't created - if (tmpImage->texW() == 0 || tmpImage->texH() == 0) { + if (tmpImage->textureWidth() == 0 || tmpImage->textureHeight() == 0) { this->createInfoOverlay("Common.Error.ReadImage"_lang); delete tmpImage; @@ -403,4 +403,4 @@ namespace Frame { delete this->msgbox; delete this->browser; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/Artists.cpp b/Application/source/ui/frame/Artists.cpp index 5cb3376..1c1e4fd 100644 --- a/Application/source/ui/frame/Artists.cpp +++ b/Application/source/ui/frame/Artists.cpp @@ -26,7 +26,7 @@ namespace Frame { this->bottomContainer->addElement(this->grid); // Create sort menu - this->sort->setCallback([this]() { + this->sort->onPress([this]() { this->app->addOverlay(this->sortMenu); }); std::vector sort = {{Database::SortBy::ArtistAsc, "Artist.Sort.ArtistAsc"_lang}, @@ -77,7 +77,7 @@ namespace Frame { l->setTextColour(this->app->theme()->FG()); l->setMutedTextColour(this->app->theme()->muted()); ArtistID id = m[i].ID; - l->setCallback([this, id](){ + l->onPress([this, id](){ this->changeFrame(Type::Artist, Action::Push, id); }); l->setMoreCallback([this, id]() { @@ -137,7 +137,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Artist.PlayAll"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, m]() { + b->onPress([this, m]() { std::vector v = this->app->database()->getSongMetadataForArtist(m.ID); std::vector ids; for (size_t i = 0; i < v.size(); i++) { @@ -155,7 +155,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { std::vector v = this->app->database()->getSongMetadataForArtist(id); for (size_t i = 0; i < v.size(); i++) { this->app->sysmodule()->sendAddToSubQueue(v[i].ID); @@ -170,7 +170,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->showAddToPlaylist([this, id](PlaylistID i) { if (i >= 0) { std::vector v = this->app->database()->getSongMetadataForArtist(id); @@ -190,7 +190,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->changeFrame(Type::ArtistInfo, Action::Push, id); this->menu->close(); }); @@ -205,4 +205,4 @@ namespace Frame { delete this->sortMenu; delete this->menu; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/Playlist.cpp b/Application/source/ui/frame/Playlist.cpp index f8499af..6710562 100644 --- a/Application/source/ui/frame/Playlist.cpp +++ b/Application/source/ui/frame/Playlist.cpp @@ -83,7 +83,7 @@ namespace Frame { this->songMenu = nullptr; // Create sort menu - this->sort->setCallback([this]() { + this->sort->onPress([this]() { this->app->addOverlay(this->sortMenu); }); std::vector sort = {{Database::SortBy::TitleAsc, "Playlist.Sort.TitleAsc"_lang}, @@ -213,7 +213,7 @@ namespace Frame { l->setMoreColour(this->app->theme()->muted()); l->setTextColour(this->app->theme()->FG()); // Need to search for element as order is changed when a song is removed - l->setCallback([this, l](){ + l->onPress([this, l](){ std::vector::iterator it = std::find(this->elms.begin(), this->elms.end(), l); if (it != this->elms.end()) { this->playPlaylist(std::distance(this->elms.begin(), it)); @@ -281,7 +281,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this]() { + b->onPress([this]() { for (size_t i = 0; i < this->songs.size(); i++) { this->app->sysmodule()->sendAddToSubQueue(this->songs[i].song.ID); } @@ -295,7 +295,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Playlist.AddToOtherPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this]() { + b->onPress([this]() { this->showAddToPlaylist([this](PlaylistID i) { if (i >= 0) { for (size_t j = 0; j < this->songs.size(); j++) { @@ -319,7 +319,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Playlist.ExportPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this]() { + b->onPress([this]() { this->exportPlaylist(); }); this->playlistMenu->addButton(b); @@ -330,7 +330,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Playlist.DeletePlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this]() { + b->onPress([this]() { this->createDeleteMenu(); }); this->playlistMenu->addButton(b); @@ -342,7 +342,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this]() { + b->onPress([this]() { this->changeFrame(Type::PlaylistInfo, Action::Push, this->metadata.ID); this->playlistMenu->close(); }); @@ -378,7 +378,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->app->sysmodule()->sendAddToSubQueue(this->songs[pos].song.ID); this->songMenu->close(); }); @@ -390,7 +390,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Playlist.AddToOtherPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->showAddToPlaylist([this, pos](PlaylistID i) { if (i >= 0) { this->app->database()->addSongToPlaylist(i, this->songs[pos].song.ID); @@ -411,7 +411,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Playlist.RemoveFromPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { // Remove from database this->app->lockDatabase(); bool ok = this->app->database()->removeSongFromPlaylist(this->songs[pos].ID); @@ -435,7 +435,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.GoToArtist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { ArtistID a = this->app->database()->getArtistIDForSong(this->songs[pos].song.ID); if (a >= 0) { this->changeFrame(Type::Artist, Action::Push, a); @@ -451,7 +451,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->changeFrame(Type::SongInfo, Action::Push, this->songs[pos].song.ID); this->songMenu->close(); }); @@ -500,4 +500,4 @@ namespace Frame { delete this->songMenu; delete this->sortMenu; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/PlaylistInfo.cpp b/Application/source/ui/frame/PlaylistInfo.cpp index 538d24c..a652ce0 100644 --- a/Application/source/ui/frame/PlaylistInfo.cpp +++ b/Application/source/ui/frame/PlaylistInfo.cpp @@ -304,7 +304,7 @@ namespace Frame { tmpImage->setWH(this->w()*0.18, this->w()*0.18); // Show error if image wasn't created - if (tmpImage->texW() == 0 || tmpImage->texH() == 0) { + if (tmpImage->textureWidth() == 0 || tmpImage->textureHeight() == 0) { this->createInfoOverlay("Common.Error.CorruptArt"_lang); delete tmpImage; @@ -331,7 +331,7 @@ namespace Frame { tmpImage->setWH(this->w()*0.18, this->w()*0.18); // Show error if image wasn't created - if (tmpImage->texW() == 0 || tmpImage->texH() == 0) { + if (tmpImage->textureWidth() == 0 || tmpImage->textureHeight() == 0) { this->createInfoOverlay("Common.Error.ReadImage"_lang); delete tmpImage; @@ -366,4 +366,4 @@ namespace Frame { delete this->msgbox; delete this->browser; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/Playlists.cpp b/Application/source/ui/frame/Playlists.cpp index a9b1bf1..785ad5f 100644 --- a/Application/source/ui/frame/Playlists.cpp +++ b/Application/source/ui/frame/Playlists.cpp @@ -62,7 +62,7 @@ namespace Frame { // Move sort button and prepare menu this->sort->setX(btn->x() - 20 - this->sort->w()); - this->sort->setCallback([this]() { + this->sort->onPress([this]() { this->app->addOverlay(this->sortMenu); }); std::vector sort = {{Database::SortBy::TitleAsc, "Playlist.Sort.TitleAltAsc"_lang}, @@ -97,7 +97,7 @@ namespace Frame { l->setMutedTextColour(this->app->theme()->muted()); // Need to search for element in callbacks as order is changed when a playlist is removed - l->setCallback([this, l](){ + l->onPress([this, l](){ std::vector::iterator it = std::find_if(this->items.begin(), this->items.end(), [this, l](const Item e) { return e.elm == l; }); @@ -240,7 +240,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.Play"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { std::vector v = this->app->database()->getSongMetadataForPlaylist(this->items[pos].meta.ID, Database::SortBy::TitleAsc); if (v.size() > 0) { std::vector ids; @@ -260,7 +260,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { std::vector v = this->app->database()->getSongMetadataForPlaylist(this->items[pos].meta.ID, Database::SortBy::TitleAsc); for (size_t i = 0; i < v.size(); i++) { this->app->sysmodule()->sendAddToSubQueue(v[i].song.ID); @@ -275,7 +275,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Playlist.AddToOtherPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->showAddToPlaylist([this, pos](PlaylistID i) { if (i >= 0) { // Get list of songs and add one-by-one to other playlist @@ -313,7 +313,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Playlist.ExportPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->exportPlaylist(this->items[pos].meta); }); this->menu->addButton(b); @@ -324,7 +324,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Playlist.DeletePlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->createDeletePlaylistMenu(pos); }); this->menu->addButton(b); @@ -336,7 +336,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->changeFrame(Type::PlaylistInfo, Action::Push, this->items[pos].meta.ID); this->menu->close(); }); @@ -579,7 +579,7 @@ namespace Frame { Aether::Image * tmpImage = new Aether::Image(0, 0, path); // Show error if image wasn't created - if (tmpImage->texW() == 0 || tmpImage->texH() == 0) { + if (tmpImage->textureWidth() == 0 || tmpImage->textureHeight() == 0) { this->createInfoOverlay("Common.Error.ReadImage"_lang); delete tmpImage; @@ -668,4 +668,4 @@ namespace Frame { delete this->newMenu; delete this->sortMenu; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/Queue.cpp b/Application/source/ui/frame/Queue.cpp index 6015880..433bae2 100644 --- a/Application/source/ui/frame/Queue.cpp +++ b/Application/source/ui/frame/Queue.cpp @@ -273,11 +273,11 @@ namespace Frame { if (sec == Section::Playing) { // Do nothing if playing but allow to be selected - l->setCallback(nullptr); + l->onPress(nullptr); } else if (sec == Section::Queue) { // Set sub queue idx - l->setCallback([this, l](){ + l->onPress([this, l](){ // Calculate distance since first song in queue size_t num = std::distance(this->queueEls.begin(), std::find(this->queueEls.begin(), this->queueEls.end(), l)); @@ -287,7 +287,7 @@ namespace Frame { } else if (sec == Section::UpNext) { // Set up next idx - l->setCallback([this, l](){ + l->onPress([this, l](){ // Calculate distance since start (find will always return within list) size_t idx = std::distance(this->upnextEls.begin(), std::find(this->upnextEls.begin(), this->upnextEls.end(), l)); idx += this->app->sysmodule()->songIdx(); @@ -344,13 +344,13 @@ namespace Frame { b->setText("Queue.RemoveFromQueue"_lang); b->setTextColour(this->app->theme()->FG()); if (sec == Section::Queue) { - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->app->sysmodule()->sendRemoveFromSubQueue(pos); this->menu->close(); }); } else if (sec == Section::UpNext) { - b->setCallback([this, pos]() { + b->onPress([this, pos]() { this->app->sysmodule()->sendRemoveFromQueue(pos); this->menu->close(); }); @@ -364,7 +364,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->app->sysmodule()->sendAddToSubQueue(id); this->menu->close(); }); @@ -376,7 +376,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->showAddToPlaylist([this, id](PlaylistID i) { if (i >= 0) { this->app->database()->addSongToPlaylist(i, id); @@ -393,7 +393,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.GoToArtist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { ArtistID a = this->app->database()->getArtistIDForSong(id); if (a >= 0) { this->changeFrame(Type::Artist, Action::Push, a); @@ -408,7 +408,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.GoToAlbum"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { AlbumID a = this->app->database()->getAlbumIDForSong(id); if (a >= 0) { this->changeFrame(Type::Album, Action::Push, a); @@ -424,7 +424,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->changeFrame(Type::SongInfo, Action::Push, id); this->menu->close(); }); @@ -442,4 +442,4 @@ namespace Frame { Queue::~Queue() { delete this->menu; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/Search.cpp b/Application/source/ui/frame/Search.cpp index fb66eae..1a9ca1c 100644 --- a/Application/source/ui/frame/Search.cpp +++ b/Application/source/ui/frame/Search.cpp @@ -117,7 +117,7 @@ namespace Frame { l->setTextColour(this->app->theme()->FG()); l->setMutedTextColour(this->app->theme()->muted()); PlaylistID id = this->playlists[i].ID; - l->setCallback([this, id](){ + l->onPress([this, id](){ this->changeFrame(Type::Playlist, Action::Push, id); }); l->setMoreCallback([this, id]() { @@ -169,7 +169,7 @@ namespace Frame { l->setTextColour(this->app->theme()->FG()); l->setMutedTextColour(this->app->theme()->muted()); ArtistID id = this->artists[i].ID; - l->setCallback([this, id](){ + l->onPress([this, id](){ this->changeFrame(Type::Artist, Action::Push, id); }); l->setMoreCallback([this, id]() { @@ -208,7 +208,7 @@ namespace Frame { l->setTextColour(this->app->theme()->FG()); l->setMutedTextColour(this->app->theme()->muted()); AlbumID id = this->albums[i].ID; - l->setCallback([this, id](){ + l->onPress([this, id](){ this->changeFrame(Type::Album, Action::Push, id); }); l->setMoreCallback([this, id]() { @@ -249,7 +249,7 @@ namespace Frame { l->setMoreColour(this->app->theme()->muted()); l->setTextColour(this->app->theme()->FG()); std::string phrase = keyboard.buffer; - l->setCallback([this, phrase, i](){ + l->onPress([this, phrase, i](){ this->playNewQueue("'" + phrase + "'", this->songIDs, i, false); }); SongID id = this->songs[i].ID; @@ -348,7 +348,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.Play"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, m]() { + b->onPress([this, m]() { std::vector v = this->app->database()->getSongMetadataForPlaylist(m.ID, Database::SortBy::TitleAsc); if (v.size() > 0) { std::vector ids; @@ -368,7 +368,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, m]() { + b->onPress([this, m]() { std::vector v = this->app->database()->getSongMetadataForPlaylist(m.ID, Database::SortBy::TitleAsc); for (size_t i = 0; i < v.size(); i++) { this->app->sysmodule()->sendAddToSubQueue(v[i].song.ID); @@ -383,7 +383,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Playlist.AddToOtherPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, m]() { + b->onPress([this, m]() { this->showAddToPlaylist([this, m](PlaylistID i) { if (i >= 0) { // Get list of songs and add one-by-one to other playlist @@ -404,7 +404,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, m]() { + b->onPress([this, m]() { this->changeFrame(Type::PlaylistInfo, Action::Push, m.ID); this->menu->close(); }); @@ -442,7 +442,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Artist.PlayAll"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, m]() { + b->onPress([this, m]() { std::vector v = this->app->database()->getSongMetadataForArtist(m.ID); std::vector ids; for (size_t i = 0; i < v.size(); i++) { @@ -460,7 +460,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { std::vector v = this->app->database()->getSongMetadataForArtist(id); for (size_t i = 0; i < v.size(); i++) { this->app->sysmodule()->sendAddToSubQueue(v[i].ID); @@ -475,7 +475,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->showAddToPlaylist([this, id](PlaylistID i) { if (i >= 0) { std::vector v = this->app->database()->getSongMetadataForArtist(id); @@ -495,7 +495,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->changeFrame(Type::ArtistInfo, Action::Push, id); this->menu->close(); }); @@ -520,7 +520,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.Play"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, m]() { + b->onPress([this, m]() { std::vector v = this->app->database()->getSongMetadataForAlbum(m.ID); std::vector ids; for (size_t i = 0; i < v.size(); i++) { @@ -538,7 +538,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { std::vector v = this->app->database()->getSongMetadataForAlbum(id); for (size_t i = 0; i < v.size(); i++) { this->app->sysmodule()->sendAddToSubQueue(v[i].ID); @@ -553,7 +553,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->showAddToPlaylist([this, id](PlaylistID i) { if (i >= 0) { std::vector v = this->app->database()->getSongMetadataForAlbum(id); @@ -575,14 +575,14 @@ namespace Frame { if (m.artist != "Various Artists") { b->setText("Common.GoToArtist"_lang); ArtistID aID = this->app->database()->getArtistIDForName(m.artist); - b->setCallback([this, aID]() { + b->onPress([this, aID]() { this->changeFrame(Type::Artist, Action::Push, aID); this->menu->close(); }); } else { b->setText("Common.ViewArtists"_lang); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->createArtistsList(id); this->menu->close(); }); @@ -596,7 +596,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->changeFrame(Type::AlbumInfo, Action::Push, id); this->menu->close(); }); @@ -623,7 +623,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->app->sysmodule()->sendAddToSubQueue(id); this->menu->close(); }); @@ -635,7 +635,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->showAddToPlaylist([this, id](PlaylistID i) { if (i >= 0) { this->app->database()->addSongToPlaylist(i, id); @@ -652,7 +652,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.GoToArtist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { ArtistID a = this->app->database()->getArtistIDForSong(id); if (a >= 0) { this->changeFrame(Type::Artist, Action::Push, a); @@ -667,7 +667,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.GoToAlbum"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { AlbumID a = this->app->database()->getAlbumIDForSong(id); if (a >= 0) { this->changeFrame(Type::Album, Action::Push, a); @@ -683,7 +683,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->changeFrame(Type::SongInfo, Action::Push, id); this->menu->close(); }); @@ -709,7 +709,7 @@ namespace Frame { l->setLineColour(this->app->theme()->muted2()); l->setTextColour(this->app->theme()->FG()); ArtistID aID = m[i].ID; - l->setCallback([this, aID]() { + l->onPress([this, aID]() { this->changeFrame(Type::Artist, Action::Push, aID); this->artistsList->close(); }); @@ -741,4 +741,4 @@ namespace Frame { delete this->artistsList; delete this->menu; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/Songs.cpp b/Application/source/ui/frame/Songs.cpp index 69ac5a8..1b2588e 100644 --- a/Application/source/ui/frame/Songs.cpp +++ b/Application/source/ui/frame/Songs.cpp @@ -28,7 +28,7 @@ namespace Frame { this->sortMenu->setIconColour(this->app->theme()->muted()); this->sortMenu->setLineColour(this->app->theme()->muted2()); this->sortMenu->setTextColour(this->app->theme()->FG()); - this->sort->setCallback([this]() { + this->sort->onPress([this]() { this->app->addOverlay(this->sortMenu); }); @@ -55,7 +55,7 @@ namespace Frame { l->setLineColour(this->app->theme()->muted2()); l->setMoreColour(this->app->theme()->muted()); l->setTextColour(this->app->theme()->FG()); - l->setCallback([this, i](){ + l->onPress([this, i](){ this->playNewQueue("Song.YourSongs"_lang, this->songIDs, i, false); }); SongID id = m[i].ID; @@ -112,7 +112,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToQueue"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->app->sysmodule()->sendAddToSubQueue(id); this->menu->close(); }); @@ -124,7 +124,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.AddToPlaylist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->showAddToPlaylist([this, id](PlaylistID i) { if (i >= 0) { this->app->database()->addSongToPlaylist(i, id); @@ -141,7 +141,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.GoToArtist"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { ArtistID a = this->app->database()->getArtistIDForSong(id); if (a >= 0) { this->changeFrame(Type::Artist, Action::Push, a); @@ -156,7 +156,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.GoToAlbum"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { AlbumID a = this->app->database()->getAlbumIDForSong(id); if (a >= 0) { this->changeFrame(Type::Album, Action::Push, a); @@ -172,7 +172,7 @@ namespace Frame { b->setIconColour(this->app->theme()->muted()); b->setText("Common.ViewInformation"_lang); b->setTextColour(this->app->theme()->FG()); - b->setCallback([this, id]() { + b->onPress([this, id]() { this->changeFrame(Type::SongInfo, Action::Push, id); this->menu->close(); }); @@ -187,4 +187,4 @@ namespace Frame { delete this->menu; delete this->sortMenu; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/settings/About.cpp b/Application/source/ui/frame/settings/About.cpp index 78ff626..290bf6f 100644 --- a/Application/source/ui/frame/settings/About.cpp +++ b/Application/source/ui/frame/settings/About.cpp @@ -79,4 +79,4 @@ namespace Frame::Settings { this->addComment("TagLib\nLGPL 2.1 License\nhttps://github.com/taglib/taglib"); this->addComment("zziplib\nCopyright © 2000-2020 Guido Draheim\nGPL 2 License\nhttps://github.com/gdraheim/zziplib"); } -} \ No newline at end of file +} diff --git a/Application/source/ui/frame/settings/AppAdvanced.cpp b/Application/source/ui/frame/settings/AppAdvanced.cpp index f612a71..7181c56 100644 --- a/Application/source/ui/frame/settings/AppAdvanced.cpp +++ b/Application/source/ui/frame/settings/AppAdvanced.cpp @@ -28,7 +28,7 @@ namespace Frame::Settings { // Advanced::set_queue_max opt = new Aether::ListOption("Settings.AppAdvanced.InitialQueueSize"_lang, std::to_string(cfg->setQueueMax()), nullptr); - opt->setCallback([this, cfg, opt]() { + opt->onPress([this, cfg, opt]() { int val = cfg->setQueueMax(); if (this->getNumberInput(val, "Settings.AppAdvanced.InitialQueueSize"_lang, "", true)) { val = (val < -1 ? -1 : (val > 65535 ? 65535 : val)); @@ -45,7 +45,7 @@ namespace Frame::Settings { // Advanced::search_max_phrases opt = new Aether::ListOption("Settings.AppAdvanced.MaximumSearchPhrases"_lang, std::to_string(cfg->searchMaxPhrases()), nullptr); - opt->setCallback([this, cfg, opt]() { + opt->onPress([this, cfg, opt]() { int val = cfg->searchMaxPhrases(); if (this->getNumberInput(val, "Settings.AppAdvanced.MaximumSearchPhrases"_lang, "", false)) { val = (val < 1 ? 1 : val); @@ -61,7 +61,7 @@ namespace Frame::Settings { // Advanced::search_max_score opt = new Aether::ListOption("Settings.AppAdvanced.MaximumSearchScore"_lang, std::to_string(cfg->searchMaxScore()), nullptr); - opt->setCallback([this, cfg, opt]() { + opt->onPress([this, cfg, opt]() { int val = cfg->searchMaxScore(); if (this->getNumberInput(val, "Settings.AppAdvanced.MaximumSearchScore"_lang, "", false)) { val = (val < 30 ? 30 : val); @@ -103,4 +103,4 @@ namespace Frame::Settings { } } } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/settings/AppAppearance.cpp b/Application/source/ui/frame/settings/AppAppearance.cpp index d57a34b..cdc5793 100644 --- a/Application/source/ui/frame/settings/AppAppearance.cpp +++ b/Application/source/ui/frame/settings/AppAppearance.cpp @@ -11,7 +11,7 @@ namespace Frame::Settings { // Appearance::accent_colour opt = new Aether::ListOption("Settings.AppAppearance.AccentColour"_lang, Theme::colourToString(cfg->accentColour()), nullptr); - opt->setCallback([this, opt]() { + opt->onPress([this, opt]() { this->showAccentColourList(opt); }); opt->setColours(this->app->theme()->muted2(), this->app->theme()->FG(), this->app->theme()->accent()); @@ -29,7 +29,7 @@ namespace Frame::Settings { // Appearance::language opt = new Aether::ListOption("Settings.AppAppearance.Language"_lang, Utils::Lang::languageToString(cfg->language()), nullptr); - opt->setCallback([this, opt]() { + opt->onPress([this, opt]() { this->showLanguageList(opt); }); opt->setColours(this->app->theme()->muted2(), this->app->theme()->FG(), this->app->theme()->accent()); @@ -113,4 +113,4 @@ namespace Frame::Settings { AppAppearance::~AppAppearance() { delete this->ovlList; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/settings/AppGeneral.cpp b/Application/source/ui/frame/settings/AppGeneral.cpp index c4be6e4..ba38a8c 100644 --- a/Application/source/ui/frame/settings/AppGeneral.cpp +++ b/Application/source/ui/frame/settings/AppGeneral.cpp @@ -55,7 +55,7 @@ namespace Frame::Settings { // General::initial_frame opt = new Aether::ListOption("Settings.AppGeneral.InitialSection"_lang, frameToString(cfg->initialFrame()), nullptr); - opt->setCallback([this, opt]() { + opt->onPress([this, opt]() { this->showInitialFrameList(opt); }); opt->setColours(this->app->theme()->muted2(), this->app->theme()->FG(), this->app->theme()->accent()); @@ -73,7 +73,7 @@ namespace Frame::Settings { // General::log_level opt = new Aether::ListOption("Settings.AppGeneral.LoggingLevel"_lang, Log::levelToString(cfg->logLevel()), nullptr); - opt->setCallback([this, opt]() { + opt->onPress([this, opt]() { this->showLogLevelList(opt); }); opt->setColours(this->app->theme()->muted2(), this->app->theme()->FG(), this->app->theme()->accent()); @@ -138,4 +138,4 @@ namespace Frame::Settings { AppGeneral::~AppGeneral() { delete this->ovlList; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/settings/AppSearch.cpp b/Application/source/ui/frame/settings/AppSearch.cpp index ce80822..aae25d9 100644 --- a/Application/source/ui/frame/settings/AppSearch.cpp +++ b/Application/source/ui/frame/settings/AppSearch.cpp @@ -10,7 +10,7 @@ namespace Frame::Settings { // Search::max_playlists opt = new Aether::ListOption("Settings.AppSearch.PlaylistLimit"_lang, std::to_string(cfg->searchMaxPlaylists()), nullptr); - opt->setCallback([this, cfg, opt]() { + opt->onPress([this, cfg, opt]() { int val = cfg->searchMaxPlaylists(); if (this->getNumberInput(val, "Settings.AppSearch.PlaylistLimit"_lang, "", true)) { val = (val < -1 ? -1 : val); @@ -24,7 +24,7 @@ namespace Frame::Settings { // Search::max_albums opt = new Aether::ListOption("Settings.AppSearch.AlbumLimit"_lang, std::to_string(cfg->searchMaxAlbums()), nullptr); - opt->setCallback([this, cfg, opt]() { + opt->onPress([this, cfg, opt]() { int val = cfg->searchMaxAlbums(); if (this->getNumberInput(val, "Settings.AppSearch.AlbumLimit"_lang, "", true)) { val = (val < -1 ? -1 : val); @@ -38,7 +38,7 @@ namespace Frame::Settings { // Search::max_artists opt = new Aether::ListOption("Settings.AppSearch.ArtistLimit"_lang, std::to_string(cfg->searchMaxArtists()), nullptr); - opt->setCallback([this, cfg, opt]() { + opt->onPress([this, cfg, opt]() { int val = cfg->searchMaxArtists(); if (this->getNumberInput(val, "Settings.AppSearch.ArtistLimit"_lang, "", true)) { val = (val < -1 ? -1 : val); @@ -52,7 +52,7 @@ namespace Frame::Settings { // Search::max_songs opt = new Aether::ListOption("Settings.AppSearch.SongLimit"_lang, std::to_string(cfg->searchMaxSongs()), nullptr); - opt->setCallback([this, cfg, opt]() { + opt->onPress([this, cfg, opt]() { int val = cfg->searchMaxSongs(); if (this->getNumberInput(val, "Settings.AppSearch.SongLimit"_lang, "", true)) { val = (val < -1 ? -1 : val); @@ -68,4 +68,4 @@ namespace Frame::Settings { this->addComment("Settings.AppSearch.Comment"_lang); this->list->addElement(new Aether::ListSeparator()); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/settings/Frame.cpp b/Application/source/ui/frame/settings/Frame.cpp index cceb0bc..f36e810 100644 --- a/Application/source/ui/frame/settings/Frame.cpp +++ b/Application/source/ui/frame/settings/Frame.cpp @@ -36,7 +36,7 @@ namespace Frame::Settings { // Create element and set appropriate text/colour based on above value Aether::ListOption * opt = new Aether::ListOption(str, (b ? "Common.Yes"_lang : "Common.No"_lang), nullptr); - opt->setCallback([this, opt, get, set]() { + opt->onPress([this, opt, get, set]() { // Set opposite value bool b = get(); set(!b); @@ -68,4 +68,4 @@ namespace Frame::Settings { } return false; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/frame/settings/SysGeneral.cpp b/Application/source/ui/frame/settings/SysGeneral.cpp index ca605cd..426547b 100644 --- a/Application/source/ui/frame/settings/SysGeneral.cpp +++ b/Application/source/ui/frame/settings/SysGeneral.cpp @@ -57,7 +57,7 @@ namespace Frame::Settings { // General::key_combo_next opt = new Aether::ListOption("Settings.SysGeneral.NextTrack"_lang, NX::comboToUnicodeString(cfg->sysKeyComboNext(), " + "), nullptr); - opt->setCallback([this, cfg, opt]() { + opt->onPress([this, cfg, opt]() { this->showPickCombo("Settings.SysGeneral.NextTrackCombination"_lang, opt, [cfg]() -> std::vector { return cfg->sysKeyComboNext(); }, [cfg](const std::vector & combo) -> bool { @@ -69,7 +69,7 @@ namespace Frame::Settings { // General::key_combo_play opt = new Aether::ListOption("Settings.SysGeneral.PlayPause"_lang, NX::comboToUnicodeString(cfg->sysKeyComboPlay(), " + "), nullptr); - opt->setCallback([this, cfg, opt]() { + opt->onPress([this, cfg, opt]() { this->showPickCombo("Settings.SysGeneral.PlayPauseCombination"_lang, opt, [cfg]() -> std::vector { return cfg->sysKeyComboPlay(); }, [cfg](const std::vector & combo) -> bool { @@ -81,7 +81,7 @@ namespace Frame::Settings { // General::key_combo_prev opt = new Aether::ListOption("Settings.SysGeneral.PrevTrack"_lang, NX::comboToUnicodeString(cfg->sysKeyComboPrev(), " + "), nullptr); - opt->setCallback([this, cfg, opt]() { + opt->onPress([this, cfg, opt]() { this->showPickCombo("Settings.SysGeneral.PrevTrackCombination"_lang, opt, [cfg]() -> std::vector { return cfg->sysKeyComboPrev(); }, [cfg](const std::vector & combo) -> bool { @@ -95,7 +95,7 @@ namespace Frame::Settings { // General::log_level opt = new Aether::ListOption("Settings.SysGeneral.LoggingLevel"_lang, Log::levelToString(cfg->sysLogLevel()), nullptr); - opt->setCallback([this, opt]() { + opt->onPress([this, opt]() { this->showLogLevelList(opt); }); opt->setColours(this->app->theme()->muted2(), this->app->theme()->FG(), this->app->theme()->accent()); @@ -191,4 +191,4 @@ namespace Frame::Settings { delete this->ovlCombo; delete this->ovlList; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/overlay/AddToPlaylist.cpp b/Application/source/ui/overlay/AddToPlaylist.cpp index 9866b73..4c95765 100644 --- a/Application/source/ui/overlay/AddToPlaylist.cpp +++ b/Application/source/ui/overlay/AddToPlaylist.cpp @@ -51,10 +51,10 @@ namespace CustomOvl { void AddToPlaylist::addPlaylist(CustomElm::ListItem::Playlist * l, PlaylistID id) { l->setMoreCallback([l]() { - l->callback(); + l->onPressFunc(); }); l->setMoreColour(Aether::Colour{0, 0, 0, 0}); - l->setCallback([this, id]() { + l->onPress([this, id]() { if (this->chosenCallback != nullptr) { this->chosenCallback(id); } @@ -66,4 +66,4 @@ namespace CustomOvl { void AddToPlaylist::setChosenCallback(std::function f) { this->chosenCallback = f; } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/overlay/ComboPicker.cpp b/Application/source/ui/overlay/ComboPicker.cpp index 1f48eed..374152f 100644 --- a/Application/source/ui/overlay/ComboPicker.cpp +++ b/Application/source/ui/overlay/ComboPicker.cpp @@ -47,9 +47,10 @@ namespace CustomOvl { this->addElement(this->tip); // Initialize controls - this->ctrl = nullptr; - this->setBackLabel(""); - this->setOKLabel(""); + this->ctrl = new Aether::ControlBar(); + this->ctrl->addControl(Aether::Button::A, ""); + this->ctrl->addControl(Aether::Button::B, ""); + this->addElement(this->ctrl); // Create pickers for (size_t i = 0; i < pickerCount; i++) { @@ -115,20 +116,12 @@ namespace CustomOvl { void ComboPicker::setBackLabel(const std::string & s) { this->labelBack = s; - this->removeElement(this->ctrl); - this->ctrl = new Aether::Controls(); - this->ctrl->addItem(new Aether::ControlItem(Aether::Button::A, this->ok->getString())); - this->ctrl->addItem(new Aether::ControlItem(Aether::Button::B, this->labelBack)); - this->addElement(this->ctrl); + this->ctrl->updateControl(Aether::Button::B, s); } void ComboPicker::setOKLabel(const std::string & s) { this->ok->setString(s); - this->removeElement(this->ctrl); - this->ctrl = new Aether::Controls(); - this->ctrl->addItem(new Aether::ControlItem(Aether::Button::A, this->ok->getString())); - this->ctrl->addItem(new Aether::ControlItem(Aether::Button::B, this->labelBack)); - this->addElement(this->ctrl); + this->ctrl->updateControl(Aether::Button::A, s); } void ComboPicker::setRemoveLabel(const std::string & s) { @@ -164,15 +157,14 @@ namespace CustomOvl { void ComboPicker::setTextColour(const Aether::Colour & c) { this->title->setColour(c); - this->ctrl->setColour(c); + this->ctrl->setEnabledColour(c); this->ok->setBorderColour(c); this->ok->setTextColour(c); Aether::Colour col = c; - col.r = c.r * 0.65; - col.g = c.g * 0.65; - col.b = c.b * 0.65; - col.r = c.r * 0.65; + col.setR(c.r() * 0.65); + col.setG(c.g() * 0.65); + col.setB(c.b() * 0.65); for (Picker & p : this->pickers) { p.remove->setBorderColour(col); p.remove->setTextColour(col); @@ -187,4 +179,4 @@ namespace CustomOvl { void ComboPicker::setTipText(const std::string & s) { this->tip->setString(s); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/overlay/Equalizer.cpp b/Application/source/ui/overlay/Equalizer.cpp index 9579399..701d950 100644 --- a/Application/source/ui/overlay/Equalizer.cpp +++ b/Application/source/ui/overlay/Equalizer.cpp @@ -25,15 +25,11 @@ namespace CustomOvl { this->title->setY(this->title->y() - this->title->h()/2); this->addElement(this->title); - this->ctrl = new Aether::Controls(); - this->ok = new Aether::ControlItem(Aether::Button::A, "OK"); - this->ctrl->addItem(this->ok); - this->back = new Aether::ControlItem(Aether::Button::B, "Cancel"); - this->ctrl->addItem(this->back); - this->apply = new Aether::ControlItem(Aether::Button::X, "Apply"); - this->ctrl->addItem(this->apply); - this->reset = new Aether::ControlItem(Aether::Button::Y, "Reset"); - this->ctrl->addItem(this->reset); + this->ctrl = new Aether::ControlBar(); + this->ctrl->addControl(Aether::Button::A, "OK"); + this->ctrl->addControl(Aether::Button::B, "Cancel"); + this->ctrl->addControl(Aether::Button::X, "Apply"); + this->ctrl->addControl(Aether::Button::Y, "Reset"); this->addElement(this->ctrl); for (size_t i = 0; i < this->sliders.size(); i++) { @@ -88,37 +84,19 @@ namespace CustomOvl { } void Equalizer::setApplyLabel(const std::string & s) { - this->ctrl->removeItem(this->apply); - this->ctrl->returnItem(this->reset); - this->apply = new Aether::ControlItem(Aether::Button::X, s); - this->ctrl->addItem(this->apply); - this->ctrl->addItem(this->reset); + this->ctrl->updateControl(Aether::Button::X, s); } void Equalizer::setBackLabel(const std::string & s) { - this->ctrl->removeItem(this->back); - this->ctrl->returnAllItems(); - this->ctrl->addItem(this->ok); - this->back = new Aether::ControlItem(Aether::Button::B, s); - this->ctrl->addItem(this->back); - this->ctrl->addItem(this->apply); - this->ctrl->addItem(this->reset); + this->ctrl->updateControl(Aether::Button::B, s); } void Equalizer::setResetLabel(const std::string & s) { - this->ctrl->removeItem(this->reset); - this->reset = new Aether::ControlItem(Aether::Button::Y, s); - this->ctrl->addItem(this->reset); + this->ctrl->updateControl(Aether::Button::Y, s); } void Equalizer::setOKLabel(const std::string & s) { - this->ctrl->removeItem(this->ok); - this->ctrl->returnAllItems(); - this->ok = new Aether::ControlItem(Aether::Button::A, s); - this->ctrl->addItem(this->ok); - this->ctrl->addItem(this->back); - this->ctrl->addItem(this->apply); - this->ctrl->addItem(this->reset); + this->ctrl->updateControl(Aether::Button::A, s); } void Equalizer::setBackgroundColour(const Aether::Colour & c) { @@ -129,7 +107,7 @@ namespace CustomOvl { for (size_t i = 0; i < this->sliderIndexes.size(); i++) { this->sliderIndexes[i]->setColour(c); } - this->ctrl->setColour(c); + this->ctrl->setEnabledColour(c); this->title->setColour(c); } @@ -155,4 +133,4 @@ namespace CustomOvl { this->sliders[i]->setKnobColour(c); } } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/overlay/FileBrowser.cpp b/Application/source/ui/overlay/FileBrowser.cpp index f640189..28f41d6 100644 --- a/Application/source/ui/overlay/FileBrowser.cpp +++ b/Application/source/ui/overlay/FileBrowser.cpp @@ -99,7 +99,7 @@ namespace CustomOvl { this->setFile(path); }); } - l->setIconColour(this->path->getColour()); + l->setIconColour(this->path->colour()); l->setTextColour(this->text); this->list->addElement(l); } @@ -176,4 +176,4 @@ namespace CustomOvl { return Overlay::handleEvent(e); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/overlay/ItemMenu.cpp b/Application/source/ui/overlay/ItemMenu.cpp index 30c483f..045a844 100644 --- a/Application/source/ui/overlay/ItemMenu.cpp +++ b/Application/source/ui/overlay/ItemMenu.cpp @@ -10,9 +10,9 @@ namespace CustomOvl { this->top = new Aether::Element(this->bg->x() + 20, this->bg->y() + this->nextY, this->bg->w() - 40, IMAGE_SIZE + 2*PADDING); this->image = nullptr; this->mainText = new Aether::Text(this->top->x() + IMAGE_SIZE + 2*PADDING, this->top->y() + 30, "", 24); - this->mainText->setScroll(true); + this->mainText->setCanScroll(true); + this->mainText->setScrollPause(1200); this->mainText->setScrollSpeed(35); - this->mainText->setScrollWaitTime(1200); this->top->addElement(this->mainText); this->subText = new Aether::Text(this->top->x() + IMAGE_SIZE + 2*PADDING, this->mainText->y() + 32, "", 18); this->top->addElement(this->subText); @@ -53,4 +53,4 @@ namespace CustomOvl { void ItemMenu::setSubTextColour(Aether::Colour c) { this->subText->setColour(c); } -} \ No newline at end of file +} diff --git a/Application/source/ui/overlay/NewPlaylist.cpp b/Application/source/ui/overlay/NewPlaylist.cpp index 94a2882..e289243 100644 --- a/Application/source/ui/overlay/NewPlaylist.cpp +++ b/Application/source/ui/overlay/NewPlaylist.cpp @@ -77,7 +77,7 @@ namespace CustomOvl { } void NewPlaylist::setImage(Aether::Image * i) { - i->setCallback(this->image->callback()); + i->onPress(this->image->onPressFunc()); i->setXY(this->image->x(), this->image->y()); i->setWH(this->image->w(), this->image->h()); this->removeElement(this->image); @@ -86,7 +86,7 @@ namespace CustomOvl { } void NewPlaylist::setImageCallback(std::function f) { - this->image->setCallback(f); + this->image->onPress(f); } void NewPlaylist::setNameCallback(std::function f) { @@ -94,7 +94,7 @@ namespace CustomOvl { } void NewPlaylist::setOKCallback(std::function f) { - this->ok->setCallback(f); + this->ok->onPress(f); } void NewPlaylist::setCancelString(const std::string & s) { @@ -133,4 +133,4 @@ namespace CustomOvl { void NewPlaylist::setTextColour(Aether::Colour c) { this->name->setTextColour(c); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/overlay/ProgressBox.cpp b/Application/source/ui/overlay/ProgressBox.cpp index a796e18..4601318 100644 --- a/Application/source/ui/overlay/ProgressBox.cpp +++ b/Application/source/ui/overlay/ProgressBox.cpp @@ -51,7 +51,7 @@ namespace CustomOvl { void ProgressBox::setSubheadingText(const std::string & s) { this->subheading->setString(s); - if (this->subheading->texW() > this->bg->w() - 2*X_PADDING) { + if (this->subheading->textureWidth() > this->bg->w() - 2*X_PADDING) { this->subheading->setW(this->bg->w() - 2*X_PADDING); } } @@ -84,4 +84,4 @@ namespace CustomOvl { this->animFrames[i]->setColour(c); } } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/overlay/SortBy.cpp b/Application/source/ui/overlay/SortBy.cpp index 3ca0139..7727b9d 100644 --- a/Application/source/ui/overlay/SortBy.cpp +++ b/Application/source/ui/overlay/SortBy.cpp @@ -68,7 +68,7 @@ namespace CustomOvl { } b->setText(sort[i].text); Entry entry = sort[i]; - b->setCallback([this, entry]() { + b->onPress([this, entry]() { this->close(); this->callback(entry.type); }); @@ -127,4 +127,4 @@ namespace CustomOvl { b->setTextColour(c); } } -} \ No newline at end of file +} diff --git a/Application/source/ui/screen/Fullscreen.cpp b/Application/source/ui/screen/Fullscreen.cpp index fe45e49..af432c2 100644 --- a/Application/source/ui/screen/Fullscreen.cpp +++ b/Application/source/ui/screen/Fullscreen.cpp @@ -36,13 +36,13 @@ namespace Screen { if (this->buttonMs < 0) { // Fade in double per = (this->buttonMs/(double)-FADE_IN_TIME); - colour.a = 255 - 255*per; + colour.setA(255 - 255*per); } else if (this->buttonMs > HI_TIMEOUT) { // Fade out int val = (this->buttonMs-HI_TIMEOUT > FADE_OUT_TIME ? FADE_OUT_TIME : this->buttonMs-HI_TIMEOUT); double per = (val/(double)FADE_OUT_TIME); - colour.a = 255 - 255*per; + colour.setA(255 - 255*per); } return colour; @@ -75,10 +75,10 @@ namespace Screen { // Now create a surface and get colours (if needed) bool useDefault = !this->app->config()->autoPlayerPalette(); - SDL_Surface * image = SDLHelper::renderImageS(path); + Aether::Drawable * image = this->renderer->renderImageSurface(path, 0, 0); if (!useDefault) { - Utils::Splash::Palette palette = Utils::Splash::getPaletteForSurface(image); + Utils::Splash::Palette palette = Utils::Splash::getPaletteForDrawable(image); if (!palette.invalid) { // Set matching colours if valid if (palette.bgLight) { @@ -89,9 +89,9 @@ namespace Screen { this->primary = palette.primary; this->secondary = palette.secondary; this->tertiary = Utils::Splash::changeLightness(this->secondary, -10); - this->tertiary.a = 200; + this->tertiary.setA(200); } - palette.background.a = (palette.bgLight ? 150 : 255); + palette.background.setA(palette.bgLight ? 150 : 255); this->targetBackground = palette.background; } else { useDefault = true; @@ -209,8 +209,8 @@ namespace Screen { size_t i = 0; while (i < this->oldAlbumArt.size()) { // Check if we need to delete the image as it is transparent - Aether::Colour colour = this->oldAlbumArt[i]->getColour(); - int alpha = colour.a; + Aether::Colour colour = this->oldAlbumArt[i]->colour(); + int alpha = colour.a(); alpha -= (255 * (dt/(double)ANIM_TIME)); if (alpha <= 0) { this->removeElement(this->oldAlbumArt[i]); @@ -219,7 +219,7 @@ namespace Screen { } // Otherwise the image can still be seen and should continue fading - colour.a = static_cast(alpha); + colour.setA(static_cast(alpha)); this->oldAlbumArt[i]->setColour(colour); i++; } @@ -227,14 +227,14 @@ namespace Screen { // Fade in new image if (this->albumArt != nullptr) { - Aether::Colour colour = this->albumArt->getColour(); - if (colour.a < 255) { - int alpha = colour.a; + Aether::Colour colour = this->albumArt->colour(); + if (colour.a() < 255) { + int alpha = colour.a(); alpha += (255 * (dt/(double)ANIM_TIME)); if (alpha > 255) { alpha = 255; } - colour.a = static_cast(alpha); + colour.setA(static_cast(alpha)); this->albumArt->setColour(colour); } } @@ -253,12 +253,12 @@ namespace Screen { Metadata::Song m = this->app->database()->getSongMetadataForID(id); if (m.ID != -1) { this->title->setString(m.title); - if (this->title->texW() > MAX_TEXT_WIDTH) { + if (this->title->textureWidth() > MAX_TEXT_WIDTH) { this->title->setW(MAX_TEXT_WIDTH); } this->title->setX(640 - this->title->w()/2); this->artist->setString(m.artist); - if (this->artist->texW() > MAX_TEXT_WIDTH) { + if (this->artist->textureWidth() > MAX_TEXT_WIDTH) { this->artist->setW(MAX_TEXT_WIDTH); } this->artist->setX(640 - this->artist->w()/2); @@ -304,7 +304,7 @@ namespace Screen { // === PLAYING FROM === this->note = new Aether::Image(40, 35, "romfs:/icons/musicnoteback.png"); this->noteElement = new Aether::Element(this->note->x() - 15, this->note->y() - 15, this->note->w() + 30, this->note->h() + 30); - this->noteElement->setCallback([this]() { + this->noteElement->onPress([this]() { this->app->popScreen(); }); this->noteElement->setSelectable(false); @@ -327,9 +327,9 @@ namespace Screen { // === METADATA === this->title = new Aether::Text(0, 450, "", 36); - this->title->setScroll(true); + this->title->setCanScroll(true); + this->title->setScrollPause(1200); this->title->setScrollSpeed(35); - this->title->setScrollWaitTime(1200); this->addElement(this->title); this->artist = new Aether::Text(0, this->title->y() + 50, "", 24); this->addElement(this->artist); @@ -340,7 +340,7 @@ namespace Screen { this->shuffle = new Aether::Image(0, 0, "romfs:/icons/shuffle.png"); this->shuffleC = new CustomElm::RoundButton(480 - BTN_SIZE/2, 590 - BTN_SIZE/2, BTN_SIZE); this->shuffleC->setImage(this->shuffle); - this->shuffleC->setCallback([this]() { + this->shuffleC->onPress([this]() { this->app->sysmodule()->sendSetShuffle((this->app->sysmodule()->shuffleMode() == ShuffleMode::Off ? ShuffleMode::On : ShuffleMode::Off)); }); this->controls->addElement(this->shuffleC); @@ -349,7 +349,7 @@ namespace Screen { this->previous = new Aether::Image(0, 0, "romfs:/icons/previous.png"); this->previousC = new CustomElm::RoundButton(560 - BTN_SIZE/2, 590 - BTN_SIZE/2, BTN_SIZE); this->previousC->setImage(this->previous); - this->previousC->setCallback([this]() { + this->previousC->onPress([this]() { this->app->sysmodule()->sendPrevious(); }); this->controls->addElement(this->previousC); @@ -359,14 +359,14 @@ namespace Screen { this->playC = new CustomElm::RoundButton(640 - BTN_SIZE/2, 590 - BTN_SIZE/2, BTN_SIZE); this->playC->setHidden(true); this->playC->setImage(this->play); - this->playC->setCallback([this]() { + this->playC->onPress([this]() { this->app->sysmodule()->sendResume(); }); this->controls->addElement(this->playC); this->pause = new Aether::Image(0, 0, "romfs:/icons/pausesmall.png"); this->pauseC = new CustomElm::RoundButton(640 - BTN_SIZE/2, 590 - BTN_SIZE/2, BTN_SIZE); this->pauseC->setImage(this->pause); - this->pauseC->setCallback([this]() { + this->pauseC->onPress([this]() { this->app->sysmodule()->sendPause(); }); this->controls->addElement(this->pauseC); @@ -376,7 +376,7 @@ namespace Screen { this->next = new Aether::Image(0, 0, "romfs:/icons/next.png"); this->nextC = new CustomElm::RoundButton(720 - BTN_SIZE/2, 590 - BTN_SIZE/2, BTN_SIZE); this->nextC->setImage(this->next); - this->nextC->setCallback([this]() { + this->nextC->onPress([this]() { this->app->sysmodule()->sendNext(); }); this->controls->addElement(this->nextC); @@ -386,7 +386,7 @@ namespace Screen { this->repeat = new Aether::Image(0, 0, "romfs:/icons/repeat.png"); this->repeatC = new CustomElm::RoundButton(800 - BTN_SIZE/2, 590 - BTN_SIZE/2, BTN_SIZE); this->repeatC->setImage(this->repeat); - this->repeatC->setCallback([this]() { + this->repeatC->onPress([this]() { if (this->app->sysmodule()->repeatMode() == RepeatMode::All) { this->app->sysmodule()->sendSetRepeat(RepeatMode::Off); } else { @@ -398,7 +398,7 @@ namespace Screen { this->repeatOneContainer = new Aether::Container(770, 600, 100, 80); this->repeatOne = new Aether::Image(0, 0, "romfs:/icons/repeatone.png"); this->repeatOneC = new CustomElm::RoundButton(800 - BTN_SIZE/2, 590 - BTN_SIZE/2, BTN_SIZE); - this->repeatOneC->setCallback([this]() { + this->repeatOneC->onPress([this]() { this->app->sysmodule()->sendSetRepeat(RepeatMode::All); }); this->repeatOneC->setImage(this->repeatOne); @@ -413,7 +413,7 @@ namespace Screen { this->addElement(this->position); this->seekBar = new CustomElm::Slider(490, 649, 300, 20, 8); this->seekBar->setNudge(1); - this->seekBar->setCallback([this]() { + this->seekBar->onPress([this]() { this->app->sysmodule()->sendSetPosition(this->seekBar->value()); }); this->addElement(this->seekBar); @@ -459,4 +459,4 @@ namespace Screen { // Reset highlight animation this->app->setHighlightAnimation(nullptr); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/screen/Home.cpp b/Application/source/ui/screen/Home.cpp index c6a742b..1913a00 100644 --- a/Application/source/ui/screen/Home.cpp +++ b/Application/source/ui/screen/Home.cpp @@ -471,7 +471,8 @@ namespace Screen { int maxW = this->backButton->w() - 70 - this->backIcon->w(); this->backText = new Aether::Text(0, 0, "Common.Back"_lang, 26); - while (this->backText->texW() > maxW) { + while (this->backText->textureWidth() > maxW) { + // TODO: Fix // This renders the text each time but should be fine :P this->backText->setFontSize(this->backText->fontSize()-2); } @@ -479,7 +480,7 @@ namespace Screen { this->backText->setColour(this->app->theme()->FG()); this->backButton->addElement(this->backText); - this->backButton->setCallback([this]() { + this->backButton->onPress([this]() { this->backCallback(); }); this->backButton->setSelectable(false); @@ -494,7 +495,8 @@ namespace Screen { maxW = quitButton->w() - 70 - quitIcon->w(); Aether::Text * quitText = new Aether::Text(0, 0, "Common.Quit"_lang, 26); - while (quitText->texW() > maxW) { + while (quitText->textureWidth() > maxW) { + // TODO: Fix // This renders the text each time but should be fine :P quitText->setFontSize(quitText->fontSize()-2); } @@ -502,7 +504,7 @@ namespace Screen { quitText->setColour(this->app->theme()->FG()); quitButton->addElement(quitText); - quitButton->setCallback([this]() { + quitButton->onPress([this]() { this->app->exit(false); }); quitButton->setSelectable(false); @@ -515,7 +517,7 @@ namespace Screen { this->sideSearch->setText("Search.Search"_lang); this->sideSearch->setActiveColour(this->app->theme()->accent()); this->sideSearch->setInactiveColour(this->app->theme()->FG()); - this->sideSearch->setCallback([this](){ + this->sideSearch->onPress([this](){ // If the current frame is search recreate it if (this->frameType == Frame::Type::Search) { this->returnElement(this->playerDim); @@ -537,7 +539,7 @@ namespace Screen { this->sidePlaylists->setText("Playlist.Playlists"_lang); this->sidePlaylists->setActiveColour(this->app->theme()->accent()); this->sidePlaylists->setInactiveColour(this->app->theme()->FG()); - this->sidePlaylists->setCallback([this](){ + this->sidePlaylists->onPress([this](){ this->changeFrame(Frame::Type::Playlists, Frame::Action::Reset); }); this->sideContainer->addElement(this->sidePlaylists); @@ -546,7 +548,7 @@ namespace Screen { this->sideSongs->setText("Song.Songs"_lang); this->sideSongs->setActiveColour(this->app->theme()->accent()); this->sideSongs->setInactiveColour(this->app->theme()->FG()); - this->sideSongs->setCallback([this](){ + this->sideSongs->onPress([this](){ this->changeFrame(Frame::Type::Songs, Frame::Action::Reset); }); this->sideContainer->addElement(this->sideSongs); @@ -555,7 +557,7 @@ namespace Screen { this->sideArtists->setText("Artist.Artists"_lang); this->sideArtists->setActiveColour(this->app->theme()->accent()); this->sideArtists->setInactiveColour(this->app->theme()->FG()); - this->sideArtists->setCallback([this](){ + this->sideArtists->onPress([this](){ this->changeFrame(Frame::Type::Artists, Frame::Action::Reset); }); this->sideContainer->addElement(this->sideArtists); @@ -564,7 +566,7 @@ namespace Screen { this->sideAlbums->setText("Album.Albums"_lang); this->sideAlbums->setActiveColour(this->app->theme()->accent()); this->sideAlbums->setInactiveColour(this->app->theme()->FG()); - this->sideAlbums->setCallback([this](){ + this->sideAlbums->onPress([this](){ this->changeFrame(Frame::Type::Albums, Frame::Action::Reset); }); this->sideContainer->addElement(this->sideAlbums); @@ -576,7 +578,7 @@ namespace Screen { this->sideQueue->setText("Queue.Heading"_lang); this->sideQueue->setActiveColour(this->app->theme()->accent()); this->sideQueue->setInactiveColour(this->app->theme()->FG()); - this->sideQueue->setCallback([this](){ + this->sideQueue->onPress([this](){ // If the current frame is queue recreate it if (this->frameType == Frame::Type::Queue) { this->returnElement(this->playerDim); @@ -598,7 +600,7 @@ namespace Screen { this->sideSettings->setText("Settings.Settings"_lang); this->sideSettings->setActiveColour(this->app->theme()->accent()); this->sideSettings->setInactiveColour(this->app->theme()->FG()); - this->sideSettings->setCallback([this](){ + this->sideSettings->onPress([this](){ this->app->pushScreen(); this->app->setScreen(Main::ScreenID::Settings); }); @@ -712,4 +714,4 @@ namespace Screen { this->removeElement(this->player); this->removeElement(this->container); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/screen/Settings.cpp b/Application/source/ui/screen/Settings.cpp index 7f72e14..e8a2756 100644 --- a/Application/source/ui/screen/Settings.cpp +++ b/Application/source/ui/screen/Settings.cpp @@ -146,7 +146,7 @@ namespace Screen { // Back this->buttonBack = new CustomElm::SideButton(0, 0, 100); this->buttonBack->setText("Settings.BackToLibrary"_lang); - this->buttonBack->setCallback([this]() { + this->buttonBack->onPress([this]() { this->backCallback(); }); this->buttonBack->setActiveColour(this->app->theme()->accent()); @@ -158,7 +158,7 @@ namespace Screen { this->addHeading("Settings.Application"_lang); this->buttonAppGeneral = new CustomElm::SideButton(0, 0, 100); this->buttonAppGeneral->setText("Settings.General"_lang); - this->buttonAppGeneral->setCallback([this]() { + this->buttonAppGeneral->onPress([this]() { this->setupNew(); this->setupAppGeneral(); }); @@ -170,7 +170,7 @@ namespace Screen { // Application (appearance) this->buttonAppAppearance = new CustomElm::SideButton(0, 0, 100); this->buttonAppAppearance->setText("Settings.Appearance"_lang); - this->buttonAppAppearance->setCallback([this]() { + this->buttonAppAppearance->onPress([this]() { this->setupNew(); this->setupAppAppearance(); }); @@ -182,7 +182,7 @@ namespace Screen { // Application (appearance) this->buttonAppMetadata = new CustomElm::SideButton(0, 0, 100); this->buttonAppMetadata->setText("Settings.Metadata"_lang); - this->buttonAppMetadata->setCallback([this]() { + this->buttonAppMetadata->onPress([this]() { this->setupNew(); this->setupAppMetadata(); }); @@ -194,7 +194,7 @@ namespace Screen { // Application (search) this->buttonAppSearch = new CustomElm::SideButton(0, 0, 100); this->buttonAppSearch->setText("Settings.Search"_lang); - this->buttonAppSearch->setCallback([this]() { + this->buttonAppSearch->onPress([this]() { this->setupNew(); this->setupAppSearch(); }); @@ -206,7 +206,7 @@ namespace Screen { // Application (advanced) this->buttonAppAdvanced = new CustomElm::SideButton(0, 0, 100); this->buttonAppAdvanced->setText("Settings.Advanced"_lang); - this->buttonAppAdvanced->setCallback([this]() { + this->buttonAppAdvanced->onPress([this]() { this->setupNew(); this->setupAppAdvanced(); }); @@ -219,7 +219,7 @@ namespace Screen { this->addHeading("Settings.Sysmodule"_lang); this->buttonSysGeneral = new CustomElm::SideButton(0, 0, 100); this->buttonSysGeneral->setText("Settings.General"_lang); - this->buttonSysGeneral->setCallback([this]() { + this->buttonSysGeneral->onPress([this]() { this->setupNew(); this->setupSysGeneral(); }); @@ -231,7 +231,7 @@ namespace Screen { // Sysmodule (MP3) this->buttonSysMP3 = new CustomElm::SideButton(0, 0, 100); this->buttonSysMP3->setText("Settings.MP3"_lang); - this->buttonSysMP3->setCallback([this]() { + this->buttonSysMP3->onPress([this]() { this->setupNew(); this->setupSysMP3(); }); @@ -244,7 +244,7 @@ namespace Screen { this->addHeading("Settings.Miscellaneous"_lang); this->buttonAbout = new CustomElm::SideButton(0, 0, 100); this->buttonAbout->setText("Settings.About"_lang); - this->buttonAbout->setCallback([this]() { + this->buttonAbout->onPress([this]() { this->setupNew(); this->setupAbout(); }); @@ -274,4 +274,4 @@ namespace Screen { this->removeElement(this->sidebarBg); this->removeElement(this->sidebarList); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/screen/Splash.cpp b/Application/source/ui/screen/Splash.cpp index ee28fdb..10f1fa0 100644 --- a/Application/source/ui/screen/Splash.cpp +++ b/Application/source/ui/screen/Splash.cpp @@ -371,7 +371,7 @@ namespace Screen { // Attempt to launch sysmodule if config option is set true if (this->app->sysmodule()->error() == Sysmodule::Error::NotConnected && this->app->config()->autoLaunchService()) { - this->launch->callback()(); + this->launch->onPressFunc()(); return; } @@ -391,4 +391,4 @@ namespace Screen { this->removeElement(this->launch); this->removeElement(this->quit); } -}; \ No newline at end of file +}; diff --git a/Application/source/ui/screen/Update.cpp b/Application/source/ui/screen/Update.cpp index 0228f28..f3df535 100644 --- a/Application/source/ui/screen/Update.cpp +++ b/Application/source/ui/screen/Update.cpp @@ -355,4 +355,4 @@ namespace Screen { delete this->msgbox; delete this->updater; } -}; \ No newline at end of file +}; diff --git a/Application/source/utils/Curl.cpp b/Application/source/utils/Curl.cpp index 625c2be..732e65e 100644 --- a/Application/source/utils/Curl.cpp +++ b/Application/source/utils/Curl.cpp @@ -268,4 +268,4 @@ namespace Utils::Curl { return ret; } -} \ No newline at end of file +} diff --git a/Application/source/utils/Splash.cpp b/Application/source/utils/Splash.cpp index 9741289..f1cbaee 100644 --- a/Application/source/utils/Splash.cpp +++ b/Application/source/utils/Splash.cpp @@ -4,42 +4,41 @@ namespace Utils::Splash { Aether::Colour changeLightness(Aether::Colour old, int val) { - ::Splash::Colour col = ::Splash::Colour(old.a, old.r, old.g, old.b); + ::Splash::Colour col = ::Splash::Colour(old.a(), old.r(), old.g(), old.b()); col = ::Splash::ColourUtils::changeColourLightness(col, val); return Aether::Colour{(uint8_t)col.r(), (uint8_t)col.g(), (uint8_t)col.b(), (uint8_t)col.a()}; } - Palette getPaletteForSurface(SDL_Surface * surf) { + Palette getPaletteForDrawable(Aether::Drawable * drawable) { // Struct to return Palette palette; palette.invalid = true; // Check we actually have a surface - if (surf == nullptr) { - Log::writeError("[SPLASH] Attempted to get a palette for a null surface"); + if (drawable == nullptr || drawable->type() == Aether::Drawable::Type::None) { + Log::writeError("[SPLASH] Attempted to get a palette for an invalid drawable"); return palette; } - // First read pixels from the surface and convert to Splash::Colour - std::vector<::Splash::Colour> pixels; - SDL_LockSurface(surf); - size_t count = surf->w * surf->h; - for (size_t i = 0; i < count; i++) { - // Get RGB values - uint8_t r, g, b, a; - SDL_GetRGBA(*((uint32_t *)surf->pixels + i), surf->format, &r, &g, &b, &a); + // Get pixels from the drawable + Aether::ImageData imageData = drawable->getImageData(); + std::vector colours = imageData.toColourVector(); + if (!imageData.valid() || colours.size() == 0) { + Log::writeError("[SPLASH] Attempted to get a palette for an invalid drawable"); + return palette; + } - // Create object and push onto vector - ::Splash::Colour colour = ::Splash::Colour(a, r, g, b); - pixels.push_back(colour); + // Convert to Splash::Colour + std::vector<::Splash::Colour> pixels; + for (const Aether::Colour & c : colours) { + pixels.push_back(::Splash::Colour(c.a(), c.r(), c.g(), c.b())); } - SDL_UnlockSurface(surf); // Now create a Splash::Bitmap and fill with pixels - ::Splash::Bitmap image = ::Splash::Bitmap(surf->w, surf->h); + ::Splash::Bitmap image = ::Splash::Bitmap(drawable->width(), drawable->height()); size_t amt = image.setPixels(pixels, 0, 0, image.getWidth(), image.getHeight()); if (amt != pixels.size()) { - Log::writeWarning("[SPLASH] Not enough pixels were written to the bitmap - this may result in incorrect colours being picked (wrote: " + std::to_string(amt) + ", wanted: " + std::to_string(surf->w * surf->h) + ")"); + Log::writeWarning("[SPLASH] Not enough pixels were written to the bitmap - this may result in incorrect colours being picked (wrote: " + std::to_string(amt) + ", wanted: " + std::to_string(drawable->width() * drawable->height()) + ")"); } pixels.clear(); @@ -64,11 +63,10 @@ namespace Utils::Splash { amt = (amt < 0.0 ? 0.0 : amt); amt = (amt > 1.0 ? 1.0 : amt); - Aether::Colour mid; - mid.r = ((1.0 - amt) * start.r) + (amt * end.r); - mid.g = ((1.0 - amt) * start.g) + (amt * end.g); - mid.b = ((1.0 - amt) * start.b) + (amt * end.b); - mid.a = ((1.0 - amt) * start.a) + (amt * end.a); - return mid; + double r = ((1.0 - amt) * start.r()) + (amt * end.r()); + double g = ((1.0 - amt) * start.g()) + (amt * end.g()); + double b = ((1.0 - amt) * start.b()) + (amt * end.b()); + double a = ((1.0 - amt) * start.a()) + (amt * end.a()); + return Aether::Colour(r, g, b, a); } -}; \ No newline at end of file +}; diff --git a/Overlay/source/gui/Error.cpp b/Overlay/source/gui/Error.cpp index 8dcf5eb..16b72f0 100644 --- a/Overlay/source/gui/Error.cpp +++ b/Overlay/source/gui/Error.cpp @@ -35,4 +35,4 @@ namespace Gui { frame->setContent(msg); return frame; } -}; \ No newline at end of file +};