Improve the look of console
This commit is contained in:
parent
1ba5d8f8f3
commit
ab814b7c78
2 changed files with 19 additions and 19 deletions
|
@ -248,18 +248,34 @@ std::string_view get_shader_source_directory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_console() {
|
void draw_console() {
|
||||||
|
const auto font_size = ImGui::GetFontSize();
|
||||||
|
const auto frame_size = ImGui::GetStyle().FrameBorderSize;
|
||||||
|
const auto padding = ImGui::GetStyle().FramePadding;
|
||||||
|
const auto inner_padding = ImGui::GetStyle().ItemInnerSpacing;
|
||||||
|
const auto text_edit_height = font_size + (frame_size + padding.y + inner_padding.y) * 2;
|
||||||
|
|
||||||
|
const auto content_size = ImGui::GetContentRegionAvail();
|
||||||
|
|
||||||
|
ImGui::BeginChild("console", ImVec2(-1, content_size.y - text_edit_height), true);
|
||||||
|
|
||||||
ImGui::Text("%s", prism::log_output.c_str());
|
ImGui::Text("%s", prism::log_output.c_str());
|
||||||
|
|
||||||
|
ImGui::EndChild();
|
||||||
|
|
||||||
static std::string console_input;
|
static std::string console_input;
|
||||||
|
|
||||||
ImGui::SetNextItemWidth(-1.0f);
|
ImGui::SetNextItemWidth(-1.0f);
|
||||||
|
|
||||||
|
ImGui::PushItemWidth(-60.0f); // todo: lol
|
||||||
|
|
||||||
const bool input_return = ImGui::InputText("##console_input", &console_input, ImGuiInputTextFlags_EnterReturnsTrue);
|
const bool input_return = ImGui::InputText("##console_input", &console_input, ImGuiInputTextFlags_EnterReturnsTrue);
|
||||||
|
|
||||||
if(input_return)
|
if(input_return)
|
||||||
ImGui::SetKeyboardFocusHere(-1);
|
ImGui::SetKeyboardFocusHere(-1);
|
||||||
|
|
||||||
const bool button_return = ImGui::Button("Input");
|
ImGui::SameLine();
|
||||||
|
|
||||||
|
const bool button_return = ImGui::Button("Submit");
|
||||||
|
|
||||||
if(input_return || button_return) {
|
if(input_return || button_return) {
|
||||||
prism::console::parse_and_invoke_command(console_input);
|
prism::console::parse_and_invoke_command(console_input);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <imgui_stdlib.h>
|
#include <imgui_stdlib.h>
|
||||||
#include <imgui_internal.h>
|
#include <imgui_internal.h>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <debug.hpp>
|
||||||
|
|
||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
#include "file.hpp"
|
#include "file.hpp"
|
||||||
|
@ -1010,24 +1011,7 @@ GFXTexture* CommonEditor::generate_common_preview(Scene& scene, const prism::flo
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonEditor::drawConsole() {
|
void CommonEditor::drawConsole() {
|
||||||
static std::string command_buffer;
|
draw_console();
|
||||||
ImGui::InputText("Command", &command_buffer);
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if(ImGui::Button("Run")) {
|
|
||||||
prism::console::parse_and_invoke_command(command_buffer);
|
|
||||||
command_buffer.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::BeginChild("console_output", ImVec2(-1, -1), true);
|
|
||||||
|
|
||||||
// TODO: implement for new log system
|
|
||||||
//for(const auto& message : prism::log::stored_output)
|
|
||||||
// ImGui::TextWrapped("%s", message.c_str());
|
|
||||||
ImGui::Text("unimplemented :-(");
|
|
||||||
|
|
||||||
ImGui::EndChild();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonEditor::load_options() {
|
void CommonEditor::load_options() {
|
||||||
|
|
Reference in a new issue