Debug Tools and Scrollable widget
This commit is contained in:
parent
f68f91f7d5
commit
458e56fb4c
27 changed files with 274 additions and 103 deletions
|
|
@ -5,6 +5,58 @@
|
|||
using namespace tp;
|
||||
|
||||
void WidgetApplication::debugUI() {
|
||||
ImGui::Text("Proc ms : %i", (int) mProcTime);
|
||||
ImGui::SameLine(); ImGui::Text("Draw ms : %i", (int) mDrawTime);
|
||||
// pass
|
||||
}
|
||||
|
||||
void WidgetApplication::setRoot(Widget* widget) {
|
||||
mRootWidget.setRootWidget(widget);
|
||||
|
||||
tp::RootWidget::setWidgetArea(*widget, {{}, mWindow->getSize()});
|
||||
}
|
||||
|
||||
void WidgetApplication::processFrame(EventHandler* eventHandler, halnf deltaTime) {
|
||||
const auto area = RectF({ 0, 0 }, mWindow->getSize());
|
||||
|
||||
gDebugWidget.update(&mRootWidget, *eventHandler);
|
||||
|
||||
if (gDebugWidget.isDebug()) {
|
||||
mGuiArea = area.splitByFactorHL(mDebugSplitFactor);
|
||||
mDebugArea = area.splitByFactorHR(mDebugSplitFactor);
|
||||
} else {
|
||||
mGuiArea = area;
|
||||
}
|
||||
|
||||
if (gDebugWidget.isFrozen()) return;
|
||||
|
||||
Timer timer;
|
||||
mRootWidget.processFrame(eventHandler, mGuiArea);
|
||||
gDebugWidget.mProcTime.addSample(timer.timePassed());
|
||||
}
|
||||
|
||||
void WidgetApplication::drawFrame(Canvas* canvas) {
|
||||
Timer timer;
|
||||
mRootWidget.drawFrame(*canvas);
|
||||
gDebugWidget.mDrawTime.addSample(timer.timePassed());
|
||||
|
||||
if (gDebugWidget.isDebug()) {
|
||||
ImGui::SetNextWindowPos(ImVec2(mDebugArea.x, mDebugArea.y));
|
||||
ImGui::SetNextWindowSize(ImVec2(mDebugArea.z, mDebugArea.w));
|
||||
|
||||
if (ImGui::Begin(
|
||||
"Existing Window Name",
|
||||
nullptr,
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoDecoration
|
||||
)) {
|
||||
|
||||
drawDebug();
|
||||
debugUI();
|
||||
|
||||
gDebugWidget.drawDebug(&mRootWidget, *canvas);
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
bool WidgetApplication::forceNewFrame() {
|
||||
return mRootWidget.needsUpdate();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue