Debug Tools and Scrollable widget
This commit is contained in:
parent
f68f91f7d5
commit
458e56fb4c
27 changed files with 274 additions and 103 deletions
|
|
@ -61,7 +61,7 @@ namespace tp {
|
|||
|
||||
protected:
|
||||
Vec2<SizePolicy> mSizePolicy = { SizePolicy::Fixed, SizePolicy::Fixed };
|
||||
Vec2F mMinSize = { 50, 50 };
|
||||
Vec2F mMinSize = { 30, 30 };
|
||||
Vec2F mMaxSize = { FLT_MAX / 2, FLT_MAX / 2 };
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ namespace tp {
|
|||
void setRootWidget(Widget* widget);
|
||||
static void setWidgetArea(Widget& widget, const RectF& rect);
|
||||
|
||||
[[nodiscard]] bool isDebug() const;
|
||||
|
||||
// Graphic Application Interface
|
||||
public:
|
||||
void processFrame(EventHandler* events, const RectF& screenArea);
|
||||
|
|
|
|||
|
|
@ -9,41 +9,24 @@ namespace tp {
|
|||
public:
|
||||
WidgetApplication() = default;
|
||||
|
||||
void setRoot(Widget* widget) {
|
||||
mRootWidget.setRootWidget(widget);
|
||||
}
|
||||
void setRoot(Widget* widget);
|
||||
|
||||
private:
|
||||
void processFrame(EventHandler* eventHandler, halnf deltaTime) override {
|
||||
const auto rec = RectF({ 0, 0 }, mWindow->getSize());
|
||||
void processFrame(EventHandler* eventHandler, halnf deltaTime) override;
|
||||
|
||||
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();
|
||||
}
|
||||
void drawFrame(Canvas* canvas) override;
|
||||
bool forceNewFrame() override ;
|
||||
|
||||
private:
|
||||
void debugUI();
|
||||
|
||||
private:
|
||||
time_ms mProcTime = 0;
|
||||
time_ms mDrawTime = 0;
|
||||
halnf mDebugSplitFactor = 0.7;
|
||||
|
||||
RootWidget mRootWidget;
|
||||
|
||||
private:
|
||||
RectF mGuiArea;
|
||||
RectF mDebugArea;
|
||||
};
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ namespace tp {
|
|||
bool mResizing = false;
|
||||
|
||||
Widget* mCenterWidget = nullptr;
|
||||
RectF mCenterArea {};
|
||||
RectF mCenterArea { 0, 0, 10, 10 };
|
||||
|
||||
// Parameters
|
||||
const halnf mHandleSplitFactor = 0.3;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,56 @@
|
|||
#include <set>
|
||||
|
||||
namespace tp {
|
||||
class DebugTimeline {
|
||||
enum {
|
||||
STEP = 10,
|
||||
LEN = 200,
|
||||
};
|
||||
|
||||
public:
|
||||
DebugTimeline() = default;
|
||||
|
||||
void addSample(time_ms time) {
|
||||
samples[end] = time;
|
||||
start++;
|
||||
end++;
|
||||
shift();
|
||||
}
|
||||
|
||||
[[nodiscard]] int size() const {
|
||||
return LEN - STEP;
|
||||
}
|
||||
|
||||
[[nodiscard]] const time_ms* get() const {
|
||||
return samples + start;
|
||||
}
|
||||
|
||||
private:
|
||||
void shift() {
|
||||
if (end >= LEN) {
|
||||
for (ualni i = STEP; i < LEN; i++) {
|
||||
samples[i - STEP] = samples[i];
|
||||
}
|
||||
start = 0;
|
||||
end = LEN - STEP;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ualni start = 0;
|
||||
ualni end = LEN - STEP;
|
||||
|
||||
time_ms samples[LEN + 1] {};
|
||||
};
|
||||
|
||||
class DebugManager {
|
||||
public:
|
||||
DebugManager() = default;
|
||||
|
||||
bool isRedrawAlways() const { return mDebugRedrawAlways; }
|
||||
bool update(RootWidget* rootWidget, EventHandler& events);
|
||||
[[nodiscard]] bool isFrozen() const { return mDebugStopProcessing; }
|
||||
[[nodiscard]] bool isRedrawAlways() const { return mDebugRedrawAlways; }
|
||||
|
||||
void update(RootWidget* rootWidget, EventHandler& events);
|
||||
void drawDebug(RootWidget* rootWidget, Canvas& canvas);
|
||||
|
||||
void checkProcBreakPoints(Widget* widget) {
|
||||
|
|
@ -32,6 +76,7 @@ namespace tp {
|
|||
private:
|
||||
void recursiveDraw(Canvas& canvas, Widget* active, const Vec2F& pos, int depthOrder);
|
||||
|
||||
void drawPerformance();
|
||||
static void widgetMenu(Widget*);
|
||||
void drawLayoutOrder();
|
||||
|
||||
|
|
@ -42,10 +87,17 @@ namespace tp {
|
|||
bool mDebug = false;
|
||||
bool mDebugStopProcessing = false;
|
||||
bool mDebugRedrawAlways = false;
|
||||
bool mSlowMotion = false;
|
||||
bool mDetailed = false;
|
||||
|
||||
std::set<Widget*> mProcBreakpoints;
|
||||
std::set<Widget*> mLayBreakpoints;
|
||||
|
||||
public:
|
||||
DebugTimeline mProcTime;
|
||||
DebugTimeline mUpdManager;
|
||||
DebugTimeline mLayManager;
|
||||
|
||||
DebugTimeline mDrawTime;
|
||||
};
|
||||
|
||||
extern DebugManager gDebugWidget;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ namespace tp {
|
|||
[[nodiscard]] bool getDirection() const { return mVertical; }
|
||||
[[nodiscard]] halnf getPosFactor() const { return mPosFactor - mSizeFactor / 2; }
|
||||
|
||||
void setDirection(bool direction) { mVertical = direction; }
|
||||
|
||||
private:
|
||||
[[nodiscard]] const RectF& getHandleRect() const;
|
||||
void updateHandleRect();
|
||||
|
|
@ -53,5 +55,13 @@ namespace tp {
|
|||
class ScrollableWidget : public Widget {
|
||||
public:
|
||||
ScrollableWidget();
|
||||
|
||||
void setDirection(bool direction);
|
||||
|
||||
Widget* getContainer() { return &mContent; }
|
||||
|
||||
private:
|
||||
Widget mContent;
|
||||
ScrollableBarWidget mScroller;
|
||||
};
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ namespace tp {
|
|||
void draw(Canvas& canvas) override;
|
||||
|
||||
[[nodiscard]] bool processesEvents() const override { return true; }
|
||||
[[nodiscard]] bool needsNextFrame() const override { return mState != SLIDING; }
|
||||
[[nodiscard]] bool needsNextFrame() const override { return mState != IDLE; }
|
||||
|
||||
[[nodiscard]] halnf val() const { return mFactor; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue