mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Merge remote-tracking branch 'origin' into 2015-03-antialiased-primitives
Conflicts: examples/directx11_example/imgui_impl_dx11.cpp examples/directx9_example/imgui_impl_dx9.cpp examples/opengl3_example/imgui_impl_glfw_gl3.cpp examples/opengl_example/imgui_impl_glfw.cpp imgui.cpp
This commit is contained in:
commit
25882c47a3
@ -119,7 +119,7 @@ static void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
|
||||
for (int n = 0; n < draw_data->cmd_lists_count; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->cmd_lists[n];
|
||||
for (size_t cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++)
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->cmd_buffer[cmd_i];
|
||||
if (pcmd->user_callback)
|
||||
|
@ -43,7 +43,7 @@ static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->cmd_lists[n];
|
||||
const ImDrawVert* vtx_src = &cmd_list->vtx_buffer[0];
|
||||
for (size_t i = 0; i < cmd_list->vtx_buffer.size(); i++)
|
||||
for (int i = 0; i < cmd_list->vtx_buffer.size(); i++)
|
||||
{
|
||||
vtx_dst->pos.x = vtx_src->pos.x;
|
||||
vtx_dst->pos.y = vtx_src->pos.y;
|
||||
@ -97,7 +97,7 @@ static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
||||
for (int n = 0; n < draw_data->cmd_lists_count; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->cmd_lists[n];
|
||||
for (size_t cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++)
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->cmd_buffer[cmd_i];
|
||||
if (pcmd->user_callback)
|
||||
|
@ -23,7 +23,7 @@ static GLuint g_FontTexture = 0;
|
||||
static int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
||||
static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0;
|
||||
static int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_AttribLocationColor = 0;
|
||||
static size_t g_VboSize = 0;
|
||||
static int g_VboSize = 0;
|
||||
static unsigned int g_VboHandle = 0, g_VaoHandle = 0;
|
||||
|
||||
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
||||
@ -59,7 +59,7 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
||||
|
||||
// Grow our buffer according to what we need
|
||||
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
|
||||
size_t needed_vtx_size = draw_data->total_vtx_count * sizeof(ImDrawVert);
|
||||
int needed_vtx_size = draw_data->total_vtx_count * sizeof(ImDrawVert);
|
||||
if (g_VboSize < needed_vtx_size)
|
||||
{
|
||||
g_VboSize = needed_vtx_size + 5000 * sizeof(ImDrawVert); // Grow buffer
|
||||
|
@ -62,7 +62,7 @@ static void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, uv)));
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, col)));
|
||||
|
||||
for (size_t cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++)
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->cmd_buffer[cmd_i];
|
||||
if (pcmd->user_callback)
|
||||
|
@ -6,11 +6,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
//---- Define your own ImVector<> type if you don't want to use the provided implementation defined in imgui.h
|
||||
//#include <vector>
|
||||
//#define ImVector std::vector
|
||||
//#define ImVector MyVector
|
||||
|
||||
//---- Define assertion handler. Defaults to calling assert().
|
||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||
|
||||
|
47
imgui.h
47
imgui.h
@ -78,7 +78,7 @@ struct ImVec4
|
||||
};
|
||||
|
||||
// Helpers at bottom of the file:
|
||||
// - class ImVector<> // Lightweight std::vector like class. Use '#define ImVector std::vector' if you want to use the STL type or your own type.
|
||||
// - class ImVector<> // Lightweight std::vector like class.
|
||||
// - IMGUI_ONCE_UPON_A_FRAME // Execute a block of code once per frame only (convenient for creating UI within deep-nested code that runs multiple times)
|
||||
// - struct ImGuiTextFilter // Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
|
||||
// - struct ImGuiTextBuffer // Text buffer for logging/accumulating text
|
||||
@ -241,9 +241,9 @@ namespace ImGui
|
||||
IMGUI_API bool ColorEdit3(const char* label, float col[3]);
|
||||
IMGUI_API bool ColorEdit4(const char* label, float col[4], bool show_alpha = true);
|
||||
IMGUI_API void ColorEditMode(ImGuiColorEditMode mode);
|
||||
IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
|
||||
IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float));
|
||||
IMGUI_API void PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0));
|
||||
IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
|
||||
IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float));
|
||||
IMGUI_API void PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0));
|
||||
|
||||
// Widgets: Drags (tip: ctrl+click on a drag box to input text)
|
||||
@ -742,15 +742,13 @@ struct ImGuiIO
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Lightweight std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
|
||||
// Use '#define ImVector std::vector' if you want to use the STL type or your own type.
|
||||
// Our implementation does NOT call c++ constructors because we don't use them in ImGui. Don't use this class as a straight std::vector replacement in your code!
|
||||
#ifndef ImVector
|
||||
template<typename T>
|
||||
class ImVector
|
||||
{
|
||||
protected:
|
||||
size_t Size;
|
||||
size_t Capacity;
|
||||
int Size;
|
||||
int Capacity;
|
||||
T* Data;
|
||||
|
||||
public:
|
||||
@ -762,13 +760,11 @@ public:
|
||||
~ImVector() { if (Data) ImGui::MemFree(Data); }
|
||||
|
||||
inline bool empty() const { return Size == 0; }
|
||||
inline size_t size() const { return Size; }
|
||||
inline size_t capacity() const { return Capacity; }
|
||||
inline int size() const { return Size; }
|
||||
inline int capacity() const { return Capacity; }
|
||||
|
||||
inline value_type& at(size_t i) { IM_ASSERT(i < Size); return Data[i]; }
|
||||
inline const value_type& at(size_t i) const { IM_ASSERT(i < Size); return Data[i]; }
|
||||
inline value_type& operator[](size_t i) { IM_ASSERT(i < Size); return Data[i]; }
|
||||
inline const value_type& operator[](size_t i) const { IM_ASSERT(i < Size); return Data[i]; }
|
||||
inline value_type& operator[](int i) { IM_ASSERT(i < Size); return Data[i]; }
|
||||
inline const value_type& operator[](int i) const { IM_ASSERT(i < Size); return Data[i]; }
|
||||
|
||||
inline void clear() { if (Data) { Size = Capacity = 0; ImGui::MemFree(Data); Data = NULL; } }
|
||||
inline iterator begin() { return Data; }
|
||||
@ -779,16 +775,16 @@ public:
|
||||
inline const value_type& front() const { IM_ASSERT(Size > 0); return Data[0]; }
|
||||
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 swap(ImVector<T>& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
|
||||
|
||||
inline size_t _grow_capacity(size_t new_size) { size_t new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > new_size ? new_capacity : new_size; }
|
||||
inline int _grow_capacity(int new_size) { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > new_size ? new_capacity : new_size; }
|
||||
|
||||
inline void resize(size_t new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
|
||||
inline void reserve(size_t new_capacity)
|
||||
inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
|
||||
inline void reserve(int 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));
|
||||
T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(value_type));
|
||||
memcpy(new_data, Data, (size_t)Size * sizeof(value_type));
|
||||
ImGui::MemFree(Data);
|
||||
Data = new_data;
|
||||
Capacity = new_capacity;
|
||||
@ -797,10 +793,9 @@ public:
|
||||
inline void push_back(const value_type& v) { if (Size == Capacity) reserve(_grow_capacity(Size+1)); Data[Size++] = v; }
|
||||
inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
|
||||
|
||||
inline iterator erase(const_iterator it) { IM_ASSERT(it >= begin() && it < end()); const ptrdiff_t off = it - begin(); memmove(Data + off, Data + off + 1, (Size - (size_t)off - 1) * sizeof(value_type)); Size--; return Data + off; }
|
||||
inline iterator insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= begin() && it <= end()); const ptrdiff_t off = it - begin(); if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); if (off < (int)Size) memmove(Data + off + 1, Data + off, (Size - (size_t)off) * sizeof(value_type)); Data[off] = v; Size++; return Data + off; }
|
||||
inline iterator erase(const_iterator it) { IM_ASSERT(it >= begin() && it < end()); const ptrdiff_t off = it - begin(); memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(value_type)); Size--; return Data + off; }
|
||||
inline iterator insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= begin() && it <= end()); const ptrdiff_t off = it - begin(); if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(value_type)); Data[off] = v; Size++; return Data + off; }
|
||||
};
|
||||
#endif // #ifndef ImVector
|
||||
|
||||
// Helper: execute a block of code once a frame only
|
||||
// Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame.
|
||||
@ -857,7 +852,7 @@ struct ImGuiTextBuffer
|
||||
ImGuiTextBuffer() { Buf.push_back(0); }
|
||||
const char* begin() const { return &Buf.front(); }
|
||||
const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator
|
||||
size_t size() const { return Buf.size()-1; }
|
||||
int size() const { return Buf.size()-1; }
|
||||
bool empty() { return size() >= 1; }
|
||||
void clear() { Buf.clear(); Buf.push_back(0); }
|
||||
IMGUI_API void append(const char* fmt, ...);
|
||||
@ -921,7 +916,7 @@ struct ImGuiTextEditCallbackData
|
||||
// Completion,History,Always events:
|
||||
ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only
|
||||
char* Buf; // Current text // Read-write (pointed data only)
|
||||
size_t BufSize; // // Read-only
|
||||
int BufSize; // // Read-only
|
||||
bool BufDirty; // Set if you modify Buf directly // Write
|
||||
int CursorPos; // // Read-write
|
||||
int SelectionStart; // // Read-write (== to SelectionEnd when no selection)
|
||||
@ -1081,7 +1076,7 @@ struct ImDrawList
|
||||
IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
|
||||
|
||||
// Internal helpers
|
||||
IMGUI_API void PrimReserve(unsigned int idx_count, unsigned int vtx_count);
|
||||
IMGUI_API void PrimReserve(int idx_count, int vtx_count);
|
||||
IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col);
|
||||
IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col);
|
||||
IMGUI_API void UpdateClipRect();
|
||||
@ -1188,7 +1183,7 @@ struct ImFont
|
||||
IMGUI_API ~ImFont();
|
||||
IMGUI_API void Clear();
|
||||
IMGUI_API void BuildLookupTable();
|
||||
IMGUI_API float GetCharAdvance(unsigned short c) const { return ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] : FallbackXAdvance; }
|
||||
IMGUI_API float GetCharAdvance(unsigned short c) const { return ((int)c < IndexXAdvance.size()) ? IndexXAdvance[(int)c] : FallbackXAdvance; }
|
||||
IMGUI_API const Glyph* FindGlyph(unsigned short c) const;
|
||||
IMGUI_API void SetFallbackChar(ImWchar c);
|
||||
IMGUI_API bool IsLoaded() const { return ContainerAtlas != NULL; }
|
||||
|
Loading…
Reference in New Issue
Block a user