mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Merge branch 'master' into 2016-02-colorpicker
This commit is contained in:
commit
3e4cb40d45
@ -9,10 +9,10 @@ compiler:
|
|||||||
- clang
|
- clang
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- if [ $TRAVIS_OS_NAME == linux ]; then sudo add-apt-repository -y ppa:pyglfw/pyglfw && sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends libglfw3-dev libxrandr-dev libxi-dev libxxf86vm-dev; fi
|
- if [ $TRAVIS_OS_NAME == linux ]; then sudo add-apt-repository -y ppa:pyglfw/pyglfw && sudo apt-add-repository --yes ppa:zoogie/sdl2-snapshots && sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends libglfw3-dev libxrandr-dev libxi-dev libxxf86vm-dev libsdl2-dev; fi
|
||||||
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3; fi
|
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install glfw3 && brew install sdl2; fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- make -C examples/opengl2_example
|
- make -C examples/opengl2_example
|
||||||
- make -C examples/opengl3_example
|
- make -C examples/opengl3_example
|
||||||
|
- make -C examples/sdl_opengl3_example
|
||||||
|
@ -3,7 +3,7 @@ dear imgui,
|
|||||||
[![Build Status](https://travis-ci.org/ocornut/imgui.svg?branch=master)](https://travis-ci.org/ocornut/imgui)
|
[![Build Status](https://travis-ci.org/ocornut/imgui.svg?branch=master)](https://travis-ci.org/ocornut/imgui)
|
||||||
[![Coverity Status](https://scan.coverity.com/projects/4720/badge.svg)](https://scan.coverity.com/projects/4720)
|
[![Coverity Status](https://scan.coverity.com/projects/4720/badge.svg)](https://scan.coverity.com/projects/4720)
|
||||||
|
|
||||||
(This library is free and will stay free, but needs your support to sustain its development. There are lots of desirable new features and maintenance to do. If you work for a company using ImGui or have the means to do so, please consider financial support. I can invoice for private support, custom development etc. E-mail: omarcornut at gmail)
|
(This library is free but needs your support to sustain its development. There are lots of desirable new features and maintenance to do. If you are an individual using dear imgui, please consider financial support via Patreon/PayPal. If your company is using dear imgui, please consider sponsorship (e.g. sponsoring a few weeks of development). I can invoice for private support, custom development etc. E-mail: omarcornut at gmail.)
|
||||||
|
|
||||||
Monthly donations via Patreon:
|
Monthly donations via Patreon:
|
||||||
<br>[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/imgui)
|
<br>[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/imgui)
|
||||||
@ -62,6 +62,7 @@ Languages:
|
|||||||
- CyImGui: Python bindings for dear imgui using Cython: https://github.com/chromy/cyimgui
|
- CyImGui: Python bindings for dear imgui using Cython: https://github.com/chromy/cyimgui
|
||||||
- pyimgui: Another Python bindings for dear imgui: https://github.com/swistakm/pyimgui
|
- pyimgui: Another Python bindings for dear imgui: https://github.com/swistakm/pyimgui
|
||||||
- LUA: https://github.com/patrickriordan/imgui_lua_bindings
|
- LUA: https://github.com/patrickriordan/imgui_lua_bindings
|
||||||
|
- imgui-pas: P ascal bindings for imgui https://github.com/dpethes/imgui-pas
|
||||||
|
|
||||||
Frameworks:
|
Frameworks:
|
||||||
- Main ImGui repository include examples for DirectX9, DirectX10, DirectX11, OpenGL2/3, Vulkan, Allegro 5, SDL+GL2/3, iOS and Marmalade: https://github.com/ocornut/imgui/tree/master/examples
|
- Main ImGui repository include examples for DirectX9, DirectX10, DirectX11, OpenGL2/3, Vulkan, Allegro 5, SDL+GL2/3, iOS and Marmalade: https://github.com/ocornut/imgui/tree/master/examples
|
||||||
|
@ -484,7 +484,7 @@ void ImGui_ImplDX10_InvalidateDeviceObjects()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_pFontSampler) { g_pFontSampler->Release(); g_pFontSampler = NULL; }
|
if (g_pFontSampler) { g_pFontSampler->Release(); g_pFontSampler = NULL; }
|
||||||
if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->TexID = 0; }
|
if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
||||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
||||||
|
|
||||||
|
@ -485,7 +485,7 @@ void ImGui_ImplDX11_InvalidateDeviceObjects()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_pFontSampler) { g_pFontSampler->Release(); g_pFontSampler = NULL; }
|
if (g_pFontSampler) { g_pFontSampler->Release(); g_pFontSampler = NULL; }
|
||||||
if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->TexID = 0; }
|
if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
||||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
||||||
|
|
||||||
|
@ -311,12 +311,14 @@ void ImGui_ImplDX9_InvalidateDeviceObjects()
|
|||||||
g_pIB->Release();
|
g_pIB->Release();
|
||||||
g_pIB = NULL;
|
g_pIB = NULL;
|
||||||
}
|
}
|
||||||
if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().Fonts->TexID)
|
|
||||||
{
|
// At this point note that we set ImGui::GetIO().Fonts->TexID to be == g_FontTexture, so clear both.
|
||||||
tex->Release();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGui::GetIO().Fonts->TexID = 0;
|
IM_ASSERT(g_FontTexture == io.Fonts->TexID);
|
||||||
}
|
if (g_FontTexture)
|
||||||
|
g_FontTexture->Release();
|
||||||
g_FontTexture = NULL;
|
g_FontTexture = NULL;
|
||||||
|
io.Fonts->TexID = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplDX9_NewFrame()
|
void ImGui_ImplDX9_NewFrame()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Cross Platform Makefile
|
# Cross Platform Makefile
|
||||||
# Compatible with Ubuntu 14.04.1 and Mac OS X
|
# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# if you using Mac OS X:
|
# if you using Mac OS X:
|
||||||
@ -37,7 +37,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
|||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(UNAME_S), MINGW64_NT-6.3)
|
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||||
ECHO_MESSAGE = "Windows"
|
ECHO_MESSAGE = "Windows"
|
||||||
LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
|
LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
#
|
#
|
||||||
# Cross Platform Makefile
|
# Cross Platform Makefile
|
||||||
# Compatible with Ubuntu 14.04.1 and Mac OS X
|
# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# You will need GLFW (http://www.glfw.org)
|
# You will need GLFW (http://www.glfw.org)
|
||||||
#
|
#
|
||||||
# apt-get install libglfw-dev # Linux
|
# apt-get install libglfw-dev # Linux
|
||||||
# brew install glfw # Mac OS X
|
# brew install glfw # Mac OS X
|
||||||
|
# pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw # MSYS2
|
||||||
#
|
#
|
||||||
|
|
||||||
#CXX = g++
|
#CXX = g++
|
||||||
@ -39,7 +40,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
|||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(UNAME_S), MINGW64_NT-6.3)
|
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||||
ECHO_MESSAGE = "Windows"
|
ECHO_MESSAGE = "Windows"
|
||||||
LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
|
LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
|
||||||
|
|
||||||
|
61
examples/sdl_opengl3_example/Makefile
Normal file
61
examples/sdl_opengl3_example/Makefile
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#
|
||||||
|
# Cross Platform Makefile
|
||||||
|
# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# You will need SDL2 (http://www.libsdl.org)
|
||||||
|
#
|
||||||
|
# apt-get install libsdl2-dev # Linux
|
||||||
|
# brew install sdl2 # Mac OS X
|
||||||
|
# pacman -S mingw-w64-i686-SDL # MSYS2
|
||||||
|
#
|
||||||
|
|
||||||
|
#CXX = g++
|
||||||
|
|
||||||
|
EXE = sdl_opengl3_example
|
||||||
|
OBJS = main.o imgui_impl_sdl_gl3.o
|
||||||
|
OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
|
||||||
|
OBJS += ../libs/gl3w/GL/gl3w.o
|
||||||
|
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(UNAME_S), Linux) #LINUX
|
||||||
|
ECHO_MESSAGE = "Linux"
|
||||||
|
LIBS = -lGL -ldl `sdl2-config --libs`
|
||||||
|
|
||||||
|
CXXFLAGS = -I../../ -I../libs/gl3w `sdl2-config --cflags`
|
||||||
|
CXXFLAGS += -Wall -Wformat
|
||||||
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(UNAME_S), Darwin) #APPLE
|
||||||
|
ECHO_MESSAGE = "Mac OS X"
|
||||||
|
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
|
||||||
|
|
||||||
|
CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include `sdl2-config --cflags`
|
||||||
|
CXXFLAGS += -Wall -Wformat
|
||||||
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||||
|
ECHO_MESSAGE = "Windows"
|
||||||
|
LIBS = -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
|
||||||
|
|
||||||
|
CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags sdl2`
|
||||||
|
CXXFLAGS += -Wall -Wformat
|
||||||
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
all: $(EXE)
|
||||||
|
@echo Build complete for $(ECHO_MESSAGE)
|
||||||
|
|
||||||
|
$(EXE): $(OBJS)
|
||||||
|
$(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm $(EXE) $(OBJS)
|
82
imgui.cpp
82
imgui.cpp
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.50 WIP
|
// dear imgui, v1.51 WIP
|
||||||
// (main code and documentation)
|
// (main code and documentation)
|
||||||
|
|
||||||
// See ImGui::ShowTestWindow() in imgui_demo.cpp for demo code.
|
// See ImGui::ShowTestWindow() in imgui_demo.cpp for demo code.
|
||||||
@ -282,8 +282,9 @@
|
|||||||
stb_textedit.h
|
stb_textedit.h
|
||||||
stb_truetype.h
|
stb_truetype.h
|
||||||
Don't overwrite imconfig.h if you have made modification to your copy.
|
Don't overwrite imconfig.h if you have made modification to your copy.
|
||||||
Check the "API BREAKING CHANGES" sections for a list of occasional API breaking changes. If you have a problem with a function, search for its name
|
If you have a problem with a missing function/symbols, search for its name in the code, there will likely be a comment about it.
|
||||||
in the code, there will likely be a comment about it. Please report any issue to the GitHub page!
|
Check the "API BREAKING CHANGES" sections for a list of occasional API breaking changes.
|
||||||
|
Please report any issue to the GitHub page!
|
||||||
|
|
||||||
Q: What is ImTextureID and how do I display an image?
|
Q: What is ImTextureID and how do I display an image?
|
||||||
A: ImTextureID is a void* used to pass renderer-agnostic texture references around until it hits your render function.
|
A: ImTextureID is a void* used to pass renderer-agnostic texture references around until it hits your render function.
|
||||||
@ -431,7 +432,8 @@
|
|||||||
ImFontConfig config;
|
ImFontConfig config;
|
||||||
config.OversampleH = 3;
|
config.OversampleH = 3;
|
||||||
config.OversampleV = 1;
|
config.OversampleV = 1;
|
||||||
config.GlyphExtraSpacing.x = 1.0f;
|
config.GlyphOffset.y -= 2.0f; // Move everything by 2 pixels up
|
||||||
|
config.GlyphExtraSpacing.x = 1.0f; // Increase spacing between characters
|
||||||
io.Fonts->LoadFromFileTTF("myfontfile.ttf", size_pixels, &config);
|
io.Fonts->LoadFromFileTTF("myfontfile.ttf", size_pixels, &config);
|
||||||
|
|
||||||
// Combine multiple fonts into one (e.g. for icon fonts)
|
// Combine multiple fonts into one (e.g. for icon fonts)
|
||||||
@ -506,6 +508,7 @@
|
|||||||
- input text multi-line: way to dynamically grow the buffer without forcing the user to initially allocate for worse case (follow up on #200)
|
- input text multi-line: way to dynamically grow the buffer without forcing the user to initially allocate for worse case (follow up on #200)
|
||||||
- input text multi-line: line numbers? status bar? (follow up on #200)
|
- input text multi-line: line numbers? status bar? (follow up on #200)
|
||||||
- input text multi-line: behave better when user changes input buffer while editing is active (even though it is illegal behavior). namely, the change of buffer can create a scrollbar glitch (#725)
|
- input text multi-line: behave better when user changes input buffer while editing is active (even though it is illegal behavior). namely, the change of buffer can create a scrollbar glitch (#725)
|
||||||
|
- input text multi-line: better horizontal scrolling support (#383, #1224)
|
||||||
- input text: allow centering/positioning text so that ctrl+clicking Drag or Slider keeps the textual value at the same pixel position.
|
- input text: allow centering/positioning text so that ctrl+clicking Drag or Slider keeps the textual value at the same pixel position.
|
||||||
- input number: optional range min/max for Input*() functions
|
- input number: optional range min/max for Input*() functions
|
||||||
- input number: holding [-]/[+] buttons could increase the step speed non-linearly (or user-controlled)
|
- input number: holding [-]/[+] buttons could increase the step speed non-linearly (or user-controlled)
|
||||||
@ -641,6 +644,7 @@
|
|||||||
|
|
||||||
// Clang warnings with -Weverything
|
// Clang warnings with -Weverything
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning : unknown warning group '-Wformat-pedantic *' // not all warnings are known by all clang versions.. so ignoring warnings triggers new warnings on some configuration. great!
|
||||||
#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
|
#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
|
||||||
#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok.
|
#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok.
|
||||||
#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code.
|
#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code.
|
||||||
@ -2599,14 +2603,19 @@ static void AddDrawListToRenderList(ImVector<ImDrawList*>& out_render_list, ImDr
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
|
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc. May trigger for you if you are using PrimXXX functions incorrectly.
|
||||||
IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
|
IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
|
||||||
IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
|
IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
|
||||||
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
|
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
|
||||||
|
|
||||||
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = 2 bytes = 64K vertices)
|
// Check that draw_list doesn't use more vertices than indexable in a single draw call (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per window)
|
||||||
// If this assert triggers because you are drawing lots of stuff manually, A) workaround by calling BeginChild()/EndChild() to put your draw commands in multiple draw lists, B) #define ImDrawIdx to a 'unsigned int' in imconfig.h and render accordingly.
|
// If this assert triggers because you are drawing lots of stuff manually, you can:
|
||||||
IM_ASSERT((int64_t)draw_list->_VtxCurrentIdx <= ((int64_t)1L << (sizeof(ImDrawIdx)*8))); // Too many vertices in same ImDrawList. See comment above.
|
// A) Add '#define ImDrawIdx unsigned int' in imconfig.h to set the index size to 4 bytes. You'll need to handle the 4-bytes indices to your renderer.
|
||||||
|
// For example, the OpenGL example code detect index size at compile-time by doing:
|
||||||
|
// 'glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);'
|
||||||
|
// Your own engine or render API may use different parameters or function calls to specify index sizes. 2 and 4 bytes indices are generally supported by most API.
|
||||||
|
// B) If for some reason you cannot use 4 bytes indices or don't want to, a workaround is to call BeginChild()/EndChild() before reaching the 64K limit to split your draw commands in multiple draw lists.
|
||||||
|
IM_ASSERT(((ImU64)draw_list->_VtxCurrentIdx >> (sizeof(ImDrawIdx)*8)) == 0); // Too many vertices in same ImDrawList. See comment above.
|
||||||
|
|
||||||
out_render_list.push_back(draw_list);
|
out_render_list.push_back(draw_list);
|
||||||
GImGui->IO.MetricsRenderVertices += draw_list->VtxBuffer.Size;
|
GImGui->IO.MetricsRenderVertices += draw_list->VtxBuffer.Size;
|
||||||
@ -3150,25 +3159,26 @@ static bool IsKeyPressedMap(ImGuiKey key, bool repeat)
|
|||||||
return ImGui::IsKeyPressed(key_index, repeat);
|
return ImGui::IsKeyPressed(key_index, repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImGui::GetKeyIndex(ImGuiKey key)
|
int ImGui::GetKeyIndex(ImGuiKey imgui_key)
|
||||||
{
|
{
|
||||||
IM_ASSERT(key >= 0 && key < ImGuiKey_COUNT);
|
IM_ASSERT(imgui_key >= 0 && imgui_key < ImGuiKey_COUNT);
|
||||||
return GImGui->IO.KeyMap[key];
|
return GImGui->IO.KeyMap[imgui_key];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui::IsKeyDown(int key_index)
|
// Note that imgui doesn't know the semantic of each entry of io.KeyDown[]. Use your own indices/enums according to how your backend/engine stored them into KeyDown[]!
|
||||||
|
bool ImGui::IsKeyDown(int user_key_index)
|
||||||
{
|
{
|
||||||
if (key_index < 0) return false;
|
if (user_key_index < 0) return false;
|
||||||
IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(GImGui->IO.KeysDown));
|
IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(GImGui->IO.KeysDown));
|
||||||
return GImGui->IO.KeysDown[key_index];
|
return GImGui->IO.KeysDown[user_key_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui::IsKeyPressed(int key_index, bool repeat)
|
bool ImGui::IsKeyPressed(int user_key_index, bool repeat)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (key_index < 0) return false;
|
if (user_key_index < 0) return false;
|
||||||
IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(g.IO.KeysDown));
|
IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown));
|
||||||
const float t = g.IO.KeysDownDuration[key_index];
|
const float t = g.IO.KeysDownDuration[user_key_index];
|
||||||
if (t == 0.0f)
|
if (t == 0.0f)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -3181,12 +3191,12 @@ bool ImGui::IsKeyPressed(int key_index, bool repeat)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui::IsKeyReleased(int key_index)
|
bool ImGui::IsKeyReleased(int user_key_index)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (key_index < 0) return false;
|
if (user_key_index < 0) return false;
|
||||||
IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(g.IO.KeysDown));
|
IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown));
|
||||||
if (g.IO.KeysDownDurationPrev[key_index] >= 0.0f && !g.IO.KeysDown[key_index])
|
if (g.IO.KeysDownDurationPrev[user_key_index] >= 0.0f && !g.IO.KeysDown[user_key_index])
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -4742,18 +4752,18 @@ struct ImGuiStyleVarInfo
|
|||||||
|
|
||||||
static const ImGuiStyleVarInfo GStyleVarInfo[ImGuiStyleVar_Count_] =
|
static const ImGuiStyleVarInfo GStyleVarInfo[ImGuiStyleVar_Count_] =
|
||||||
{
|
{
|
||||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) },
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha
|
||||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) },
|
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
|
||||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) },
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding
|
||||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) },
|
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize
|
||||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildWindowRounding) },
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildWindowRounding) }, // ImGuiStyleVar_ChildWindowRounding
|
||||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) },
|
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding
|
||||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) },
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding
|
||||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) },
|
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
|
||||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) },
|
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
|
||||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) },
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
|
||||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) },
|
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
|
||||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) },
|
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
|
||||||
};
|
};
|
||||||
|
|
||||||
static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx)
|
static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx)
|
||||||
@ -8124,7 +8134,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
select_start_offset.y = searches_result_line_number[1] * g.FontSize;
|
select_start_offset.y = searches_result_line_number[1] * g.FontSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate text height
|
// Store text height (note that we haven't calculated text width at all, see GitHub issues #383, #1224)
|
||||||
if (is_multiline)
|
if (is_multiline)
|
||||||
text_size = ImVec2(size.x, line_count * g.FontSize);
|
text_size = ImVec2(size.x, line_count * g.FontSize);
|
||||||
}
|
}
|
||||||
|
86
imgui.h
86
imgui.h
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.50 WIP
|
// dear imgui, v1.51 WIP
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// See imgui.cpp file for documentation.
|
// See imgui.cpp file for documentation.
|
||||||
@ -16,7 +16,7 @@
|
|||||||
#include <stddef.h> // ptrdiff_t, NULL
|
#include <stddef.h> // ptrdiff_t, NULL
|
||||||
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
||||||
|
|
||||||
#define IMGUI_VERSION "1.50 WIP"
|
#define IMGUI_VERSION "1.51 WIP"
|
||||||
|
|
||||||
// Define attributes of all API symbols declarations, e.g. for DLL under Windows.
|
// Define attributes of all API symbols declarations, e.g. for DLL under Windows.
|
||||||
#ifndef IMGUI_API
|
#ifndef IMGUI_API
|
||||||
@ -79,6 +79,11 @@ typedef int ImGuiSelectableFlags; // flags for Selectable() // e
|
|||||||
typedef int ImGuiTreeNodeFlags; // flags for TreeNode*(), Collapsing*() // enum ImGuiTreeNodeFlags_
|
typedef int ImGuiTreeNodeFlags; // flags for TreeNode*(), Collapsing*() // enum ImGuiTreeNodeFlags_
|
||||||
typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
|
typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
|
||||||
typedef void (*ImGuiSizeConstraintCallback)(ImGuiSizeConstraintCallbackData* data);
|
typedef void (*ImGuiSizeConstraintCallback)(ImGuiSizeConstraintCallbackData* data);
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
typedef unsigned __int64 ImU64; // 64-bit unsigned integer
|
||||||
|
#else
|
||||||
|
typedef unsigned long long ImU64; // 64-bit unsigned integer
|
||||||
|
#endif
|
||||||
|
|
||||||
// Others helpers at bottom of the file:
|
// Others helpers at bottom of the file:
|
||||||
// class ImVector<> // Lightweight std::vector like class.
|
// class ImVector<> // Lightweight std::vector like class.
|
||||||
@ -115,10 +120,12 @@ namespace ImGui
|
|||||||
IMGUI_API void NewFrame(); // start a new ImGui frame, you can submit any command from this point until NewFrame()/Render().
|
IMGUI_API void NewFrame(); // start a new ImGui frame, you can submit any command from this point until NewFrame()/Render().
|
||||||
IMGUI_API void Render(); // ends the ImGui frame, finalize rendering data, then call your io.RenderDrawListsFn() function if set.
|
IMGUI_API void Render(); // ends the ImGui frame, finalize rendering data, then call your io.RenderDrawListsFn() function if set.
|
||||||
IMGUI_API void Shutdown();
|
IMGUI_API void Shutdown();
|
||||||
IMGUI_API void ShowUserGuide(); // help block
|
|
||||||
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // style editor block. you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
|
// Demo/Debug/Info
|
||||||
IMGUI_API void ShowTestWindow(bool* p_open = NULL); // test window demonstrating ImGui features
|
IMGUI_API void ShowTestWindow(bool* p_open = NULL); // create demo/test window. demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
|
||||||
IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // metrics window for debugging ImGui (browse draw commands, individual vertices, window list, etc.)
|
IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create metrics window. display ImGui internals: browse window list, draw commands, individual vertices, basic internal state, etc.
|
||||||
|
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
|
||||||
|
IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls).
|
||||||
|
|
||||||
// Window
|
// Window
|
||||||
IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_open' creates a widget on the upper-right to close the window (which sets your bool to false).
|
IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_open' creates a widget on the upper-right to close the window (which sets your bool to false).
|
||||||
@ -428,10 +435,10 @@ namespace ImGui
|
|||||||
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
||||||
|
|
||||||
// Inputs
|
// Inputs
|
||||||
IMGUI_API int GetKeyIndex(ImGuiKey key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key]
|
IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key]
|
||||||
IMGUI_API bool IsKeyDown(int key_index); // key_index into the keys_down[] array, imgui doesn't know the semantic of each entry, uses your own indices!
|
IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. note that imgui doesn't know the semantic of each entry of io.KeyDown[]. Use your own indices/enums according to how your backend/engine stored them into KeyDown[]!
|
||||||
IMGUI_API bool IsKeyPressed(int key_index, bool repeat = true); // uses user's key indices as stored in the keys_down[] array. if repeat=true. uses io.KeyRepeatDelay / KeyRepeatRate
|
IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
|
||||||
IMGUI_API bool IsKeyReleased(int key_index); // "
|
IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down)..
|
||||||
IMGUI_API bool IsMouseDown(int button); // is mouse button held
|
IMGUI_API bool IsMouseDown(int button); // is mouse button held
|
||||||
IMGUI_API bool IsMouseClicked(int button, bool repeat = false); // did mouse button clicked (went from !Down to Down)
|
IMGUI_API bool IsMouseClicked(int button, bool repeat = false); // did mouse button clicked (went from !Down to Down)
|
||||||
IMGUI_API bool IsMouseDoubleClicked(int button); // did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
|
IMGUI_API bool IsMouseDoubleClicked(int button); // did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
|
||||||
@ -463,7 +470,7 @@ namespace ImGui
|
|||||||
IMGUI_API ImGuiContext* GetCurrentContext();
|
IMGUI_API ImGuiContext* GetCurrentContext();
|
||||||
IMGUI_API void SetCurrentContext(ImGuiContext* ctx);
|
IMGUI_API void SetCurrentContext(ImGuiContext* ctx);
|
||||||
|
|
||||||
// Obsolete (will be removed)
|
// Obsolete functions (Will be removed! Also see 'API BREAKING CHANGES' section in imgui.cpp)
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
static inline bool CollapsingHeader(const char* label, const char* str_id, bool framed = true, bool default_open = false) { (void)str_id; (void)framed; ImGuiTreeNodeFlags default_open_flags = 1<<5; return CollapsingHeader(label, (default_open ? default_open_flags : 0)); } // OBSOLETE 1.49+
|
static inline bool CollapsingHeader(const char* label, const char* str_id, bool framed = true, bool default_open = false) { (void)str_id; (void)framed; ImGuiTreeNodeFlags default_open_flags = 1<<5; return CollapsingHeader(label, (default_open ? default_open_flags : 0)); } // OBSOLETE 1.49+
|
||||||
static inline ImFont* GetWindowFont() { return GetFont(); } // OBSOLETE 1.48+
|
static inline ImFont* GetWindowFont() { return GetFont(); } // OBSOLETE 1.48+
|
||||||
@ -632,22 +639,24 @@ enum ImGuiCol_
|
|||||||
ImGuiCol_COUNT
|
ImGuiCol_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
// Enumeration for PushStyleVar() / PopStyleVar()
|
// Enumeration for PushStyleVar() / PopStyleVar() to temporarily modify the ImGuiStyle structure.
|
||||||
// NB: the enum only refers to fields of ImGuiStyle() which makes sense to be pushed/poped in UI code. Feel free to add others.
|
// NB: the enum only refers to fields of ImGuiStyle which makes sense to be pushed/poped inside UI code. During initialization, feel free to just poke into ImGuiStyle directly.
|
||||||
|
// NB: if changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type.
|
||||||
enum ImGuiStyleVar_
|
enum ImGuiStyleVar_
|
||||||
{
|
{
|
||||||
ImGuiStyleVar_Alpha, // float
|
// Enum name ......................// Member in ImGuiStyle structure (see ImGuiStyle for descriptions)
|
||||||
ImGuiStyleVar_WindowPadding, // ImVec2
|
ImGuiStyleVar_Alpha, // float Alpha
|
||||||
ImGuiStyleVar_WindowRounding, // float
|
ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding
|
||||||
ImGuiStyleVar_WindowMinSize, // ImVec2
|
ImGuiStyleVar_WindowRounding, // float WindowRounding
|
||||||
ImGuiStyleVar_ChildWindowRounding, // float
|
ImGuiStyleVar_WindowMinSize, // ImVec2 WindowMinSize
|
||||||
ImGuiStyleVar_FramePadding, // ImVec2
|
ImGuiStyleVar_ChildWindowRounding, // float ChildWindowRounding
|
||||||
ImGuiStyleVar_FrameRounding, // float
|
ImGuiStyleVar_FramePadding, // ImVec2 FramePadding
|
||||||
ImGuiStyleVar_ItemSpacing, // ImVec2
|
ImGuiStyleVar_FrameRounding, // float FrameRounding
|
||||||
ImGuiStyleVar_ItemInnerSpacing, // ImVec2
|
ImGuiStyleVar_ItemSpacing, // ImVec2 ItemSpacing
|
||||||
ImGuiStyleVar_IndentSpacing, // float
|
ImGuiStyleVar_ItemInnerSpacing, // ImVec2 ItemInnerSpacing
|
||||||
ImGuiStyleVar_GrabMinSize, // float
|
ImGuiStyleVar_IndentSpacing, // float IndentSpacing
|
||||||
ImGuiStyleVar_ButtonTextAlign, // flags ImGuiAlign_*
|
ImGuiStyleVar_GrabMinSize, // float GrabMinSize
|
||||||
|
ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign
|
||||||
ImGuiStyleVar_Count_
|
ImGuiStyleVar_Count_
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -958,10 +967,10 @@ struct ImGuiTextBuffer
|
|||||||
// Helper: Simple Key->value storage
|
// Helper: Simple Key->value storage
|
||||||
// Typically you don't have to worry about this since a storage is held within each Window.
|
// Typically you don't have to worry about this since a storage is held within each Window.
|
||||||
// We use it to e.g. store collapse state for a tree (Int 0/1), store color edit options.
|
// We use it to e.g. store collapse state for a tree (Int 0/1), store color edit options.
|
||||||
// You can use it as custom user storage for temporary values.
|
// This is optimized for efficient reading (dichotomy into a contiguous buffer), rare writing (typically tied to user interactions)
|
||||||
// Declare your own storage if:
|
// You can use it as custom user storage for temporary values. Declare your own storage if, for example:
|
||||||
// - 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 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.
|
// - You want to store custom debug data easily without adding or editing structures in your code (probably not efficient, but convenient)
|
||||||
// Types are NOT stored, so it is up to you to make sure your Key don't collide with different types.
|
// Types are NOT stored, so it is up to you to make sure your Key don't collide with different types.
|
||||||
struct ImGuiStorage
|
struct ImGuiStorage
|
||||||
{
|
{
|
||||||
@ -1149,6 +1158,7 @@ struct ImDrawVert
|
|||||||
// You can override the vertex format layout by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h
|
// You can override the vertex format layout by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h
|
||||||
// The code expect ImVec2 pos (8 bytes), ImVec2 uv (8 bytes), ImU32 col (4 bytes), but you can re-order them or add other fields as needed to simplify integration in your engine.
|
// The code expect ImVec2 pos (8 bytes), ImVec2 uv (8 bytes), ImU32 col (4 bytes), but you can re-order them or add other fields as needed to simplify integration in your engine.
|
||||||
// The type has to be described within the macro (you can either declare the struct or use a typedef)
|
// The type has to be described within the macro (you can either declare the struct or use a typedef)
|
||||||
|
// NOTE: IMGUI DOESN'T CLEAR THE STRUCTURE AND DOESN'T CALL A CONSTRUCTOR SO ANY CUSTOM FIELD WILL BE UNINITIALIZED. IF YOU ADD EXTRA FIELDS (SUCH AS A 'Z' COORDINATES) YOU WILL NEED TO CLEAR THEM DURING RENDER OR TO IGNORE THEM.
|
||||||
IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT;
|
IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1165,11 +1175,12 @@ struct ImDrawChannel
|
|||||||
// At the moment, each ImGui window contains its own ImDrawList but they could potentially be merged in the future.
|
// At the moment, each ImGui window contains its own ImDrawList but they could potentially be merged in the future.
|
||||||
// If you want to add custom rendering within a window, you can use ImGui::GetWindowDrawList() to access the current draw list and add your own primitives.
|
// If you want to add custom rendering within a window, you can use ImGui::GetWindowDrawList() to access the current draw list and add your own primitives.
|
||||||
// You can interleave normal ImGui:: calls and adding primitives to the current draw list.
|
// You can interleave normal ImGui:: calls and adding primitives to the current draw list.
|
||||||
// All positions are in screen coordinates (0,0=top-left, 1 pixel per unit). Primitives are always added to the list and not culled (culling is done at render time and at a higher-level by ImGui:: functions).
|
// All positions are generally in pixel coordinates (top-left at (0,0), bottom-right at io.DisplaySize), however you are totally free to apply whatever transformation matrix to want to the data (if you apply such transformation you'll want to apply it to ClipRect as well)
|
||||||
|
// Primitives are always added to the list and not culled (culling is done at higher-level by ImGui:: functions).
|
||||||
struct ImDrawList
|
struct ImDrawList
|
||||||
{
|
{
|
||||||
// This is what you have to render
|
// This is what you have to render
|
||||||
ImVector<ImDrawCmd> CmdBuffer; // Commands. Typically 1 command = 1 gpu draw call.
|
ImVector<ImDrawCmd> CmdBuffer; // Commands. Typically 1 command = 1 GPU draw call.
|
||||||
ImVector<ImDrawIdx> IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those
|
ImVector<ImDrawIdx> IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those
|
||||||
ImVector<ImDrawVert> VtxBuffer; // Vertex buffer.
|
ImVector<ImDrawVert> VtxBuffer; // Vertex buffer.
|
||||||
|
|
||||||
@ -1260,7 +1271,7 @@ struct ImDrawData
|
|||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
ImDrawData() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; }
|
ImDrawData() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; }
|
||||||
IMGUI_API void DeIndexAllBuffers(); // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
IMGUI_API void DeIndexAllBuffers(); // For backward compatibility or convenience: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
||||||
IMGUI_API void ScaleClipRects(const ImVec2& sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
IMGUI_API void ScaleClipRects(const ImVec2& sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1273,13 +1284,13 @@ struct ImFontConfig
|
|||||||
float SizePixels; // // Size in pixels for rasterizer
|
float SizePixels; // // Size in pixels for rasterizer
|
||||||
int OversampleH, OversampleV; // 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
|
int OversampleH, OversampleV; // 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
|
||||||
bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1.
|
bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1.
|
||||||
ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs
|
ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
|
||||||
ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input
|
ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input
|
||||||
const ImWchar* GlyphRanges; // // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
|
const ImWchar* GlyphRanges; // // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
|
||||||
bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights.
|
bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights.
|
||||||
|
|
||||||
// [Internal]
|
// [Internal]
|
||||||
char Name[32]; // Name (strictly for debugging)
|
char Name[32]; // Name (strictly to ease debugging)
|
||||||
ImFont* DstFont;
|
ImFont* DstFont;
|
||||||
|
|
||||||
IMGUI_API ImFontConfig();
|
IMGUI_API ImFontConfig();
|
||||||
@ -1292,8 +1303,7 @@ struct ImFontConfig
|
|||||||
// 2. Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
|
// 2. Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
|
||||||
// 3. Upload the pixels data into a texture within your graphics system.
|
// 3. Upload the pixels data into a texture within your graphics system.
|
||||||
// 4. Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture. This value will be passed back to you during rendering to identify the texture.
|
// 4. Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture. This value will be passed back to you during rendering to identify the texture.
|
||||||
// 5. Call ClearTexData() to free textures memory on the heap.
|
// IMPORTANT: If you pass a 'glyph_ranges' array to AddFont*** functions, you need to make sure that your array persist up until the ImFont is build (when calling GetTextData*** or Build()). We only copy the pointer, not the data.
|
||||||
// NB: If you use a 'glyph_ranges' array you need to make sure that your array persist up until the ImFont is cleared. We only copy the pointer, not the data.
|
|
||||||
struct ImFontAtlas
|
struct ImFontAtlas
|
||||||
{
|
{
|
||||||
IMGUI_API ImFontAtlas();
|
IMGUI_API ImFontAtlas();
|
||||||
@ -1316,10 +1326,10 @@ struct ImFontAtlas
|
|||||||
// Pitch = Width * BytesPerPixels
|
// Pitch = Width * BytesPerPixels
|
||||||
IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
|
IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
|
||||||
IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
|
IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
|
||||||
void SetTexID(void* id) { TexID = id; }
|
void SetTexID(ImTextureID id) { TexID = id; }
|
||||||
|
|
||||||
// Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
|
// Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
|
||||||
// NB: Make sure that your string are UTF-8 and NOT in your local code page. See FAQ for details.
|
// NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create a UTF-8 string literally using the u8"Hello world" syntax. See FAQ for details.
|
||||||
IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
|
IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
|
||||||
IMGUI_API const ImWchar* GetGlyphRangesKorean(); // Default + Korean characters
|
IMGUI_API const ImWchar* GetGlyphRangesKorean(); // Default + Korean characters
|
||||||
IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
|
IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
|
||||||
@ -1329,7 +1339,7 @@ struct ImFontAtlas
|
|||||||
|
|
||||||
// Members
|
// Members
|
||||||
// (Access texture data via GetTexData*() calls which will setup a default font for you.)
|
// (Access texture data via GetTexData*() calls which will setup a default font for you.)
|
||||||
void* TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It ia passed back to you during rendering.
|
ImTextureID TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure.
|
||||||
unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
|
unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
|
||||||
unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
|
unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
|
||||||
int TexWidth; // Texture width calculated during Build().
|
int TexWidth; // Texture width calculated during Build().
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.50 WIP
|
// dear imgui, v1.51 WIP
|
||||||
// (demo code)
|
// (demo code)
|
||||||
|
|
||||||
// Message to the person tempted to delete this file when integrating ImGui into their code base:
|
// Message to the person tempted to delete this file when integrating ImGui into their code base:
|
||||||
@ -15,7 +15,7 @@
|
|||||||
#include <ctype.h> // toupper, isprint
|
#include <ctype.h> // toupper, isprint
|
||||||
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
|
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
|
||||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||||
#include <stdlib.h> // NULL, malloc, free, qsort, atoi
|
#include <stdlib.h> // NULL, malloc, free, atoi
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||||
#include <stddef.h> // intptr_t
|
#include <stddef.h> // intptr_t
|
||||||
#else
|
#else
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.50 WIP
|
// dear imgui, v1.51 WIP
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
// Contains implementation for
|
// Contains implementation for
|
||||||
@ -359,13 +359,13 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
|||||||
ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size-1];
|
ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size-1];
|
||||||
draw_cmd.ElemCount += idx_count;
|
draw_cmd.ElemCount += idx_count;
|
||||||
|
|
||||||
int vtx_buffer_size = VtxBuffer.Size;
|
int vtx_buffer_old_size = VtxBuffer.Size;
|
||||||
VtxBuffer.resize(vtx_buffer_size + vtx_count);
|
VtxBuffer.resize(vtx_buffer_old_size + vtx_count);
|
||||||
_VtxWritePtr = VtxBuffer.Data + vtx_buffer_size;
|
_VtxWritePtr = VtxBuffer.Data + vtx_buffer_old_size;
|
||||||
|
|
||||||
int idx_buffer_size = IdxBuffer.Size;
|
int idx_buffer_old_size = IdxBuffer.Size;
|
||||||
IdxBuffer.resize(idx_buffer_size + idx_count);
|
IdxBuffer.resize(idx_buffer_old_size + idx_count);
|
||||||
_IdxWritePtr = IdxBuffer.Data + idx_buffer_size;
|
_IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fully unrolled with inline call to keep our debug builds decently fast.
|
// Fully unrolled with inline call to keep our debug builds decently fast.
|
||||||
@ -933,7 +933,7 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
|
|||||||
if (text_begin == text_end)
|
if (text_begin == text_end)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Note: This is one of the few instance of breaking the encapsulation of ImDrawList, as we pull this from ImGui state, but it is just SO useful.
|
// IMPORTANT: This is one of the few instance of breaking the encapsulation of ImDrawList, as we pull this from ImGui state, but it is just SO useful.
|
||||||
// Might just move Font/FontSize to ImDrawList?
|
// Might just move Font/FontSize to ImDrawList?
|
||||||
if (font == NULL)
|
if (font == NULL)
|
||||||
font = GImGui->Font;
|
font = GImGui->Font;
|
||||||
@ -955,7 +955,7 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
|
|||||||
|
|
||||||
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
|
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
|
||||||
{
|
{
|
||||||
AddText(GImGui->Font, GImGui->FontSize, pos, col, text_begin, text_end);
|
AddText(NULL, 0.0f, pos, col, text_begin, text_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col)
|
void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col)
|
||||||
@ -1161,7 +1161,7 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IM_ASSERT(!Fonts.empty()); // When using MergeMode make sure that a font has already been added before. You can use ImGui::AddFontDefault() to add the default imgui font.
|
IM_ASSERT(!Fonts.empty()); // When using MergeMode make sure that a font has already been added before. You can use ImGui::GetIO().Fonts->AddFontDefault() to add the default imgui font.
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigData.push_back(*font_cfg);
|
ConfigData.push_back(*font_cfg);
|
||||||
@ -2167,8 +2167,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug build.
|
// We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug builds. Inlined here:
|
||||||
// Inlined here:
|
|
||||||
{
|
{
|
||||||
idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2);
|
idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2);
|
||||||
idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3);
|
idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.50 WIP
|
// dear imgui, v1.51 WIP
|
||||||
// (internals)
|
// (internals)
|
||||||
|
|
||||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||||
|
Loading…
Reference in New Issue
Block a user