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();
|
||||
}
|
||||
}
|
||||
43
src/frontend/frontend.h
Normal file
43
src/frontend/frontend.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include "imgui.h"
|
||||
#include "backend/debug_backend.h"
|
||||
|
||||
namespace dbgui::frontend {
|
||||
|
||||
struct Target {
|
||||
backend::TargetState state = backend::TargetState::stopped;
|
||||
std::string filename;
|
||||
uint64_t id;
|
||||
|
||||
std::unique_ptr<backend::Backend> backend = nullptr;
|
||||
};
|
||||
|
||||
struct Frontend {
|
||||
Frontend() {
|
||||
_open_popup_name_buf.resize(512);
|
||||
}
|
||||
|
||||
void run_frame();
|
||||
|
||||
private:
|
||||
void draw_header();
|
||||
void draw_open_popup();
|
||||
void draw_status();
|
||||
|
||||
bool _draw_second = false;
|
||||
ImGuiID _dock_id = 0;
|
||||
|
||||
bool _draw_open_popup = false;
|
||||
ImGuiID _open_popup_id = 0;
|
||||
std::vector<char> _open_popup_name_buf = {};
|
||||
|
||||
std::optional<Target> _target = {};
|
||||
};
|
||||
}
|
||||
47
src/frontend/window.h
Normal file
47
src/frontend/window.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace dbgui::frontend {
|
||||
enum class WindowType : uint8_t {
|
||||
regs,
|
||||
source,
|
||||
memory,
|
||||
variables,
|
||||
stack,
|
||||
threads,
|
||||
disassembly,
|
||||
};
|
||||
|
||||
struct RegWindow {
|
||||
enum class RegValType : uint8_t {
|
||||
flag,
|
||||
u64,
|
||||
u128,
|
||||
u256,
|
||||
u512,
|
||||
};
|
||||
|
||||
struct Reg {
|
||||
std::string name;
|
||||
RegValType type;
|
||||
union {
|
||||
bool bval;
|
||||
uint64_t u64val;
|
||||
uint64_t u128_val[2];
|
||||
uint64_t u256_val[4];
|
||||
uint64_t u512_val[8];
|
||||
};
|
||||
};
|
||||
|
||||
std::vector<Reg> regs;
|
||||
|
||||
void draw();
|
||||
};
|
||||
|
||||
struct Window {
|
||||
WindowType type;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user