mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
ColorPicker4: Use nav flag to provide a slighly better experience when using navigation (#787, #346)
This commit is contained in:
parent
7c2926de17
commit
df366b230e
10
imgui.cpp
10
imgui.cpp
@ -6648,7 +6648,8 @@ bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags
|
|||||||
if (!ItemAdd(bb, &id))
|
if (!ItemAdd(bb, &id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat) flags |= ImGuiButtonFlags_Repeat;
|
if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat)
|
||||||
|
flags |= ImGuiButtonFlags_Repeat;
|
||||||
bool hovered, held;
|
bool hovered, held;
|
||||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
|
bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
|
||||||
|
|
||||||
@ -10598,6 +10599,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
|
|
||||||
bool value_changed = false, value_changed_h = false, value_changed_sv = false;
|
bool value_changed = false, value_changed_h = false, value_changed_sv = false;
|
||||||
|
|
||||||
|
PushItemFlag(ImGuiItemFlags_NoNav, true);
|
||||||
if (flags & ImGuiColorEditFlags_PickerHueWheel)
|
if (flags & ImGuiColorEditFlags_PickerHueWheel)
|
||||||
{
|
{
|
||||||
// Hue wheel + SV triangle logic
|
// Hue wheel + SV triangle logic
|
||||||
@ -10655,10 +10657,9 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
value_changed = value_changed_h = true;
|
value_changed = value_changed_h = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alpha bar logic
|
|
||||||
if (alpha_bar)
|
if (alpha_bar)
|
||||||
{
|
{
|
||||||
|
// Alpha bar logic
|
||||||
SetCursorScreenPos(ImVec2(bar1_pos_x, picker_pos.y));
|
SetCursorScreenPos(ImVec2(bar1_pos_x, picker_pos.y));
|
||||||
InvisibleButton("alpha", ImVec2(bars_width, sv_picker_size));
|
InvisibleButton("alpha", ImVec2(bars_width, sv_picker_size));
|
||||||
if (IsItemActive())
|
if (IsItemActive())
|
||||||
@ -10667,6 +10668,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
value_changed = true;
|
value_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PopItemFlag(); // ImGuiItemFlags_NoNav
|
||||||
|
|
||||||
if (!(flags & ImGuiColorEditFlags_NoSidePreview))
|
if (!(flags & ImGuiColorEditFlags_NoSidePreview))
|
||||||
{
|
{
|
||||||
@ -10687,6 +10689,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
|
|
||||||
if (!(flags & ImGuiColorEditFlags_NoSidePreview))
|
if (!(flags & ImGuiColorEditFlags_NoSidePreview))
|
||||||
{
|
{
|
||||||
|
PushItemFlag(ImGuiItemFlags_NoNavDefaultFocus, true);
|
||||||
ImVec4 col_v4(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]);
|
ImVec4 col_v4(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]);
|
||||||
if ((flags & ImGuiColorEditFlags_NoLabel))
|
if ((flags & ImGuiColorEditFlags_NoLabel))
|
||||||
Text("Current");
|
Text("Current");
|
||||||
@ -10701,6 +10704,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
value_changed = true;
|
value_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PopItemFlag();
|
||||||
EndGroup();
|
EndGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ enum ImGuiButtonFlags_
|
|||||||
ImGuiButtonFlags_FlattenChilds = 1 << 5, // allow interactions even if a child window is overlapping
|
ImGuiButtonFlags_FlattenChilds = 1 << 5, // allow interactions even if a child window is overlapping
|
||||||
ImGuiButtonFlags_DontClosePopups = 1 << 6, // disable automatically closing parent popup on press // [UNUSED]
|
ImGuiButtonFlags_DontClosePopups = 1 << 6, // disable automatically closing parent popup on press // [UNUSED]
|
||||||
ImGuiButtonFlags_Disabled = 1 << 7, // disable interactions
|
ImGuiButtonFlags_Disabled = 1 << 7, // disable interactions
|
||||||
ImGuiButtonFlags_AlignTextBaseLine = 1 << 8, // vertically align button to match text baseline - ButtonEx() only
|
ImGuiButtonFlags_AlignTextBaseLine = 1 << 8, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled SmallButton(), not possible currently because of DC.CursorPosPrevLine
|
||||||
ImGuiButtonFlags_NoKeyModifiers = 1 << 9, // disable interaction if a key modifier is held
|
ImGuiButtonFlags_NoKeyModifiers = 1 << 9, // disable interaction if a key modifier is held
|
||||||
ImGuiButtonFlags_AllowOverlapMode = 1 << 10, // require previous frame HoveredId to either match id or be null before being usable
|
ImGuiButtonFlags_AllowOverlapMode = 1 << 10, // require previous frame HoveredId to either match id or be null before being usable
|
||||||
ImGuiButtonFlags_NoNavOverride = 1 << 11 // don't override navigation id when activated
|
ImGuiButtonFlags_NoNavOverride = 1 << 11 // don't override navigation id when activated
|
||||||
|
Loading…
Reference in New Issue
Block a user