mirror of
https://github.com/wolfpld/tracy.git
synced 2026-08-06 05:19:16 +00:00
Bump imgui to ecf82ca8066.
This commit is contained in:
@@ -1676,6 +1676,7 @@ bool ImGui::Combo(const char* label, int* current_item, const char* items_separa
|
||||
// - DataTypeFormatString()
|
||||
// - DataTypeApplyOp()
|
||||
// - DataTypeApplyOpFromText()
|
||||
// - DataTypeClamp()
|
||||
// - GetMinimumStepAtDecimalPrecision
|
||||
// - RoundScalarWithFormat<>()
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -1827,11 +1828,9 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
return false;
|
||||
|
||||
// Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all.
|
||||
IM_ASSERT(data_type < ImGuiDataType_COUNT);
|
||||
int data_backup[2];
|
||||
const ImGuiDataTypeInfo* type_info = ImGui::DataTypeGetInfo(data_type);
|
||||
IM_ASSERT(type_info->Size <= sizeof(data_backup));
|
||||
memcpy(data_backup, p_data, type_info->Size);
|
||||
const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type);
|
||||
ImGuiDataTypeTempStorage data_backup;
|
||||
memcpy(&data_backup, p_data, type_info->Size);
|
||||
|
||||
if (format == NULL)
|
||||
format = type_info->ScanFmt;
|
||||
@@ -1903,7 +1902,35 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
IM_ASSERT(0);
|
||||
}
|
||||
|
||||
return memcmp(data_backup, p_data, type_info->Size) != 0;
|
||||
return memcmp(&data_backup, p_data, type_info->Size) != 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static bool ClampBehaviorT(T* v, T v_min, T v_max)
|
||||
{
|
||||
if (*v < v_min) { *v = v_min; return true; }
|
||||
if (*v > v_max) { *v = v_max; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ImGui::DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max)
|
||||
{
|
||||
switch (data_type)
|
||||
{
|
||||
case ImGuiDataType_S8: return ClampBehaviorT<ImS8 >((ImS8* )p_data, *(const ImS8* )p_min, *(const ImS8* )p_max);
|
||||
case ImGuiDataType_U8: return ClampBehaviorT<ImU8 >((ImU8* )p_data, *(const ImU8* )p_min, *(const ImU8* )p_max);
|
||||
case ImGuiDataType_S16: return ClampBehaviorT<ImS16 >((ImS16* )p_data, *(const ImS16* )p_min, *(const ImS16* )p_max);
|
||||
case ImGuiDataType_U16: return ClampBehaviorT<ImU16 >((ImU16* )p_data, *(const ImU16* )p_min, *(const ImU16* )p_max);
|
||||
case ImGuiDataType_S32: return ClampBehaviorT<ImS32 >((ImS32* )p_data, *(const ImS32* )p_min, *(const ImS32* )p_max);
|
||||
case ImGuiDataType_U32: return ClampBehaviorT<ImU32 >((ImU32* )p_data, *(const ImU32* )p_min, *(const ImU32* )p_max);
|
||||
case ImGuiDataType_S64: return ClampBehaviorT<ImS64 >((ImS64* )p_data, *(const ImS64* )p_min, *(const ImS64* )p_max);
|
||||
case ImGuiDataType_U64: return ClampBehaviorT<ImU64 >((ImU64* )p_data, *(const ImU64* )p_min, *(const ImU64* )p_max);
|
||||
case ImGuiDataType_Float: return ClampBehaviorT<float >((float* )p_data, *(const float* )p_min, *(const float* )p_max);
|
||||
case ImGuiDataType_Double: return ClampBehaviorT<double>((double*)p_data, *(const double*)p_min, *(const double*)p_max);
|
||||
case ImGuiDataType_COUNT: break;
|
||||
}
|
||||
IM_ASSERT(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
static float GetMinimumStepAtDecimalPrecision(int decimal_precision)
|
||||
@@ -2155,8 +2182,10 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Our current specs do NOT clamp when using CTRL+Click manual input, but we should eventually add a flag for that..
|
||||
if (temp_input_is_active || temp_input_start)
|
||||
return TempInputScalar(frame_bb, id, label, data_type, p_data, format);
|
||||
return TempInputScalar(frame_bb, id, label, data_type, p_data, format);// , p_min, p_max);
|
||||
|
||||
// Draw frame
|
||||
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
||||
@@ -2352,7 +2381,7 @@ float ImGui::SliderCalcRatioFromValueT(ImGuiDataType data_type, TYPE v, TYPE v_m
|
||||
return (float)((FLOATTYPE)(v_clamped - v_min) / (FLOATTYPE)(v_max - v_min));
|
||||
}
|
||||
|
||||
// FIXME: Move some of the code into SliderBehavior(). Current responsability is larger than what the equivalent DragBehaviorT<> does, we also do some rendering, etc.
|
||||
// FIXME: Move some of the code into SliderBehavior(). Current responsibility is larger than what the equivalent DragBehaviorT<> does, we also do some rendering, etc.
|
||||
template<typename TYPE, typename SIGNEDTYPE, typename FLOATTYPE>
|
||||
bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, TYPE* v, const TYPE v_min, const TYPE v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb)
|
||||
{
|
||||
@@ -2606,8 +2635,10 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Our current specs do NOT clamp when using CTRL+Click manual input, but we should eventually add a flag for that..
|
||||
if (temp_input_is_active || temp_input_start)
|
||||
return TempInputScalar(frame_bb, id, label, data_type, p_data, format);
|
||||
return TempInputScalar(frame_bb, id, label, data_type, p_data, format);// , p_min, p_max);
|
||||
|
||||
// Draw frame
|
||||
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
||||
@@ -2906,7 +2937,21 @@ bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char*
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format)
|
||||
// Note that Drag/Slider functions are currently NOT forwarding the min/max values clamping values!
|
||||
// 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.
|
||||
// In the future we should add flags to Slider/Drag to specify how to enforce min/max values with CTRL+Click.
|
||||
// See GitHub issues #1829 and #3209
|
||||
// In the meanwhile, you can easily "wrap" those functions to enforce clamping, using wrapper functions, e.g.
|
||||
// bool SliderFloatClamp(const char* label, float* v, float v_min, float v_max)
|
||||
// {
|
||||
// float v_backup = *v;
|
||||
// if (!SliderFloat(label, v, v_min, v_max))
|
||||
// return false;
|
||||
// *v = ImClamp(*v, v_min, v_max);
|
||||
// return v_backup != *v;
|
||||
// }
|
||||
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)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
@@ -2918,10 +2963,21 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
||||
|
||||
ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoMarkEdited;
|
||||
flags |= ((data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImGuiInputTextFlags_CharsScientific : ImGuiInputTextFlags_CharsDecimal);
|
||||
bool value_changed = TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags);
|
||||
if (value_changed)
|
||||
bool value_changed = false;
|
||||
if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags))
|
||||
{
|
||||
value_changed = DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialTextA.Data, data_type, p_data, NULL);
|
||||
// Backup old value
|
||||
size_t data_type_size = DataTypeGetInfo(data_type)->Size;
|
||||
ImGuiDataTypeTempStorage data_backup;
|
||||
memcpy(&data_backup, p_data, data_type_size);
|
||||
|
||||
// Apply new value (or operations) then clamp
|
||||
DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialTextA.Data, data_type, p_data, NULL);
|
||||
if (p_clamp_min && p_clamp_max)
|
||||
DataTypeClamp(data_type, p_data, p_clamp_min, p_clamp_max);
|
||||
|
||||
// Only mark as edited if new value is different
|
||||
value_changed = memcmp(&data_type, p_data, data_type_size) != 0;
|
||||
if (value_changed)
|
||||
MarkItemEdited(id);
|
||||
}
|
||||
@@ -2949,7 +3005,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
||||
if ((flags & (ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0)
|
||||
flags |= ImGuiInputTextFlags_CharsDecimal;
|
||||
flags |= ImGuiInputTextFlags_AutoSelectAll;
|
||||
flags |= ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselve by comparing the actual data rather than the string.
|
||||
flags |= ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
|
||||
|
||||
if (p_step != NULL)
|
||||
{
|
||||
@@ -3367,7 +3423,7 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons
|
||||
if (!is_resizable)
|
||||
return;
|
||||
|
||||
// Contrary to STB_TEXTEDIT_INSERTCHARS() this is working in the UTF8 buffer, hence the midly similar code (until we remove the U16 buffer alltogether!)
|
||||
// Contrary to STB_TEXTEDIT_INSERTCHARS() this is working in the UTF8 buffer, hence the mildly similar code (until we remove the U16 buffer altogether!)
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiInputTextState* edit_state = &g.InputTextState;
|
||||
IM_ASSERT(edit_state->ID != 0 && g.ActiveId == edit_state->ID);
|
||||
@@ -3474,6 +3530,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
IM_ASSERT(buf != NULL && buf_size >= 0);
|
||||
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys)
|
||||
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key)
|
||||
|
||||
@@ -4755,7 +4812,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
if (flags & ImGuiColorEditFlags_DisplayRGB || (flags & ImGuiColorEditFlags__DisplayMask) == 0)
|
||||
if (ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_DisplayRGB))
|
||||
{
|
||||
// FIXME: Hackily differenciating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget.
|
||||
// FIXME: Hackily differentiating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget.
|
||||
// For the later we don't want to run the hue-wrap canceling code. If you are well versed in HSV picker please provide your input! (See #2050)
|
||||
value_changed_fix_hue_wrap = (g.ActiveId != 0 && !g.ActiveIdAllowOverlap);
|
||||
value_changed = true;
|
||||
@@ -6280,7 +6337,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
||||
g.NavWindow = window; // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent)
|
||||
|
||||
// The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu,
|
||||
// However the final position is going to be different! It is choosen by FindBestWindowPosForPopup().
|
||||
// However the final position is going to be different! It is chosen by FindBestWindowPosForPopup().
|
||||
// e.g. Menus tend to overlap each other horizontally to amplify relative Z-ordering.
|
||||
ImVec2 popup_pos, pos = window->DC.CursorPos;
|
||||
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
||||
@@ -7175,6 +7232,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||
tab_bar->NextSelectedTabId = id;
|
||||
|
||||
// Lock visibility
|
||||
// (Note: tab_contents_visible != tab_selected... because CTRL+TAB operations may preview some tabs without selecting them!)
|
||||
bool tab_contents_visible = (tab_bar->VisibleTabId == id);
|
||||
if (tab_contents_visible)
|
||||
tab_bar->VisibleTabWasSubmitted = true;
|
||||
@@ -7323,7 +7381,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||
|
||||
// Render tab label, process close button
|
||||
const ImGuiID close_button_id = p_open ? window->GetID((void*)((intptr_t)id + 1)) : 0;
|
||||
bool just_closed = TabItemLabelAndCloseButton(display_draw_list, bb, flags, tab_bar->FramePadding, label, id, close_button_id);
|
||||
bool just_closed = TabItemLabelAndCloseButton(display_draw_list, bb, flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible);
|
||||
if (just_closed && p_open != NULL)
|
||||
{
|
||||
*p_open = false;
|
||||
@@ -7408,13 +7466,21 @@ void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabI
|
||||
|
||||
// Render text label (with custom clipping) + Unsaved Document marker + Close Button logic
|
||||
// We tend to lock style.FramePadding for a given tab-bar, hence the 'frame_padding' parameter.
|
||||
bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id)
|
||||
bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||
if (bb.GetWidth() <= 1.0f)
|
||||
return false;
|
||||
|
||||
// In Style V2 we'll have full override of all colors per state (e.g. focused, selected)
|
||||
// But right now if you want to alter text color of tabs this is what you need to do.
|
||||
#if 0
|
||||
const float backup_alpha = g.Style.Alpha;
|
||||
if (!is_contents_visible)
|
||||
g.Style.Alpha *= 0.7f;
|
||||
#endif
|
||||
|
||||
// Render text label (with clipping + alpha gradient) + unsaved marker
|
||||
const char* TAB_UNSAVED_MARKER = "*";
|
||||
ImRect text_pixel_clip_bb(bb.Min.x + frame_padding.x, bb.Min.y + frame_padding.y, bb.Max.x - frame_padding.x, bb.Max.y);
|
||||
@@ -7434,8 +7500,9 @@ 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 (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == close_button_id)
|
||||
close_button_visible = true;
|
||||
if (is_contents_visible || bb.GetWidth() >= g.Style.TabMinWidthForUnselectedCloseButton)
|
||||
if (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == close_button_id)
|
||||
close_button_visible = true;
|
||||
if (close_button_visible)
|
||||
{
|
||||
ImGuiItemHoveredDataBackup last_item_backup;
|
||||
@@ -7456,6 +7523,11 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
||||
float ellipsis_max_x = close_button_visible ? text_pixel_clip_bb.Max.x : bb.Max.x - 1.0f;
|
||||
RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, text_pixel_clip_bb.Max.x, ellipsis_max_x, label, NULL, &label_size);
|
||||
|
||||
#if 0
|
||||
if (!is_contents_visible)
|
||||
g.Style.Alpha = backup_alpha;
|
||||
#endif
|
||||
|
||||
return close_button_pressed;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user