mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Merge branch 'master' into 2016-02-colorpicker
This commit is contained in:
57
imgui.cpp
57
imgui.cpp
@ -25,6 +25,7 @@
|
||||
- How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on the purpose of labels/IDs.
|
||||
- How can I tell when ImGui wants my mouse/keyboard inputs and when I can pass them to my application?
|
||||
- How can I load a different font than the default?
|
||||
- How can I easily use icons in my application?
|
||||
- How can I load multiple fonts?
|
||||
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
||||
- How can I use the drawing facilities without an ImGui window? (using ImDrawList API)
|
||||
@ -152,6 +153,7 @@
|
||||
|
||||
- 2016/08/xx (1.XX) - removed ColorEditMode() and ImGuiColorEditMode in favor of ImGuiColorEditFlags and parameters to ColorEdit*() functions
|
||||
replaced ColorEdit4() third parameter 'bool show_alpha=true' to 'ImGuiColorEditFlags flags=0x01' where ImGuiColorEditFlags_Alpha=0x01 for dodgy compatibility
|
||||
- 2016/11/06 (1.50) - BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetId() and use it instead of passing string to BeginChild().
|
||||
- 2016/10/15 (1.50) - avoid 'void* user_data' parameter to io.SetClipboardTextFn/io.GetClipboardTextFn pointers. We pass io.ClipboardUserData to it.
|
||||
- 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc.
|
||||
- 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal.
|
||||
@ -407,6 +409,10 @@
|
||||
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
|
||||
io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
|
||||
|
||||
Q: How can I easily use icons in my application?
|
||||
A: The most convenient and practical way is to merge an icon font such as FontAwesome inside you main font. Then you can refer to icons within your strings.
|
||||
Read 'How can I load multiple fonts?' and the file 'extra_fonts/README.txt' for instructions.
|
||||
|
||||
Q: How can I load multiple fonts?
|
||||
A: Use the font atlas to pack them into a single texture:
|
||||
(Read extra_fonts/README.txt and the code in ImFontAtlas for more details.)
|
||||
@ -426,13 +432,13 @@
|
||||
config.GlyphExtraSpacing.x = 1.0f;
|
||||
io.Fonts->LoadFromFileTTF("myfontfile.ttf", size_pixels, &config);
|
||||
|
||||
// Combine multiple fonts into one
|
||||
// Combine multiple fonts into one (e.g. for icon fonts)
|
||||
ImWchar ranges[] = { 0xf000, 0xf3ff, 0 };
|
||||
ImFontConfig config;
|
||||
config.MergeMode = true;
|
||||
io.Fonts->AddFontDefault();
|
||||
io.Fonts->LoadFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges);
|
||||
io.Fonts->LoadFromFileTTF("myfontfile.ttf", size_pixels, NULL, &config, io.Fonts->GetGlyphRangesJapanese());
|
||||
io.Fonts->LoadFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges); // Merge icon font
|
||||
io.Fonts->LoadFromFileTTF("myfontfile.ttf", size_pixels, NULL, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge japanese glyphs
|
||||
|
||||
Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
||||
A: When loading a font, pass custom Unicode ranges to specify the glyphs to load.
|
||||
@ -659,6 +665,7 @@ static float GetDraggedColumnOffset(int column_index);
|
||||
|
||||
static bool IsKeyPressedMap(ImGuiKey key, bool repeat = true);
|
||||
|
||||
static ImFont* GetDefaultFont();
|
||||
static void SetCurrentFont(ImFont* font);
|
||||
static void SetCurrentWindow(ImGuiWindow* window);
|
||||
static void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y);
|
||||
@ -810,6 +817,7 @@ ImGuiIO::ImGuiIO()
|
||||
LogFilename = "imgui_log.txt";
|
||||
Fonts = &GImDefaultFontAtlas;
|
||||
FontGlobalScale = 1.0f;
|
||||
FontDefault = NULL;
|
||||
DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
||||
MousePos = ImVec2(-1,-1);
|
||||
MousePosPrev = ImVec2(-1,-1);
|
||||
@ -2107,7 +2115,8 @@ void ImGui::NewFrame()
|
||||
g.Initialized = true;
|
||||
}
|
||||
|
||||
SetCurrentFont(g.IO.Fonts->Fonts[0]);
|
||||
SetCurrentFont(GetDefaultFont());
|
||||
IM_ASSERT(g.Font->IsLoaded());
|
||||
|
||||
g.Time += g.IO.DeltaTime;
|
||||
g.FrameCount += 1;
|
||||
@ -3583,12 +3592,12 @@ bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button)
|
||||
return BeginPopup(str_id);
|
||||
}
|
||||
|
||||
bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
|
||||
static bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow;
|
||||
|
||||
const ImVec2 content_avail = GetContentRegionAvail();
|
||||
const ImVec2 content_avail = ImGui::GetContentRegionAvail();
|
||||
ImVec2 size = ImFloor(size_arg);
|
||||
if (size.x <= 0.0f)
|
||||
{
|
||||
@ -3607,22 +3616,28 @@ bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border,
|
||||
flags |= extra_flags;
|
||||
|
||||
char title[256];
|
||||
ImFormatString(title, IM_ARRAYSIZE(title), "%s.%s", window->Name, str_id);
|
||||
if (name)
|
||||
ImFormatString(title, IM_ARRAYSIZE(title), "%s.%s.%08X", window->Name, name, id);
|
||||
else
|
||||
ImFormatString(title, IM_ARRAYSIZE(title), "%s.%08X", window->Name, id);
|
||||
|
||||
bool ret = ImGui::Begin(title, NULL, size, -1.0f, flags);
|
||||
|
||||
if (!(window->Flags & ImGuiWindowFlags_ShowBorders))
|
||||
GetCurrentWindow()->Flags &= ~ImGuiWindowFlags_ShowBorders;
|
||||
ImGui::GetCurrentWindow()->Flags &= ~ImGuiWindowFlags_ShowBorders;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ImGui::BeginChild(ImGuiID id, const ImVec2& size, bool border, ImGuiWindowFlags extra_flags)
|
||||
bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
|
||||
{
|
||||
char str_id[32];
|
||||
ImFormatString(str_id, IM_ARRAYSIZE(str_id), "child_%08x", id);
|
||||
bool ret = ImGui::BeginChild(str_id, size, border, extra_flags);
|
||||
return ret;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags);
|
||||
}
|
||||
|
||||
bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
|
||||
{
|
||||
return BeginChildEx(NULL, id, size_arg, border, extra_flags);
|
||||
}
|
||||
|
||||
void ImGui::EndChild()
|
||||
@ -4318,8 +4333,8 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
||||
ImVec2 text_max = window->Pos + ImVec2(window->Size.x, style.FramePadding.y*2 + text_size.y);
|
||||
ImRect clip_rect;
|
||||
clip_rect.Max = ImVec2(window->Pos.x + window->Size.x - (p_open ? title_bar_rect.GetHeight() - 3 : style.FramePadding.x), text_max.y); // Match the size of CloseWindowButton()
|
||||
float pad_left = (flags & ImGuiWindowFlags_NoCollapse) == 0 ? (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x) : 0.0f;
|
||||
float pad_right = (p_open != NULL) ? (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x) : 0.0f;
|
||||
float pad_left = (flags & ImGuiWindowFlags_NoCollapse) == 0 ? (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x) : style.FramePadding.x;
|
||||
float pad_right = (p_open != NULL) ? (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x) : style.FramePadding.x;
|
||||
if (style.WindowTitleAlign.x > 0.0f) pad_right = ImLerp(pad_right, pad_left, style.WindowTitleAlign.x);
|
||||
text_min.x += pad_left;
|
||||
text_max.x -= pad_right;
|
||||
@ -4580,6 +4595,12 @@ float ImGui::CalcItemWidth()
|
||||
return w;
|
||||
}
|
||||
|
||||
static ImFont* GetDefaultFont()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0];
|
||||
}
|
||||
|
||||
static void SetCurrentFont(ImFont* font)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -4595,7 +4616,7 @@ void ImGui::PushFont(ImFont* font)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!font)
|
||||
font = g.IO.Fonts->Fonts[0];
|
||||
font = GetDefaultFont();
|
||||
SetCurrentFont(font);
|
||||
g.FontStack.push_back(font);
|
||||
g.CurrentWindow->DrawList->PushTextureID(font->ContainerAtlas->TexID);
|
||||
@ -4606,7 +4627,7 @@ void ImGui::PopFont()
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.CurrentWindow->DrawList->PopTextureID();
|
||||
g.FontStack.pop_back();
|
||||
SetCurrentFont(g.FontStack.empty() ? g.IO.Fonts->Fonts[0] : g.FontStack.back());
|
||||
SetCurrentFont(g.FontStack.empty() ? GetDefaultFont() : g.FontStack.back());
|
||||
}
|
||||
|
||||
void ImGui::PushAllowKeyboardFocus(bool allow_keyboard_focus)
|
||||
|
Reference in New Issue
Block a user