|
|
@@ -251,6 +251,7 @@
|
|
|
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
|
|
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
|
|
|
|
|
+ - 2018/03/03 (1.60) - Renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums.
|
|
|
- 2018/02/18 (1.60) - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment.
|
|
|
- 2018/02/16 (1.60) - obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). Use ImGui::GetDrawData() to retrieve the ImDrawData* to display.
|
|
|
- 2018/02/07 (1.60) - reorganized context handling to be more explicit,
|
|
|
@@ -4280,7 +4281,7 @@ void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding)
|
|
|
}
|
|
|
|
|
|
// Render a triangle to denote expanded/collapsed state
|
|
|
-void ImGui::RenderTriangle(ImVec2 p_min, ImGuiDir dir, float scale)
|
|
|
+void ImGui::RenderArrow(ImVec2 p_min, ImGuiDir dir, float scale)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
@@ -4309,7 +4310,7 @@ void ImGui::RenderTriangle(ImVec2 p_min, ImGuiDir dir, float scale)
|
|
|
c = ImVec2(-0.500f,-0.866f) * r;
|
|
|
break;
|
|
|
case ImGuiDir_None:
|
|
|
- case ImGuiDir_Count_:
|
|
|
+ case ImGuiDir_COUNT:
|
|
|
IM_ASSERT(0);
|
|
|
break;
|
|
|
}
|
|
|
@@ -5203,8 +5204,8 @@ static ImVec2 FindBestWindowPosForPopup(const ImVec2& ref_pos, const ImVec2& siz
|
|
|
// Combo Box policy (we want a connecting edge)
|
|
|
if (policy == ImGuiPopupPositionPolicy_ComboBox)
|
|
|
{
|
|
|
- const ImGuiDir dir_prefered_order[ImGuiDir_Count_] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up };
|
|
|
- for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_Count_; n++)
|
|
|
+ const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up };
|
|
|
+ for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
|
|
|
{
|
|
|
const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
|
|
|
if (n != -1 && dir == *last_dir) // Already tried this direction?
|
|
|
@@ -5222,8 +5223,8 @@ static ImVec2 FindBestWindowPosForPopup(const ImVec2& ref_pos, const ImVec2& siz
|
|
|
}
|
|
|
|
|
|
// Default popup policy
|
|
|
- const ImGuiDir dir_prefered_order[ImGuiDir_Count_] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left };
|
|
|
- for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_Count_; n++)
|
|
|
+ const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left };
|
|
|
+ for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
|
|
|
{
|
|
|
const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
|
|
|
if (n != -1 && dir == *last_dir) // Already tried this direction?
|
|
|
@@ -6082,7 +6083,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
if (ButtonBehavior(bb, id, NULL, NULL))
|
|
|
window->CollapseToggleWanted = true; // Defer collapsing to next frame as we are too far in the Begin() function
|
|
|
RenderNavHighlight(bb, id);
|
|
|
- RenderTriangle(window->Pos + style.FramePadding, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
|
|
|
+ RenderArrow(window->Pos + style.FramePadding, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
|
|
|
}
|
|
|
|
|
|
// Close button
|
|
|
@@ -6601,8 +6602,8 @@ static const ImGuiStyleVarInfo GStyleVarInfo[] =
|
|
|
|
|
|
static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx)
|
|
|
{
|
|
|
- IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_Count_);
|
|
|
- IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_Count_);
|
|
|
+ IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT);
|
|
|
+ IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_COUNT);
|
|
|
return &GStyleVarInfo[idx];
|
|
|
}
|
|
|
|
|
|
@@ -7667,6 +7668,32 @@ bool ImGui::SmallButton(const char* label)
|
|
|
return pressed;
|
|
|
}
|
|
|
|
|
|
+bool ImGui::ArrowButton(const char* str_id, ImGuiDir dir)
|
|
|
+{
|
|
|
+ ImGuiWindow* window = GetCurrentWindow();
|
|
|
+ if (window->SkipItems)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ const ImGuiID id = window->GetID(str_id);
|
|
|
+ float sz = ImGui::GetFrameHeight();
|
|
|
+ const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(sz, sz));
|
|
|
+ ItemSize(bb);
|
|
|
+ if (!ItemAdd(bb, id))
|
|
|
+ return false;
|
|
|
+
|
|
|
+ bool hovered, held;
|
|
|
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held);
|
|
|
+
|
|
|
+ // Render
|
|
|
+ const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
|
+ RenderNavHighlight(bb, id);
|
|
|
+ RenderFrame(bb.Min, bb.Max, col, true, g.Style.FrameRounding);
|
|
|
+ RenderArrow(bb.Min + g.Style.FramePadding, dir);
|
|
|
+
|
|
|
+ return pressed;
|
|
|
+}
|
|
|
+
|
|
|
// Tip: use ImGui::PushID()/PopID() to push indices or pointers in the ID stack.
|
|
|
// Then you can keep 'str_id' empty or the same for all your buttons (instead of creating a string based on a non-string id)
|
|
|
bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg)
|
|
|
@@ -7740,7 +7767,7 @@ bool ImGui::ArrowButton(ImGuiID id, ImGuiDir dir, ImVec2 padding, ImGuiButtonFla
|
|
|
const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
|
RenderNavHighlight(bb, id);
|
|
|
RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
|
|
|
- RenderTriangle(bb.Min + padding, dir, 1.0f);
|
|
|
+ RenderArrow(bb.Min + padding, dir, 1.0f);
|
|
|
|
|
|
return pressed;
|
|
|
}
|
|
|
@@ -8070,7 +8097,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
|
// Framed type
|
|
|
RenderFrame(frame_bb.Min, frame_bb.Max, col, true, style.FrameRounding);
|
|
|
RenderNavHighlight(frame_bb, id, ImGuiNavHighlightFlags_TypeThin);
|
|
|
- RenderTriangle(frame_bb.Min + ImVec2(padding.x, text_base_offset_y), is_open ? ImGuiDir_Down : ImGuiDir_Right, 1.0f);
|
|
|
+ RenderArrow(frame_bb.Min + ImVec2(padding.x, text_base_offset_y), is_open ? ImGuiDir_Down : ImGuiDir_Right, 1.0f);
|
|
|
if (g.LogEnabled)
|
|
|
{
|
|
|
// NB: '##' is normally used to hide text (as a library-wide feature), so we need to specify the text range to make sure the ## aren't stripped out here.
|
|
|
@@ -8097,7 +8124,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
|
if (flags & ImGuiTreeNodeFlags_Bullet)
|
|
|
RenderBullet(frame_bb.Min + ImVec2(text_offset_x * 0.5f, g.FontSize*0.50f + text_base_offset_y));
|
|
|
else if (!(flags & ImGuiTreeNodeFlags_Leaf))
|
|
|
- RenderTriangle(frame_bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), is_open ? ImGuiDir_Down : ImGuiDir_Right, 0.70f);
|
|
|
+ RenderArrow(frame_bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), is_open ? ImGuiDir_Down : ImGuiDir_Right, 0.70f);
|
|
|
if (g.LogEnabled)
|
|
|
LogRenderedText(&text_pos, ">");
|
|
|
RenderText(text_pos, label, label_end, false);
|
|
|
@@ -8566,7 +8593,7 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
|
|
|
const ImGuiStyle& style = g.Style;
|
|
|
|
|
|
// Draw frame
|
|
|
- const ImU32 frame_col = GetColorU32((g.ActiveId == id && g.ActiveIdSource == ImGuiInputSource_Nav) ? ImGuiCol_FrameBgActive : ImGuiCol_FrameBg);
|
|
|
+ const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
|
|
RenderNavHighlight(frame_bb, id);
|
|
|
RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, style.FrameRounding);
|
|
|
|
|
|
@@ -10577,16 +10604,19 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiCond backup_next_window_size_constraint = g.NextWindowData.SizeConstraintCond;
|
|
|
g.NextWindowData.SizeConstraintCond = 0;
|
|
|
-
|
|
|
+
|
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
|
if (window->SkipItems)
|
|
|
return false;
|
|
|
|
|
|
+ IM_ASSERT((flags & (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)) != (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)); // Can't use both flags together
|
|
|
+
|
|
|
const ImGuiStyle& style = g.Style;
|
|
|
const ImGuiID id = window->GetID(label);
|
|
|
- const float w = CalcItemWidth();
|
|
|
|
|
|
+ const float arrow_size = (flags & ImGuiComboFlags_NoArrowButton) ? 0.0f : GetFrameHeight();
|
|
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
|
|
+ const float w = (flags & ImGuiComboFlags_NoPreview) ? arrow_size : CalcItemWidth();
|
|
|
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
|
|
|
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
|
|
|
ItemSize(total_bb, style.FramePadding.y);
|
|
|
@@ -10597,13 +10627,18 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|
|
bool pressed = ButtonBehavior(frame_bb, id, &hovered, &held);
|
|
|
bool popup_open = IsPopupOpen(id);
|
|
|
|
|
|
- const float arrow_size = GetFrameHeight();
|
|
|
const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
|
|
|
+ const ImU32 frame_col = GetColorU32(hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
|
|
RenderNavHighlight(frame_bb, id);
|
|
|
- RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
|
|
- RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(popup_open || hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
|
|
|
- RenderTriangle(ImVec2(frame_bb.Max.x - arrow_size + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), ImGuiDir_Down);
|
|
|
- if (preview_value != NULL)
|
|
|
+ if (!(flags & ImGuiComboFlags_NoPreview))
|
|
|
+ window->DrawList->AddRectFilled(frame_bb.Min, ImVec2(frame_bb.Max.x - arrow_size, frame_bb.Max.y), frame_col, style.FrameRounding, ImDrawCornerFlags_Left);
|
|
|
+ if (!(flags & ImGuiComboFlags_NoArrowButton))
|
|
|
+ {
|
|
|
+ window->DrawList->AddRectFilled(ImVec2(frame_bb.Max.x - arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32((popup_open || hovered) ? ImGuiCol_ButtonHovered : ImGuiCol_Button), style.FrameRounding, (w <= arrow_size) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Right);
|
|
|
+ RenderArrow(ImVec2(frame_bb.Max.x - arrow_size + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), ImGuiDir_Down);
|
|
|
+ }
|
|
|
+ RenderFrameBorder(frame_bb.Min, frame_bb.Max, style.FrameRounding);
|
|
|
+ if (preview_value != NULL && !(flags & ImGuiComboFlags_NoPreview))
|
|
|
RenderTextClipped(frame_bb.Min + style.FramePadding, value_bb.Max, preview_value, NULL, NULL, ImVec2(0.0f,0.0f));
|
|
|
if (label_size.x > 0)
|
|
|
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
|
|
@@ -11154,7 +11189,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|
|
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w);
|
|
|
pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
|
|
|
if (!enabled) PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
|
|
|
- RenderTriangle(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), ImGuiDir_Right);
|
|
|
+ RenderArrow(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), ImGuiDir_Right);
|
|
|
if (!enabled) PopStyleColor();
|
|
|
}
|
|
|
|
|
|
@@ -11730,7 +11765,7 @@ static void RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGui
|
|
|
case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return;
|
|
|
case ImGuiDir_Up: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return;
|
|
|
case ImGuiDir_Down: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return;
|
|
|
- case ImGuiDir_None: case ImGuiDir_Count_: break; // Fix warnings
|
|
|
+ case ImGuiDir_None: case ImGuiDir_COUNT: break; // Fix warnings
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -13231,7 +13266,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
}
|
|
|
if (ImGui::TreeNode("Internal state"))
|
|
|
{
|
|
|
- const char* input_source_names[] = { "None", "Mouse", "Nav", "NavGamepad", "NavKeyboard" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_Count_);
|
|
|
+ const char* input_source_names[] = { "None", "Mouse", "Nav", "NavGamepad", "NavKeyboard" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT);
|
|
|
ImGui::Text("HoveredWindow: '%s'", g.HoveredWindow ? g.HoveredWindow->Name : "NULL");
|
|
|
ImGui::Text("HoveredRootWindow: '%s'", g.HoveredRootWindow ? g.HoveredRootWindow->Name : "NULL");
|
|
|
ImGui::Text("HoveredId: 0x%08X/0x%08X (%.2f sec)", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not
|