PokeMe64/include/widget/IWidget.h
Philippe Symons e51726eef9 Initial import of the first (extremely early) functional version.
It doesn't look like much, but it's functional ;-)

It can inject distribution pokémon into gen 1 and gen 2 original
cartridges and inject the GS ball in Pokémon Crystal.

That's it. But that was the minimal feature set I had in mind for the
project. In the Readme.md you can find the ideas I have for expanding
the project.

But the first priority is the UI, because it really looks bad right now.
(as I was mostly focused on building blocks and transfer pak
functionality. Not on making it looks good)
2024-07-19 21:46:11 +02:00

76 lines
2.2 KiB
C++
Executable File

#ifndef _IWIDGET_H
#define _IWIDGET_H
#include "core/common.h"
#include <libdragon.h>
class RDPQGraphics;
/**
* This interface class will be used for every UI widget on screen to expose common APIs
*/
class IWidget
{
public:
/**
* @brief Returns whether the widget is currently focused
*/
virtual bool isFocused() const = 0;
/**
* @brief Sets whether the widget is currently focused
*
*/
virtual void setFocused(bool isFocused) = 0;
/**
* @brief Returns whether the widget is currently visible
*/
virtual bool isVisible() const = 0;
/**
* @brief Changes the visibility of the widget
*/
virtual void setVisible(bool visible) = 0;
/**
* @brief Returns the current (relative) bounds of the widget
*/
virtual Rectangle getBounds() const = 0;
/**
* @brief Changes the current (relative) bounds of the widget
*/
virtual void setBounds(const Rectangle& bounds) = 0;
/**
* @brief Returns the size (width/height) of the widget
*/
virtual Dimensions getSize() const = 0;
/**
* @brief Handles user input
*
* For button presses, it is advised to track button release situations instead of
* button presses for executing an action. Otherwise the key press might be handled again immediately
* in the next scene/widget because the user wouldn't have had the time to actually release the key.
*/
virtual bool handleUserInput(const joypad_inputs_t& userInput) = 0;
/**
* @brief Renders the widget
*
* @param gfx The graphics instance that must be used to render the widget
* @param parentBounds The bounds of the parent widget or scene. You must add the x,y offset of your own bounds
* to the parentBounds to get the absolute bounds for rendering.
*
* Getting the parentBounds as an argument of this function was done because a parent widget may be
* animated or change positions independent of the child widget. But when the parent widget moves, the child must as well!
*/
virtual void render(RDPQGraphics& gfx, const Rectangle& parentBounds) = 0;
protected:
private:
};
#endif