Skip to content

Commit a0f0dd3

Browse files
author
Adrien GIVRY
committed
Fixing layout reset and updating ImGui to 1.77 WIP
The `Layout -> Reset` button accessible from the menu bar is now correctly reseting the editor layout. This has been achieved by adding a `ResetLayout` method in the `UIManager`, which internally calls `ImGui::LoadIniSettingsFromDisk`. Previously, ImGui wasn't supporting runtime settings loading. This issue has been fixed recently (May 2020), and thus, an upgrade to the latest ImGui docking version was necessary. This upgrade had some breaking changes (Ex: Some style flag names changed) and forced us to update some code of `OvUI`.
1 parent 31cafa5 commit a0f0dd3

16 files changed

Lines changed: 13305 additions & 8368 deletions

File tree

Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ OvEditor::Core::Context::Context(const std::string& p_projectPath, const std::st
7575
uiManager->EnableDocking(true);
7676

7777
if (!std::filesystem::exists(std::string(getenv("APPDATA")) + "\\OverloadTech\\OvEditor\\layout.ini"))
78-
ImGui::LoadIniSettingsFromDisk("Config\\layout.ini");
78+
uiManager->ResetLayout("Config\\layout.ini");
7979

8080
/* Audio */
8181
audioEngine = std::make_unique<OvAudio::Core::AudioEngine>(projectAssetsPath);

Sources/Overload/OvEditor/src/OvEditor/Core/EditorActions.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ void OvEditor::Core::EditorActions::SetActorSpawnMode(EActorSpawnMode p_value)
362362

363363
void OvEditor::Core::EditorActions::ResetLayout()
364364
{
365-
// TODO
366-
std::filesystem::copy_file("default.ini", std::string(getenv("APPDATA")) + "/OverloadTech/OvEditor/layout.ini", std::filesystem::copy_options::overwrite_existing);
365+
DelayAction([this]() {m_context.uiManager->ResetLayout("Config\\layout.ini"); });
367366
}
368367

369368
void OvEditor::Core::EditorActions::SetSceneViewCameraSpeed(int p_speed)

Sources/Overload/OvUI/include/OvUI/Core/UIManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ namespace OvUI::Core
9696
*/
9797
void EnableDocking(bool p_value);
9898

99+
/**
100+
* Reset the UI layout to the given configuration file
101+
* @param p_config
102+
*/
103+
void ResetLayout(const std::string & p_config) const;
104+
99105
/**
100106
* Return true if the docking system is enabled
101107
*/

Sources/Overload/OvUI/include/OvUI/ImGui/imconfig.h

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,43 @@
33
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
44
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
55
//-----------------------------------------------------------------------------
6-
// A) You may edit imconfig.h (and not overwrite it when updating imgui, or maintain a patch/branch with your modifications to imconfig.h)
6+
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/branch with your modifications to imconfig.h)
77
// B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h"
8-
// If you do so you need to make sure that configuration settings are defined consistently _everywhere_ dear imgui is used, which include
9-
// the imgui*.cpp files but also _any_ of your code that uses imgui. This is because some compile-time options have an affect on data structures.
8+
// If you do so you need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include
9+
// the imgui*.cpp files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
1010
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
1111
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
1212
//-----------------------------------------------------------------------------
1313

1414
#pragma once
1515

1616
//---- Define assertion handler. Defaults to calling assert().
17+
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
1718
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
1819
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
1920

20-
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
21+
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
22+
// Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
2123
#define IMGUI_API __declspec( dllexport )
2224
//#define IMGUI_API __declspec( dllimport )
2325

24-
//---- Don't define obsolete functions/enums names. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
26+
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
2527
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
2628

27-
//---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
28-
//---- It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp.
29-
//#define IMGUI_DISABLE_DEMO_WINDOWS
29+
//---- Disable all of Dear ImGui or don't implement standard windows.
30+
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
31+
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
32+
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
33+
//#define IMGUI_DISABLE_METRICS_WINDOW // Disable debug/metrics window: ShowMetricsWindow() will be empty.
3034

3135
//---- Don't implement some functions to reduce linkage requirements.
3236
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
3337
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
34-
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function.
35-
//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself if you don't want to link with vsnprintf.
36-
//#define IMGUI_DISABLE_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 wrapper so you can implement them yourself. Declare your prototypes in imconfig.h.
38+
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
39+
//#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).
40+
//#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)
41+
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
42+
//#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.
3743
//#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().
3844

3945
//---- Include imgui_user.h at the end of imgui.h as a convenience
@@ -42,13 +48,20 @@
4248
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
4349
//#define IMGUI_USE_BGRA_PACKED_COLOR
4450

51+
//---- Use 32-bit for ImWchar (default is 16-bit) to support full unicode code points.
52+
//#define IMGUI_USE_WCHAR32
53+
4554
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
4655
// By default the embedded implementations are declared static and not available outside of imgui cpp files.
4756
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
4857
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
4958
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
5059
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
5160

61+
//---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library.
62+
// Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
63+
// #define IMGUI_USE_STB_SPRINTF
64+
5265
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
5366
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
5467
/*
@@ -61,9 +74,31 @@
6174
operator MyVec4() const { return MyVec4(x,y,z,w); }
6275
*/
6376

64-
//---- Use 32-bit vertex indices (default is 16-bit) to allow meshes with more than 64K vertices. Render function needs to support it.
77+
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
78+
// Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bit indices).
79+
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
80+
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
6581
//#define ImDrawIdx unsigned int
6682

83+
//---- Override ImDrawCallback signature (will need to modify renderer back-ends accordingly)
84+
//struct ImDrawList;
85+
//struct ImDrawCmd;
86+
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
87+
//#define ImDrawCallback MyImDrawCallback
88+
89+
//---- Debug Tools: Macro to break in Debugger
90+
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
91+
//#define IM_DEBUG_BREAK IM_ASSERT(0)
92+
//#define IM_DEBUG_BREAK __debugbreak()
93+
94+
//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
95+
// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
96+
// This adds a small runtime cost which is why it is not enabled by default.
97+
//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
98+
99+
//---- Debug Tools: Enable slower asserts
100+
//#define IMGUI_DEBUG_PARANOID
101+
67102
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
68103
/*
69104
namespace ImGui

0 commit comments

Comments
 (0)