Reorganize code in widgets
This commit is contained in:
parent
837d8dc507
commit
e00dec67ba
31 changed files with 652 additions and 481 deletions
|
|
@ -2,54 +2,41 @@
|
|||
|
||||
#include "Widget.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include "UpdateManager.hpp"
|
||||
#include "LayoutManager.hpp"
|
||||
#include "DebugManager.hpp"
|
||||
|
||||
namespace tp {
|
||||
class RootWidget : public WidgetManagerInterface {
|
||||
friend DebugManager;
|
||||
|
||||
public:
|
||||
RootWidget() { setDebug("root", RGBA(1)); }
|
||||
RootWidget();
|
||||
|
||||
// User Interface
|
||||
public:
|
||||
void setRootWidget(Widget* widget);
|
||||
void updateWidget(Widget*, const char* reason = nullptr) override;
|
||||
|
||||
static void setWidgetArea(Widget& widget, const RectF& rect);
|
||||
|
||||
// Graphic Application Interface
|
||||
public:
|
||||
void processFrame(EventHandler* events, const RectF& screenArea);
|
||||
void drawFrame(Canvas& canvas);
|
||||
|
||||
[[nodiscard]] bool needsUpdate() const;
|
||||
|
||||
// Internals
|
||||
private:
|
||||
void updateTreeToProcess();
|
||||
void updateAnimations();
|
||||
void processLayout();
|
||||
void drawRecursion(Canvas& canvas, Widget* active, const Vec2F& pos);
|
||||
void drawDebug(Canvas& canvas, Widget* active, const Vec2F& pos, int depthOrder);
|
||||
void findFocusWidget(Widget* iter, Widget** focus, const Vec2F& pointer);
|
||||
void handleFocusChanges(EventHandler& events);
|
||||
void getWidgetPath(Widget* widget, std::vector<Widget*>& out);
|
||||
void processActiveTree(Widget* iter, EventHandler& events, Vec2F pos);
|
||||
void processFocusItems(EventHandler& events);
|
||||
|
||||
void updateWidget(Widget*, const char* reason = nullptr) override;
|
||||
void updateAnimations();
|
||||
void updateAreaCache(Widget* iter, bool read);
|
||||
static void debugDrawWidget(Widget* widget);
|
||||
|
||||
private:
|
||||
LayoutManager mLayoutManager;
|
||||
|
||||
RectF mScreenArea;
|
||||
Widget* mRoot = nullptr;
|
||||
|
||||
// frame to frame changes
|
||||
std::map<Widget*, bool> mTriggeredWidgets;
|
||||
Widget* mInFocusWidget = nullptr;
|
||||
|
||||
bool mDebug = true;
|
||||
bool mDebugStopProcessing = false;
|
||||
bool mDebugRedrawAlways = false;
|
||||
int mDebugWidgetsToProcess = 0;
|
||||
LayoutManager mLayoutManager;
|
||||
UpdateManager mUpdateManager;
|
||||
DebugManager mDebugManager;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue