Updated ImGui.
This commit is contained in:
parent
6af3a7c952
commit
3ca4d7feb3
356
3rdparty/ocornut-imgui/imgui.cpp
vendored
356
3rdparty/ocornut-imgui/imgui.cpp
vendored
File diff suppressed because it is too large
Load Diff
22
3rdparty/ocornut-imgui/imgui.h
vendored
22
3rdparty/ocornut-imgui/imgui.h
vendored
@ -54,6 +54,7 @@ struct ImGuiTextFilter; // Parse and apply text filters. In format "
|
||||
struct ImGuiTextBuffer; // Text buffer for logging/accumulating text
|
||||
struct ImGuiTextEditCallbackData; // Shared state of ImGui::InputText() when using custom callbacks (advanced)
|
||||
struct ImGuiListClipper; // Helper to manually clip large list of items
|
||||
struct ImGuiContext; // ImGui context (opaque)
|
||||
|
||||
// Enumerations (declared as int for compatibility and to not pollute the top of this file)
|
||||
typedef unsigned int ImU32;
|
||||
@ -158,7 +159,7 @@ namespace ImGui
|
||||
IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()]
|
||||
IMGUI_API void SetScrollHere(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom.
|
||||
IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions.
|
||||
IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget
|
||||
IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use negative 'offset' to access previous widgets.
|
||||
IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
|
||||
IMGUI_API ImGuiStorage* GetStateStorage();
|
||||
|
||||
@ -442,11 +443,12 @@ namespace ImGui
|
||||
IMGUI_API const char* GetClipboardText();
|
||||
IMGUI_API void SetClipboardText(const char* text);
|
||||
|
||||
// Internal state/context access - if you want to use multiple ImGui context, or share context between modules (e.g. DLL), or allocate the memory yourself
|
||||
// Internal context access - if you want to use multiple context, share context between modules (e.g. DLL). There is a default context created and active by default.
|
||||
IMGUI_API const char* GetVersion();
|
||||
IMGUI_API void* GetInternalState();
|
||||
IMGUI_API size_t GetInternalStateSize();
|
||||
IMGUI_API void SetInternalState(void* state, bool construct = false);
|
||||
IMGUI_API ImGuiContext* CreateContext(void* (*malloc_fn)(size_t) = NULL, void (*free_fn)(void*) = NULL);
|
||||
IMGUI_API void DestroyContext(ImGuiContext* ctx);
|
||||
IMGUI_API ImGuiContext* GetCurrentContext();
|
||||
IMGUI_API void SetCurrentContext(ImGuiContext* ctx);
|
||||
|
||||
// Obsolete (will be removed)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
@ -950,7 +952,7 @@ struct ImGuiTextBuffer
|
||||
IMGUI_API void appendv(const char* fmt, va_list args);
|
||||
};
|
||||
|
||||
// Helper: Key->value storage
|
||||
// Helper: Simple Key->value storage
|
||||
// - Store collapse state for a tree (Int 0/1)
|
||||
// - Store color edit options (Int using values in ImGuiColorEditMode enum).
|
||||
// - Custom user storage for temporary values.
|
||||
@ -958,6 +960,7 @@ struct ImGuiTextBuffer
|
||||
// Declare your own storage if:
|
||||
// - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state).
|
||||
// - You want to store custom debug data easily without adding or editing structures in your code.
|
||||
// Types are NOT stored, so it is up to you to make sure your Key don't collide with different types.
|
||||
struct ImGuiStorage
|
||||
{
|
||||
struct Pair
|
||||
@ -972,10 +975,12 @@ struct ImGuiStorage
|
||||
|
||||
// - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
|
||||
// - Set***() functions find pair, insertion on demand if missing.
|
||||
// - Sorted insertion is costly but should amortize. A typical frame shouldn't need to insert any new pair.
|
||||
// - Sorted insertion is costly, paid once. A typical frame shouldn't need to insert any new pair.
|
||||
IMGUI_API void Clear();
|
||||
IMGUI_API int GetInt(ImGuiID key, int default_val = 0) const;
|
||||
IMGUI_API void SetInt(ImGuiID key, int val);
|
||||
IMGUI_API bool GetBool(ImGuiID key, bool default_val = false) const;
|
||||
IMGUI_API void SetBool(ImGuiID key, bool val);
|
||||
IMGUI_API float GetFloat(ImGuiID key, float default_val = 0.0f) const;
|
||||
IMGUI_API void SetFloat(ImGuiID key, float val);
|
||||
IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL
|
||||
@ -987,7 +992,8 @@ struct ImGuiStorage
|
||||
// float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
|
||||
// - You can also use this to quickly create temporary editable values during a session of using Edit&Continue, without restarting your application.
|
||||
IMGUI_API int* GetIntRef(ImGuiID key, int default_val = 0);
|
||||
IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0);
|
||||
IMGUI_API bool* GetBoolRef(ImGuiID key, bool default_val = false);
|
||||
IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0.0f);
|
||||
IMGUI_API void** GetVoidPtrRef(ImGuiID key, void* default_val = NULL);
|
||||
|
||||
// Use on your own storage if you know only integer are being stored (open/close all tree nodes)
|
||||
|
4
3rdparty/ocornut-imgui/imgui_demo.cpp
vendored
4
3rdparty/ocornut-imgui/imgui_demo.cpp
vendored
@ -35,6 +35,8 @@
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
|
||||
#pragma GCC diagnostic ignored "-Wformat-security" // warning : format string is not a string literal (potentially insecure)
|
||||
#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
|
||||
#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
|
||||
#endif
|
||||
|
||||
// Play it nice with Windows users. Notepad in 2015 still doesn't display text data with Unix-style \n.
|
||||
@ -1030,9 +1032,11 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
static bool track = true;
|
||||
static int track_line = 50, scroll_to_px = 200;
|
||||
ImGui::Checkbox("Track", &track);
|
||||
ImGui::PushItemWidth(100);
|
||||
ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line %.0f");
|
||||
bool scroll_to = ImGui::Button("Scroll To");
|
||||
ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "y = %.0f px");
|
||||
ImGui::PopItemWidth();
|
||||
if (scroll_to) track = false;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
|
6
3rdparty/ocornut-imgui/imgui_draw.cpp
vendored
6
3rdparty/ocornut-imgui/imgui_draw.cpp
vendored
@ -41,6 +41,8 @@
|
||||
#endif
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
||||
#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
|
||||
#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -246,7 +248,7 @@ void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_
|
||||
void ImDrawList::PushClipRectFullScreen()
|
||||
{
|
||||
PushClipRect(ImVec2(GNullClipRect.x, GNullClipRect.y), ImVec2(GNullClipRect.z, GNullClipRect.w));
|
||||
//PushClipRect(GetVisibleRect()); // FIXME-OPT: This would be more correct but we're not supposed to access ImGuiState from here?
|
||||
//PushClipRect(GetVisibleRect()); // FIXME-OPT: This would be more correct but we're not supposed to access ImGuiContext from here?
|
||||
}
|
||||
|
||||
void ImDrawList::PopClipRect()
|
||||
@ -1667,7 +1669,7 @@ ImFont::~ImFont()
|
||||
// If you want to delete fonts you need to do it between Render() and NewFrame().
|
||||
// FIXME-CLEANUP
|
||||
/*
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.Font == this)
|
||||
g.Font = NULL;
|
||||
*/
|
||||
|
25
3rdparty/ocornut-imgui/imgui_internal.h
vendored
25
3rdparty/ocornut-imgui/imgui_internal.h
vendored
@ -33,7 +33,6 @@ struct ImGuiTextEditState;
|
||||
struct ImGuiIniData;
|
||||
struct ImGuiMouseCursorData;
|
||||
struct ImGuiPopupRef;
|
||||
struct ImGuiState;
|
||||
struct ImGuiWindow;
|
||||
|
||||
typedef int ImGuiLayoutType; // enum ImGuiLayoutType_
|
||||
@ -71,7 +70,7 @@ namespace ImGuiStb
|
||||
// Context
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern IMGUI_API ImGuiState* GImGui;
|
||||
extern IMGUI_API ImGuiContext* GImGui; // current implicit ImGui context pointer
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
@ -144,7 +143,7 @@ static inline ImVec2 ImFloor(ImVec2 v)
|
||||
struct ImPlacementNewDummy {};
|
||||
inline void* operator new(size_t, ImPlacementNewDummy, void* ptr) { return ptr; }
|
||||
inline void operator delete(void*, ImPlacementNewDummy, void*) {}
|
||||
#define IM_PLACEMENT_NEW(_PTR) new(ImPlacementNewDummy() ,_PTR)
|
||||
#define IM_PLACEMENT_NEW(_PTR) new(ImPlacementNewDummy(), _PTR)
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -274,7 +273,7 @@ struct ImGuiColumnData
|
||||
//float IndentX;
|
||||
};
|
||||
|
||||
// Simple column measurement currently used for MenuItem() only. This is very short-sighted for now and NOT a generic helper.
|
||||
// Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper.
|
||||
struct IMGUI_API ImGuiSimpleColumns
|
||||
{
|
||||
int Count;
|
||||
@ -283,9 +282,9 @@ struct IMGUI_API ImGuiSimpleColumns
|
||||
float Pos[8], NextWidths[8];
|
||||
|
||||
ImGuiSimpleColumns();
|
||||
void Update(int count, float spacing, bool clear);
|
||||
float DeclColumns(float w0, float w1, float w2);
|
||||
float CalcExtraSpace(float avail_w);
|
||||
void Update(int count, float spacing, bool clear);
|
||||
float DeclColumns(float w0, float w1, float w2);
|
||||
float CalcExtraSpace(float avail_w);
|
||||
};
|
||||
|
||||
// Internal state of the currently focused/edited text input box
|
||||
@ -345,7 +344,7 @@ struct ImGuiPopupRef
|
||||
};
|
||||
|
||||
// Main state for ImGui
|
||||
struct ImGuiState
|
||||
struct ImGuiContext
|
||||
{
|
||||
bool Initialized;
|
||||
ImGuiIO IO;
|
||||
@ -378,7 +377,7 @@ struct ImGuiState
|
||||
ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window.
|
||||
ImGuiID MovedWindowMoveId; // == MovedWindow->RootWindow->MoveId
|
||||
ImVector<ImGuiIniData> Settings; // .ini Settings
|
||||
float SettingsDirtyTimer; // Save .ini settinngs on disk when time reaches zero
|
||||
float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero
|
||||
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
|
||||
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
|
||||
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()
|
||||
@ -417,7 +416,7 @@ struct ImGuiState
|
||||
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
|
||||
float DragSpeedScaleSlow;
|
||||
float DragSpeedScaleFast;
|
||||
ImVec2 ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
|
||||
ImVec2 ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
|
||||
char Tooltip[1024];
|
||||
char* PrivateClipboard; // If no custom clipboard handler is defined
|
||||
ImVec2 OsImePosRequest, OsImePosSet; // Cursor position request & last passed to the OS Input Method Editor
|
||||
@ -437,7 +436,7 @@ struct ImGuiState
|
||||
int CaptureKeyboardNextFrame;
|
||||
char TempBuffer[1024*3+1]; // temporary text buffer
|
||||
|
||||
ImGuiState()
|
||||
ImGuiContext()
|
||||
{
|
||||
Initialized = false;
|
||||
Font = NULL;
|
||||
@ -673,8 +672,8 @@ namespace ImGui
|
||||
// If this ever crash because g.CurrentWindow is NULL it means that either
|
||||
// - ImGui::NewFrame() has never been called, which is illegal.
|
||||
// - You are calling ImGui functions after ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
|
||||
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiState& g = *GImGui; return g.CurrentWindow; }
|
||||
inline ImGuiWindow* GetCurrentWindow() { ImGuiState& g = *GImGui; g.CurrentWindow->Accessed = true; return g.CurrentWindow; }
|
||||
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
|
||||
inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->Accessed = true; return g.CurrentWindow; }
|
||||
IMGUI_API ImGuiWindow* GetParentWindow();
|
||||
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||
|
25
3rdparty/ocornut-imgui/imgui_wm.cpp
vendored
25
3rdparty/ocornut-imgui/imgui_wm.cpp
vendored
@ -915,14 +915,11 @@ namespace ImGuiWM
|
||||
m_bMain = bMain;
|
||||
m_bIsDragWindow = bIsDragWindow;
|
||||
m_pContainer = IMGUI_NEW(Container)(this);
|
||||
m_pState = NULL;
|
||||
m_pPreviousState = NULL;
|
||||
|
||||
void* pTemp = ImGui::GetInternalState();
|
||||
m_pState = ImGui::MemAlloc(ImGui::GetInternalStateSize());
|
||||
ImGui::SetInternalState(m_pState, false);
|
||||
ImGui::GetIO().IniFilename = NULL;
|
||||
ImGui::SetInternalState(pTemp);
|
||||
|
||||
m_pState = ImGui::CreateContext();
|
||||
}
|
||||
|
||||
PlatformWindow::~PlatformWindow()
|
||||
@ -936,7 +933,8 @@ namespace ImGuiWM
|
||||
}
|
||||
|
||||
RestoreState();
|
||||
ImGui::MemFree(m_pState);
|
||||
ImGui::DestroyContext(m_pState);
|
||||
m_pState = NULL;
|
||||
}
|
||||
|
||||
void PlatformWindow::OnClose()
|
||||
@ -955,22 +953,22 @@ namespace ImGuiWM
|
||||
{
|
||||
IM_ASSERT(s_bStatePush == false);
|
||||
s_bStatePush = true;
|
||||
m_pPreviousState = ImGui::GetInternalState();
|
||||
ImGui::SetInternalState(m_pState);
|
||||
memcpy(&((ImGuiState*)m_pState)->Style, &((ImGuiState*)m_pPreviousState)->Style, sizeof(ImGuiStyle));
|
||||
m_pPreviousState = ImGui::GetCurrentContext();
|
||||
ImGui::SetCurrentContext(m_pState);
|
||||
memcpy(&m_pState->Style, &m_pPreviousState->Style, sizeof(ImGuiStyle) );
|
||||
}
|
||||
|
||||
void PlatformWindow::RestoreState()
|
||||
{
|
||||
IM_ASSERT(s_bStatePush == true);
|
||||
s_bStatePush = false;
|
||||
memcpy(&((ImGuiState*)m_pPreviousState)->Style, &((ImGuiState*)m_pState)->Style, sizeof(ImGuiStyle));
|
||||
ImGui::SetInternalState(m_pPreviousState);
|
||||
memcpy(&m_pPreviousState->Style, &m_pState->Style, sizeof(ImGuiStyle) );
|
||||
ImGui::SetCurrentContext(m_pPreviousState);
|
||||
}
|
||||
|
||||
void PlatformWindow::OnLoseFocus()
|
||||
{
|
||||
ImGuiState& g = *((ImGuiState*)m_pState);
|
||||
ImGuiContext& g = *m_pState;
|
||||
g.SetNextWindowPosCond = g.SetNextWindowSizeCond = g.SetNextWindowContentSizeCond = g.SetNextWindowCollapsedCond = g.SetNextWindowFocus = 0;
|
||||
}
|
||||
|
||||
@ -1444,7 +1442,7 @@ namespace ImGuiWM
|
||||
m_lPlatformWindowActions.push_back(pAction);
|
||||
|
||||
Dock(pWindow, E_DOCK_ORIENTATION_CENTER, m_pDragPlatformWindow);
|
||||
((ImGuiState*)m_pDragPlatformWindow->m_pState)->IO.MouseDown[0] = true;
|
||||
m_pDragPlatformWindow->m_pState->IO.MouseDown[0] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1486,7 +1484,6 @@ namespace ImGuiWM
|
||||
DrawWindowArea(pBestContainer->GetPlatformWindowParent(), oHightlightPos, oHightlightSize, m_oConfig.m_oHightlightAreaColor);
|
||||
}
|
||||
|
||||
//if (!((ImGuiState*)m_pDragPlatformWindow->m_pState)->IO.MouseDown[0])
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (!io.MouseDown[0])
|
||||
{
|
||||
|
4
3rdparty/ocornut-imgui/imgui_wm.h
vendored
4
3rdparty/ocornut-imgui/imgui_wm.h
vendored
@ -172,8 +172,8 @@ namespace ImGuiWM
|
||||
bool m_bMain;
|
||||
bool m_bIsDragWindow;
|
||||
Container* m_pContainer;
|
||||
void* m_pState;
|
||||
void* m_pPreviousState;
|
||||
ImGuiContext* m_pState;
|
||||
ImGuiContext* m_pPreviousState;
|
||||
};
|
||||
|
||||
typedef ImwList<PlatformWindow*> PlatformWindowList;
|
||||
|
Loading…
Reference in New Issue
Block a user