|
@@ -1685,7 +1685,7 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|
|
const ImGuiID id = window->GetID(label);
|
|
|
IM_ASSERT((flags & (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)) != (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)); // Can't use both flags together
|
|
|
if (flags & ImGuiComboFlags_WidthFitPreview)
|
|
|
- IM_ASSERT((flags & (ImGuiComboFlags_NoPreview | ImGuiComboFlags_CustomPreview)) == 0);
|
|
|
+ IM_ASSERT((flags & (ImGuiComboFlags_NoPreview | (ImGuiComboFlags)ImGuiComboFlags_CustomPreview)) == 0);
|
|
|
|
|
|
const float arrow_size = (flags & ImGuiComboFlags_NoArrowButton) ? 0.0f : GetFrameHeight();
|
|
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
|
@@ -3432,7 +3432,7 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
|
|
DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format);
|
|
|
ImStrTrimBlanks(data_buf);
|
|
|
|
|
|
- ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoMarkEdited;
|
|
|
+ ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited;
|
|
|
flags |= InputScalar_DefaultCharsFilter(data_type, format);
|
|
|
|
|
|
bool value_changed = false;
|
|
@@ -3480,7 +3480,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
|
|
// Testing ActiveId as a minor optimization as filtering is not needed until active
|
|
|
if (g.ActiveId == 0 && (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0)
|
|
|
flags |= InputScalar_DefaultCharsFilter(data_type, format);
|
|
|
- flags |= ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
|
|
|
+ flags |= ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
|
|
|
|
|
|
bool value_changed = false;
|
|
|
if (p_step == NULL)
|
|
@@ -4111,12 +4111,6 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
|
|
|
|
const bool RENDER_SELECTION_WHEN_INACTIVE = false;
|
|
|
const bool is_multiline = (flags & ImGuiInputTextFlags_Multiline) != 0;
|
|
|
- const bool is_readonly = (flags & ImGuiInputTextFlags_ReadOnly) != 0;
|
|
|
- const bool is_password = (flags & ImGuiInputTextFlags_Password) != 0;
|
|
|
- const bool is_undoable = (flags & ImGuiInputTextFlags_NoUndoRedo) == 0;
|
|
|
- const bool is_resizable = (flags & ImGuiInputTextFlags_CallbackResize) != 0;
|
|
|
- if (is_resizable)
|
|
|
- IM_ASSERT(callback != NULL); // Must provide a callback if you set the ImGuiInputTextFlags_CallbackResize flag!
|
|
|
|
|
|
if (is_multiline) // Open group before calling GetID() because groups tracks id created within their scope (including the scrollbar)
|
|
|
BeginGroup();
|
|
@@ -4186,6 +4180,15 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
|
// We are only allowed to access the state if we are already the active widget.
|
|
|
ImGuiInputTextState* state = GetInputTextState(id);
|
|
|
|
|
|
+ if (g.LastItemData.InFlags & ImGuiItemFlags_ReadOnly)
|
|
|
+ flags |= ImGuiInputTextFlags_ReadOnly;
|
|
|
+ const bool is_readonly = (flags & ImGuiInputTextFlags_ReadOnly) != 0;
|
|
|
+ const bool is_password = (flags & ImGuiInputTextFlags_Password) != 0;
|
|
|
+ const bool is_undoable = (flags & ImGuiInputTextFlags_NoUndoRedo) == 0;
|
|
|
+ const bool is_resizable = (flags & ImGuiInputTextFlags_CallbackResize) != 0;
|
|
|
+ if (is_resizable)
|
|
|
+ IM_ASSERT(callback != NULL); // Must provide a callback if you set the ImGuiInputTextFlags_CallbackResize flag!
|
|
|
+
|
|
|
const bool input_requested_by_tabbing = (item_status_flags & ImGuiItemStatusFlags_FocusedByTabbing) != 0;
|
|
|
const bool input_requested_by_nav = (g.ActiveId != id) && ((g.NavActivateId == id) && ((g.NavActivateFlags & ImGuiActivateFlags_PreferInput) || (g.NavInputSource == ImGuiInputSource_Keyboard)));
|
|
|
|
|
@@ -4722,7 +4725,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
|
if (callback_data.SelectionEnd != utf8_selection_end || buf_dirty) { state->Stb.select_end = (callback_data.SelectionEnd == callback_data.SelectionStart) ? state->Stb.select_start : ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionEnd); }
|
|
|
if (buf_dirty)
|
|
|
{
|
|
|
- IM_ASSERT((flags & ImGuiInputTextFlags_ReadOnly) == 0);
|
|
|
+ IM_ASSERT(!is_readonly);
|
|
|
IM_ASSERT(callback_data.BufTextLen == (int)strlen(callback_data.Buf)); // You need to maintain BufTextLen if you change the text!
|
|
|
InputTextReconcileUndoStateAfterUserCallback(state, callback_data.Buf, callback_data.BufTextLen); // FIXME: Move the rest of this block inside function and rename to InputTextReconcileStateAfterUserCallback() ?
|
|
|
if (callback_data.BufTextLen > backup_current_text_length && is_resizable)
|
|
@@ -5344,7 +5347,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|
|
|
|
|
// Drag and Drop Target
|
|
|
// NB: The flag test is merely an optional micro-optimization, BeginDragDropTarget() does the same test.
|
|
|
- if ((g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect) && !(flags & ImGuiColorEditFlags_NoDragDrop) && BeginDragDropTarget())
|
|
|
+ if ((g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect) && !(g.LastItemData.InFlags & ImGuiItemFlags_ReadOnly) && !(flags & ImGuiColorEditFlags_NoDragDrop) && BeginDragDropTarget())
|
|
|
{
|
|
|
bool accepted_drag_drop = false;
|
|
|
if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F))
|
|
@@ -5409,6 +5412,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|
|
ImGuiIO& io = g.IO;
|
|
|
|
|
|
const float width = CalcItemWidth();
|
|
|
+ const bool is_readonly = ((g.NextItemData.ItemFlags | g.CurrentItemFlags) & ImGuiItemFlags_ReadOnly) != 0;
|
|
|
g.NextItemData.ClearFlags();
|
|
|
|
|
|
PushID(label);
|
|
@@ -5479,7 +5483,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|
|
{
|
|
|
// Hue wheel + SV triangle logic
|
|
|
InvisibleButton("hsv", ImVec2(sv_picker_size + style.ItemInnerSpacing.x + bars_width, sv_picker_size));
|
|
|
- if (IsItemActive())
|
|
|
+ if (IsItemActive() && !is_readonly)
|
|
|
{
|
|
|
ImVec2 initial_off = g.IO.MouseClickedPos[0] - wheel_center;
|
|
|
ImVec2 current_off = g.IO.MousePos - wheel_center;
|
|
@@ -5514,7 +5518,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|
|
{
|
|
|
// SV rectangle logic
|
|
|
InvisibleButton("sv", ImVec2(sv_picker_size, sv_picker_size));
|
|
|
- if (IsItemActive())
|
|
|
+ if (IsItemActive() && !is_readonly)
|
|
|
{
|
|
|
S = ImSaturate((io.MousePos.x - picker_pos.x) / (sv_picker_size - 1));
|
|
|
V = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size - 1));
|
|
@@ -5527,7 +5531,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|
|
// Hue bar logic
|
|
|
SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y));
|
|
|
InvisibleButton("hue", ImVec2(bars_width, sv_picker_size));
|
|
|
- if (IsItemActive())
|
|
|
+ if (IsItemActive() && !is_readonly)
|
|
|
{
|
|
|
H = ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size - 1));
|
|
|
value_changed = value_changed_h = true;
|
|
@@ -6472,7 +6476,7 @@ bool ImGui::CollapsingHeader(const char* label, bool* p_visible, ImGuiTreeNodeFl
|
|
|
ImGuiID id = window->GetID(label);
|
|
|
flags |= ImGuiTreeNodeFlags_CollapsingHeader;
|
|
|
if (p_visible)
|
|
|
- flags |= ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_ClipLabelForTrailingButton;
|
|
|
+ flags |= ImGuiTreeNodeFlags_AllowOverlap | (ImGuiTreeNodeFlags)ImGuiTreeNodeFlags_ClipLabelForTrailingButton;
|
|
|
bool is_open = TreeNodeBehavior(id, flags, label);
|
|
|
if (p_visible != NULL)
|
|
|
{
|
|
@@ -7524,18 +7528,18 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|
|
ImGuiWindow* child_menu_window = (child_popup && child_popup->Window && child_popup->Window->ParentWindow == window) ? child_popup->Window : NULL;
|
|
|
if (g.HoveredWindow == window && child_menu_window != NULL)
|
|
|
{
|
|
|
- float ref_unit = g.FontSize; // FIXME-DPI
|
|
|
- float child_dir = (window->Pos.x < child_menu_window->Pos.x) ? 1.0f : -1.0f;
|
|
|
- ImRect next_window_rect = child_menu_window->Rect();
|
|
|
+ const float ref_unit = g.FontSize; // FIXME-DPI
|
|
|
+ const float child_dir = (window->Pos.x < child_menu_window->Pos.x) ? 1.0f : -1.0f;
|
|
|
+ const ImRect next_window_rect = child_menu_window->Rect();
|
|
|
ImVec2 ta = (g.IO.MousePos - g.IO.MouseDelta);
|
|
|
ImVec2 tb = (child_dir > 0.0f) ? next_window_rect.GetTL() : next_window_rect.GetTR();
|
|
|
ImVec2 tc = (child_dir > 0.0f) ? next_window_rect.GetBL() : next_window_rect.GetBR();
|
|
|
- float extra = ImClamp(ImFabs(ta.x - tb.x) * 0.30f, ref_unit * 0.5f, ref_unit * 2.5f); // add a bit of extra slack.
|
|
|
+ const float pad_farmost_h = ImClamp(ImFabs(ta.x - tb.x) * 0.30f, ref_unit * 0.5f, ref_unit * 2.5f); // Add a bit of extra slack.
|
|
|
ta.x += child_dir * -0.5f;
|
|
|
tb.x += child_dir * ref_unit;
|
|
|
tc.x += child_dir * ref_unit;
|
|
|
- tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -ref_unit * 8.0f); // triangle has maximum height to limit the slope and the bias toward large sub-menus
|
|
|
- tc.y = ta.y + ImMin((tc.y + extra) - ta.y, +ref_unit * 8.0f);
|
|
|
+ tb.y = ta.y + ImMax((tb.y - pad_farmost_h) - ta.y, -ref_unit * 8.0f); // Triangle has maximum height to limit the slope and the bias toward large sub-menus
|
|
|
+ tc.y = ta.y + ImMin((tc.y + pad_farmost_h) - ta.y, +ref_unit * 8.0f);
|
|
|
moving_toward_child_menu = ImTriangleContainsPoint(ta, tb, tc, g.IO.MousePos);
|
|
|
//GetForegroundDrawList()->AddTriangleFilled(ta, tb, tc, moving_toward_child_menu ? IM_COL32(0,128,0,128) : IM_COL32(128,0,0,128)); // [DEBUG]
|
|
|
}
|
|
@@ -7547,10 +7551,13 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|
|
want_close = true;
|
|
|
|
|
|
// Open
|
|
|
+ // (note: at this point 'hovered' actually includes the NavDisableMouseHover == false test)
|
|
|
if (!menu_is_open && pressed) // Click/activate to open
|
|
|
want_open = true;
|
|
|
else if (!menu_is_open && hovered && !moving_toward_child_menu) // Hover to open
|
|
|
want_open = true;
|
|
|
+ else if (!menu_is_open && hovered && g.HoveredIdTimer >= 0.30f && g.MouseStationaryTimer >= 0.30f) // Hover to open (timer fallback)
|
|
|
+ want_open = true;
|
|
|
if (g.NavId == id && g.NavMoveDir == ImGuiDir_Right) // Nav-Right to open
|
|
|
{
|
|
|
want_open = true;
|