WIP
This commit is contained in:
139
src/frontend/frontend.cpp
Normal file
139
src/frontend/frontend.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
#include "frontend.h"
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
using namespace dbgui;
|
||||
using namespace dbgui::frontend;
|
||||
|
||||
void Frontend::run_frame() {
|
||||
this->draw_open_popup();
|
||||
this->draw_header();
|
||||
|
||||
// main window
|
||||
float height = ImGui::GetFrameHeight();
|
||||
|
||||
const auto vp_size = ImGui::GetMainViewport()->Size;
|
||||
const auto win_pos = ImVec2{0, height*2};
|
||||
const auto win_size = ImVec2{vp_size.x, vp_size.y - height*3};
|
||||
|
||||
const auto win_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoSavedSettings;
|
||||
|
||||
ImGui::SetNextWindowPos(win_pos, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(win_size, ImGuiCond_Always);
|
||||
|
||||
if (ImGui::Begin("Test", nullptr, win_flags)) {
|
||||
_dock_id = ImGui::GetID("MyDockSpace");
|
||||
ImGui::DockSpace(_dock_id, ImVec2{0, 0}, ImGuiDockNodeFlags_PassthruCentralNode);
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
this->draw_status();
|
||||
}
|
||||
|
||||
void Frontend::draw_header() {
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_MenuBar;
|
||||
float height = ImGui::GetFrameHeight();
|
||||
|
||||
if (ImGui::BeginMainMenuBar()) {
|
||||
if (ImGui::BeginMenu("File")) {
|
||||
if (ImGui::MenuItem("Open")) {
|
||||
_draw_open_popup = true;
|
||||
ImGui::OpenPopup(_open_popup_id);
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
||||
if (ImGui::BeginViewportSideBar("##SecondaryMenuBar", NULL, ImGuiDir_Up, height, window_flags)) {
|
||||
if (ImGui::BeginMenuBar()) {
|
||||
const auto orig_cursor_x = ImGui::GetCursorPosX();
|
||||
if (_target) {
|
||||
switch (_target->state) {
|
||||
using enum backend::TargetState;
|
||||
|
||||
case stopped:
|
||||
ImGui::Button("Run");
|
||||
break;
|
||||
case paused:
|
||||
ImGui::Button("Continue");
|
||||
break;
|
||||
case running:
|
||||
ImGui::Button("Pause");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ImGui::BeginDisabled();
|
||||
ImGui::Button("Continue");
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
|
||||
// TODO: this depends on font-size, we just want to make sure the the other buttons don't flicker even if the state is changed
|
||||
ImGui::SetCursorPosX(orig_cursor_x + 71.f);
|
||||
|
||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical, 2.f);
|
||||
|
||||
const auto is_paused = _target && _target->state == backend::TargetState::paused;
|
||||
const auto is_running = _target && _target->state == backend::TargetState::running;
|
||||
|
||||
if (!is_paused) {
|
||||
ImGui::BeginDisabled();
|
||||
}
|
||||
|
||||
ImGui::Button("Step Over");
|
||||
ImGui::Button("Step Into");
|
||||
ImGui::Button("Step Out");
|
||||
|
||||
if (!is_paused) {
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
|
||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical, 2.f);
|
||||
|
||||
if (!is_paused && !is_running) {
|
||||
ImGui::BeginDisabled();
|
||||
}
|
||||
|
||||
ImGui::Button("Stop");
|
||||
ImGui::Button("Restart");
|
||||
|
||||
if (!is_paused && !is_running) {
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
void Frontend::draw_status() {
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_MenuBar;
|
||||
float height = ImGui::GetFrameHeight();
|
||||
|
||||
if (ImGui::BeginViewportSideBar("##MainStatusBar", NULL, ImGuiDir_Down, height, window_flags)) {
|
||||
if (ImGui::BeginMenuBar()) {
|
||||
ImGui::Text("Happy status bar");
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
void Frontend::draw_open_popup() {
|
||||
if (!_open_popup_id) {
|
||||
_open_popup_id = ImGui::GetID("Open Executable##OpenPopup");
|
||||
}
|
||||
if (ImGui::BeginPopupModal("Open Executable##OpenPopup", &_draw_open_popup, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::InputText("File Path", _open_popup_name_buf.data(), _open_popup_name_buf.size());
|
||||
|
||||
if (ImGui::Button("Start")) {
|
||||
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user