mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
Merge remote-tracking branch 'origin' into 2015-03-antialiased-primitives
This commit is contained in:
commit
bb385fabd4
@ -149,11 +149,11 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplDX11_Init(hwnd, g_pd3dDevice, g_pd3dDeviceContext);
|
ImGui_ImplDX11_Init(hwnd, g_pd3dDevice, g_pd3dDeviceContext);
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImFont* my_font0 = io.Fonts->AddFontDefault();
|
||||||
//ImFont* my_font1 = io.Fonts->AddFontDefault();
|
//ImFont* my_font1 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("extra_fonts/Karla-Regular.ttf", 15.0f);
|
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f);
|
||||||
//ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1;
|
//ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1;
|
||||||
//ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1;
|
//ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1;
|
||||||
//ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese());
|
//ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese());
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_test_window = true;
|
||||||
|
@ -73,11 +73,11 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplDX9_Init(hwnd, g_pd3dDevice);
|
ImGui_ImplDX9_Init(hwnd, g_pd3dDevice);
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImFont* my_font0 = io.Fonts->AddFontDefault();
|
||||||
//ImFont* my_font1 = io.Fonts->AddFontDefault();
|
//ImFont* my_font1 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("extra_fonts/Karla-Regular.ttf", 15.0f);
|
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f);
|
||||||
//ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1;
|
//ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1;
|
||||||
//ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1;
|
//ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1;
|
||||||
//ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese());
|
//ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese());
|
||||||
|
|
||||||
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
||||||
|
@ -27,10 +27,11 @@ int main(int, char**)
|
|||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplGlfwGL3_Init(window, true);
|
ImGui_ImplGlfwGL3_Init(window, true);
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//ImFont* my_font1 = io.Fonts->AddFontDefault();
|
//ImFont* my_font0 = io.Fonts->AddFontDefault();
|
||||||
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("extra_fonts/Karla-Regular.ttf", 15.0f);
|
//ImFont* my_font1 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1;
|
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f);
|
||||||
//ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1;
|
//ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1;
|
||||||
|
//ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1;
|
||||||
//ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese());
|
//ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese());
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_test_window = true;
|
||||||
|
@ -22,10 +22,11 @@ int main(int, char**)
|
|||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplGlfw_Init(window, true);
|
ImGui_ImplGlfw_Init(window, true);
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//ImFont* my_font1 = io.Fonts->AddFontDefault();
|
//ImFont* my_font0 = io.Fonts->AddFontDefault();
|
||||||
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("extra_fonts/Karla-Regular.ttf", 15.0f);
|
//ImFont* my_font1 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1;
|
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f);
|
||||||
//ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1;
|
//ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1;
|
||||||
|
//ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1;
|
||||||
//ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese());
|
//ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese());
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_test_window = true;
|
||||||
|
116
imgui.cpp
116
imgui.cpp
@ -1,4 +1,4 @@
|
|||||||
// ImGui library v1.37
|
// ImGui library v1.38 WIP
|
||||||
// See ImGui::ShowTestWindow() for sample code.
|
// See ImGui::ShowTestWindow() for sample code.
|
||||||
// Read 'Programmer guide' below for notes on how to setup ImGui in your codebase.
|
// Read 'Programmer guide' below for notes on how to setup ImGui in your codebase.
|
||||||
// Get latest version at https://github.com/ocornut/imgui
|
// Get latest version at https://github.com/ocornut/imgui
|
||||||
@ -1094,7 +1094,8 @@ struct ImGuiState
|
|||||||
ImGuiIO IO;
|
ImGuiIO IO;
|
||||||
ImGuiStyle Style;
|
ImGuiStyle Style;
|
||||||
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
||||||
float FontSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Size of characters.
|
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize()
|
||||||
|
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Size of characters.
|
||||||
ImVec2 FontTexUvWhitePixel; // (Shortcut) == Font->TexUvForWhite
|
ImVec2 FontTexUvWhitePixel; // (Shortcut) == Font->TexUvForWhite
|
||||||
|
|
||||||
float Time;
|
float Time;
|
||||||
@ -1163,7 +1164,7 @@ struct ImGuiState
|
|||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
Font = NULL;
|
Font = NULL;
|
||||||
FontSize = 0.0f;
|
FontBaseSize = FontSize = 0.0f;
|
||||||
FontTexUvWhitePixel = ImVec2(0.0f, 0.0f);
|
FontTexUvWhitePixel = ImVec2(0.0f, 0.0f);
|
||||||
|
|
||||||
Time = 0.0f;
|
Time = 0.0f;
|
||||||
@ -1267,10 +1268,8 @@ public:
|
|||||||
void FocusItemUnregister();
|
void FocusItemUnregister();
|
||||||
|
|
||||||
ImRect Rect() const { return ImRect(Pos, Pos+Size); }
|
ImRect Rect() const { return ImRect(Pos, Pos+Size); }
|
||||||
ImFont* Font() const { return GImGui->Font; }
|
float CalcFontSize() const { return GImGui->FontBaseSize * FontWindowScale; }
|
||||||
float FontSize() const { return GImGui->FontSize * FontWindowScale; }
|
float TitleBarHeight() const { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0 : CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f; }
|
||||||
ImVec2 CursorPos() const { return DC.CursorPos; }
|
|
||||||
float TitleBarHeight() const { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0 : FontSize() + GImGui->Style.FramePadding.y * 2.0f; }
|
|
||||||
ImRect TitleBarRect() const { return ImRect(Pos, Pos + ImVec2(SizeFull.x, TitleBarHeight())); }
|
ImRect TitleBarRect() const { return ImRect(Pos, Pos + ImVec2(SizeFull.x, TitleBarHeight())); }
|
||||||
ImVec2 WindowPadding() const { return ((Flags & ImGuiWindowFlags_ChildWindow) && !(Flags & ImGuiWindowFlags_ShowBorders)) ? ImVec2(0,0) : GImGui->Style.WindowPadding; }
|
ImVec2 WindowPadding() const { return ((Flags & ImGuiWindowFlags_ChildWindow) && !(Flags & ImGuiWindowFlags_ShowBorders)) ? ImVec2(0,0) : GImGui->Style.WindowPadding; }
|
||||||
ImU32 Color(ImGuiCol idx, float a=1.f) const { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * a; return ImGui::ColorConvertFloat4ToU32(c); }
|
ImU32 Color(ImGuiCol idx, float a=1.f) const { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * a; return ImGui::ColorConvertFloat4ToU32(c); }
|
||||||
@ -1285,6 +1284,14 @@ static inline ImGuiWindow* GetCurrentWindow()
|
|||||||
return g.CurrentWindow;
|
return g.CurrentWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void SetCurrentWindow(ImGuiWindow* window)
|
||||||
|
{
|
||||||
|
ImGuiState& g = *GImGui;
|
||||||
|
g.CurrentWindow = window;
|
||||||
|
if (window)
|
||||||
|
g.FontSize = window->CalcFontSize();
|
||||||
|
}
|
||||||
|
|
||||||
static inline ImGuiWindow* GetParentWindow()
|
static inline ImGuiWindow* GetParentWindow()
|
||||||
{
|
{
|
||||||
ImGuiState& g = *GImGui;
|
ImGuiState& g = *GImGui;
|
||||||
@ -1967,6 +1974,7 @@ void ImGui::NewFrame()
|
|||||||
float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
|
float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
|
||||||
float scale = new_font_scale / window->FontWindowScale;
|
float scale = new_font_scale / window->FontWindowScale;
|
||||||
window->FontWindowScale = new_font_scale;
|
window->FontWindowScale = new_font_scale;
|
||||||
|
g.FontSize = window->CalcFontSize();
|
||||||
|
|
||||||
const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size;
|
const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size;
|
||||||
window->Pos += offset;
|
window->Pos += offset;
|
||||||
@ -1981,7 +1989,7 @@ void ImGui::NewFrame()
|
|||||||
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse))
|
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse))
|
||||||
{
|
{
|
||||||
const int scroll_lines = (window->Flags & ImGuiWindowFlags_ComboBox) ? 3 : 5;
|
const int scroll_lines = (window->Flags & ImGuiWindowFlags_ComboBox) ? 3 : 5;
|
||||||
window->NextScrollY -= g.IO.MouseWheel * window->FontSize() * scroll_lines;
|
window->NextScrollY -= g.IO.MouseWheel * g.FontSize * scroll_lines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2357,7 +2365,7 @@ static void RenderText(ImVec2 pos, const char* text, const char* text_end, bool
|
|||||||
if (text_len > 0)
|
if (text_len > 0)
|
||||||
{
|
{
|
||||||
// Render
|
// Render
|
||||||
window->DrawList->AddText(window->Font(), window->FontSize(), pos, window->Color(ImGuiCol_Text), text, text_display_end);
|
window->DrawList->AddText(g.Font, g.FontSize, pos, window->Color(ImGuiCol_Text), text, text_display_end);
|
||||||
|
|
||||||
// Log as text
|
// Log as text
|
||||||
if (g.LogEnabled)
|
if (g.LogEnabled)
|
||||||
@ -2377,7 +2385,7 @@ static void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end
|
|||||||
if (text_len > 0)
|
if (text_len > 0)
|
||||||
{
|
{
|
||||||
// Render
|
// Render
|
||||||
window->DrawList->AddText(window->Font(), window->FontSize(), pos, window->Color(ImGuiCol_Text), text, text_end, wrap_width);
|
window->DrawList->AddText(g.Font, g.FontSize, pos, window->Color(ImGuiCol_Text), text, text_end, wrap_width);
|
||||||
|
|
||||||
// Log as text
|
// Log as text
|
||||||
if (g.LogEnabled)
|
if (g.LogEnabled)
|
||||||
@ -2401,7 +2409,7 @@ static void RenderTextClipped(ImVec2 pos, const char* text, const char* text_end
|
|||||||
const bool need_clipping = (pos.x + text_size.x >= clip_max.x) || (pos.y + text_size.y >= clip_max.y);
|
const bool need_clipping = (pos.x + text_size.x >= clip_max.x) || (pos.y + text_size.y >= clip_max.y);
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
window->DrawList->AddText(window->Font(), window->FontSize(), pos, window->Color(ImGuiCol_Text), text, text_display_end, 0.0f, need_clipping ? &clip_max : NULL);
|
window->DrawList->AddText(g.Font, g.FontSize, pos, window->Color(ImGuiCol_Text), text, text_display_end, 0.0f, need_clipping ? &clip_max : NULL);
|
||||||
|
|
||||||
// Log as text
|
// Log as text
|
||||||
if (g.LogEnabled)
|
if (g.LogEnabled)
|
||||||
@ -2425,9 +2433,10 @@ static void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border,
|
|||||||
// Render a triangle to denote expanded/collapsed state
|
// Render a triangle to denote expanded/collapsed state
|
||||||
static void RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale, bool shadow)
|
static void RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale, bool shadow)
|
||||||
{
|
{
|
||||||
|
ImGuiState& g = *GImGui;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
|
|
||||||
const float h = window->FontSize() * 1.00f;
|
const float h = g.FontSize * 1.00f;
|
||||||
const float r = h * 0.40f * scale;
|
const float r = h * 0.40f * scale;
|
||||||
ImVec2 center = p_min + ImVec2(h*0.50f, h*0.50f*scale);
|
ImVec2 center = p_min + ImVec2(h*0.50f, h*0.50f*scale);
|
||||||
|
|
||||||
@ -2455,7 +2464,7 @@ static void RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale, bool
|
|||||||
// CalcTextSize("") should return ImVec2(0.0f, GImGui->FontSize)
|
// CalcTextSize("") should return ImVec2(0.0f, GImGui->FontSize)
|
||||||
ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width)
|
ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiState& g = *GImGui;
|
||||||
|
|
||||||
const char* text_display_end;
|
const char* text_display_end;
|
||||||
if (hide_text_after_double_hash)
|
if (hide_text_after_double_hash)
|
||||||
@ -2463,8 +2472,8 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
|
|||||||
else
|
else
|
||||||
text_display_end = text_end;
|
text_display_end = text_end;
|
||||||
|
|
||||||
ImFont* font = window->Font();
|
ImFont* font = g.Font;
|
||||||
const float font_size = window->FontSize();
|
const float font_size = g.FontSize;
|
||||||
ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL);
|
ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL);
|
||||||
|
|
||||||
// Cancel out character spacing for the last character of a line (it is baked into glyph->XAdvance field)
|
// Cancel out character spacing for the last character of a line (it is baked into glyph->XAdvance field)
|
||||||
@ -2920,7 +2929,12 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
|||||||
window->Size = window->SizeFull = size;
|
window->Size = window->SizeFull = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImLengthSqr(window->Size) < 0.00001f)
|
if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0)
|
||||||
|
{
|
||||||
|
window->AutoFitFrames = 2;
|
||||||
|
window->AutoFitOnlyGrows = false;
|
||||||
|
}
|
||||||
|
else if (ImLengthSqr(window->Size) < 0.00001f)
|
||||||
{
|
{
|
||||||
window->AutoFitFrames = 2;
|
window->AutoFitFrames = 2;
|
||||||
window->AutoFitOnlyGrows = true;
|
window->AutoFitOnlyGrows = true;
|
||||||
@ -2963,7 +2977,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
|||||||
|
|
||||||
// Add to stack
|
// Add to stack
|
||||||
g.CurrentWindowStack.push_back(window);
|
g.CurrentWindowStack.push_back(window);
|
||||||
g.CurrentWindow = window;
|
SetCurrentWindow(window);
|
||||||
|
|
||||||
// Process SetNextWindow***() calls
|
// Process SetNextWindow***() calls
|
||||||
bool window_pos_set_by_api = false;
|
bool window_pos_set_by_api = false;
|
||||||
@ -3326,7 +3340,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
|||||||
if (!(window->Flags & ImGuiWindowFlags_NoCollapse))
|
if (!(window->Flags & ImGuiWindowFlags_NoCollapse))
|
||||||
{
|
{
|
||||||
RenderCollapseTriangle(window->Pos + style.FramePadding, !window->Collapsed, 1.0f, true);
|
RenderCollapseTriangle(window->Pos + style.FramePadding, !window->Collapsed, 1.0f, true);
|
||||||
text_min.x += window->FontSize() + style.ItemInnerSpacing.x;
|
text_min.x += g.FontSize + style.ItemInnerSpacing.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImVec2 text_size = CalcTextSize(name, NULL, true);
|
const ImVec2 text_size = CalcTextSize(name, NULL, true);
|
||||||
@ -3413,7 +3427,7 @@ void ImGui::End()
|
|||||||
// Pop
|
// Pop
|
||||||
// NB: we don't clear 'window->RootWindow'. The pointer is allowed to live until the next call to Begin().
|
// NB: we don't clear 'window->RootWindow'. The pointer is allowed to live until the next call to Begin().
|
||||||
g.CurrentWindowStack.pop_back();
|
g.CurrentWindowStack.pop_back();
|
||||||
g.CurrentWindow = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
|
SetCurrentWindow(g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vertical scrollbar
|
// Vertical scrollbar
|
||||||
@ -3544,7 +3558,8 @@ static void SetFont(ImFont* font)
|
|||||||
IM_ASSERT(font && font->IsLoaded());
|
IM_ASSERT(font && font->IsLoaded());
|
||||||
IM_ASSERT(font->Scale > 0.0f);
|
IM_ASSERT(font->Scale > 0.0f);
|
||||||
g.Font = font;
|
g.Font = font;
|
||||||
g.FontSize = g.IO.FontGlobalScale * g.Font->FontSize * g.Font->Scale;
|
g.FontBaseSize = g.IO.FontGlobalScale * g.Font->FontSize * g.Font->Scale;
|
||||||
|
g.FontSize = g.CurrentWindow ? g.CurrentWindow->CalcFontSize() : 0.0f;
|
||||||
g.FontTexUvWhitePixel = g.Font->ContainerAtlas->TexUvWhitePixel;
|
g.FontTexUvWhitePixel = g.Font->ContainerAtlas->TexUvWhitePixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3943,15 +3958,14 @@ ImVec2 ImGui::GetWindowContentRegionMax()
|
|||||||
|
|
||||||
float ImGui::GetTextLineHeight()
|
float ImGui::GetTextLineHeight()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiState& g = *GImGui;
|
||||||
return window->FontSize();
|
return g.FontSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ImGui::GetTextLineHeightWithSpacing()
|
float ImGui::GetTextLineHeightWithSpacing()
|
||||||
{
|
{
|
||||||
ImGuiState& g = *GImGui;
|
ImGuiState& g = *GImGui;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
return g.FontSize + g.Style.ItemSpacing.y;
|
||||||
return window->FontSize() + g.Style.ItemSpacing.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImDrawList* ImGui::GetWindowDrawList()
|
ImDrawList* ImGui::GetWindowDrawList()
|
||||||
@ -3962,20 +3976,22 @@ ImDrawList* ImGui::GetWindowDrawList()
|
|||||||
|
|
||||||
ImFont* ImGui::GetWindowFont()
|
ImFont* ImGui::GetWindowFont()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiState& g = *GImGui;
|
||||||
return window->Font();
|
return g.Font;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ImGui::GetWindowFontSize()
|
float ImGui::GetWindowFontSize()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiState& g = *GImGui;
|
||||||
return window->FontSize();
|
return g.FontSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::SetWindowFontScale(float scale)
|
void ImGui::SetWindowFontScale(float scale)
|
||||||
{
|
{
|
||||||
|
ImGuiState& g = *GImGui;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
window->FontWindowScale = scale;
|
window->FontWindowScale = scale;
|
||||||
|
g.FontSize = window->CalcFontSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
// NB: internally we store CursorPos in absolute screen coordinates because it is more convenient.
|
// NB: internally we store CursorPos in absolute screen coordinates because it is more convenient.
|
||||||
@ -4230,7 +4246,7 @@ void ImGui::AlignFirstTextHeightToWidgets()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Declare a dummy item size to that upcoming items that are smaller will center-align on the newly expanded line height.
|
// Declare a dummy item size to that upcoming items that are smaller will center-align on the newly expanded line height.
|
||||||
ItemSize(ImVec2(0, window->FontSize() + g.Style.FramePadding.y*2), g.Style.FramePadding.y);
|
ItemSize(ImVec2(0, g.FontSize + g.Style.FramePadding.y*2), g.Style.FramePadding.y);
|
||||||
ImGui::SameLine(0, 0);
|
ImGui::SameLine(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4692,7 +4708,7 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: we don't provide our width so that it doesn't get feed back into AutoFit. Should manage that better so we can still hover without extending ContentsSize
|
// FIXME: we don't provide our width so that it doesn't get feed back into AutoFit. Should manage that better so we can still hover without extending ContentsSize
|
||||||
const ImRect text_bb(bb.Min, bb.Min + ImVec2(window->FontSize() + style.FramePadding.x*2*2,0) + label_size);
|
const ImRect text_bb(bb.Min, bb.Min + ImVec2(g.FontSize + style.FramePadding.x*2*2,0) + label_size);
|
||||||
ItemSize(ImVec2(text_bb.GetSize().x, bb.GetSize().y), display_frame ? style.FramePadding.y : 0.0f);
|
ItemSize(ImVec2(text_bb.GetSize().x, bb.GetSize().y), display_frame ? style.FramePadding.y : 0.0f);
|
||||||
|
|
||||||
// When logging is enabled, if automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior).
|
// When logging is enabled, if automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior).
|
||||||
@ -4724,7 +4740,7 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display
|
|||||||
const char log_prefix[] = "\n##";
|
const char log_prefix[] = "\n##";
|
||||||
LogText(bb.Min + style.FramePadding, log_prefix, log_prefix+3);
|
LogText(bb.Min + style.FramePadding, log_prefix, log_prefix+3);
|
||||||
}
|
}
|
||||||
RenderText(bb.Min + style.FramePadding + ImVec2(window->FontSize() + style.FramePadding.x*2,0), label);
|
RenderText(bb.Min + style.FramePadding + ImVec2(g.FontSize + style.FramePadding.x*2,0), label);
|
||||||
if (g.LogEnabled)
|
if (g.LogEnabled)
|
||||||
{
|
{
|
||||||
const char log_suffix[] = "##";
|
const char log_suffix[] = "##";
|
||||||
@ -4736,10 +4752,10 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display
|
|||||||
// Unframed typed for tree nodes
|
// Unframed typed for tree nodes
|
||||||
if ((held && hovered) || hovered)
|
if ((held && hovered) || hovered)
|
||||||
RenderFrame(bb.Min, bb.Max, col, false);
|
RenderFrame(bb.Min, bb.Max, col, false);
|
||||||
RenderCollapseTriangle(bb.Min + ImVec2(style.FramePadding.x, window->FontSize()*0.15f), opened, 0.70f, false);
|
RenderCollapseTriangle(bb.Min + ImVec2(style.FramePadding.x, g.FontSize*0.15f), opened, 0.70f, false);
|
||||||
if (g.LogEnabled)
|
if (g.LogEnabled)
|
||||||
LogText(bb.Min, ">");
|
LogText(bb.Min, ">");
|
||||||
RenderText(bb.Min + ImVec2(window->FontSize() + style.FramePadding.x*2,0), label);
|
RenderText(bb.Min + ImVec2(g.FontSize + style.FramePadding.x*2,0), label);
|
||||||
}
|
}
|
||||||
|
|
||||||
return opened;
|
return opened;
|
||||||
@ -4753,7 +4769,7 @@ void ImGui::Bullet()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
const float line_height = window->FontSize();
|
const float line_height = g.FontSize;
|
||||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(line_height, line_height));
|
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(line_height, line_height));
|
||||||
ItemSize(bb);
|
ItemSize(bb);
|
||||||
if (!ItemAdd(bb, NULL))
|
if (!ItemAdd(bb, NULL))
|
||||||
@ -4779,7 +4795,7 @@ void ImGui::BulletTextV(const char* fmt, va_list args)
|
|||||||
const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
|
const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
|
||||||
|
|
||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
const float line_height = window->FontSize();
|
const float line_height = g.FontSize;
|
||||||
const ImVec2 label_size = CalcTextSize(text_begin, text_end, true);
|
const ImVec2 label_size = CalcTextSize(text_begin, text_end, true);
|
||||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(line_height + (label_size.x > 0.0f ? (style.FramePadding.x*2) : 0.0f),0) + label_size); // Empty text doesn't add padding
|
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(line_height + (label_size.x > 0.0f ? (style.FramePadding.x*2) : 0.0f),0) + label_size); // Empty text doesn't add padding
|
||||||
ItemSize(bb);
|
ItemSize(bb);
|
||||||
@ -4789,7 +4805,7 @@ void ImGui::BulletTextV(const char* fmt, va_list args)
|
|||||||
// Render
|
// Render
|
||||||
const float bullet_size = line_height*0.15f;
|
const float bullet_size = line_height*0.15f;
|
||||||
window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + line_height*0.5f, line_height*0.5f), bullet_size, window->Color(ImGuiCol_Text));
|
window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + line_height*0.5f, line_height*0.5f), bullet_size, window->Color(ImGuiCol_Text));
|
||||||
RenderText(bb.Min+ImVec2(window->FontSize() + style.FramePadding.x*2,0), text_begin, text_end);
|
RenderText(bb.Min+ImVec2(g.FontSize + style.FramePadding.x*2,0), text_begin, text_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::BulletText(const char* fmt, ...)
|
void ImGui::BulletText(const char* fmt, ...)
|
||||||
@ -5851,7 +5867,7 @@ bool ImGui::InputFloat(const char* label, float *v, float step, float step_fast,
|
|||||||
|
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
ImGui::PushID(label);
|
ImGui::PushID(label);
|
||||||
const ImVec2 button_sz = ImVec2(window->FontSize(), window->FontSize()) + style.FramePadding * 2;
|
const ImVec2 button_sz = ImVec2(g.FontSize, g.FontSize) + style.FramePadding * 2;
|
||||||
if (step > 0.0f)
|
if (step > 0.0f)
|
||||||
ImGui::PushItemWidth(ImMax(1.0f, w - (button_sz.x + style.ItemInnerSpacing.x)*2));
|
ImGui::PushItemWidth(ImMax(1.0f, w - (button_sz.x + style.ItemInnerSpacing.x)*2));
|
||||||
|
|
||||||
@ -6096,15 +6112,15 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
|
|||||||
// Update some data if we are active or last active
|
// Update some data if we are active or last active
|
||||||
edit_state.Width = w + style.FramePadding.x;
|
edit_state.Width = w + style.FramePadding.x;
|
||||||
edit_state.BufSizeA = buf_size;
|
edit_state.BufSizeA = buf_size;
|
||||||
edit_state.Font = window->Font();
|
edit_state.Font = g.Font;
|
||||||
edit_state.FontSize = window->FontSize();
|
edit_state.FontSize = g.FontSize;
|
||||||
edit_state.UpdateScrollOffset();
|
edit_state.UpdateScrollOffset();
|
||||||
}
|
}
|
||||||
if (g.ActiveId == id)
|
if (g.ActiveId == id)
|
||||||
{
|
{
|
||||||
// Edit in progress
|
// Edit in progress
|
||||||
const float mx = g.IO.MousePos.x - frame_bb.Min.x - style.FramePadding.x;
|
const float mx = g.IO.MousePos.x - frame_bb.Min.x - style.FramePadding.x;
|
||||||
const float my = window->FontSize()*0.5f; // Flatten mouse because we are doing a single-line edit
|
const float my = g.FontSize*0.5f; // Flatten mouse because we are doing a single-line edit
|
||||||
|
|
||||||
if (select_all || (hovered && io.MouseDoubleClicked[0]))
|
if (select_all || (hovered && io.MouseDoubleClicked[0]))
|
||||||
{
|
{
|
||||||
@ -6289,8 +6305,8 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
|
|||||||
|
|
||||||
RenderFrame(frame_bb.Min, frame_bb.Max, window->Color(ImGuiCol_FrameBg), true, style.FrameRounding);
|
RenderFrame(frame_bb.Min, frame_bb.Max, window->Color(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||||
|
|
||||||
const ImVec2 font_off_up = ImVec2(0.0f,window->FontSize()+1.0f); // FIXME: those offsets are part of the style or font API
|
const ImVec2 font_off_up = ImVec2(0.0f, g.FontSize+1.0f); // FIXME: those offsets are part of the style or font API
|
||||||
const ImVec2 font_off_dn = ImVec2(0.0f,2.0f);
|
const ImVec2 font_off_dn = ImVec2(0.0f, 2.0f);
|
||||||
|
|
||||||
if (g.ActiveId == id)
|
if (g.ActiveId == id)
|
||||||
{
|
{
|
||||||
@ -6307,7 +6323,7 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
|
|||||||
|
|
||||||
//const float render_scroll_x = (g.ActiveId == id) ? edit_state.ScrollX : 0.0f;
|
//const float render_scroll_x = (g.ActiveId == id) ? edit_state.ScrollX : 0.0f;
|
||||||
const float render_scroll_x = (edit_state.Id == id) ? edit_state.ScrollX : 0.0f;
|
const float render_scroll_x = (edit_state.Id == id) ? edit_state.ScrollX : 0.0f;
|
||||||
ImGuiTextEditState::RenderTextScrolledClipped(window->Font(), window->FontSize(), buf, frame_bb.Min + style.FramePadding, w + style.FramePadding.x, render_scroll_x);
|
ImGuiTextEditState::RenderTextScrolledClipped(g.Font, g.FontSize, buf, frame_bb.Min + style.FramePadding, w + style.FramePadding.x, render_scroll_x);
|
||||||
|
|
||||||
if (g.ActiveId == id)
|
if (g.ActiveId == id)
|
||||||
{
|
{
|
||||||
@ -6319,7 +6335,7 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
|
|||||||
|
|
||||||
// Notify OS of text input position for advanced IME
|
// Notify OS of text input position for advanced IME
|
||||||
if (io.ImeSetInputScreenPosFn && ImLengthSqr(edit_state.InputCursorScreenPos - cursor_pos) > 0.0001f)
|
if (io.ImeSetInputScreenPosFn && ImLengthSqr(edit_state.InputCursorScreenPos - cursor_pos) > 0.0001f)
|
||||||
io.ImeSetInputScreenPosFn((int)cursor_pos.x - 1, (int)(cursor_pos.y - window->FontSize())); // -1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.
|
io.ImeSetInputScreenPosFn((int)cursor_pos.x - 1, (int)(cursor_pos.y - g.FontSize)); // -1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.
|
||||||
|
|
||||||
edit_state.InputCursorScreenPos = cursor_pos;
|
edit_state.InputCursorScreenPos = cursor_pos;
|
||||||
}
|
}
|
||||||
@ -6506,7 +6522,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
|||||||
if (!ItemAdd(total_bb, &id))
|
if (!ItemAdd(total_bb, &id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const float arrow_size = (window->FontSize() + style.FramePadding.x * 2.0f);
|
const float arrow_size = (g.FontSize + style.FramePadding.x * 2.0f);
|
||||||
const bool hovered = IsHovered(frame_bb, id);
|
const bool hovered = IsHovered(frame_bb, id);
|
||||||
|
|
||||||
bool value_changed = false;
|
bool value_changed = false;
|
||||||
@ -6752,7 +6768,7 @@ bool ImGui::ColorButton(const ImVec4& col, bool small_height, bool outline_borde
|
|||||||
|
|
||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
const ImGuiID id = window->GetID("#colorbutton");
|
const ImGuiID id = window->GetID("#colorbutton");
|
||||||
const float square_size = window->FontSize();
|
const float square_size = g.FontSize;
|
||||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(square_size + style.FramePadding.x*2, square_size + (small_height ? 0 : style.FramePadding.y*2)));
|
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(square_size + style.FramePadding.x*2, square_size + (small_height ? 0 : style.FramePadding.y*2)));
|
||||||
ItemSize(bb, small_height ? 0.0f : style.FramePadding.y);
|
ItemSize(bb, small_height ? 0.0f : style.FramePadding.y);
|
||||||
if (!ItemAdd(bb, &id))
|
if (!ItemAdd(bb, &id))
|
||||||
@ -6800,7 +6816,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
|
|||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
const ImGuiID id = window->GetID(label);
|
const ImGuiID id = window->GetID(label);
|
||||||
const float w_full = ImGui::CalcItemWidth();
|
const float w_full = ImGui::CalcItemWidth();
|
||||||
const float square_sz = (window->FontSize() + style.FramePadding.x * 2.0f);
|
const float square_sz = (g.FontSize + style.FramePadding.x * 2.0f);
|
||||||
|
|
||||||
ImGuiColorEditMode edit_mode = window->DC.ColorEditMode;
|
ImGuiColorEditMode edit_mode = window->DC.ColorEditMode;
|
||||||
if (edit_mode == ImGuiColorEditMode_UserSelect || edit_mode == ImGuiColorEditMode_UserSelectShowButton)
|
if (edit_mode == ImGuiColorEditMode_UserSelect || edit_mode == ImGuiColorEditMode_UserSelectShowButton)
|
||||||
@ -9587,7 +9603,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::BeginPopup(&popup_open);
|
ImGui::BeginPopup(&popup_open);
|
||||||
ImGui::Text("Aquarium");
|
ImGui::Text("Aquarium");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
for (size_t i = 0; i < IM_ARRAYSIZE(fishes); i++)
|
for (int i = 0; i < IM_ARRAYSIZE(fishes); i++)
|
||||||
{
|
{
|
||||||
if (ImGui::Selectable(fishes[i], false))
|
if (ImGui::Selectable(fishes[i], false))
|
||||||
{
|
{
|
||||||
@ -10342,9 +10358,9 @@ static void ShowExampleAppManipulatingWindowTitle(bool* opened)
|
|||||||
ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.");
|
ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
// Using "###" to display a changing title but keep a static identifier "MyWindow"
|
// Using "###" to display a changing title but keep a static identifier "AnimatedTitle"
|
||||||
char buf[128];
|
char buf[128];
|
||||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "Animated title %c %d###MyWindow", "|/-\\"[(int)(ImGui::GetTime()/0.25f)&3], rand());
|
ImFormatString(buf, IM_ARRAYSIZE(buf), "Animated title %c %d##AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime()/0.25f)&3], rand());
|
||||||
ImGui::SetNextWindowPos(ImVec2(100,300), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(100,300), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::Begin(buf);
|
ImGui::Begin(buf);
|
||||||
ImGui::Text("This window has a changing title.");
|
ImGui::Text("This window has a changing title.");
|
||||||
|
4
imgui.h
4
imgui.h
@ -1,4 +1,4 @@
|
|||||||
// ImGui library v1.37
|
// ImGui library v1.38 WIP
|
||||||
// See .cpp file for documentation.
|
// See .cpp file for documentation.
|
||||||
// See ImGui::ShowTestWindow() for sample code.
|
// See ImGui::ShowTestWindow() for sample code.
|
||||||
// Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
|
// Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
|
||||||
@ -13,7 +13,7 @@
|
|||||||
#include <stdlib.h> // NULL, malloc, free, qsort, atoi
|
#include <stdlib.h> // NULL, malloc, free, qsort, atoi
|
||||||
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
||||||
|
|
||||||
#define IMGUI_VERSION "1.37"
|
#define IMGUI_VERSION "1.38 WIP"
|
||||||
|
|
||||||
// Define assertion handler.
|
// Define assertion handler.
|
||||||
#ifndef IM_ASSERT
|
#ifndef IM_ASSERT
|
||||||
|
Loading…
Reference in New Issue
Block a user