Still use a fixed-width font for the disassembly (might change this)

This commit is contained in:
Henrik Rydgård 2024-11-25 00:03:06 +01:00
parent 2a1cda05b0
commit e31636caec
5 changed files with 32 additions and 13 deletions

View file

@ -368,10 +368,6 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
Core_Break("Menu:Break");
}
}
ImGui::Separator();
if (ImGui::MenuItem("Toggle Breakpoint")) {
// TODO
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("CPU")) {

View file

@ -1,5 +1,6 @@
#include "ext/imgui/imgui_internal.h"
#include "ext/imgui/imgui_impl_thin3d.h"
#include "Common/StringUtils.h"
#include "Common/Log.h"
@ -178,8 +179,7 @@ void ImDisasmView::drawBranchLine(ImDrawList *drawList, Rect rect, std::map<u32,
bottomY = (float)addressPositions[line.second] + rowHeight_ / 2;
}
if ((topY < 0 && bottomY < 0) || (topY > rect.bottom && bottomY > rect.bottom))
{
if ((topY < 0 && bottomY < 0) || (topY > rect.bottom && bottomY > rect.bottom)) {
return;
}
@ -316,6 +316,8 @@ void ImDisasmView::drawArguments(ImDrawList *drawList, Rect rc, const Disassembl
void ImDisasmView::Draw(ImDrawList *drawList) {
// TODO: Don't need to do these every frame.
ImGui_PushFixedFont();
rowHeight_ = ImGui::GetTextLineHeightWithSpacing();
charWidth_ = ImGui::CalcTextSize("W", nullptr, false, -1.0f).x;
@ -482,10 +484,13 @@ void ImDisasmView::Draw(ImDrawList *drawList) {
}
}
ImGui_PopFont();
ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
PopupMenu();
drawList->PopClipRect();
}
void ImDisasmView::ScrollRelative(int amount) {
@ -528,7 +533,7 @@ void ImDisasmView::onChar(int c) {
}
void ImDisasmView::editBreakpoint() {
void ImDisasmView::editBreakpoint(ImConfig &cfg) {
/*
BreakpointWindow win(wnd, debugger);
@ -583,7 +588,7 @@ void ImDisasmView::ProcessKeyboardShortcuts() {
// gotoAddr(addr);
}
if (ImGui::IsKeyPressed(ImGuiKey_E)) {
editBreakpoint();
// editBreakpoint();
}
if (ImGui::IsKeyPressed(ImGuiKey_D)) {
toggleBreakpoint(true);

View file

@ -11,6 +11,8 @@
#include "Core/Debugger/DisassemblyManager.h"
#include "Core/Debugger/DebugInterface.h"
struct ImConfig;
// Corresponds to CtrlDisAsmView
// TODO: Fold out common code.
class ImDisasmView {
@ -77,7 +79,7 @@ public:
showHex_ = s;
}
void toggleBreakpoint(bool toggleEnabled = false);
void editBreakpoint();
void editBreakpoint(ImConfig &cfg);
void setCurAddress(u32 newAddress, bool extend = false) {
newAddress = manager.getStartAddress(newAddress);

View file

@ -7,7 +7,10 @@
#include "Common/System/Display.h"
#include "Common/Math/lin/matrix4x4.h"
Lin::Matrix4x4 g_drawMatrix;
static Lin::Matrix4x4 g_drawMatrix;
static ImFont *g_proportionalFont = nullptr;
static ImFont *g_fixedFont = nullptr;
struct ImGui_ImplThin3d_Data {
Draw::SamplerState *fontSampler = nullptr;
@ -220,12 +223,14 @@ void ImGui_ImplThin3d_DestroyDeviceObjects() {
bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw, const uint8_t *ttf_font, size_t size) {
ImGuiIO& io = ImGui::GetIO();
if (ttf_font) {
io.Fonts->AddFontFromMemoryTTF((void *)ttf_font, (int)size, 21.0f / g_display.dpi_scale_x, nullptr, io.Fonts->GetGlyphRangesDefault());
g_proportionalFont = io.Fonts->AddFontFromMemoryTTF((void *)ttf_font, (int)size, 21.0f / g_display.dpi_scale_x, nullptr, io.Fonts->GetGlyphRangesDefault());
} else {
// necessary?
io.Fonts->AddFontDefault();
// fallback
g_proportionalFont = g_fixedFont;
}
g_fixedFont = io.Fonts->AddFontDefault();
ImGui::GetStyle().ScaleAllSizes(1.0f / g_display.dpi_scale_x);
ImGui::GetStyle().Colors[ImGuiCol_Border] = ImColor(IM_COL32(0x2A, 0x2F, 0x3B, 0xFF));
IMGUI_CHECKVERSION();
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
@ -239,6 +244,14 @@ bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw, const uint8_t *ttf_font, siz
return true;
}
void ImGui_PushFixedFont() {
ImGui::PushFont(g_fixedFont);
}
void ImGui_PopFont() {
ImGui::PopFont();
}
void ImGui_ImplThin3d_Shutdown() {
ImGui_ImplThin3d_Data* bd = ImGui_ImplThin3d_GetBackendData();
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");

View file

@ -44,6 +44,9 @@ IMGUI_IMPL_API void ImGui_ImplThin3d_DestroyDeviceObjects();
IMGUI_IMPL_API ImTextureID ImGui_ImplThin3d_AddTexture(Draw::Texture *texture);
IMGUI_IMPL_API Draw::Texture *ImGui_ImplThin3d_RemoveTexture(ImTextureID texture);
void ImGui_PushFixedFont();
void ImGui_PopFont();
// Helper structure to hold the data needed by one rendering context into one OS window
// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.)
struct ImGui_ImplThin3dH_Window