diff --git a/sources/enduro2d/core/dbgui.cpp b/sources/enduro2d/core/dbgui.cpp index 48df160f..585266bf 100644 --- a/sources/enduro2d/core/dbgui.cpp +++ b/sources/enduro2d/core/dbgui.cpp @@ -8,6 +8,7 @@ #include "dbgui_impl/widgets/console_widget.hpp" #include "dbgui_impl/widgets/engine_widget.hpp" +#include "dbgui_impl/widgets/input_widget.hpp" #include "dbgui_impl/widgets/window_widget.hpp" namespace e2d @@ -420,6 +421,7 @@ namespace e2d : state_(new internal_state(d, i, r, w)) { register_menu_widget("Debug", "Console...", d); register_menu_widget("Debug", "Engine..."); + register_menu_widget("Debug", "Input..."); register_menu_widget("Debug", "Window..."); } dbgui::~dbgui() noexcept = default; diff --git a/sources/enduro2d/core/dbgui_impl/widgets/input_widget.cpp b/sources/enduro2d/core/dbgui_impl/widgets/input_widget.cpp new file mode 100644 index 00000000..b4d21868 --- /dev/null +++ b/sources/enduro2d/core/dbgui_impl/widgets/input_widget.cpp @@ -0,0 +1,68 @@ +/******************************************************************************* + * This file is part of the "Enduro2D" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#include "input_widget.hpp" + +namespace e2d::dbgui_widgets +{ + input_widget::input_widget() { + desc_.title = "Input"; + } + + bool input_widget::show() { + if ( !modules::is_initialized() ) { + return false; + } + + input& i = the(); + + { + imgui_utils::show_formatted_text( + "cursor pos: %0", + strings::make_format_arg(i.mouse().cursor_pos(), 0u, 2u)); + + imgui_utils::show_formatted_text( + "scroll delta: %0", + strings::make_format_arg(i.mouse().scroll_delta(), 0u, 2u)); + + ImGui::Separator(); + + imgui_utils::show_formatted_text( + "input text: %0", + i.keyboard().input_text()); + + { + ImGui::Text("pressed keys:"); + + ImGui::Indent(); + E2D_DEFER([](){ ImGui::Unindent(); }); + + const vector pressed_keys = i.keyboard().pressed_keys(); + for ( keyboard_key pk : pressed_keys ) { + imgui_utils::show_formatted_text("%0", pk); + } + } + + { + ImGui::Text("pressed buttons:"); + + ImGui::Indent(); + E2D_DEFER([](){ ImGui::Unindent(); }); + + const vector pressed_buttons = i.mouse().pressed_buttons(); + for ( mouse_button mb : pressed_buttons ) { + imgui_utils::show_formatted_text("%0", mb); + } + } + } + + return true; + } + + const input_widget::description& input_widget::desc() const noexcept { + return desc_; + } +} diff --git a/sources/enduro2d/core/dbgui_impl/widgets/input_widget.hpp b/sources/enduro2d/core/dbgui_impl/widgets/input_widget.hpp new file mode 100644 index 00000000..006b3882 --- /dev/null +++ b/sources/enduro2d/core/dbgui_impl/widgets/input_widget.hpp @@ -0,0 +1,23 @@ +/******************************************************************************* + * This file is part of the "Enduro2D" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../dbgui.hpp" + +namespace e2d::dbgui_widgets +{ + class input_widget final : public dbgui::widget { + public: + input_widget(); + ~input_widget() noexcept = default; + + bool show() override; + const description& desc() const noexcept override; + private: + description desc_; + }; +}