mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-17 21:56:36 +00:00
Merged changes from original master
This commit is contained in:
commit
e6318abcee
@ -36,7 +36,7 @@ Gallery
|
||||
![screenshot 4](/web/test_window_04.png?raw=true)
|
||||
![screenshot 4](/web/examples_02.png?raw=true)
|
||||
|
||||
ImGui can load TTF fonts. UTF-8 is supported for text display and input. Here using M+ font to display Japanese:
|
||||
ImGui can load TTF fonts. UTF-8 is supported for text display and input. Here using Arial Unicode font to display Japanese:
|
||||
|
||||
![utf-8 screenshot](/web/utf8_sample_01.png?raw=true)
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
BIN
extra_fonts/DroidSans.ttf
Normal file
BIN
extra_fonts/DroidSans.ttf
Normal file
Binary file not shown.
@ -5,6 +5,11 @@
|
||||
EXTRA FONTS FOR IMGUI
|
||||
---------------------------------
|
||||
|
||||
DroidSans.ttf
|
||||
Copyright (c) Steve Matteson
|
||||
Apache License, version 2.0
|
||||
http://www.google.com/fonts/specimen/Droid+Sans
|
||||
|
||||
ProggyClean.ttf
|
||||
Copyright (c) 2004, 2005 Tristan Grimmer
|
||||
MIT License
|
||||
|
21
imgui.cpp
21
imgui.cpp
@ -1,4 +1,4 @@
|
||||
// ImGui library v1.30
|
||||
// ImGui library v1.31 wip
|
||||
// See ImGui::ShowTestWindow() for sample code.
|
||||
// Read 'Programmer guide' below for notes on how to setup ImGui in your codebase.
|
||||
// Get latest version at https://github.com/ocornut/imgui
|
||||
@ -128,6 +128,7 @@
|
||||
Occasionally introducing changes that are breaking the API. The breakage are generally minor and easy to fix.
|
||||
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
||||
|
||||
- 2015/02/01 (1.31) - removed IO.MemReallocFn (unused)
|
||||
- 2015/01/19 (1.30) - renamed ImGuiStorage::GetIntPtr()/GetFloatPtr() to GetIntRef()/GetIntRef() because Ptr was conflicting with actual pointer storage functions.
|
||||
- 2015/01/11 (1.30) - big font/image API change! now loads TTF file. allow for multiple fonts. no need for a PNG loader.
|
||||
(1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels.
|
||||
@ -983,6 +984,7 @@ struct ImGuiState
|
||||
|
||||
// Render
|
||||
ImVector<ImDrawList*> RenderDrawLists;
|
||||
ImVector<ImGuiWindow*> RenderSortedWindows;
|
||||
|
||||
// Widget state
|
||||
ImGuiTextEditState InputTextState;
|
||||
@ -1768,7 +1770,7 @@ void ImGui::NewFrame()
|
||||
|
||||
// No window should be open at the beginning of the frame.
|
||||
// But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear.
|
||||
g.CurrentWindowStack.clear();
|
||||
g.CurrentWindowStack.resize(0);
|
||||
|
||||
// Create implicit window - we will only render it if the user has added something to it.
|
||||
ImGui::Begin("Debug", NULL, ImVec2(400,400));
|
||||
@ -1885,18 +1887,18 @@ void ImGui::Render()
|
||||
|
||||
// Sort the window list so that all child windows are after their parent
|
||||
// We cannot do that on FocusWindow() because childs may not exist yet
|
||||
ImVector<ImGuiWindow*> sorted_windows;
|
||||
sorted_windows.reserve(g.Windows.size());
|
||||
g.RenderSortedWindows.resize(0);
|
||||
g.RenderSortedWindows.reserve(g.Windows.size());
|
||||
for (size_t i = 0; i != g.Windows.size(); i++)
|
||||
{
|
||||
ImGuiWindow* window = g.Windows[i];
|
||||
if (window->Flags & ImGuiWindowFlags_ChildWindow) // if a child is visible its parent will add it
|
||||
if (window->Flags & ImGuiWindowFlags_ChildWindow) // if a child is visible its parent will add it
|
||||
if (window->Visible)
|
||||
continue;
|
||||
AddWindowToSortedBuffer(window, sorted_windows);
|
||||
AddWindowToSortedBuffer(window, g.RenderSortedWindows);
|
||||
}
|
||||
IM_ASSERT(g.Windows.size() == sorted_windows.size()); // We done something wrong
|
||||
g.Windows.swap(sorted_windows);
|
||||
IM_ASSERT(g.Windows.size() == g.RenderSortedWindows.size()); // We done something wrong
|
||||
g.Windows.swap(g.RenderSortedWindows);
|
||||
|
||||
// Clear data for next frame
|
||||
g.IO.MouseWheel = 0.0f;
|
||||
@ -5038,6 +5040,9 @@ static bool InputTextFilterCharacter(ImWchar c, ImGuiInputTextFlags flags)
|
||||
if (c < 128 && c != ' ' && !isprint((int)(c & 0xFF)))
|
||||
return true;
|
||||
|
||||
if (c >= 0xE000 && c <= 0xF8FF) // Filter private Unicode range. I don't imagine anybody would want to input them. GLFW on OSX seems to send private characters for special keys like arrow keys.
|
||||
return true;
|
||||
|
||||
if (flags & ImGuiInputTextFlags_CharsDecimal)
|
||||
if (!(c >= '0' && c <= '9') && (c != '.') && (c != '-') && (c != '+') && (c != '*') && (c != '/'))
|
||||
return true;
|
||||
|
25
imgui.h
25
imgui.h
@ -1,4 +1,4 @@
|
||||
// ImGui library v1.30
|
||||
// ImGui library v1.31 wip
|
||||
// See .cpp file for commentary.
|
||||
// See ImGui::ShowTestWindow() for sample code.
|
||||
// Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
|
||||
@ -69,7 +69,7 @@ struct ImVec4
|
||||
|
||||
namespace ImGui
|
||||
{
|
||||
// Proxy functions to access the MemAllocFn/MemFreeFn/MemReallocFn pointers in ImGui::GetIO(). The only reason they exist here is to allow ImVector<> to compile inline.
|
||||
// Proxy functions to access the MemAllocFn/MemFreeFn pointers in ImGui::GetIO(). The only reason they exist here is to allow ImVector<> to compile inline.
|
||||
IMGUI_API void* MemAlloc(size_t sz);
|
||||
IMGUI_API void MemFree(void* ptr);
|
||||
}
|
||||
@ -113,14 +113,17 @@ public:
|
||||
inline value_type& back() { IM_ASSERT(Size > 0); return Data[Size-1]; }
|
||||
inline const value_type& back() const { IM_ASSERT(Size > 0); return Data[Size-1]; }
|
||||
inline void swap(ImVector<T>& rhs) { const size_t rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const size_t rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
|
||||
inline void reserve(size_t new_capacity) { if( new_capacity <= Capacity )
|
||||
return;
|
||||
T* NewData = (value_type*)ImGui::MemAlloc(new_capacity * sizeof(value_type));
|
||||
memcpy(NewData, Data, Size * sizeof(value_type));
|
||||
ImGui::MemFree(Data);
|
||||
Data = NewData;
|
||||
Capacity = new_capacity; }
|
||||
|
||||
inline void resize(size_t new_size) { if (new_size > Capacity) reserve(new_size); Size = new_size; }
|
||||
inline void reserve(size_t new_capacity)
|
||||
{
|
||||
if (new_capacity <= Capacity) return;
|
||||
T* new_data = (value_type*)ImGui::MemAlloc(new_capacity * sizeof(value_type));
|
||||
memcpy(new_data, Data, Size * sizeof(value_type));
|
||||
ImGui::MemFree(Data);
|
||||
Data = new_data;
|
||||
Capacity = new_capacity;
|
||||
}
|
||||
|
||||
inline void push_back(const value_type& v) { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; }
|
||||
inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
|
||||
@ -530,7 +533,7 @@ struct ImGuiIO
|
||||
const char* (*GetClipboardTextFn)();
|
||||
void (*SetClipboardTextFn)(const char* text);
|
||||
|
||||
// Optional: override memory allocations (default to posix malloc/free)
|
||||
// Optional: override memory allocations (default to posix malloc/free). MemFreeFn() may be called with a NULL pointer.
|
||||
void* (*MemAllocFn)(size_t sz);
|
||||
void (*MemFreeFn)(void* ptr);
|
||||
|
||||
@ -710,7 +713,7 @@ struct ImColor
|
||||
{
|
||||
ImVec4 Value;
|
||||
|
||||
ImColor(int r, int g, int b, int a = 255) { Value.x = r / 255.0f; Value.y = g / 255.0f; Value.z = b / 255.0f; Value.w = a / 255.0f; }
|
||||
ImColor(int r, int g, int b, int a = 255) { Value.x = (float)r / 255.0f; Value.y = (float)g / 255.0f; Value.z = (float)b / 255.0f; Value.w = (float)a / 255.0f; }
|
||||
ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
|
||||
ImColor(const ImVec4& col) { Value = col; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user