Merge branch 'master' into docking

# Conflicts:
#	examples/example_apple_opengl2/main.mm
#	imgui.cpp
This commit is contained in:
ocornut
2020-10-01 13:33:08 +02:00
11 changed files with 227 additions and 87 deletions

View File

@ -2249,8 +2249,8 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
if (temp_input_is_active)
{
// Only clamp CTRL+Click input when ImGuiSliderFlags_ClampInput is set
const bool is_clamp_input = (flags & ImGuiSliderFlags_ClampOnInput) != 0 && (p_min == NULL || p_max == NULL || DataTypeCompare(data_type, p_min, p_max) < 0);
// Only clamp CTRL+Click input when ImGuiSliderFlags_AlwaysClamp is set
const bool is_clamp_input = (flags & ImGuiSliderFlags_AlwaysClamp) != 0 && (p_min == NULL || p_max == NULL || DataTypeCompare(data_type, p_min, p_max) < 0);
return TempInputScalar(frame_bb, id, label, data_type, p_data, format, is_clamp_input ? p_min : NULL, is_clamp_input ? p_max : NULL);
}
@ -2331,7 +2331,7 @@ bool ImGui::DragFloat4(const char* label, float v[4], float v_speed, float v_min
return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, flags);
}
// NB: You likely want to specify the ImGuiSliderFlags_ClampOnInput when using this.
// NB: You likely want to specify the ImGuiSliderFlags_AlwaysClamp when using this.
bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed, float v_min, float v_max, const char* format, const char* format_max, ImGuiSliderFlags flags)
{
ImGuiWindow* window = GetCurrentWindow();
@ -2384,7 +2384,7 @@ bool ImGui::DragInt4(const char* label, int v[4], float v_speed, int v_min, int
return DragScalarN(label, ImGuiDataType_S32, v, 4, v_speed, &v_min, &v_max, format, flags);
}
// NB: You likely want to specify the ImGuiSliderFlags_ClampOnInput when using this.
// NB: You likely want to specify the ImGuiSliderFlags_AlwaysClamp when using this.
bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed, int v_min, int v_max, const char* format, const char* format_max, ImGuiSliderFlags flags)
{
ImGuiWindow* window = GetCurrentWindow();
@ -2856,8 +2856,8 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
if (temp_input_is_active)
{
// Only clamp CTRL+Click input when ImGuiSliderFlags_ClampInput is set
const bool is_clamp_input = (flags & ImGuiSliderFlags_ClampOnInput) != 0;
// Only clamp CTRL+Click input when ImGuiSliderFlags_AlwaysClamp is set
const bool is_clamp_input = (flags & ImGuiSliderFlags_AlwaysClamp) != 0;
return TempInputScalar(frame_bb, id, label, data_type, p_data, format, is_clamp_input ? p_min : NULL, is_clamp_input ? p_max : NULL);
}
@ -3185,8 +3185,7 @@ bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char*
return value_changed;
}
// Note that Drag/Slider functions are only forwarding the min/max values clamping values if the
// ImGuiSliderFlags_ClampOnInput / ImGuiSliderFlags_ClampOnInput flag is set!
// Note that Drag/Slider functions are only forwarding the min/max values clamping values if the ImGuiSliderFlags_AlwaysClamp flag is set!
// This is intended: this way we allow CTRL+Click manual input to set a value out of bounds, for maximum flexibility.
// However this may not be ideal for all uses, as some user code may break on out of bound values.
bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min, const void* p_clamp_max)
@ -5953,6 +5952,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
ItemSize(size, 0.0f);
// Fill horizontal space
// We don't support (size < 0.0f) in Selectable() because the ItemSpacing extension would make explicitely right-aligned sizes not visibly match other widgets.
const float min_x = span_all_columns ? window->ParentWorkRect.Min.x : pos.x;
const float max_x = span_all_columns ? window->ParentWorkRect.Max.x : window->WorkRect.Max.x;
if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_SpanAvailWidth))
@ -6164,7 +6164,8 @@ bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(v
// 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.
ImGuiListClipper clipper;
clipper.Begin(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())
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
{
@ -7037,13 +7038,16 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
tab->IndexDuringLayout = (ImS8)tab_dst_n;
// We will need sorting if tabs have changed section (e.g. moved from one of Leading/Central/Trailing to another)
ImGuiTabItem* prev_tab = &tab_bar->Tabs[tab_dst_n - 1];
int curr_tab_section_n = (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
int prev_tab_section_n = (prev_tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (prev_tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
if (tab_dst_n > 0 && curr_tab_section_n == 0 && prev_tab_section_n != 0)
need_sort_by_section = true;
if (tab_dst_n > 0 && prev_tab_section_n == 2 && curr_tab_section_n != 2)
need_sort_by_section = true;
if (tab_dst_n > 0)
{
ImGuiTabItem* prev_tab = &tab_bar->Tabs[tab_dst_n - 1];
int prev_tab_section_n = (prev_tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (prev_tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
if (curr_tab_section_n == 0 && prev_tab_section_n != 0)
need_sort_by_section = true;
if (prev_tab_section_n == 2 && curr_tab_section_n != 2)
need_sort_by_section = true;
}
sections[curr_tab_section_n].TabCount++;
tab_dst_n++;
@ -7948,7 +7952,7 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
bool close_button_pressed = false;
bool close_button_visible = false;
if (close_button_id != 0)
if (is_contents_visible || bb.GetWidth() >= g.Style.TabMinWidthForUnselectedCloseButton)
if (is_contents_visible || bb.GetWidth() >= g.Style.TabMinWidthForCloseButton)
if (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == tab_id || g.ActiveId == close_button_id)
close_button_visible = true;
if (close_button_visible)