7,123 changes: 4,914 additions & 2,209 deletions Externals/imgui/imgui.cpp

Large diffs are not rendered by default.

1,133 changes: 711 additions & 422 deletions Externals/imgui/imgui.h

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Externals/imgui/imgui.vcxproj
Expand Up @@ -18,14 +18,16 @@
<ItemDefinitionGroup>
<ClCompile>
<!--IM_ASSERT is defined as Dolphin's ASSERT() :( (DolphinLib circular dependency)-->
<AdditionalIncludeDirectories>$(CoreDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>.;$(CoreDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="imgui.cpp" />
<ClCompile Include="imgui_demo.cpp" />
<ClCompile Include="imgui_draw.cpp" />
<ClCompile Include="imgui_tables.cpp" />
<ClCompile Include="imgui_widgets.cpp" />
<ClCompile Include="misc/cpp/imgui_stdlib.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="imconfig.h" />
Expand All @@ -34,6 +36,7 @@
<ClInclude Include="imstb_rectpack.h" />
<ClInclude Include="imstb_textedit.h" />
<ClInclude Include="imstb_truetype.h" />
<ClInclude Include="misc/cpp/imgui_stdlib.h" />
</ItemGroup>
<Import Project="$(ExternalsDir)fmt\exports.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
8,130 changes: 8,130 additions & 0 deletions Externals/imgui/imgui_demo.cpp

Large diffs are not rendered by default.

419 changes: 208 additions & 211 deletions Externals/imgui/imgui_draw.cpp

Large diffs are not rendered by default.

1,295 changes: 909 additions & 386 deletions Externals/imgui/imgui_internal.h

Large diffs are not rendered by default.

427 changes: 243 additions & 184 deletions Externals/imgui/imgui_tables.cpp

Large diffs are not rendered by default.

2,120 changes: 1,269 additions & 851 deletions Externals/imgui/imgui_widgets.cpp

Large diffs are not rendered by default.

42 changes: 15 additions & 27 deletions Externals/imgui/imstb_rectpack.h
@@ -1,15 +1,19 @@
// [DEAR IMGUI]
// This is a slightly modified version of stb_rect_pack.h 1.00.
// Those changes would need to be pushed into nothings/stb:
// - Added STBRP__CDECL
// This is a slightly modified version of stb_rect_pack.h 1.01.
// Grep for [DEAR IMGUI] to find the changes.

// stb_rect_pack.h - v1.00 - public domain - rectangle packing
//
// stb_rect_pack.h - v1.01 - public domain - rectangle packing
// Sean Barrett 2014
//
// Useful for e.g. packing rectangular textures into an atlas.
// Does not do rotation.
//
// Before #including,
//
// #define STB_RECT_PACK_IMPLEMENTATION
//
// in the file that you want to have the implementation.
//
// Not necessarily the awesomest packing method, but better than
// the totally naive one in stb_truetype (which is primarily what
// this is meant to replace).
Expand Down Expand Up @@ -41,6 +45,7 @@
//
// Version history:
//
// 1.01 (2021-07-11) always use large rect mode, expose STBRP__MAXVAL in public section
// 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles
// 0.99 (2019-02-07) warning fixes
// 0.11 (2017-03-03) return packing success/fail result
Expand Down Expand Up @@ -81,11 +86,10 @@ typedef struct stbrp_context stbrp_context;
typedef struct stbrp_node stbrp_node;
typedef struct stbrp_rect stbrp_rect;

#ifdef STBRP_LARGE_RECTS
typedef int stbrp_coord;
#else
typedef unsigned short stbrp_coord;
#endif

#define STBRP__MAXVAL 0x7fffffff
// Mostly for internal use, but this is the maximum supported coordinate value.

STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
// Assign packed locations to rectangles. The rectangles are of type
Expand Down Expand Up @@ -213,10 +217,9 @@ struct stbrp_context
#define STBRP_ASSERT assert
#endif

// [DEAR IMGUI] Added STBRP__CDECL
#ifdef _MSC_VER
#define STBRP__NOTUSED(v) (void)(v)
#define STBRP__CDECL __cdecl
#define STBRP__CDECL __cdecl
#else
#define STBRP__NOTUSED(v) (void)sizeof(v)
#define STBRP__CDECL
Expand Down Expand Up @@ -262,9 +265,6 @@ STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_ou
STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
{
int i;
#ifndef STBRP_LARGE_RECTS
STBRP_ASSERT(width <= 0xffff && height <= 0xffff);
#endif

for (i=0; i < num_nodes-1; ++i)
nodes[i].next = &nodes[i+1];
Expand All @@ -283,11 +283,7 @@ STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height,
context->extra[0].y = 0;
context->extra[0].next = &context->extra[1];
context->extra[1].x = (stbrp_coord) width;
#ifdef STBRP_LARGE_RECTS
context->extra[1].y = (1<<30);
#else
context->extra[1].y = 65535;
#endif
context->extra[1].next = NULL;
}

Expand Down Expand Up @@ -433,7 +429,7 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt
if (y <= best_y) {
if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
best_x = xpos;
STBRP_ASSERT(y <= best_y);
//STBRP_ASSERT(y <= best_y); [DEAR IMGUI]
best_y = y;
best_waste = waste;
best = prev;
Expand Down Expand Up @@ -529,7 +525,6 @@ static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, i
return res;
}

// [DEAR IMGUI] Added STBRP__CDECL
static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
{
const stbrp_rect *p = (const stbrp_rect *) a;
Expand All @@ -541,20 +536,13 @@ static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
return (p->w > q->w) ? -1 : (p->w < q->w);
}

// [DEAR IMGUI] Added STBRP__CDECL
static int STBRP__CDECL rect_original_order(const void *a, const void *b)
{
const stbrp_rect *p = (const stbrp_rect *) a;
const stbrp_rect *q = (const stbrp_rect *) b;
return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
}

#ifdef STBRP_LARGE_RECTS
#define STBRP__MAXVAL 0xffffffff
#else
#define STBRP__MAXVAL 0xffff
#endif

STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
{
int i, all_rects_packed = 1;
Expand Down
50 changes: 19 additions & 31 deletions Externals/imgui/imstb_textedit.h
@@ -1,10 +1,11 @@
// [DEAR IMGUI]
// This is a slightly modified version of stb_textedit.h 1.13.
// This is a slightly modified version of stb_textedit.h 1.14.
// Those changes would need to be pushed into nothings/stb:
// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
// - Fix in stb_textedit_find_charpos to handle last line (see https://github.com/ocornut/imgui/issues/6000)
// Grep for [DEAR IMGUI] to find the changes.

// stb_textedit.h - v1.13 - public domain - Sean Barrett
// stb_textedit.h - v1.14 - public domain - Sean Barrett
// Development of this library was sponsored by RAD Game Tools
//
// This C header file implements the guts of a multi-line text-editing
Expand Down Expand Up @@ -35,6 +36,7 @@
//
// VERSION HISTORY
//
// 1.14 (2021-07-11) page up/down, various fixes
// 1.13 (2019-02-07) fix bug in undo size management
// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash
// 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield
Expand All @@ -58,6 +60,7 @@
// Ulf Winklemann: move-by-word in 1.1
// Fabian Giesen: secondary key inputs in 1.5
// Martins Mozeiko: STB_TEXTEDIT_memmove in 1.6
// Louis Schnellbach: page up/down in 1.14
//
// Bugfixes:
// Scott Graham
Expand Down Expand Up @@ -93,8 +96,8 @@
// moderate sizes. The undo system does no memory allocations, so
// it grows STB_TexteditState by the worst-case storage which is (in bytes):
//
// [4 + 3 * sizeof(STB_TEXTEDIT_POSITIONTYPE)] * STB_TEXTEDIT_UNDOSTATE_COUNT
// + sizeof(STB_TEXTEDIT_CHARTYPE) * STB_TEXTEDIT_UNDOCHAR_COUNT
// [4 + 3 * sizeof(STB_TEXTEDIT_POSITIONTYPE)] * STB_TEXTEDIT_UNDOSTATECOUNT
// + sizeof(STB_TEXTEDIT_CHARTYPE) * STB_TEXTEDIT_UNDOCHARCOUNT
//
//
// Implementation mode:
Expand Down Expand Up @@ -522,29 +525,14 @@ static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *s
int z = STB_TEXTEDIT_STRINGLEN(str);
int i=0, first;

if (n == z) {
// if it's at the end, then find the last line -- simpler than trying to
// explicitly handle this case in the regular code
if (single_line) {
STB_TEXTEDIT_LAYOUTROW(&r, str, 0);
find->y = 0;
find->first_char = 0;
find->length = z;
find->height = r.ymax - r.ymin;
find->x = r.x1;
} else {
find->y = 0;
find->x = 0;
find->height = 1;
while (i < z) {
STB_TEXTEDIT_LAYOUTROW(&r, str, i);
prev_start = i;
i += r.num_chars;
}
find->first_char = i;
find->length = 0;
find->prev_first = prev_start;
}
if (n == z && single_line) {
// special case if it's at the end (may not be needed?)
STB_TEXTEDIT_LAYOUTROW(&r, str, 0);
find->y = 0;
find->first_char = 0;
find->length = z;
find->height = r.ymax - r.ymin;
find->x = r.x1;
return;
}

Expand All @@ -555,9 +543,13 @@ static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *s
STB_TEXTEDIT_LAYOUTROW(&r, str, i);
if (n < i + r.num_chars)
break;
if (i + r.num_chars == z && z > 0 && STB_TEXTEDIT_GETCHAR(str, z - 1) != STB_TEXTEDIT_NEWLINE) // [DEAR IMGUI] special handling for last line
break; // [DEAR IMGUI]
prev_start = i;
i += r.num_chars;
find->y += r.baseline_y_delta;
if (i == z) // [DEAR IMGUI]
break; // [DEAR IMGUI]
}

find->first_char = first = i;
Expand Down Expand Up @@ -716,10 +708,6 @@ static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditSta
state->has_preferred_x = 0;
return 1;
}
// [DEAR IMGUI]
//// remove the undo since we didn't actually insert the characters
//if (state->undostate.undo_point)
// --state->undostate.undo_point;
// note: paste failure will leave deleted selection, may be restored with an undo (see https://github.com/nothings/stb/issues/734 for details)
return 0;
}
Expand Down
824 changes: 503 additions & 321 deletions Externals/imgui/imstb_truetype.h

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions Externals/imgui/misc/README.txt
@@ -0,0 +1,23 @@

misc/cpp/
InputText() wrappers for C++ standard library (STL) type: std::string.
This is also an example of how you may wrap your own similar types.

misc/debuggers/
Helper files for popular debuggers.
With the .natvis file, types like ImVector<> will be displayed nicely in Visual Studio debugger.

misc/fonts/
Fonts loading/merging instructions (e.g. How to handle glyph ranges, how to merge icons fonts).
Command line tool "binary_to_compressed_c" to create compressed arrays to embed data in source code.
Suggested fonts and links.

misc/freetype/
Font atlas builder/rasterizer using FreeType instead of stb_truetype.
Benefit from better FreeType rasterization, in particular for small fonts.

misc/single_file/
Single-file header stub.
We use this to validate compiling all *.cpp files in a same compilation unit.
Users of that technique (also called "Unity builds") can generally provide this themselves,
so we don't really recommend you use this in your projects.
13 changes: 13 additions & 0 deletions Externals/imgui/misc/cpp/README.txt
@@ -0,0 +1,13 @@

imgui_stdlib.h + imgui_stdlib.cpp
InputText() wrappers for C++ standard library (STL) type: std::string.
This is also an example of how you may wrap your own similar types.

imgui_scoped.h
[Experimental, not currently in main repository]
Additional header file with some RAII-style wrappers for common Dear ImGui functions.
Try by merging: https://github.com/ocornut/imgui/pull/2197
Discuss at: https://github.com/ocornut/imgui/issues/2096

See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness
75 changes: 75 additions & 0 deletions Externals/imgui/misc/cpp/imgui_stdlib.cpp
@@ -0,0 +1,75 @@
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
// This is also an example of how you may wrap your own similar types.

// Changelog:
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string

// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness

#include "imgui.h"
#include "imgui_stdlib.h"

struct InputTextCallback_UserData
{
std::string* Str;
ImGuiInputTextCallback ChainCallback;
void* ChainCallbackUserData;
};

static int InputTextCallback(ImGuiInputTextCallbackData* data)
{
InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData;
if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
{
// Resize string callback
// If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want.
std::string* str = user_data->Str;
IM_ASSERT(data->Buf == str->c_str());
str->resize(data->BufTextLen);
data->Buf = (char*)str->c_str();
}
else if (user_data->ChainCallback)
{
// Forward to user callback, if any
data->UserData = user_data->ChainCallbackUserData;
return user_data->ChainCallback(data);
}
return 0;
}

bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
{
IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
flags |= ImGuiInputTextFlags_CallbackResize;

InputTextCallback_UserData cb_user_data;
cb_user_data.Str = str;
cb_user_data.ChainCallback = callback;
cb_user_data.ChainCallbackUserData = user_data;
return InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
}

bool ImGui::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
{
IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
flags |= ImGuiInputTextFlags_CallbackResize;

InputTextCallback_UserData cb_user_data;
cb_user_data.Str = str;
cb_user_data.ChainCallback = callback;
cb_user_data.ChainCallbackUserData = user_data;
return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data);
}

bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
{
IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
flags |= ImGuiInputTextFlags_CallbackResize;

InputTextCallback_UserData cb_user_data;
cb_user_data.Str = str;
cb_user_data.ChainCallback = callback;
cb_user_data.ChainCallbackUserData = user_data;
return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
}
21 changes: 21 additions & 0 deletions Externals/imgui/misc/cpp/imgui_stdlib.h
@@ -0,0 +1,21 @@
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
// This is also an example of how you may wrap your own similar types.

// Changelog:
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string

// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness

#pragma once

#include <string>

namespace ImGui
{
// ImGui::InputText() with std::string
// Because text input needs dynamic resizing, we need to setup a callback to grow the capacity
IMGUI_API bool InputText(const char* label, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr);
IMGUI_API bool InputTextMultiline(const char* label, std::string* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr);
IMGUI_API bool InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr);
}
2 changes: 1 addition & 1 deletion Externals/implot/implot
Submodule implot updated 5 files
+282 −246 implot.cpp
+33 −33 implot.h
+65 −65 implot_demo.cpp
+39 −42 implot_internal.h
+30 −24 implot_items.cpp
16 changes: 9 additions & 7 deletions Source/Core/VideoCommon/OnScreenUI.cpp
Expand Up @@ -356,35 +356,37 @@ void OnScreenUI::SetScale(float backbuffer_scale)
}
void OnScreenUI::SetKeyMap(const DolphinKeyMap& key_map)
{
// Right now this is a 1:1 mapping. But might not be true later
static constexpr DolphinKeyMap dolphin_to_imgui_map = {
ImGuiKey_Tab, ImGuiKey_LeftArrow, ImGuiKey_RightArrow, ImGuiKey_UpArrow,
ImGuiKey_DownArrow, ImGuiKey_PageUp, ImGuiKey_PageDown, ImGuiKey_Home,
ImGuiKey_End, ImGuiKey_Insert, ImGuiKey_Delete, ImGuiKey_Backspace,
ImGuiKey_Space, ImGuiKey_Enter, ImGuiKey_Escape, ImGuiKey_KeyPadEnter,
ImGuiKey_Space, ImGuiKey_Enter, ImGuiKey_Escape, ImGuiKey_KeypadEnter,
ImGuiKey_A, ImGuiKey_C, ImGuiKey_V, ImGuiKey_X,
ImGuiKey_Y, ImGuiKey_Z,
};
static_assert(dolphin_to_imgui_map.size() == ImGuiKey_COUNT); // Fail if ImGui adds keys

auto lock = GetImGuiLock();

if (!ImGui::GetCurrentContext())
return;

m_dolphin_to_imgui_map.clear();
for (int dolphin_key = 0; dolphin_key <= static_cast<int>(DolphinKey::Z); dolphin_key++)
{
int imgui_key = dolphin_to_imgui_map[DolphinKey(dolphin_key)];
const int imgui_key = dolphin_to_imgui_map[DolphinKey(dolphin_key)];
if (imgui_key >= 0)
ImGui::GetIO().KeyMap[imgui_key] = (key_map[DolphinKey(dolphin_key)] & 0x1FF);
{
const int mapped_key = key_map[DolphinKey(dolphin_key)];
m_dolphin_to_imgui_map[mapped_key & 0x1FF] = imgui_key;
}
}
}

void OnScreenUI::SetKey(u32 key, bool is_down, const char* chars)
{
auto lock = GetImGuiLock();
if (key < std::size(ImGui::GetIO().KeysDown))
ImGui::GetIO().KeysDown[key] = is_down;
if (auto iter = m_dolphin_to_imgui_map.find(key); iter != m_dolphin_to_imgui_map.end())
ImGui::GetIO().AddKeyEvent((ImGuiKey)iter->second, is_down);

if (chars)
ImGui::GetIO().AddInputCharactersUTF8(chars);
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/VideoCommon/OnScreenUI.h
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include <map>
#include <memory>
#include <mutex>
#include <span>
Expand Down Expand Up @@ -65,6 +66,7 @@ class OnScreenUI
std::unique_ptr<NativeVertexFormat> m_imgui_vertex_format;
std::vector<std::unique_ptr<AbstractTexture>> m_imgui_textures;
std::unique_ptr<AbstractPipeline> m_imgui_pipeline;
std::map<u32, int> m_dolphin_to_imgui_map;
std::mutex m_imgui_mutex;
u64 m_imgui_last_frame_time = 0;

Expand Down