Add FpsGraphWindow::DockGraph and UndockGraph
This commit is contained in:
@@ -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:
|
||||
|
16
main.cpp
16
main.cpp
@@ -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");
|
||||
|
Reference in New Issue
Block a user