Skip to content

Commit

Permalink
Update to ImGui 1.83
Browse files Browse the repository at this point in the history
  • Loading branch information
mtheall committed Jun 2, 2021
1 parent c6681e9 commit c927405
Show file tree
Hide file tree
Showing 16 changed files with 16,472 additions and 2,856 deletions.
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ all-classic: nds 3dsx-classic nro-classic linux
format:
@clang-format -style=file -i $(filter-out \
include/imgui.h \
source/linux/imgui_impl_glfw.cpp \
source/linux/imgui_impl_glfw.h \
source/linux/imgui_impl_opengl3.cpp \
source/linux/imgui_impl_opengl3.h \
source/linux/KHR/khrplatform.h \
source/linux/glad.c \
source/linux/glad/glad.h \
source/imgui/imgui.cpp \
source/imgui/imgui_demo.cpp \
source/imgui/imgui_draw.cpp \
source/imgui/imgui_internal.h \
source/imgui/imgui_internal.h, \
source/imgui/imgui_tables.cpp \
source/imgui/imgui_widgets.cpp \
source/imgui/imstb_rectpack.h \
source/imgui/imstb_textedit.h \
source/imgui/imstb_truetype.h \
source/imgui/imgui_internal.h, \
source/linux/KHR/khrplatform.h \
source/linux/glad.c \
source/linux/glad/glad.h \
source/linux/imgui_impl_glfw.cpp \
source/linux/imgui_impl_glfw.h \
source/linux/imgui_impl_opengl3.cpp \
source/linux/imgui_impl_opengl3.h \
$(shell find source include -type f -name \*.c -o -name \*.cpp -o -name \*.h))

clean:
Expand Down
944 changes: 657 additions & 287 deletions include/imgui.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/3ds/imgui_citro3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void imgui::citro3d::init ()
config.GlyphMinAdvanceX = 0.0f;
config.GlyphMaxAdvanceX = std::numeric_limits<float>::max ();
config.MergeMode = false;
config.RasterizerFlags = 0;
config.FontBuilderFlags = 0;
config.RasterizerMultiply = 1.0f;
config.EllipsisChar = 0x2026;
std::memset (config.Name, 0, sizeof (config.Name));
Expand Down
2 changes: 1 addition & 1 deletion source/3ds/imgui_ctru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void updateKeyboard (ImGuiIO &io_)
swkbdSetInitialText (
&kbd, std::string (textState.InitialTextA.Data, textState.InitialTextA.Size).c_str ());

if (textState.UserFlags & ImGuiInputTextFlags_Password)
if (textState.Flags & ImGuiInputTextFlags_Password)
swkbdSetPasswordMode (&kbd, SWKBD_PASSWORD_HIDE_DELAY);

char buffer[32] = {0};
Expand Down
3,079 changes: 1,904 additions & 1,175 deletions source/imgui/imgui.cpp

Large diffs are not rendered by default.

7,725 changes: 7,725 additions & 0 deletions source/imgui/imgui_demo.cpp

Large diffs are not rendered by default.

772 changes: 560 additions & 212 deletions source/imgui/imgui_draw.cpp

Large diffs are not rendered by default.

1,067 changes: 831 additions & 236 deletions source/imgui/imgui_internal.h

Large diffs are not rendered by default.

4,028 changes: 4,028 additions & 0 deletions source/imgui/imgui_tables.cpp

Large diffs are not rendered by default.

1,393 changes: 575 additions & 818 deletions source/imgui/imgui_widgets.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/imgui/imstb_truetype.h
Original file line number Diff line number Diff line change
Expand Up @@ -4302,7 +4302,7 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex
int winding = 0;

orig[0] = x;
//orig[1] = y; // [DEAR IMGUI] commmented double assignment
//orig[1] = y; // [DEAR IMGUI] commented double assignment

// make sure y never passes through a vertex of the shape
y_frac = (float) STBTT_fmod(y, 1.0f);
Expand Down
2 changes: 1 addition & 1 deletion source/licenses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#endif

char const *const g_dearImGuiVersion = "Dear ImGui " IMGUI_VERSION;
char const *const g_dearImGuiCopyright = "Copyright (C) 2014-2020 Omar Cornut";
char const *const g_dearImGuiCopyright = "Copyright (C) 2014-2021 Omar Cornut";

char const *const g_mitLicense =
"The MIT License (MIT)\n"
Expand Down
36 changes: 22 additions & 14 deletions source/linux/imgui_impl_glfw.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// dear imgui: Platform Binding for GLFW
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..)
// dear imgui: Platform Backend for GLFW
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
// (Requires: GLFW 3.1+)

Expand All @@ -9,9 +9,9 @@
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).

// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
// https://github.com/ocornut/imgui
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
// Read online: https://github.com/ocornut/imgui/tree/master/docs

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
Expand Down Expand Up @@ -68,7 +68,7 @@ enum GlfwClientApi
static GLFWwindow* g_Window = NULL; // Main window
static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown;
static double g_Time = 0.0;
static bool g_MouseJustPressed[5] = { false, false, false, false, false };
static bool g_MouseJustPressed[ImGuiMouseButton_COUNT] = {};
static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
static bool g_InstalledCallbacks = false;

Expand Down Expand Up @@ -113,10 +113,13 @@ void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int a
g_PrevUserCallbackKey(window, key, scancode, action, mods);

ImGuiIO& io = ImGui::GetIO();
if (action == GLFW_PRESS)
io.KeysDown[key] = true;
if (action == GLFW_RELEASE)
io.KeysDown[key] = false;
if (key >= 0 && key < IM_ARRAYSIZE(io.KeysDown))
{
if (action == GLFW_PRESS)
io.KeysDown[key] = true;
if (action == GLFW_RELEASE)
io.KeysDown[key] = false;
}

// Modifiers are not reliable across systems
io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
Expand All @@ -143,13 +146,13 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
g_Window = window;
g_Time = 0.0;

// Setup back-end capabilities flags
// Setup backend capabilities flags
ImGuiIO& io = ImGui::GetIO();
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
io.BackendPlatformName = "imgui_impl_glfw";

// Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
// Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array.
io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB;
io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
Expand Down Expand Up @@ -231,6 +234,11 @@ bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks)
return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan);
}

bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks)
{
return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Unknown);
}

void ImGui_ImplGlfw_Shutdown()
{
if (g_InstalledCallbacks)
Expand Down Expand Up @@ -345,7 +353,7 @@ static void ImGui_ImplGlfw_UpdateGamepads()
void ImGui_ImplGlfw_NewFrame()
{
ImGuiIO& io = ImGui::GetIO();
IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer backend. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");

// Setup display size (every frame to accommodate for window resizing)
int w, h;
Expand All @@ -358,7 +366,7 @@ void ImGui_ImplGlfw_NewFrame()

// Setup time step
double current_time = glfwGetTime();
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f);
g_Time = current_time;

ImGui_ImplGlfw_UpdateMousePosAndButtons();
Expand Down
11 changes: 6 additions & 5 deletions source/linux/imgui_impl_glfw.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// dear imgui: Platform Binding for GLFW
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..)
// dear imgui: Platform Backend for GLFW
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)

// Implemented features:
Expand All @@ -8,9 +8,9 @@
// [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW.
// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).

// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
// https://github.com/ocornut/imgui
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
// Read online: https://github.com/ocornut/imgui/tree/master/docs

// About GLSL version:
// The 'glsl_version' initialization parameter defaults to "#version 150" if NULL.
Expand All @@ -23,6 +23,7 @@ struct GLFWwindow;

IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();

Expand Down
Loading

0 comments on commit c927405

Please sign in to comment.