Replace Old Widgets
This commit is contained in:
parent
cce8f0e1bc
commit
fcd5eb2d2a
81 changed files with 388 additions and 278 deletions
49
Widgets/public/WidgetApplication.hpp
Normal file
49
Widgets/public/WidgetApplication.hpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#pragma once
|
||||
|
||||
#include "GraphicApplication.hpp"
|
||||
#include "RootWidget.hpp"
|
||||
#include "Timing.hpp"
|
||||
|
||||
namespace tp {
|
||||
class WidgetApplication : public Application {
|
||||
public:
|
||||
WidgetApplication() = default;
|
||||
|
||||
void setRoot(Widget* widget) {
|
||||
mRootWidget.setRootWidget(widget);
|
||||
}
|
||||
|
||||
private:
|
||||
void processFrame(EventHandler* eventHandler, halnf deltaTime) override {
|
||||
const auto rec = RectF({ 0, 0 }, mWindow->getSize());
|
||||
|
||||
Timer timer;
|
||||
mRootWidget.processFrame(eventHandler, rec);
|
||||
mProcTime = timer.timePassed();
|
||||
}
|
||||
|
||||
void drawFrame(Canvas* canvas) override {
|
||||
Timer timer;
|
||||
mRootWidget.drawFrame(*canvas);
|
||||
mDrawTime = timer.timePassed();
|
||||
|
||||
if (mRootWidget.isDebug()) {
|
||||
drawDebug();
|
||||
debugUI();
|
||||
}
|
||||
}
|
||||
|
||||
bool forceNewFrame() override {
|
||||
return mRootWidget.needsUpdate();
|
||||
}
|
||||
|
||||
private:
|
||||
void debugUI();
|
||||
|
||||
private:
|
||||
time_ms mProcTime = 0;
|
||||
time_ms mDrawTime = 0;
|
||||
|
||||
RootWidget mRootWidget;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue