mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-16 09:43:13 +02:00
Merge branch 'master' into navigation
# Conflicts: # imgui_demo.cpp
This commit is contained in:
66
imgui.cpp
66
imgui.cpp
@ -249,6 +249,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.
|
||||
|
||||
- 2017/12/10 (1.53) - removed SetNextWindowContentWidth(), prefer using SetNextWindowContentSize(). Kept redirection function (will obsolete).
|
||||
- 2017/11/27 (1.53) - renamed ImGuiTextBuffer::append() helper to appendf(), appendv() to appendfv(). If you copied the 'Log' demo in your code, it uses appendv() so that needs to be renamed.
|
||||
- 2017/11/18 (1.53) - Style, Begin: removed ImGuiWindowFlags_ShowBorders window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. style.FrameBorderSize, style.WindowBorderSize). Use ImGui::ShowStyleEditor() to look them up.
|
||||
Please note that the style system will keep evolving (hopefully stabilizing in Q1 2018), and so custom styles will probably subtly break over time. It is recommended you use the StyleColorsClassic(), StyleColorsDark(), StyleColorsLight() functions.
|
||||
@ -5298,7 +5299,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
}
|
||||
if (g.SetNextWindowContentSizeCond)
|
||||
{
|
||||
// Adjust passed "client size" to become a "window size"
|
||||
window->SizeContentsExplicit = g.SetNextWindowContentSizeVal;
|
||||
window->SizeContentsExplicit.y += window->TitleBarHeight() + window->MenuBarHeight();
|
||||
g.SetNextWindowContentSizeCond = 0;
|
||||
}
|
||||
else if (first_begin_of_the_frame)
|
||||
@ -5429,7 +5432,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->Size = window->Collapsed ? window->TitleBarRect().GetSize() : window->SizeFull;
|
||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup))
|
||||
{
|
||||
IM_ASSERT(window_size_x_set_by_api && window_size_x_set_by_api); // Submitted by BeginChild()
|
||||
IM_ASSERT(window_size_x_set_by_api && window_size_y_set_by_api); // Submitted by BeginChild()
|
||||
window->Size = window->SizeFull;
|
||||
}
|
||||
|
||||
@ -5705,7 +5708,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->DrawList->AddLine(border.Min, border.Max, GetColorU32(ImGuiCol_SeparatorActive), ImMax(1.0f, window_border_size));
|
||||
}
|
||||
if (style.FrameBorderSize > 0 && !(flags & ImGuiWindowFlags_NoTitleBar))
|
||||
window->DrawList->AddLine(title_bar_rect.GetBL()+ImVec2(1,-1), title_bar_rect.GetBR()+ImVec2(-1,-1), GetColorU32(ImGuiCol_Border), style.FrameBorderSize);
|
||||
window->DrawList->AddLine(title_bar_rect.GetBL() + ImVec2(style.WindowBorderSize, -1), title_bar_rect.GetBR() + ImVec2(-style.WindowBorderSize,-1), GetColorU32(ImGuiCol_Border), style.FrameBorderSize);
|
||||
}
|
||||
|
||||
// Store a backup of SizeFull which we will use next frame to decide if we need scrollbars.
|
||||
@ -5836,10 +5839,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
// Inner rectangle
|
||||
// We set this up after processing the resize grip so that our clip rectangle doesn't lag by a frame
|
||||
// Note that if our window is collapsed we will end up with a null clipping rectangle which is the correct behavior.
|
||||
window->InnerRect.Min.x = title_bar_rect.Min.x;
|
||||
window->InnerRect.Min.y = title_bar_rect.Max.y + window->MenuBarHeight();
|
||||
window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x;
|
||||
window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y;
|
||||
window->InnerRect.Min.x = title_bar_rect.Min.x + window->WindowBorderSize;
|
||||
window->InnerRect.Min.y = title_bar_rect.Max.y + window->MenuBarHeight() + (((flags & ImGuiWindowFlags_MenuBar) || !(flags & ImGuiWindowFlags_NoTitleBar)) ? style.FrameBorderSize : window->WindowBorderSize);
|
||||
window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x - window->WindowBorderSize;
|
||||
window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y - window->WindowBorderSize;
|
||||
//window->DrawList->AddRect(window->InnerRect.Min, window->InnerRect.Max, IM_COL32_WHITE);
|
||||
|
||||
// After Begin() we fill the last item / hovered data using the title bar data. Make that a standard behavior (to allow usage of context menus on title bar only, etc.).
|
||||
@ -5852,10 +5855,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
// Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result.
|
||||
const float border_size = window->WindowBorderSize;
|
||||
ImRect clip_rect;
|
||||
clip_rect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + ImMax(border_size, ImFloor(window->WindowPadding.x*0.5f)));
|
||||
clip_rect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y + border_size);
|
||||
clip_rect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - ImMax(border_size, ImFloor(window->WindowPadding.x*0.5f)));
|
||||
clip_rect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y - border_size);
|
||||
clip_rect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + ImMax(0.0f, ImFloor(window->WindowPadding.x*0.5f - border_size)));
|
||||
clip_rect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y);
|
||||
clip_rect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - ImMax(0.0f, ImFloor(window->WindowPadding.x*0.5f - border_size)));
|
||||
clip_rect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y);
|
||||
PushClipRect(clip_rect.Min, clip_rect.Max, true);
|
||||
|
||||
// Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused)
|
||||
@ -5956,10 +5959,8 @@ void ImGui::Scrollbar(ImGuiLayoutType direction)
|
||||
const ImRect window_rect = window->Rect();
|
||||
const float border_size = window->WindowBorderSize;
|
||||
ImRect bb = horizontal
|
||||
? ImRect(window->Pos.x + border_size, window_rect.Max.y - style.ScrollbarSize, window_rect.Max.x - other_scrollbar_size_w - border_size, window_rect.Max.y - border_size)
|
||||
: ImRect(window_rect.Max.x - style.ScrollbarSize, window->Pos.y + border_size, window_rect.Max.x - border_size, window_rect.Max.y - other_scrollbar_size_w - border_size);
|
||||
if (!horizontal)
|
||||
bb.Min.y += window->TitleBarHeight() + ((window->Flags & ImGuiWindowFlags_MenuBar) ? window->MenuBarHeight() : 0.0f);
|
||||
? ImRect(window->InnerRect.Min.x, window_rect.Max.y - style.ScrollbarSize, window->InnerRect.Max.x, window_rect.Max.y - border_size)
|
||||
: ImRect(window_rect.Max.x - style.ScrollbarSize, window->InnerRect.Min.y, window_rect.Max.x - border_size, window->InnerRect.Max.y);
|
||||
if (bb.GetWidth() <= 0.0f || bb.GetHeight() <= 0.0f)
|
||||
return;
|
||||
|
||||
@ -6642,14 +6643,7 @@ void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& s
|
||||
void ImGui::SetNextWindowContentSize(const ImVec2& size)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.SetNextWindowContentSizeVal = size;
|
||||
g.SetNextWindowContentSizeCond = ImGuiCond_Always;
|
||||
}
|
||||
|
||||
void ImGui::SetNextWindowContentWidth(float width)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.SetNextWindowContentSizeVal = ImVec2(width, g.SetNextWindowContentSizeCond ? g.SetNextWindowContentSizeVal.y : 0.0f);
|
||||
g.SetNextWindowContentSizeVal = size; // In Begin() we will add the size of window decorations (title bar, menu etc.) to that to form a SizeContents value.
|
||||
g.SetNextWindowContentSizeCond = ImGuiCond_Always;
|
||||
}
|
||||
|
||||
@ -10290,7 +10284,7 @@ void ImGui::EndCombo()
|
||||
EndPopup();
|
||||
}
|
||||
|
||||
// Combo box function.
|
||||
// Old API, prefer using BeginCombo() nowadays if you can.
|
||||
bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int popup_max_height_in_items)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -10299,16 +10293,18 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
if (*current_item >= 0 && *current_item < items_count)
|
||||
items_getter(data, *current_item, &preview_text);
|
||||
|
||||
// The old Combo() API exposed "popup_max_height_in_items", however the new more general BeginCombo() API doesn't, so we emulate it here.
|
||||
if (popup_max_height_in_items != -1 && !g.SetNextWindowSizeConstraint)
|
||||
{
|
||||
float popup_max_height = CalcMaxPopupHeightFromItemCount(popup_max_height_in_items);
|
||||
SetNextWindowSizeConstraints(ImVec2(0,0), ImVec2(FLT_MAX, popup_max_height));
|
||||
}
|
||||
|
||||
if (!BeginCombo(label, preview_text, 0))
|
||||
return false;
|
||||
|
||||
// Display items
|
||||
// FIXME-OPT: Use clipper
|
||||
// FIXME-OPT: Use clipper (if we can disable it on the appearing frame to make sure our call to SetScrollHere() is processed)
|
||||
bool value_changed = false;
|
||||
for (int i = 0; i < items_count; i++)
|
||||
{
|
||||
@ -10360,7 +10356,7 @@ static bool Items_SingleStringGetter(void* data, int idx, const char** out_text)
|
||||
}
|
||||
|
||||
// Combo box helper allowing to pass an array of strings.
|
||||
bool ImGui::Combo(const char* label, int* current_item, const char* const* items, int items_count, int height_in_items)
|
||||
bool ImGui::Combo(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items)
|
||||
{
|
||||
const bool value_changed = Combo(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_in_items);
|
||||
return value_changed;
|
||||
@ -11065,7 +11061,7 @@ void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
|
||||
EndPopup();
|
||||
}
|
||||
|
||||
static void ColorPickerOptionsPopup(ImGuiColorEditFlags flags, float* ref_col)
|
||||
static void ColorPickerOptionsPopup(ImGuiColorEditFlags flags, const float* ref_col)
|
||||
{
|
||||
bool allow_opt_picker = !(flags & ImGuiColorEditFlags__PickerMask);
|
||||
bool allow_opt_alpha_bar = !(flags & ImGuiColorEditFlags_NoAlpha) && !(flags & ImGuiColorEditFlags_AlphaBar);
|
||||
@ -11218,7 +11214,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
PopItemWidth();
|
||||
}
|
||||
|
||||
bool picker_active = false;
|
||||
ImGuiWindow* picker_active_window = NULL;
|
||||
if (!(flags & ImGuiColorEditFlags_NoSmallPreview))
|
||||
{
|
||||
if (!(flags & ImGuiColorEditFlags_NoInputs))
|
||||
@ -11240,7 +11236,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
|
||||
if (BeginPopup("picker"))
|
||||
{
|
||||
picker_active = true;
|
||||
picker_active_window = g.CurrentWindow;
|
||||
if (label != label_display_end)
|
||||
{
|
||||
TextUnformatted(label, label_display_end);
|
||||
@ -11262,7 +11258,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
}
|
||||
|
||||
// Convert back
|
||||
if (!picker_active)
|
||||
if (picker_active_window == NULL)
|
||||
{
|
||||
if (!value_changed_as_float)
|
||||
for (int n = 0; n < 4; n++)
|
||||
@ -11282,6 +11278,10 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
PopID();
|
||||
EndGroup();
|
||||
|
||||
// When picker is being actively used, use its active id so IsItemActive() will function on ColorEdit4().
|
||||
if (picker_active_window && g.ActiveId != 0 && g.ActiveIdWindow == picker_active_window)
|
||||
window->DC.LastItemId = g.ActiveId;
|
||||
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
@ -11345,6 +11345,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags_AlphaBar);
|
||||
|
||||
// Setup
|
||||
int components = (flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4;
|
||||
bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha);
|
||||
ImVec2 picker_pos = window->DC.CursorPos;
|
||||
float square_sz = SmallSquareSize();
|
||||
@ -11354,6 +11355,9 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x;
|
||||
float bars_triangles_half_sz = (float)(int)(bars_width * 0.20f);
|
||||
|
||||
float backup_initial_col[4];
|
||||
memcpy(backup_initial_col, col, components * sizeof(float));
|
||||
|
||||
float wheel_thickness = sv_picker_size * 0.08f;
|
||||
float wheel_r_outer = sv_picker_size * 0.50f;
|
||||
float wheel_r_inner = wheel_r_outer - wheel_thickness;
|
||||
@ -11471,7 +11475,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
ImVec4 ref_col_v4(ref_col[0], ref_col[1], ref_col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : ref_col[3]);
|
||||
if (ColorButton("##original", ref_col_v4, (flags & (ImGuiColorEditFlags_HDR|ImGuiColorEditFlags_AlphaPreview|ImGuiColorEditFlags_AlphaPreviewHalf|ImGuiColorEditFlags_NoTooltip)), ImVec2(square_sz * 3, square_sz * 2)))
|
||||
{
|
||||
memcpy(col, ref_col, ((flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4) * sizeof(float));
|
||||
memcpy(col, ref_col, components * sizeof(float));
|
||||
value_changed = true;
|
||||
}
|
||||
}
|
||||
@ -11602,7 +11606,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
EndGroup();
|
||||
PopID();
|
||||
|
||||
return value_changed;
|
||||
return value_changed && memcmp(backup_initial_col, col, components * sizeof(float));
|
||||
}
|
||||
|
||||
// Horizontal separating line.
|
||||
|
Reference in New Issue
Block a user