diff options
author | Marcelo Fernandez <marcelofg55@gmail.com> | 2018-06-23 22:15:10 -0300 |
---|---|---|
committer | Marcelo Fernandez <marcelofg55@gmail.com> | 2018-06-23 22:15:10 -0300 |
commit | 9634e3586cf547fc951a58983b494f9f0131b07f (patch) | |
tree | 6482d1990df9e638504d41a3d7af711bd7f6fb07 | |
parent | 25275de50e31aa081cdefe0c8b3b76b6389cb6a6 (diff) |
Add a Clear button to the profiler
-rw-r--r-- | editor/editor_profiler.cpp | 19 | ||||
-rw-r--r-- | editor/editor_profiler.h | 2 |
2 files changed, 17 insertions, 4 deletions
diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index fcd3dc2f68..d4a97b7095 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -424,20 +424,25 @@ void EditorProfiler::_update_frame() { void EditorProfiler::_activate_pressed() { if (activate->is_pressed()) { - clear(); activate->set_icon(get_icon("Stop", "EditorIcons")); - activate->set_text(TTR("Stop Profiling")); + activate->set_text(TTR("Stop")); } else { activate->set_icon(get_icon("Play", "EditorIcons")); - activate->set_text(TTR("Start Profiling")); + activate->set_text(TTR("Start")); } emit_signal("enable_profiling", activate->is_pressed()); } +void EditorProfiler::_clear_pressed() { + + clear(); +} + void EditorProfiler::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { activate->set_icon(get_icon("Play", "EditorIcons")); + clear_button->set_icon(get_icon("Clear", "EditorIcons")); } } @@ -599,6 +604,7 @@ void EditorProfiler::_bind_methods() { ClassDB::bind_method(D_METHOD("_update_frame"), &EditorProfiler::_update_frame); ClassDB::bind_method(D_METHOD("_update_plot"), &EditorProfiler::_update_plot); ClassDB::bind_method(D_METHOD("_activate_pressed"), &EditorProfiler::_activate_pressed); + ClassDB::bind_method(D_METHOD("_clear_pressed"), &EditorProfiler::_clear_pressed); ClassDB::bind_method(D_METHOD("_graph_tex_draw"), &EditorProfiler::_graph_tex_draw); ClassDB::bind_method(D_METHOD("_graph_tex_input"), &EditorProfiler::_graph_tex_input); ClassDB::bind_method(D_METHOD("_graph_tex_mouse_exit"), &EditorProfiler::_graph_tex_mouse_exit); @@ -625,10 +631,15 @@ EditorProfiler::EditorProfiler() { add_child(hb); activate = memnew(Button); activate->set_toggle_mode(true); - activate->set_text(TTR("Start Profiling")); + activate->set_text(TTR("Start")); activate->connect("pressed", this, "_activate_pressed"); hb->add_child(activate); + clear_button = memnew(Button); + clear_button->set_text(TTR("Clear")); + clear_button->connect("pressed", this, "_clear_pressed"); + hb->add_child(clear_button); + hb->add_child(memnew(Label(TTR("Measure:")))); display_mode = memnew(OptionButton); diff --git a/editor/editor_profiler.h b/editor/editor_profiler.h index d902a97c5d..cb451475e7 100644 --- a/editor/editor_profiler.h +++ b/editor/editor_profiler.h @@ -100,6 +100,7 @@ public: private: Button *activate; + Button *clear_button; TextureRect *graph; Ref<ImageTexture> graph_texture; PoolVector<uint8_t> graph_image; @@ -133,6 +134,7 @@ private: void _update_frame(); void _activate_pressed(); + void _clear_pressed(); String _get_time_as_text(Metric &m, float p_time, int p_calls); |