mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Merge branch 'master' into navigation
This commit is contained in:
commit
a2b2e56e8e
115
imgui.cpp
115
imgui.cpp
@ -2903,15 +2903,12 @@ void ImGui::NewFrame()
|
||||
{
|
||||
KeepAliveID(g.MovedWindowMoveId);
|
||||
IM_ASSERT(g.MovedWindow && g.MovedWindow->RootWindow);
|
||||
IM_ASSERT(g.MovedWindow->RootWindow->MoveId == g.MovedWindowMoveId);
|
||||
IM_ASSERT(g.MovedWindow->MoveId == g.MovedWindowMoveId);
|
||||
if (g.IO.MouseDown[0])
|
||||
{
|
||||
if (!(g.MovedWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
g.MovedWindow->PosFloat += g.IO.MouseDelta;
|
||||
if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f)
|
||||
MarkIniSettingsDirty(g.MovedWindow);
|
||||
}
|
||||
g.MovedWindow->RootWindow->PosFloat += g.IO.MouseDelta;
|
||||
if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f)
|
||||
MarkIniSettingsDirty(g.MovedWindow->RootWindow);
|
||||
FocusWindow(g.MovedWindow);
|
||||
}
|
||||
else
|
||||
@ -3388,7 +3385,7 @@ void ImGui::EndFrame()
|
||||
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
g.MovedWindow = g.HoveredWindow;
|
||||
g.MovedWindowMoveId = g.HoveredRootWindow->MoveId;
|
||||
g.MovedWindowMoveId = g.HoveredWindow->MoveId;
|
||||
SetActiveIDNoNav(g.MovedWindowMoveId, g.HoveredRootWindow);
|
||||
}
|
||||
}
|
||||
@ -4359,7 +4356,7 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags ext
|
||||
SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||
|
||||
ImGuiWindowFlags flags = extra_flags|ImGuiWindowFlags_Popup|ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoSavedSettings;
|
||||
bool is_open = ImGui::Begin(name, p_open, flags);
|
||||
bool is_open = Begin(name, p_open, flags);
|
||||
if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||
{
|
||||
EndPopup();
|
||||
@ -4376,9 +4373,9 @@ void ImGui::EndPopup()
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
IM_ASSERT(window->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls
|
||||
IM_ASSERT(GImGui->CurrentPopupStack.Size > 0);
|
||||
ImGui::End();
|
||||
End();
|
||||
if (!(window->Flags & ImGuiWindowFlags_Modal))
|
||||
ImGui::PopStyleVar();
|
||||
PopStyleVar();
|
||||
}
|
||||
|
||||
// This is a helper to handle the most simple case of associating one named popup to one given widget.
|
||||
@ -4507,17 +4504,17 @@ bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags ext
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, style.Colors[ImGuiCol_FrameBg]);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, style.FrameRounding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
|
||||
return ImGui::BeginChild(id, size, (g.CurrentWindow->Flags & ImGuiWindowFlags_ShowBorders) ? true : false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding | extra_flags);
|
||||
PushStyleColor(ImGuiCol_ChildWindowBg, style.Colors[ImGuiCol_FrameBg]);
|
||||
PushStyleVar(ImGuiStyleVar_ChildWindowRounding, style.FrameRounding);
|
||||
PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
|
||||
return BeginChild(id, size, (g.CurrentWindow->Flags & ImGuiWindowFlags_ShowBorders) ? true : false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding | extra_flags);
|
||||
}
|
||||
|
||||
void ImGui::EndChildFrame()
|
||||
{
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::PopStyleColor();
|
||||
EndChild();
|
||||
PopStyleVar(2);
|
||||
PopStyleColor();
|
||||
}
|
||||
|
||||
// Save and compare stack sizes on Begin()/End() to detect usage errors
|
||||
@ -5995,7 +5992,7 @@ void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pi
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
void ImGui::SetNextWindowPosCenter(ImGuiCond cond)
|
||||
{
|
||||
SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, cond, ImVec2(0.5f, 0.5f));
|
||||
SetNextWindowPos(GetIO().DisplaySize * 0.5f, cond, ImVec2(0.5f, 0.5f));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -9538,8 +9535,11 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImVec2 popu
|
||||
return false;
|
||||
|
||||
const float arrow_size = SmallSquareSize();
|
||||
const bool hovered = IsHovered(frame_bb, id);
|
||||
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(frame_bb, id, &hovered, &held);
|
||||
const bool navigated = g.NavId == id;
|
||||
|
||||
bool popup_open = IsPopupOpen(id);
|
||||
|
||||
const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
|
||||
@ -9554,32 +9554,12 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImVec2 popu
|
||||
if (label_size.x > 0)
|
||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||
|
||||
bool popup_toggled = false;
|
||||
if (hovered)
|
||||
if ((pressed || g.NavActivateId == id) && !popup_open)
|
||||
{
|
||||
SetHoveredID(id);
|
||||
if (g.IO.MouseClicked[0])
|
||||
{
|
||||
ClearActiveID();
|
||||
popup_toggled = true;
|
||||
}
|
||||
}
|
||||
if (g.NavActivateId == id)
|
||||
popup_toggled = true;
|
||||
if (popup_toggled)
|
||||
{
|
||||
if (popup_open)
|
||||
{
|
||||
ClosePopup(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (window->DC.NavLayerCurrent == 0)
|
||||
window->NavLastId = id;
|
||||
FocusWindow(window);
|
||||
OpenPopupEx(id, false);
|
||||
}
|
||||
popup_open = !popup_open;
|
||||
if (window->DC.NavLayerCurrent == 0)
|
||||
window->NavLastId = id;
|
||||
OpenPopupEx(id, false);
|
||||
popup_open = true;
|
||||
}
|
||||
|
||||
if (!popup_open)
|
||||
@ -10095,7 +10075,7 @@ void ImGui::EndMenu()
|
||||
}
|
||||
|
||||
// Note: only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set.
|
||||
void ImGui::ColorTooltip(const char* text, const float col[4], ImGuiColorEditFlags flags)
|
||||
void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
@ -10236,51 +10216,52 @@ bool ImGui::ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flag
|
||||
return ColorEdit4(label, col, flags | ImGuiColorEditFlags_NoAlpha);
|
||||
}
|
||||
|
||||
static void ColorEditOptionsPopup(ImGuiColorEditFlags flags, float* col)
|
||||
void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
|
||||
{
|
||||
bool allow_opt_inputs = !(flags & ImGuiColorEditFlags__InputsMask);
|
||||
bool allow_opt_datatype = !(flags & ImGuiColorEditFlags__DataTypeMask);
|
||||
if ((!allow_opt_inputs && !allow_opt_datatype) || !ImGui::BeginPopup("context"))
|
||||
if ((!allow_opt_inputs && !allow_opt_datatype) || !BeginPopup("context"))
|
||||
return;
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiColorEditFlags opts = g.ColorEditOptions;
|
||||
if (allow_opt_inputs)
|
||||
{
|
||||
if (ImGui::RadioButton("RGB", (opts & ImGuiColorEditFlags_RGB) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_RGB;
|
||||
if (ImGui::RadioButton("HSV", (opts & ImGuiColorEditFlags_HSV) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_HSV;
|
||||
if (ImGui::RadioButton("HEX", (opts & ImGuiColorEditFlags_HEX) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_HEX;
|
||||
if (RadioButton("RGB", (opts & ImGuiColorEditFlags_RGB) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_RGB;
|
||||
if (RadioButton("HSV", (opts & ImGuiColorEditFlags_HSV) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_HSV;
|
||||
if (RadioButton("HEX", (opts & ImGuiColorEditFlags_HEX) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_HEX;
|
||||
}
|
||||
if (allow_opt_datatype)
|
||||
{
|
||||
if (allow_opt_inputs) ImGui::Separator();
|
||||
if (ImGui::RadioButton("0..255", (opts & ImGuiColorEditFlags_Uint8) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Uint8;
|
||||
if (ImGui::RadioButton("0.00..1.00", (opts & ImGuiColorEditFlags_Float) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Float;
|
||||
if (allow_opt_inputs) Separator();
|
||||
if (RadioButton("0..255", (opts & ImGuiColorEditFlags_Uint8) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Uint8;
|
||||
if (RadioButton("0.00..1.00", (opts & ImGuiColorEditFlags_Float) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Float;
|
||||
}
|
||||
|
||||
if (allow_opt_inputs || allow_opt_datatype) ImGui::Separator();
|
||||
if (ImGui::Button("Copy as..", ImVec2(-1,0)))
|
||||
ImGui::OpenPopup("Copy");
|
||||
if (ImGui::BeginPopup("Copy"))
|
||||
if (allow_opt_inputs || allow_opt_datatype)
|
||||
Separator();
|
||||
if (Button("Copy as..", ImVec2(-1,0)))
|
||||
OpenPopup("Copy");
|
||||
if (BeginPopup("Copy"))
|
||||
{
|
||||
int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]);
|
||||
char buf[64];
|
||||
sprintf(buf, "(%.3ff, %.3ff, %.3ff, %.3ff)", col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]);
|
||||
if (ImGui::Selectable(buf))
|
||||
ImGui::SetClipboardText(buf);
|
||||
if (Selectable(buf))
|
||||
SetClipboardText(buf);
|
||||
sprintf(buf, "(%d,%d,%d,%d)", cr, cg, cb, ca);
|
||||
if (ImGui::Selectable(buf))
|
||||
ImGui::SetClipboardText(buf);
|
||||
if (Selectable(buf))
|
||||
SetClipboardText(buf);
|
||||
if (flags & ImGuiColorEditFlags_NoAlpha)
|
||||
sprintf(buf, "0x%02X%02X%02X", cr, cg, cb);
|
||||
else
|
||||
sprintf(buf, "0x%02X%02X%02X%02X", cr, cg, cb, ca);
|
||||
if (ImGui::Selectable(buf))
|
||||
ImGui::SetClipboardText(buf);
|
||||
ImGui::EndPopup();
|
||||
if (Selectable(buf))
|
||||
SetClipboardText(buf);
|
||||
EndPopup();
|
||||
}
|
||||
|
||||
g.ColorEditOptions = opts;
|
||||
ImGui::EndPopup();
|
||||
EndPopup();
|
||||
}
|
||||
|
||||
static void ColorPickerOptionsPopup(ImGuiColorEditFlags flags, float* ref_col)
|
||||
@ -10351,7 +10332,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
|
||||
// Context menu: display and modify options (before defaults are applied)
|
||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||
ColorEditOptionsPopup(flags, col);
|
||||
ColorEditOptionsPopup(col, flags);
|
||||
|
||||
// Read stored options
|
||||
if (!(flags & ImGuiColorEditFlags__InputsMask))
|
||||
|
1
imgui.h
1
imgui.h
@ -1475,7 +1475,6 @@ struct ImFontAtlas
|
||||
|
||||
IMGUI_API int AddCustomRectRegular(unsigned int id, int width, int height); // Id needs to be >= 0x10000. Id >= 0x80000000 are reserved for ImGui and ImDrawList
|
||||
IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0,0)); // Id needs to be < 0x10000 to register a rectangle to map into a specific font.
|
||||
IMGUI_API void ClearCustomRects();
|
||||
IMGUI_API void CalcCustomRectUV(const CustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max);
|
||||
const CustomRect* GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; }
|
||||
|
||||
|
@ -1134,6 +1134,8 @@ void ImFontAtlas::ClearInputData()
|
||||
}
|
||||
ConfigData.clear();
|
||||
CustomRects.clear();
|
||||
for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++)
|
||||
CustomRectIds[n] = -1;
|
||||
}
|
||||
|
||||
void ImFontAtlas::ClearTexData()
|
||||
@ -1597,6 +1599,8 @@ void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* pack_context_opaq
|
||||
stbrp_context* pack_context = (stbrp_context*)pack_context_opaque;
|
||||
|
||||
ImVector<ImFontAtlas::CustomRect>& user_rects = atlas->CustomRects;
|
||||
IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong.
|
||||
|
||||
ImVector<stbrp_rect> pack_rects;
|
||||
pack_rects.resize(user_rects.Size);
|
||||
memset(pack_rects.Data, 0, sizeof(stbrp_rect) * user_rects.Size);
|
||||
|
@ -903,7 +903,8 @@ namespace ImGui
|
||||
IMGUI_API bool InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags);
|
||||
IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision);
|
||||
|
||||
IMGUI_API void ColorTooltip(const char* text, const float col[4], ImGuiColorEditFlags flags);
|
||||
IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
|
||||
IMGUI_API void ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags);
|
||||
|
||||
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
|
||||
IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
|
||||
|
Loading…
Reference in New Issue
Block a user