mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-17 21:56:36 +00:00
Merge branch 'master' into 2016-02-colorpicker
This commit is contained in:
commit
c8553817d9
@ -20,7 +20,8 @@
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS
|
||||
|
||||
//---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty)
|
||||
//---- Don't implement test window functionality (ShowTestWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
|
||||
//---- It is very strongly recommended to NOT disable the test windows. Please read the comment at the top of imgui_demo.cpp to learn why.
|
||||
//#define IMGUI_DISABLE_TEST_WINDOWS
|
||||
|
||||
//---- Don't define obsolete functions names
|
||||
|
66
imgui.cpp
66
imgui.cpp
@ -154,6 +154,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
|
||||
- 2017/07/20 (1.51) - Removed IsPosHoveringAnyWindow(ImVec2), which was partly broken and misleading. ASSERT + redirect user to io.WantCaptureMouse
|
||||
- 2017/05/26 (1.50) - Removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset.
|
||||
- 2017/05/01 (1.50) - Renamed ImDrawList::PathFill() (rarely used directly) to ImDrawList::PathFillConvex() for clarity.
|
||||
- 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().
|
||||
@ -1777,7 +1778,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
|
||||
MoveId = GetID("#MOVE");
|
||||
|
||||
Flags = 0;
|
||||
IndexWithinParent = 0;
|
||||
OrderWithinParent = 0;
|
||||
PosFloat = Pos = ImVec2(0.0f, 0.0f);
|
||||
Size = SizeFull = ImVec2(0.0f, 0.0f);
|
||||
SizeContents = SizeContentsExplicit = ImVec2(0.0f, 0.0f);
|
||||
@ -2158,7 +2159,7 @@ void ImGui::NewFrame()
|
||||
|
||||
g.Time += g.IO.DeltaTime;
|
||||
g.FrameCount += 1;
|
||||
g.Tooltip[0] = '\0';
|
||||
g.TooltipOverrideCount = 0;
|
||||
g.OverlayDrawList.Clear();
|
||||
g.OverlayDrawList.PushTextureID(g.IO.Fonts->TexID);
|
||||
g.OverlayDrawList.PushClipRectFullScreen();
|
||||
@ -2569,7 +2570,7 @@ static int ChildWindowComparer(const void* lhs, const void* rhs)
|
||||
return d;
|
||||
if (int d = (a->Flags & ImGuiWindowFlags_ComboBox) - (b->Flags & ImGuiWindowFlags_ComboBox))
|
||||
return d;
|
||||
return (a->IndexWithinParent - b->IndexWithinParent);
|
||||
return (a->OrderWithinParent - b->OrderWithinParent);
|
||||
}
|
||||
|
||||
static void AddWindowToSortedBuffer(ImVector<ImGuiWindow*>& out_sorted_windows, ImGuiWindow* window)
|
||||
@ -2658,14 +2659,6 @@ void ImGui::EndFrame()
|
||||
IM_ASSERT(g.Initialized); // Forgot to call ImGui::NewFrame()
|
||||
IM_ASSERT(g.FrameCountEnded != g.FrameCount); // ImGui::EndFrame() called multiple times, or forgot to call ImGui::NewFrame() again
|
||||
|
||||
// Render tooltip
|
||||
if (g.Tooltip[0])
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::TextUnformatted(g.Tooltip);
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
// Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
|
||||
if (g.IO.ImeSetInputScreenPosFn && ImLengthSqr(g.OsImePosRequest - g.OsImePosSet) > 0.0001f)
|
||||
{
|
||||
@ -3148,11 +3141,6 @@ bool ImGui::IsMouseHoveringAnyWindow()
|
||||
return g.HoveredWindow != NULL;
|
||||
}
|
||||
|
||||
bool ImGui::IsPosHoveringAnyWindow(const ImVec2& pos)
|
||||
{
|
||||
return FindHoveredWindow(pos, false) != NULL;
|
||||
}
|
||||
|
||||
static bool IsKeyPressedMap(ImGuiKey key, bool repeat)
|
||||
{
|
||||
const int key_index = GImGui->IO.KeyMap[key];
|
||||
@ -3386,11 +3374,36 @@ ImVec2 ImGui::CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge, float ou
|
||||
return rect.GetClosestPoint(pos, on_edge);
|
||||
}
|
||||
|
||||
// Tooltip is stored and turned into a BeginTooltip()/EndTooltip() sequence at the end of the frame. Each call override previous value.
|
||||
void ImGui::SetTooltipV(const char* fmt, va_list args)
|
||||
static ImRect GetVisibleRect()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImFormatStringV(g.Tooltip, IM_ARRAYSIZE(g.Tooltip), fmt, args);
|
||||
if (g.IO.DisplayVisibleMin.x != g.IO.DisplayVisibleMax.x && g.IO.DisplayVisibleMin.y != g.IO.DisplayVisibleMax.y)
|
||||
return ImRect(g.IO.DisplayVisibleMin, g.IO.DisplayVisibleMax);
|
||||
return ImRect(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y);
|
||||
}
|
||||
|
||||
// Not exposed publicly as BeginTooltip() because bool parameters are evil. Let's see if other needs arise first.
|
||||
static void BeginTooltipEx(bool override_previous_tooltip)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
char window_name[16];
|
||||
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip%02d", g.TooltipOverrideCount);
|
||||
if (override_previous_tooltip)
|
||||
if (ImGuiWindow* window = ImGui::FindWindowByName(window_name))
|
||||
if (window->Active)
|
||||
{
|
||||
// Hide previous tooltips. We can't easily "reset" the content of a window so we create a new one.
|
||||
window->HiddenFrames = 1;
|
||||
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip%02d", ++g.TooltipOverrideCount);
|
||||
}
|
||||
ImGui::Begin(window_name, NULL, ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize);
|
||||
}
|
||||
|
||||
void ImGui::SetTooltipV(const char* fmt, va_list args)
|
||||
{
|
||||
BeginTooltipEx(true);
|
||||
TextV(fmt, args);
|
||||
EndTooltip();
|
||||
}
|
||||
|
||||
void ImGui::SetTooltip(const char* fmt, ...)
|
||||
@ -3401,18 +3414,9 @@ void ImGui::SetTooltip(const char* fmt, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static ImRect GetVisibleRect()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.IO.DisplayVisibleMin.x != g.IO.DisplayVisibleMax.x && g.IO.DisplayVisibleMin.y != g.IO.DisplayVisibleMax.y)
|
||||
return ImRect(g.IO.DisplayVisibleMin, g.IO.DisplayVisibleMax);
|
||||
return ImRect(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y);
|
||||
}
|
||||
|
||||
void ImGui::BeginTooltip()
|
||||
{
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize;
|
||||
ImGui::Begin("##Tooltip", NULL, flags);
|
||||
BeginTooltipEx(false);
|
||||
}
|
||||
|
||||
void ImGui::EndTooltip()
|
||||
@ -3997,7 +4001,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
||||
if (first_begin_of_the_frame)
|
||||
{
|
||||
window->Active = true;
|
||||
window->IndexWithinParent = 0;
|
||||
window->OrderWithinParent = 0;
|
||||
window->BeginCount = 0;
|
||||
window->ClipRect = ImVec4(-FLT_MAX,-FLT_MAX,+FLT_MAX,+FLT_MAX);
|
||||
window->LastFrameActive = current_frame;
|
||||
@ -4117,7 +4121,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
||||
// Position child window
|
||||
if (flags & ImGuiWindowFlags_ChildWindow)
|
||||
{
|
||||
window->IndexWithinParent = parent_window->DC.ChildWindows.Size;
|
||||
window->OrderWithinParent = parent_window->DC.ChildWindows.Size;
|
||||
parent_window->DC.ChildWindows.push_back(window);
|
||||
}
|
||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup))
|
||||
|
6
imgui.h
6
imgui.h
@ -362,9 +362,9 @@ namespace ImGui
|
||||
IMGUI_API void ValueColor(const char* prefix, ImU32 v);
|
||||
|
||||
// Tooltips
|
||||
IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins
|
||||
IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); // set text tooltip under mouse-cursor, typically use with ImGui::IsItemHovered(). overidde any previous call to SetTooltip().
|
||||
IMGUI_API void SetTooltipV(const char* fmt, va_list args);
|
||||
IMGUI_API void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text
|
||||
IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of contents).
|
||||
IMGUI_API void EndTooltip();
|
||||
|
||||
// Menus
|
||||
@ -418,7 +418,6 @@ namespace ImGui
|
||||
IMGUI_API bool IsRootWindowOrAnyChildHovered(); // is current root window or any of its child (including current window) hovered and hoverable (not blocked by a popup)
|
||||
IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped.
|
||||
IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
|
||||
IMGUI_API bool IsPosHoveringAnyWindow(const ImVec2& pos); // is given position hovering any active imgui window
|
||||
IMGUI_API float GetTime();
|
||||
IMGUI_API int GetFrameCount();
|
||||
IMGUI_API const char* GetStyleColName(ImGuiCol idx);
|
||||
@ -472,6 +471,7 @@ namespace ImGui
|
||||
|
||||
// Obsolete functions (Will be removed! Also see 'API BREAKING CHANGES' section in imgui.cpp)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
static inline bool IsPosHoveringAnyWindow(const ImVec2&) { IM_ASSERT(0); return false; } // OBSOLETE 1.51+. This was partly broken. You probably wanted to use ImGui::GetIO().WantCaptureMouse instead.
|
||||
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 float GetWindowFontSize() { return GetFontSize(); } // OBSOLETE 1.48+
|
||||
|
@ -2,10 +2,17 @@
|
||||
// (demo code)
|
||||
|
||||
// Message to the person tempted to delete this file when integrating ImGui into their code base:
|
||||
// Do NOT remove this file from your project! It is useful reference code that you and other users will want to refer to.
|
||||
// Don't do it! Do NOT remove this file from your project! It is useful reference code that you and other users will want to refer to.
|
||||
// Everything in this file will be stripped out by the linker if you don't call ImGui::ShowTestWindow().
|
||||
// During development, you can call ImGui::ShowTestWindow() in your code to learn about various features of ImGui.
|
||||
// Removing this file from your project is hindering your access to documentation, likely leading you to poorer usage of the library.
|
||||
// During development, you can call ImGui::ShowTestWindow() in your code to learn about various features of ImGui. Have it wired in a debug menu!
|
||||
// Removing this file from your project is hindering access to documentation for everyone in your team, likely leading you to poorer usage of the library.
|
||||
|
||||
// Note that you can #define IMGUI_DISABLE_TEST_WINDOWS in imconfig.h for the same effect.
|
||||
// If you want to link core ImGui in your public builds but not those test windows, #define IMGUI_DISABLE_TEST_WINDOWS in imconfig.h and those functions will be empty.
|
||||
// For any other case, if you have ImGui available you probably want this to be available for reference and execution.
|
||||
|
||||
// Thank you,
|
||||
// -Your beloved friend, imgui_demo.cpp (that you won't delete)
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
@ -438,7 +438,7 @@ struct ImGuiContext
|
||||
float DragSpeedScaleSlow;
|
||||
float DragSpeedScaleFast;
|
||||
ImVec2 ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
|
||||
char Tooltip[1024];
|
||||
int TooltipOverrideCount;
|
||||
char* PrivateClipboard; // If no custom clipboard handler is defined
|
||||
ImVec2 OsImePosRequest, OsImePosSet; // Cursor position request & last passed to the OS Input Method Editor
|
||||
|
||||
@ -507,7 +507,7 @@ struct ImGuiContext
|
||||
DragSpeedScaleSlow = 0.01f;
|
||||
DragSpeedScaleFast = 10.0f;
|
||||
ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
|
||||
memset(Tooltip, 0, sizeof(Tooltip));
|
||||
TooltipOverrideCount = 0;
|
||||
PrivateClipboard = NULL;
|
||||
OsImePosRequest = OsImePosSet = ImVec2(-1.0f, -1.0f);
|
||||
|
||||
@ -619,7 +619,7 @@ struct IMGUI_API ImGuiWindow
|
||||
char* Name;
|
||||
ImGuiID ID; // == ImHash(Name)
|
||||
ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
|
||||
int IndexWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0.
|
||||
int OrderWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0.
|
||||
ImVec2 PosFloat;
|
||||
ImVec2 Pos; // Position rounded-up to nearest pixel
|
||||
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
||||
|
Loading…
Reference in New Issue
Block a user