This commit is contained in:
Branimir Karadžić
2016-05-28 17:14:19 -07:00
parent dda0de635e
commit 58156ea4e8
6 changed files with 60 additions and 20 deletions

View File

@@ -1 +1,18 @@
namespace ImGui
{
struct Font
{
enum Enum
{
Regular,
Mono,
Count
};
};
void PushFont(Font::Enum _font);
} // namespace ImGui
#include "widgets/memory_editor.h"

View File

@@ -21,6 +21,7 @@ namespace ImGui
strcpy(AddrInput, "");
}
void Draw(unsigned char* mem_data, int mem_size, size_t base_display_addr = 0);
void Draw(void* mem_data, int mem_size, size_t base_display_addr = 0);
void Draw(const void* mem_data, int mem_size, size_t base_display_addr = 0);
};
} // namespace ImGui

View File

@@ -6,10 +6,20 @@ namespace ImGui
// End();
// }
void MemoryEditor::Draw(unsigned char* mem_data, int mem_size, size_t base_display_addr)
void MemoryEditor::Draw(void* mem_data_void, int mem_size, size_t base_display_addr)
{
PushFont(Font::Mono);
unsigned char* mem_data = (unsigned char*)mem_data_void;
BeginChild("##scrolling", ImVec2(0, -GetItemsLineHeightWithSpacing()));
if (ImGui::BeginPopupContextWindow() )
{
ImGui::Checkbox("HexII", &HexII);
ImGui::EndPopup();
}
PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f) );
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f) );
@@ -223,6 +233,13 @@ namespace ImGui
}
PopItemWidth();
PopFont();
}
void MemoryEditor::Draw(const void* mem_data, int mem_size, size_t base_display_addr)
{
Draw(const_cast<void*>(mem_data), mem_size, base_display_addr);
}
} // namespace ImGui

View File

@@ -280,19 +280,6 @@ namespace ImGui
SetCursorPosY(GetCursorPosY() + GetTextLineHeightWithSpacing() );
}
struct Font
{
enum Enum
{
Regular,
Mono,
Count
};
};
void PushFont(Font::Enum _font);
} // namespace ImGui
#endif // IMGUI_H_HEADER_GUARD

View File

@@ -453,8 +453,8 @@ struct OcornutImguiContext
config.MergeMode = false;
// config.MergeGlyphCenterV = true;
m_font[ImGui::Font::Regular] = io.Fonts->AddFontFromMemoryTTF( (void*)s_robotoRegularTtf, sizeof(s_robotoRegularTtf), _fontSize, &config);
m_font[ImGui::Font::Mono ] = io.Fonts->AddFontFromMemoryTTF( (void*)s_robotoMonoRegularTtf, sizeof(s_robotoMonoRegularTtf), _fontSize, &config);
m_font[ImGui::Font::Regular] = io.Fonts->AddFontFromMemoryTTF( (void*)s_robotoRegularTtf, sizeof(s_robotoRegularTtf), _fontSize, &config);
m_font[ImGui::Font::Mono ] = io.Fonts->AddFontFromMemoryTTF( (void*)s_robotoMonoRegularTtf, sizeof(s_robotoMonoRegularTtf), _fontSize-3.0f, &config);
config.MergeMode = true;
config.DstFont = m_font[ImGui::Font::Regular];
@@ -660,9 +660,24 @@ struct OcornutImguiContext
#endif // 0
#if 0
extern void ShowExampleAppCustomNodeGraph(bool* opened);
bool opened = true;
ShowExampleAppCustomNodeGraph(&opened);
{
static ImGui::MemoryEditor me;
bool open = true;
if (ImGui::Begin("HexII", &open))
{
me.Draw(s_iconsKenneyTtf, sizeof(s_iconsKenneyTtf) );
ImGui::End();
}
}
#endif // 0
#if 0
{
extern void ShowExampleAppCustomNodeGraph(bool* opened);
bool opened = true;
ShowExampleAppCustomNodeGraph(&opened);
}
#endif // 0
}

View File

@@ -733,6 +733,7 @@ int _main_(int _argc, char** _argv)
ImGui::Text("Key bindings:\n\n");
ImGui::PushFont(ImGui::Font::Mono);
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "ESC"); ImGui::SameLine(64); ImGui::Text("Exit.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "h"); ImGui::SameLine(64); ImGui::Text("Toggle help screen.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "f"); ImGui::SameLine(64); ImGui::Text("Toggle full-screen.");
@@ -753,6 +754,8 @@ int _main_(int _argc, char** _argv)
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "r/g/b"); ImGui::SameLine(64); ImGui::Text("Toggle R, G, or B color channel.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "a"); ImGui::SameLine(64); ImGui::Text("Toggle alpha blending.");
ImGui::PopFont();
ImGui::NextLine();
ImGui::Dummy(ImVec2(0.0f, 0.0f) );