add input debug widget

This commit is contained in:
2020-01-30 11:39:00 +07:00
parent 698a3fb419
commit ae54d9112d
3 changed files with 93 additions and 0 deletions

View File

@@ -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<dbgui_widgets::console_widget>("Debug", "Console...", d);
register_menu_widget<dbgui_widgets::engine_widget>("Debug", "Engine...");
register_menu_widget<dbgui_widgets::input_widget>("Debug", "Input...");
register_menu_widget<dbgui_widgets::window_widget>("Debug", "Window...");
}
dbgui::~dbgui() noexcept = default;

View File

@@ -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<input>() ) {
return false;
}
input& i = the<input>();
{
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<keyboard_key> 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<mouse_button> 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_;
}
}

View File

@@ -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_;
};
}