mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 21:39:54 +02:00
Merge branch 'master' into viewport
# Conflicts: # imgui.cpp # imgui.h
This commit is contained in:
59
imgui.cpp
59
imgui.cpp
@ -318,6 +318,7 @@
|
||||
- 2018/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||
- 2018/XX/XX (1.XX) - removed io.DisplayVisibleMin, io.DisplayVisibleMax settings (it was used to clip within the DisplayMin..DisplayMax range, I don't know of anyone using it)
|
||||
|
||||
- 2018/08/22 (1.63) - renamed IsItemDeactivatedAfterChange() to IsItemDeactivatedAfterEdit() for consistency with new IsItemEdited() API. Kept redirection function (will obsolete soonish as IsItemDeactivatedAfterChange() is very recent).
|
||||
- 2018/08/21 (1.63) - renamed ImGuiTextEditCallback to ImGuiInputTextCallback, ImGuiTextEditCallbackData to ImGuiInputTextCallbackData for consistency. Kept redirection types (will obsolete).
|
||||
- 2018/08/21 (1.63) - removed ImGuiInputTextCallbackData::ReadOnly since it is a duplication of (ImGuiInputTextCallbackData::Flags & ImGuiInputTextFlags_ReadOnly).
|
||||
- 2018/08/01 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.ConfigResizeWindowsFromEdges to enable the feature.
|
||||
@ -2288,7 +2289,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
||||
if (g.ActiveIdIsJustActivated)
|
||||
{
|
||||
g.ActiveIdTimer = 0.0f;
|
||||
g.ActiveIdValueChanged = false;
|
||||
g.ActiveIdHasBeenEdited = false;
|
||||
if (id != 0)
|
||||
{
|
||||
g.LastActiveId = id;
|
||||
@ -2357,14 +2358,16 @@ void ImGui::KeepAliveID(ImGuiID id)
|
||||
g.ActiveIdPreviousFrameIsAlive = true;
|
||||
}
|
||||
|
||||
void ImGui::MarkItemValueChanged(ImGuiID id)
|
||||
void ImGui::MarkItemEdited(ImGuiID id)
|
||||
{
|
||||
// This marking is solely to be able to provide info for IsItemDeactivatedAfterChange().
|
||||
// This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit().
|
||||
// ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data.
|
||||
(void)id; // Avoid unused variable warnings when asserts are compiled out.
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive);
|
||||
g.ActiveIdValueChanged = true;
|
||||
//IM_ASSERT(g.CurrentWindow->DC.LastItemId == id);
|
||||
g.ActiveIdHasBeenEdited = true;
|
||||
g.CurrentWindow->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited;
|
||||
}
|
||||
|
||||
static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags)
|
||||
@ -4439,7 +4442,7 @@ void ImGui::NewFrame()
|
||||
g.LastActiveIdTimer += g.IO.DeltaTime;
|
||||
g.ActiveIdPreviousFrame = g.ActiveId;
|
||||
g.ActiveIdPreviousFrameWindow = g.ActiveIdWindow;
|
||||
g.ActiveIdPreviousFrameValueChanged = g.ActiveIdValueChanged;
|
||||
g.ActiveIdPreviousFrameHasBeenEdited = g.ActiveIdHasBeenEdited;
|
||||
g.ActiveIdIsAlive = 0;
|
||||
g.ActiveIdPreviousFrameIsAlive = false;
|
||||
g.ActiveIdIsJustActivated = false;
|
||||
@ -5899,10 +5902,10 @@ bool ImGui::IsItemDeactivated()
|
||||
return (g.ActiveIdPreviousFrame == window->DC.LastItemId && g.ActiveIdPreviousFrame != 0 && g.ActiveId != window->DC.LastItemId);
|
||||
}
|
||||
|
||||
bool ImGui::IsItemDeactivatedAfterChange()
|
||||
bool ImGui::IsItemDeactivatedAfterEdit()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
return IsItemDeactivated() && (g.ActiveIdPreviousFrameValueChanged || (g.ActiveId == 0 && g.ActiveIdValueChanged));
|
||||
return IsItemDeactivated() && (g.ActiveIdPreviousFrameHasBeenEdited || (g.ActiveId == 0 && g.ActiveIdHasBeenEdited));
|
||||
}
|
||||
|
||||
bool ImGui::IsItemFocused()
|
||||
@ -5940,6 +5943,12 @@ bool ImGui::IsItemVisible()
|
||||
return window->ClipRect.Overlaps(window->DC.LastItemRect);
|
||||
}
|
||||
|
||||
bool ImGui::IsItemEdited()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
return (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_Edited) != 0;
|
||||
}
|
||||
|
||||
// Allow last item to be overlapped by a subsequent item. Both may be activated during the same frame before the later one takes priority.
|
||||
void ImGui::SetItemAllowOverlap()
|
||||
{
|
||||
@ -8162,7 +8171,7 @@ void ImGui::PopTextWrapPos()
|
||||
void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiColMod backup;
|
||||
ImGuiColorMod backup;
|
||||
backup.Col = idx;
|
||||
backup.BackupValue = g.Style.Colors[idx];
|
||||
g.ColorModifiers.push_back(backup);
|
||||
@ -8172,7 +8181,7 @@ void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col)
|
||||
void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiColMod backup;
|
||||
ImGuiColorMod backup;
|
||||
backup.Col = idx;
|
||||
backup.BackupValue = g.Style.Colors[idx];
|
||||
g.ColorModifiers.push_back(backup);
|
||||
@ -8184,7 +8193,7 @@ void ImGui::PopStyleColor(int count)
|
||||
ImGuiContext& g = *GImGui;
|
||||
while (count > 0)
|
||||
{
|
||||
ImGuiColMod& backup = g.ColorModifiers.back();
|
||||
ImGuiColorMod& backup = g.ColorModifiers.back();
|
||||
g.Style.Colors[backup.Col] = backup.BackupValue;
|
||||
g.ColorModifiers.pop_back();
|
||||
count--;
|
||||
@ -9295,7 +9304,7 @@ bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
|
||||
if (pressed)
|
||||
MarkItemValueChanged(id);
|
||||
MarkItemEdited(id);
|
||||
|
||||
// Render
|
||||
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
||||
@ -10636,7 +10645,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* v, co
|
||||
ImRect grab_bb;
|
||||
const bool value_changed = SliderBehavior(frame_bb, id, data_type, v, v_min, v_max, format, power, ImGuiSliderFlags_None, &grab_bb);
|
||||
if (value_changed)
|
||||
MarkItemValueChanged(id);
|
||||
MarkItemEdited(id);
|
||||
|
||||
// Render grab
|
||||
window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
|
||||
@ -10702,7 +10711,7 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d
|
||||
ImRect grab_bb;
|
||||
const bool value_changed = SliderBehavior(frame_bb, id, data_type, v, v_min, v_max, format, power, ImGuiSliderFlags_Vertical, &grab_bb);
|
||||
if (value_changed)
|
||||
MarkItemValueChanged(id);
|
||||
MarkItemEdited(id);
|
||||
|
||||
// Render grab
|
||||
window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
|
||||
@ -10983,7 +10992,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, floa
|
||||
ItemSize(total_bb, style.FramePadding.y);
|
||||
const bool value_changed = DragBehavior(id, data_type, v, v_speed, v_min, v_max, format, power);
|
||||
if (value_changed)
|
||||
MarkItemValueChanged(id);
|
||||
MarkItemEdited(id);
|
||||
|
||||
// Draw frame
|
||||
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
||||
@ -11334,7 +11343,7 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
||||
if (pressed)
|
||||
{
|
||||
*v = !(*v);
|
||||
MarkItemValueChanged(id);
|
||||
MarkItemEdited(id);
|
||||
}
|
||||
|
||||
RenderNavHighlight(total_bb, id);
|
||||
@ -11404,7 +11413,7 @@ bool ImGui::RadioButton(const char* label, bool active)
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(total_bb, id, &hovered, &held);
|
||||
if (pressed)
|
||||
MarkItemValueChanged(id);
|
||||
MarkItemEdited(id);
|
||||
|
||||
RenderNavHighlight(total_bb, id);
|
||||
window->DrawList->AddCircleFilled(center, radius, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), 16);
|
||||
@ -12388,7 +12397,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||
|
||||
if (value_changed)
|
||||
MarkItemValueChanged(id);
|
||||
MarkItemEdited(id);
|
||||
|
||||
if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0)
|
||||
return enter_pressed;
|
||||
@ -12855,7 +12864,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
SetNavID(id, window->DC.NavLayerCurrent);
|
||||
}
|
||||
if (pressed)
|
||||
MarkItemValueChanged(id);
|
||||
MarkItemEdited(id);
|
||||
|
||||
// Render
|
||||
if (hovered || selected)
|
||||
@ -12965,6 +12974,7 @@ bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(v
|
||||
return false;
|
||||
|
||||
// Assume all items have even height (= 1 line of text). If you need items of different or variable sizes you can create a custom version of ListBox() in your code without using the clipper.
|
||||
ImGuiContext& g = *GImGui;
|
||||
bool value_changed = false;
|
||||
ImGuiListClipper clipper(items_count, GetTextLineHeightWithSpacing()); // We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to.
|
||||
while (clipper.Step())
|
||||
@ -12986,6 +12996,9 @@ bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(v
|
||||
PopID();
|
||||
}
|
||||
ListBoxFooter();
|
||||
if (value_changed)
|
||||
MarkItemEdited(g.CurrentWindow->DC.LastItemId);
|
||||
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
@ -13451,7 +13464,7 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
|
||||
ColorTooltip(desc_id, &col.x, flags & (ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf));
|
||||
|
||||
if (pressed)
|
||||
MarkItemValueChanged(id);
|
||||
MarkItemEdited(id);
|
||||
|
||||
return pressed;
|
||||
}
|
||||
@ -13748,7 +13761,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
window->DC.LastItemId = g.ActiveId;
|
||||
|
||||
if (value_changed)
|
||||
MarkItemValueChanged(window->DC.LastItemId);
|
||||
MarkItemEdited(window->DC.LastItemId);
|
||||
|
||||
return value_changed;
|
||||
}
|
||||
@ -14064,7 +14077,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
if (value_changed && memcmp(backup_initial_col, col, components * sizeof(float)) == 0)
|
||||
value_changed = false;
|
||||
if (value_changed)
|
||||
MarkItemValueChanged(window->DC.LastItemId);
|
||||
MarkItemEdited(window->DC.LastItemId);
|
||||
|
||||
PopID();
|
||||
|
||||
@ -14184,7 +14197,7 @@ bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float
|
||||
*size1 += mouse_delta;
|
||||
*size2 -= mouse_delta;
|
||||
bb_render.Translate((axis == ImGuiAxis_X) ? ImVec2(mouse_delta, 0.0f) : ImVec2(0.0f, mouse_delta));
|
||||
MarkItemValueChanged(id);
|
||||
MarkItemEdited(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14279,7 +14292,7 @@ void ImGui::EndGroup()
|
||||
}
|
||||
|
||||
// If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group.
|
||||
// It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but put a little more burden on individual widgets.
|
||||
// It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but would put a little more burden on individual widgets.
|
||||
// (and if you grep for LastItemId you'll notice it is only used in that context.
|
||||
if ((group_data.BackupActiveIdIsAlive != g.ActiveId) && (g.ActiveIdIsAlive == g.ActiveId) && g.ActiveId) // && g.ActiveIdWindow->RootWindow == window->RootWindow)
|
||||
window->DC.LastItemId = g.ActiveId;
|
||||
|
Reference in New Issue
Block a user