Add FpsGraphWindow::DockGraph and UndockGraph

This commit is contained in:
2025-06-24 02:52:48 -05:00
parent f46bf097ac
commit 3a0743e787
2 changed files with 26 additions and 2 deletions

View File

@@ -101,7 +101,17 @@ namespace JUI {
FpsGraphWindow();
explicit FpsGraphWindow(Widget* parent);
FpsGraph* GraphWidget() {return data_graph; }
void DockGraph() {
this->Close();
// TODO:: unsafe.
data_graph->Parent(this->GetParent());
data_graph->SetupAsPseudoDockedElementAtBottomOfScreen();
}
void UndockGraph() {
this->Open();
data_graph->Parent(this->Content());
}
protected:
FpsGraph* data_graph;
private:

View File

@@ -56,6 +56,7 @@ JUI::TextRect* widget_count = nullptr;
JUI::CommandLine* console = nullptr;
JUI::Window* nineslice_demo_window = nullptr;
JUI::UtilityBar* topbar = nullptr;
JUI::FpsGraphWindow* fps_graph = nullptr;
/// Returns the sum total of widgets that are considered "descendnats" of the given widget.
/// A descendant is classified as being a child, or child of a child, and so on, of a given widget.
@@ -179,6 +180,19 @@ JUI::UtilityBar* CreateUtilityBar(JUI::Widget* root) {
view->AddButton("Decrease UI Scale 5%", [&] {
ui_scale -= 0.05f;
});
view->AddSeparator();
view->AddButton("Toggle Docked FPSGraph", [&] mutable {
static bool docked = false;
if (docked) {
fps_graph->UndockGraph();
docked = false;
} else {
fps_graph->DockGraph();
docked = true;
}
});
}
@@ -469,7 +483,7 @@ JUI::Scene* CreateScene() {
auto *root = new Scene();
auto* graph_window = new JUI::FpsGraphWindow(root);
fps_graph = new JUI::FpsGraphWindow(root);
auto* colorpicker_wnd = new JUI::Window(root);
colorpicker_wnd->Name("Slider ColorPicker");