Skip to content

Commit

Permalink
Update Aether and UI
Browse files Browse the repository at this point in the history
  • Loading branch information
tallbl0nde committed Jul 25, 2021
1 parent 6db12f8 commit 2ebea6c
Show file tree
Hide file tree
Showing 82 changed files with 705 additions and 760 deletions.
13 changes: 6 additions & 7 deletions Application/include/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Aether::Colour(uint32_t)>);

Expand All @@ -75,7 +75,6 @@ namespace Main {
void setScreen(ScreenID);
void pushScreen();
void popScreen();
void dropScreen();
void updateScreenTheme();

// Helper functions for database
Expand All @@ -96,14 +95,14 @@ 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
~Application();
};
};

#endif
#endif
6 changes: 3 additions & 3 deletions Application/include/ui/element/ButtonPicker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -39,4 +39,4 @@ namespace CustomElm {
};
};

#endif
#endif
18 changes: 6 additions & 12 deletions Application/include/ui/element/GridItem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,11 +18,11 @@ namespace CustomElm {
std::function<void()> 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<Aether::Text * ()>);

public:
// Constructor sets up elements and takes path to image
Expand Down Expand Up @@ -59,4 +53,4 @@ namespace CustomElm {
};
};

#endif
#endif
31 changes: 23 additions & 8 deletions Application/include/ui/element/Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif
8 changes: 4 additions & 4 deletions Application/include/ui/element/NumberBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif
8 changes: 4 additions & 4 deletions Application/include/ui/element/RoundButton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif
4 changes: 2 additions & 2 deletions Application/include/ui/element/ScrollableGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,4 +59,4 @@ namespace CustomElm {
};
};

#endif
#endif
8 changes: 4 additions & 4 deletions Application/include/ui/element/Slider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif
8 changes: 4 additions & 4 deletions Application/include/ui/element/TextBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif
8 changes: 4 additions & 4 deletions Application/include/ui/element/VSlider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif
4 changes: 2 additions & 2 deletions Application/include/ui/element/listitem/AlbumSong.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,4 +27,4 @@ namespace CustomElm::ListItem {
};
};

#endif
#endif
4 changes: 2 additions & 2 deletions Application/include/ui/element/listitem/Artist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace CustomElm::ListItem {
// Elements
Aether::Image * image;
Aether::Text * name;
void positionItems();
void positionElements();

public:
// Constructor accepts path to image
Expand All @@ -25,4 +25,4 @@ namespace CustomElm::ListItem {
};
};

#endif
#endif
4 changes: 2 additions & 2 deletions Application/include/ui/element/listitem/File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,4 +26,4 @@ namespace CustomElm::ListItem {
};
};

#endif
#endif
39 changes: 9 additions & 30 deletions Application/include/ui/element/listitem/Item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,30 @@
#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<Aether::Texture *> 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<Aether::Text * ()>);

public:
// The constructor will create a line texture if one isn't present
// Optionally takes height of item
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
#endif
4 changes: 3 additions & 1 deletion Application/include/ui/element/listitem/More.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace CustomElm::ListItem {
std::function<void()> moreCallback;
bool touchedMore;

// Note: positionElements() isn't defined by this class!

protected:
//'More' image (child should position it)
Aether::Image * more;
Expand All @@ -31,4 +33,4 @@ namespace CustomElm::ListItem {
};
};

#endif
#endif
4 changes: 2 additions & 2 deletions Application/include/ui/element/listitem/Playlist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -27,4 +27,4 @@ namespace CustomElm::ListItem {
};
};

#endif
#endif
4 changes: 2 additions & 2 deletions Application/include/ui/element/listitem/Song.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,4 +27,4 @@ namespace CustomElm::ListItem {
};
};

#endif
#endif
Loading

0 comments on commit 2ebea6c

Please sign in to comment.