Skip to content

Commit

Permalink
Imgui 1.90.7 (#51)
Browse files Browse the repository at this point in the history
* imgui 1.90.7

* Use io.AddKeyEvent() in imgui_SetKeyDown() so that non-text keys work
  • Loading branch information
dri-richard authored Jun 6, 2024
1 parent 2cd5f39 commit dc65c4d
Show file tree
Hide file tree
Showing 17 changed files with 5,533 additions and 2,444 deletions.
6 changes: 3 additions & 3 deletions imgui/src/extension_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ static int imgui_SetKeyDown(lua_State* L)
DM_LUA_STACK_CHECK(L, 0);
ImGuiIO& io = ImGui::GetIO();
uint32_t key = luaL_checknumber(L, 1);
io.KeysDown[key] = lua_toboolean(L, 2);
io.AddKeyEvent((ImGuiKey)key, lua_toboolean(L, 2));
return 0;
}

Expand Down Expand Up @@ -2275,7 +2275,7 @@ static int imgui_FontAddTTFData(lua_State * L)
memcpy(ttf_data_cpy, ttf_data, ttf_data_size);

ImGuiIO& io = ImGui::GetIO();
ImFont* font = io.Fonts->AddFontFromMemoryTTF((void *)ttf_data_cpy, font_size, font_pixels);
ImFont* font = io.Fonts->AddFontFromMemoryTTF((void *)ttf_data_cpy, ttf_data_size, font_pixels);
// Put font in map.
if(font != NULL)
{
Expand Down Expand Up @@ -2787,7 +2787,7 @@ static void LuaInit(lua_State* L)
lua_setfieldstringint(L, "KEY_SPACE", ImGuiKey_Space);
lua_setfieldstringint(L, "KEY_ENTER", ImGuiKey_Enter);
lua_setfieldstringint(L, "KEY_ESCAPE", ImGuiKey_Escape);
lua_setfieldstringint(L, "KEY_KEYPADENTER", ImGuiKey_KeyPadEnter);
lua_setfieldstringint(L, "KEY_KEYPADENTER", ImGuiKey_KeypadEnter);
lua_setfieldstringint(L, "KEY_A", ImGuiKey_A);
lua_setfieldstringint(L, "KEY_C", ImGuiKey_C);
lua_setfieldstringint(L, "KEY_V", ImGuiKey_V);
Expand Down
8 changes: 5 additions & 3 deletions imgui/src/imgui/imconfig.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@

//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names.
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87+ disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This is automatically done by IMGUI_DISABLE_OBSOLETE_FUNCTIONS.

//---- Disable all of Dear ImGui or don't implement standard windows/tools.
// It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp.
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty.
//#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowStackToolWindow() will be empty (this was called IMGUI_DISABLE_METRICS_WINDOW before 1.88).
//#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowIDStackToolWindow() will be empty.

//---- Don't implement some functions to reduce linkage requirements.
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
Expand All @@ -80,12 +80,14 @@
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available

//---- Include imgui_user.h at the end of imgui.h as a convenience
// May be convenient for some users to only explicitly include vanilla imgui.h and have extra stuff included.
//#define IMGUI_INCLUDE_IMGUI_USER_H
//#define IMGUI_USER_H_FILENAME "my_folder/my_imgui_user.h"

//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
//#define IMGUI_USE_BGRA_PACKED_COLOR

//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
//---- Use 32-bit for ImWchar (default is 16-bit) to support Unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
//#define IMGUI_USE_WCHAR32

//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
Expand Down
2,976 changes: 1,998 additions & 978 deletions imgui/src/imgui/imgui.cpp
100755 → 100644

Large diffs are not rendered by default.

938 changes: 551 additions & 387 deletions imgui/src/imgui/imgui.h
100755 → 100644

Large diffs are not rendered by default.

944 changes: 719 additions & 225 deletions imgui/src/imgui/imgui_demo.cpp
100755 → 100644

Large diffs are not rendered by default.

507 changes: 451 additions & 56 deletions imgui/src/imgui/imgui_draw.cpp
100755 → 100644

Large diffs are not rendered by default.

31 changes: 19 additions & 12 deletions imgui/src/imgui/imgui_impl_android.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// 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
// Learn about Dear ImGui:
// - FAQ https://dearimgui.com/faq
// - Getting Started https://dearimgui.com/getting-started
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
// - Introduction, links and more at the top of imgui.cpp

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
Expand Down Expand Up @@ -155,7 +158,7 @@ static ImGuiKey ImGui_ImplAndroid_KeyCodeToImGuiKey(int32_t key_code)
}
}

int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
int32_t ImGui_ImplAndroid_HandleInputEvent(const AInputEvent* input_event)
{
ImGuiIO& io = ImGui::GetIO();
int32_t event_type = AInputEvent_getType(input_event);
Expand All @@ -182,7 +185,7 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
case AKEY_EVENT_ACTION_UP:
{
ImGuiKey key = ImGui_ImplAndroid_KeyCodeToImGuiKey(event_key_code);
if (key != ImGuiKey_None && (event_action == AKEY_EVENT_ACTION_DOWN || event_action == AKEY_EVENT_ACTION_UP))
if (key != ImGuiKey_None)
{
io.AddKeyEvent(key, event_action == AKEY_EVENT_ACTION_DOWN);
io.SetKeyEventNativeData(key, event_key_code, event_scan_code);
Expand Down Expand Up @@ -220,25 +223,27 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
{
case AMOTION_EVENT_ACTION_DOWN:
case AMOTION_EVENT_ACTION_UP:
{
// Physical mouse buttons (and probably other physical devices) also invoke the actions AMOTION_EVENT_ACTION_DOWN/_UP,
// but we have to process them separately to identify the actual button pressed. This is done below via
// AMOTION_EVENT_ACTION_BUTTON_PRESS/_RELEASE. Here, we only process "FINGER" input (and "UNKNOWN", as a fallback).
if((AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_FINGER)
|| (AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_UNKNOWN))
int tool_type = AMotionEvent_getToolType(input_event, event_pointer_index);
if (tool_type == AMOTION_EVENT_TOOL_TYPE_FINGER || tool_type == AMOTION_EVENT_TOOL_TYPE_UNKNOWN)
{
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
io.AddMouseButtonEvent(0, event_action == AMOTION_EVENT_ACTION_DOWN);
}
break;
}
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
case AMOTION_EVENT_ACTION_BUTTON_RELEASE:
{
int32_t button_state = AMotionEvent_getButtonState(input_event);
io.AddMouseButtonEvent(0, (button_state & AMOTION_EVENT_BUTTON_PRIMARY) != 0);
io.AddMouseButtonEvent(1, (button_state & AMOTION_EVENT_BUTTON_SECONDARY) != 0);
io.AddMouseButtonEvent(2, (button_state & AMOTION_EVENT_BUTTON_TERTIARY) != 0);
}
{
int32_t button_state = AMotionEvent_getButtonState(input_event);
io.AddMouseButtonEvent(0, (button_state & AMOTION_EVENT_BUTTON_PRIMARY) != 0);
io.AddMouseButtonEvent(1, (button_state & AMOTION_EVENT_BUTTON_SECONDARY) != 0);
io.AddMouseButtonEvent(2, (button_state & AMOTION_EVENT_BUTTON_TERTIARY) != 0);
break;
}
case AMOTION_EVENT_ACTION_HOVER_MOVE: // Hovering: Tool moves while NOT pressed (such as a physical mouse)
case AMOTION_EVENT_ACTION_MOVE: // Touch pointer moves while DOWN
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
Expand All @@ -260,6 +265,8 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)

bool ImGui_ImplAndroid_Init(ANativeWindow* window)
{
IMGUI_CHECKVERSION();

g_Window = window;
g_Time = 0.0;

Expand Down
9 changes: 6 additions & 3 deletions imgui/src/imgui/imgui_impl_android.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// 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
// Learn about Dear ImGui:
// - FAQ https://dearimgui.com/faq
// - Getting Started https://dearimgui.com/getting-started
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
// - Introduction, links and more at the top of imgui.cpp

#pragma once
#include "imgui.h" // IMGUI_IMPL_API
Expand All @@ -26,7 +29,7 @@ struct ANativeWindow;
struct AInputEvent;

IMGUI_IMPL_API bool ImGui_ImplAndroid_Init(ANativeWindow* window);
IMGUI_IMPL_API int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event);
IMGUI_IMPL_API int32_t ImGui_ImplAndroid_HandleInputEvent(const AInputEvent* input_event);
IMGUI_IMPL_API void ImGui_ImplAndroid_Shutdown();
IMGUI_IMPL_API void ImGui_ImplAndroid_NewFrame();

Expand Down
Loading

0 comments on commit dc65c4d

Please sign in to comment.