mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-09 23:54:20 +00:00
Demo: tweaked ShowFontSelector() and ShowStyleSelector() to update selection while navigating and to not close popup automatically.
This commit is contained in:
parent
8e4955bb23
commit
045645e5f1
3 changed files with 20 additions and 10 deletions
|
|
@ -80,6 +80,8 @@ Other Changes:
|
||||||
is now skipped. (#8904, #4631)
|
is now skipped. (#8904, #4631)
|
||||||
- Debug Tools: ID Stack Tool: added option to hex-encode non-ASCII characters in
|
- Debug Tools: ID Stack Tool: added option to hex-encode non-ASCII characters in
|
||||||
output path. (#8904, #4631)
|
output path. (#8904, #4631)
|
||||||
|
- Demo: tweaked ShowFontSelector() and ShowStyleSelector() to update selection
|
||||||
|
while navigating and to not close popup automatically.
|
||||||
- Examples: Android: Android+OpenGL3: update Gradle project (#8888, #8878) [@scribam]
|
- Examples: Android: Android+OpenGL3: update Gradle project (#8888, #8878) [@scribam]
|
||||||
- Backends: SDL_GPU: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and
|
- Backends: SDL_GPU: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and
|
||||||
PresentMode to configure how secondary viewports are created. Currently only used
|
PresentMode to configure how secondary viewports are created. Currently only used
|
||||||
|
|
|
||||||
|
|
@ -17873,7 +17873,7 @@ void ImGui::ShowFontSelector(const char* label)
|
||||||
for (ImFont* font : io.Fonts->Fonts)
|
for (ImFont* font : io.Fonts->Fonts)
|
||||||
{
|
{
|
||||||
PushID((void*)font);
|
PushID((void*)font);
|
||||||
if (Selectable(font->GetDebugName(), font == font_current))
|
if (Selectable(font->GetDebugName(), font == font_current, ImGuiSelectableFlags_SelectOnNav | ImGuiSelectableFlags_NoAutoClosePopups))
|
||||||
io.FontDefault = font;
|
io.FontDefault = font;
|
||||||
if (font == font_current)
|
if (font == font_current)
|
||||||
SetItemDefaultFocus();
|
SetItemDefaultFocus();
|
||||||
|
|
|
||||||
|
|
@ -8229,17 +8229,25 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
||||||
bool ImGui::ShowStyleSelector(const char* label)
|
bool ImGui::ShowStyleSelector(const char* label)
|
||||||
{
|
{
|
||||||
static int style_idx = -1;
|
static int style_idx = -1;
|
||||||
if (ImGui::Combo(label, &style_idx, "Dark\0Light\0Classic\0"))
|
const char* style_names[] = { "Dark", "Light", "Classic" };
|
||||||
|
bool ret = false;
|
||||||
|
if (ImGui::BeginCombo(label, (style_idx >= 0 && style_idx < IM_ARRAYSIZE(style_names)) ? style_names[style_idx] : ""))
|
||||||
{
|
{
|
||||||
switch (style_idx)
|
for (int n = 0; n < IM_ARRAYSIZE(style_names); n++)
|
||||||
{
|
if (ImGui::Selectable(style_names[n], style_idx == n, ImGuiSelectableFlags_SelectOnNav | ImGuiSelectableFlags_NoAutoClosePopups))
|
||||||
case 0: ImGui::StyleColorsDark(); break;
|
{
|
||||||
case 1: ImGui::StyleColorsLight(); break;
|
style_idx = n;
|
||||||
case 2: ImGui::StyleColorsClassic(); break;
|
ret = true;
|
||||||
}
|
switch (style_idx)
|
||||||
return true;
|
{
|
||||||
|
case 0: ImGui::StyleColorsDark(); break;
|
||||||
|
case 1: ImGui::StyleColorsLight(); break;
|
||||||
|
case 2: ImGui::StyleColorsClassic(); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
return false;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* GetTreeLinesFlagsName(ImGuiTreeNodeFlags flags)
|
static const char* GetTreeLinesFlagsName(ImGuiTreeNodeFlags flags)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue