Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ActiveIdWindowIsJustChanged, WantTextInputIsJustChanged #29

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions CMakeLists.txt

This file was deleted.

6 changes: 3 additions & 3 deletions imconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
//#define IMGUI_DISABLE_METRICS_WINDOW // Disable metrics/debugger window: ShowMetricsWindow() 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)
#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. (imm32.lib/.a)
//#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)
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. (imm32.lib/.a)
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available

Expand Down
47 changes: 4 additions & 43 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,49 +1565,7 @@ bool ImFileClose(ImFileHandle f) { return fclose(f) == 0; }
ImU64 ImFileGetSize(ImFileHandle f) { long off = 0, sz = 0; return ((off = ftell(f)) != -1 && !fseek(f, 0, SEEK_END) && (sz = ftell(f)) != -1 && !fseek(f, off, SEEK_SET)) ? (ImU64)sz : (ImU64)-1; }
ImU64 ImFileRead(void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fread(data, (size_t)sz, (size_t)count, f); }
ImU64 ImFileWrite(const void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fwrite(data, (size_t)sz, (size_t)count, f); }
#else
//Functions to redirect to our hook object function calls if it exists
ImFileHandle ImFileOpen(const char* filename, const char* mode) {
if (auto context = ImGui::GetCurrentContext()) {
if (ImIFileHelper* fileHelperPtr = context->FileHelper) {
return fileHelperPtr->ImFileOpen(filename, mode);
}
}
return nullptr;
}
bool ImFileClose(ImFileHandle file) {
if (auto context = ImGui::GetCurrentContext()) {
if (ImIFileHelper* fileHelperPtr = context->FileHelper) {
return fileHelperPtr->ImFileClose(file);
}
}
return false;
}
ImU64 ImFileGetSize(ImFileHandle file) {
if (auto context = ImGui::GetCurrentContext()) {
if (ImIFileHelper* fileHelperPtr = context->FileHelper) {
return fileHelperPtr->ImFileGetSize(file);
}
}
return 0;
}
ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file) {
if (auto context = ImGui::GetCurrentContext()) {
if (ImIFileHelper* fileHelperPtr = context->FileHelper) {
return fileHelperPtr->ImFileRead(data, size, count, file);
}
}
return 0;
}
ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file) {
if (auto context = ImGui::GetCurrentContext()) {
if (ImIFileHelper* fileHelperPtr = context->FileHelper) {
return fileHelperPtr->ImFileWrite(data, size, count, file);
}
}
return 0;
}
#endif
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS

// Helper: Load file content into memory
// Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree()
Expand Down Expand Up @@ -3113,6 +3071,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
g.ActiveId = id;
g.ActiveIdAllowOverlap = false;
g.ActiveIdNoClearOnFocusLoss = false;
g.ActiveIdWindowIsJustChanged = (g.ActiveIdWindow != window);
g.ActiveIdWindow = window;
g.ActiveIdHasBeenEditedThisFrame = false;
if (id)
Expand Down Expand Up @@ -3930,7 +3889,9 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
g.IO.WantCaptureKeyboard = true;

// Update io.WantTextInput flag, this is to allow systems without a keyboard (e.g. mobile, hand-held) to show a software keyboard if possible
const bool oldWantTextInput = g.IO.WantTextInput;
g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
g.IO.WantTextInputIsJustChanged = (g.IO.WantTextInput != oldWantTextInput);
}

ImGuiKeyModFlags ImGui::GetMergedKeyModFlags()
Expand Down
1 change: 1 addition & 0 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,7 @@ struct ImGuiIO
bool WantCaptureMouse; // Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
bool WantCaptureKeyboard; // Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
bool WantTextInputIsJustChanged; // Set when WantTextInput is changed.
bool WantSetMousePos; // MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving!
bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
Expand Down
24 changes: 3 additions & 21 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,25 +372,8 @@ IMGUI_API bool ImFileClose(ImFileHandle file);
IMGUI_API ImU64 ImFileGetSize(ImFileHandle file);
IMGUI_API ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file);
IMGUI_API ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file);
#else //Bedrock File Handler Hook so we can use our own internal file handling
#else
#define IMGUI_DISABLE_TTY_FUNCTIONS // Can't use stdout, fflush if we are not using default file functions
//We'll cast this to our own internal type as needed
typedef void* ImFileHandle;
//Helper struct for hooking file operations to external systems
struct ImIFileHelper {
virtual ~ImIFileHelper() = default;
virtual ImFileHandle ImFileOpen(const char* filename, const char* mode) = 0;
virtual bool ImFileClose(ImFileHandle file) = 0;
virtual ImU64 ImFileGetSize(ImFileHandle file) = 0;
virtual ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file) = 0;
virtual ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file) = 0;
};

IMGUI_API ImFileHandle ImFileOpen(const char* filename, const char* mode);
IMGUI_API bool ImFileClose(ImFileHandle file);
IMGUI_API ImU64 ImFileGetSize(ImFileHandle file);
IMGUI_API ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file);
IMGUI_API ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file);
#endif
IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size = NULL, int padding_bytes = 0);

Expand Down Expand Up @@ -1460,6 +1443,7 @@ struct ImGuiContext
ImU64 ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
ImGuiWindow* ActiveIdWindow;
bool ActiveIdWindowIsJustChanged;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment explaining what this is and how this is different from ActiveIdIsJustActivated?

ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
int ActiveIdMouseButton;
ImGuiID ActiveIdPreviousFrame;
Expand Down Expand Up @@ -1615,9 +1599,6 @@ struct ImGuiContext
ImChunkStream<ImGuiTableSettings> SettingsTables; // ImGuiTable .ini settings entries
ImVector<ImGuiContextHook> Hooks; // Hooks for extensions (e.g. test engine)
ImGuiID HookIdNext; // Next available HookId
#ifdef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
ImIFileHelper* FileHelper = nullptr; // Hook object for external source to implement their own fileIO
#endif

// Capture/Logging
bool LogEnabled; // Currently capturing
Expand Down Expand Up @@ -1692,6 +1673,7 @@ struct ImGuiContext
ActiveIdUsingKeyInputMask = 0x00;
ActiveIdClickOffset = ImVec2(-1, -1);
ActiveIdWindow = NULL;
ActiveIdWindowIsJustChanged = false;
ActiveIdSource = ImGuiInputSource_None;
ActiveIdMouseButton = -1;
ActiveIdPreviousFrame = 0;
Expand Down
Loading