diff --git a/src/Menu.cpp b/src/Menu.cpp index 52f8e05c3e..7b5f694465 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -112,6 +112,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( GlobalScale, UseSimplePalette, ShowActionIcons, + TooltipHoverDelay, Palette, StatusPalette, FeatureHeading, @@ -141,6 +142,7 @@ void Menu::SetupImGuiStyle() const styleCopy.ScaleAllSizes(exp2(settings.Theme.GlobalScale)); styleCopy.MouseCursorScale = 1.f; style = styleCopy; + style.HoverDelayNormal = themeSettings.TooltipHoverDelay; if (themeSettings.UseSimplePalette) { float hovoredAlpha{ 0.1f }; @@ -1155,11 +1157,10 @@ void Menu::DrawGeneralSettings() auto shaderCache = globals::shaderCache; auto& themeSettings = settings.Theme; - if (ImGui::CollapsingHeader("General", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) { - bool useCustomShaders = shaderCache->IsEnabled(); - if (ImGui::BeginTable("##GeneralToggles", 3, ImGuiTableFlags_SizingStretchSame)) { - ImGui::TableNextColumn(); - if (ImGui::Checkbox("Enable Shaders", &useCustomShaders)) { + if (ImGui::BeginTabBar("##GeneralTabBar", ImGuiTabBarFlags_None)) { + if (ImGui::BeginTabItem("Shaders")) { + bool useCustomShaders = shaderCache->IsEnabled(); + if (ImGui::Checkbox("Use Custom Shaders", &useCustomShaders)) { shaderCache->SetEnabled(useCustomShaders); } if (auto _tt = Util::HoverTooltipWrapper()) { @@ -1167,9 +1168,6 @@ void Menu::DrawGeneralSettings() } bool useDiskCache = shaderCache->IsDiskCache(); - - ImGui::TableNextColumn(); - if (ImGui::Checkbox("Enable Disk Cache", &useDiskCache)) { shaderCache->SetDiskCache(useDiskCache); } @@ -1178,9 +1176,6 @@ void Menu::DrawGeneralSettings() } bool useAsync = shaderCache->IsAsync(); - - ImGui::TableNextColumn(); - if (ImGui::Checkbox("Enable Async", &useAsync)) { shaderCache->SetAsync(useAsync); } @@ -1188,178 +1183,184 @@ void Menu::DrawGeneralSettings() ImGui::Text("Skips a shader being replaced if it hasn't been compiled yet. Also makes compilation blazingly fast!"); } - ImGui::EndTable(); + ImGui::EndTabItem(); } - } - - if (ImGui::CollapsingHeader("Keybindings", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) { - if (settingToggleKey) { - ImGui::Text("Press any key to set as toggle key..."); - } else { - ImGui::AlignTextToFramePadding(); - ImGui::Text("Toggle Key:"); - ImGui::SameLine(); - ImGui::AlignTextToFramePadding(); - ImGui::TextColored(themeSettings.StatusPalette.CurrentHotkey, "%s", KeyIdToString(settings.ToggleKey)); + if (ImGui::BeginTabItem("Keybindings")) { + if (settingToggleKey) { + ImGui::Text("Press any key to set as toggle key..."); + } else { + ImGui::AlignTextToFramePadding(); + ImGui::Text("Toggle Key:"); + ImGui::SameLine(); + ImGui::AlignTextToFramePadding(); + ImGui::TextColored(themeSettings.StatusPalette.CurrentHotkey, "%s", KeyIdToString(settings.ToggleKey)); - ImGui::AlignTextToFramePadding(); - ImGui::SameLine(); - if (ImGui::Button("Change##toggle")) { - settingToggleKey = true; + ImGui::AlignTextToFramePadding(); + ImGui::SameLine(); + if (ImGui::Button("Change##toggle")) { + settingToggleKey = true; + } } - } - if (settingsEffectsToggle) { - ImGui::Text("Press any key to set as a toggle key for all effects..."); - } else { - ImGui::AlignTextToFramePadding(); - ImGui::Text("Effect Toggle Key:"); - ImGui::SameLine(); - ImGui::AlignTextToFramePadding(); - ImGui::TextColored(themeSettings.StatusPalette.CurrentHotkey, "%s", KeyIdToString(settings.EffectToggleKey)); + if (settingsEffectsToggle) { + ImGui::Text("Press any key to set as a toggle key for all effects..."); + } else { + ImGui::AlignTextToFramePadding(); + ImGui::Text("Effect Toggle Key:"); + ImGui::SameLine(); + ImGui::AlignTextToFramePadding(); + ImGui::TextColored(themeSettings.StatusPalette.CurrentHotkey, "%s", KeyIdToString(settings.EffectToggleKey)); - ImGui::AlignTextToFramePadding(); - ImGui::SameLine(); - if (ImGui::Button("Change##EffectToggle")) { - settingsEffectsToggle = true; + ImGui::AlignTextToFramePadding(); + ImGui::SameLine(); + if (ImGui::Button("Change##EffectToggle")) { + settingsEffectsToggle = true; + } } - } - if (settingSkipCompilationKey) { - ImGui::Text("Press any key to set as Skip Compilation Key..."); - } else { - ImGui::AlignTextToFramePadding(); - ImGui::Text("Skip Compilation Key:"); - ImGui::SameLine(); - ImGui::AlignTextToFramePadding(); - ImGui::TextColored(themeSettings.StatusPalette.CurrentHotkey, "%s", KeyIdToString(settings.SkipCompilationKey)); + if (settingSkipCompilationKey) { + ImGui::Text("Press any key to set as Skip Compilation Key..."); + } else { + ImGui::AlignTextToFramePadding(); + ImGui::Text("Skip Compilation Key:"); + ImGui::SameLine(); + ImGui::AlignTextToFramePadding(); + ImGui::TextColored(themeSettings.StatusPalette.CurrentHotkey, "%s", KeyIdToString(settings.SkipCompilationKey)); - ImGui::AlignTextToFramePadding(); - ImGui::SameLine(); - if (ImGui::Button("Change##skip")) { - settingSkipCompilationKey = true; + ImGui::AlignTextToFramePadding(); + ImGui::SameLine(); + if (ImGui::Button("Change##skip")) { + settingSkipCompilationKey = true; + } } + ImGui::EndTabItem(); } - } + if (ImGui::BeginTabItem("Interface")) { + auto& style = themeSettings.Style; + auto& colors = themeSettings.FullPalette; - if (ImGui::CollapsingHeader("Theme", ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) { - auto& style = themeSettings.Style; - auto& colors = themeSettings.FullPalette; + if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None)) { + if (ImGui::BeginTabItem("UI Options")) { + if (ImGui::SliderFloat("Global Scale", &themeSettings.GlobalScale, -1.f, 1.f, "%.2f")) { + float trueScale = exp2(themeSettings.GlobalScale); - if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None)) { - if (ImGui::BeginTabItem("UI Options")) { - if (ImGui::SliderFloat("Global Scale", &themeSettings.GlobalScale, -1.f, 1.f, "%.2f")) { - float trueScale = exp2(themeSettings.GlobalScale); + auto& io = ImGui::GetIO(); + io.FontGlobalScale = trueScale; + } - auto& io = ImGui::GetIO(); - io.FontGlobalScale = trueScale; - } + ImGui::SeparatorText("UI Elements"); + ImGui::Checkbox("Use Icon Buttons in Header", &themeSettings.ShowActionIcons); + if (auto _tt = Util::HoverTooltipWrapper()) { + ImGui::Text( + "When enabled: Shows action buttons (Save, Load, Clear Cache, Clear Disk Cache) as icons in the header\n" + "When disabled: Shows as text buttons below the header"); + } - ImGui::SeparatorText("UI Elements"); - ImGui::Checkbox("Use Icon Buttons in Header", &themeSettings.ShowActionIcons); - if (auto _tt = Util::HoverTooltipWrapper()) { - ImGui::Text( - "When enabled: Shows action buttons (Save, Load, Clear Cache, Clear Disk Cache) as icons in the header\n" - "When disabled: Shows as text buttons below the header"); - } + ImGui::SliderFloat("Tooltip Hover Delay", &themeSettings.TooltipHoverDelay, 0.0f, 2.0f, "%.2f s", ImGuiSliderFlags_AlwaysClamp); + if (auto _tt = Util::HoverTooltipWrapper()) { + ImGui::TextUnformatted("Time in seconds to wait before a tooltip appears when hovering over an item."); + } - ImGui::EndTabItem(); - } + ImGui::EndTabItem(); + } - if (ImGui::BeginTabItem("Sizes")) { - ImGui::SeparatorText("Main"); - ImGui::SliderFloat2("Window Padding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("Frame Padding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("Item Spacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("Item Inner Spacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat("Indent Spacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f"); - ImGui::SliderFloat("Scrollbar Size", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); - ImGui::SliderFloat("Grab Min Size", &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); - - ImGui::SeparatorText("Borders"); - ImGui::SliderFloat("Window Border Size", &style.WindowBorderSize, 0.0f, 5.0f, "%.0f"); - ImGui::SliderFloat("Child Border Size", &style.ChildBorderSize, 0.0f, 5.0f, "%.0f"); - ImGui::SliderFloat("Popup Border Size", &style.PopupBorderSize, 0.0f, 5.0f, "%.0f"); - ImGui::SliderFloat("Frame Border Size", &style.FrameBorderSize, 0.0f, 5.0f, "%.0f"); - ImGui::SliderFloat("Tab Border Size", &style.TabBorderSize, 0.0f, 5.0f, "%.0f"); - ImGui::SliderFloat("Tab Bar Border Size", &style.TabBarBorderSize, 0.0f, 5.0f, "%.0f"); - - ImGui::SeparatorText("Rounding"); - ImGui::SliderFloat("Window Rounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("Child Rounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("Frame Rounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("Popup Rounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("Scrollbar Rounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("Grab Rounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("Tab Rounding", &style.TabRounding, 0.0f, 12.0f, "%.0f"); - - ImGui::SeparatorText("Tables"); - ImGui::SliderFloat2("Cell Padding", (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderAngle("Table Angled Headers Angle", &style.TableAngledHeadersAngle, -50.0f, +50.0f); - - ImGui::SeparatorText("Widgets"); - ImGui::Combo("ColorButtonPosition", (int*)&style.ColorButtonPosition, "Left\0Right\0"); - ImGui::SliderFloat2("Button Text Align", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); - if (auto _tt = Util::HoverTooltipWrapper()) - ImGui::Text("Alignment applies when a button is larger than its text content."); - ImGui::SliderFloat2("Selectable Text Align", (float*)&style.SelectableTextAlign, 0.0f, 1.0f, "%.2f"); - if (auto _tt = Util::HoverTooltipWrapper()) - ImGui::Text("Alignment applies when a selectable is larger than its text content."); - ImGui::SliderFloat("Separator Text Border Size", &style.SeparatorTextBorderSize, 0.0f, 10.0f, "%.0f"); - ImGui::SliderFloat2("Separator Text Align", (float*)&style.SeparatorTextAlign, 0.0f, 1.0f, "%.2f"); - ImGui::SliderFloat2("Separator Text Padding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f"); - ImGui::SliderFloat("Log Slider Deadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f"); - - ImGui::SeparatorText("Docking"); - ImGui::SliderFloat("Docking Splitter Size", &style.DockingSeparatorSize, 0.0f, 12.0f, "%.0f"); - - ImGui::EndTabItem(); - } + if (ImGui::BeginTabItem("Sizes")) { + ImGui::SeparatorText("Main"); + ImGui::SliderFloat2("Window Padding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2("Frame Padding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2("Item Spacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat2("Item Inner Spacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); + ImGui::SliderFloat("Indent Spacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f"); + ImGui::SliderFloat("Scrollbar Size", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); + ImGui::SliderFloat("Grab Min Size", &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); + + ImGui::SeparatorText("Borders"); + ImGui::SliderFloat("Window Border Size", &style.WindowBorderSize, 0.0f, 5.0f, "%.0f"); + ImGui::SliderFloat("Child Border Size", &style.ChildBorderSize, 0.0f, 5.0f, "%.0f"); + ImGui::SliderFloat("Popup Border Size", &style.PopupBorderSize, 0.0f, 5.0f, "%.0f"); + ImGui::SliderFloat("Frame Border Size", &style.FrameBorderSize, 0.0f, 5.0f, "%.0f"); + ImGui::SliderFloat("Tab Border Size", &style.TabBorderSize, 0.0f, 5.0f, "%.0f"); + ImGui::SliderFloat("Tab Bar Border Size", &style.TabBarBorderSize, 0.0f, 5.0f, "%.0f"); + + ImGui::SeparatorText("Rounding"); + ImGui::SliderFloat("Window Rounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("Child Rounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("Frame Rounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("Popup Rounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("Scrollbar Rounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("Grab Rounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("Tab Rounding", &style.TabRounding, 0.0f, 12.0f, "%.0f"); + + ImGui::SeparatorText("Tables"); + ImGui::SliderFloat2("Cell Padding", (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderAngle("Table Angled Headers Angle", &style.TableAngledHeadersAngle, -50.0f, +50.0f); + + ImGui::SeparatorText("Widgets"); + ImGui::Combo("ColorButtonPosition", (int*)&style.ColorButtonPosition, "Left\0Right\0"); + ImGui::SliderFloat2("Button Text Align", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); + if (auto _tt = Util::HoverTooltipWrapper()) + ImGui::Text("Alignment applies when a button is larger than its text content."); + ImGui::SliderFloat2("Selectable Text Align", (float*)&style.SelectableTextAlign, 0.0f, 1.0f, "%.2f"); + if (auto _tt = Util::HoverTooltipWrapper()) + ImGui::Text("Alignment applies when a selectable is larger than its text content."); + ImGui::SliderFloat("Separator Text Border Size", &style.SeparatorTextBorderSize, 0.0f, 10.0f, "%.0f"); + ImGui::SliderFloat2("Separator Text Align", (float*)&style.SeparatorTextAlign, 0.0f, 1.0f, "%.2f"); + ImGui::SliderFloat2("Separator Text Padding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f"); + ImGui::SliderFloat("Log Slider Deadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f"); + + ImGui::SeparatorText("Docking"); + ImGui::SliderFloat("Docking Splitter Size", &style.DockingSeparatorSize, 0.0f, 12.0f, "%.0f"); + + ImGui::EndTabItem(); + } - if (ImGui::BeginTabItem("Colors")) { - ImGui::SeparatorText("Status"); + if (ImGui::BeginTabItem("Colors")) { + ImGui::SeparatorText("Status"); - ImGui::ColorEdit4("Disabled Text", (float*)&themeSettings.StatusPalette.Disable); - ImGui::ColorEdit4("Error Text", (float*)&themeSettings.StatusPalette.Error); - ImGui::ColorEdit4("Warning Text", (float*)&themeSettings.StatusPalette.Warning); - ImGui::ColorEdit4("Restart Needed Text", (float*)&themeSettings.StatusPalette.RestartNeeded); - ImGui::ColorEdit4("Current Hotkey Text", (float*)&themeSettings.StatusPalette.CurrentHotkey); - ImGui::ColorEdit4("Success Text", (float*)&themeSettings.StatusPalette.SuccessColor); - ImGui::ColorEdit4("Info Text", (float*)&themeSettings.StatusPalette.InfoColor); + ImGui::ColorEdit4("Disabled Text", (float*)&themeSettings.StatusPalette.Disable); + ImGui::ColorEdit4("Error Text", (float*)&themeSettings.StatusPalette.Error); + ImGui::ColorEdit4("Warning Text", (float*)&themeSettings.StatusPalette.Warning); + ImGui::ColorEdit4("Restart Needed Text", (float*)&themeSettings.StatusPalette.RestartNeeded); + ImGui::ColorEdit4("Current Hotkey Text", (float*)&themeSettings.StatusPalette.CurrentHotkey); + ImGui::ColorEdit4("Success Text", (float*)&themeSettings.StatusPalette.SuccessColor); + ImGui::ColorEdit4("Info Text", (float*)&themeSettings.StatusPalette.InfoColor); - ImGui::SeparatorText("Feature Headings"); + ImGui::SeparatorText("Feature Headings"); - ImGui::ColorEdit4("Regular", (float*)&themeSettings.FeatureHeading.ColorDefault); - ImGui::ColorEdit4("Hovered", (float*)&themeSettings.FeatureHeading.ColorHovered); - ImGui::SliderFloat("Minimized Alpha Factor", &themeSettings.FeatureHeading.MinimizedFactor, 0.0f, 1.0f, "%.2f"); + ImGui::ColorEdit4("Regular", (float*)&themeSettings.FeatureHeading.ColorDefault); + ImGui::ColorEdit4("Hovered", (float*)&themeSettings.FeatureHeading.ColorHovered); + ImGui::SliderFloat("Minimized Alpha Factor", &themeSettings.FeatureHeading.MinimizedFactor, 0.0f, 1.0f, "%.2f"); - ImGui::SeparatorText("Palette"); + ImGui::SeparatorText("Palette"); - if (ImGui::RadioButton("Simple Palette", themeSettings.UseSimplePalette)) - themeSettings.UseSimplePalette = true; - ImGui::SameLine(); - if (ImGui::RadioButton("Full Palette", !themeSettings.UseSimplePalette)) - themeSettings.UseSimplePalette = false; + if (ImGui::RadioButton("Simple Palette", themeSettings.UseSimplePalette)) + themeSettings.UseSimplePalette = true; + ImGui::SameLine(); + if (ImGui::RadioButton("Full Palette", !themeSettings.UseSimplePalette)) + themeSettings.UseSimplePalette = false; - if (themeSettings.UseSimplePalette) { - ImGui::ColorEdit4("Background", (float*)&themeSettings.Palette.Background); - ImGui::ColorEdit4("Text", (float*)&themeSettings.Palette.Text); - ImGui::ColorEdit4("Border", (float*)&themeSettings.Palette.Border); - } else { - static ImGuiTextFilter filter; - filter.Draw("Filter colors", ImGui::GetFontSize() * 16); - - for (int i = 0; i < ImGuiCol_COUNT; i++) { - const char* name = ImGui::GetStyleColorName(i); - if (!filter.PassFilter(name)) - continue; - ImGui::ColorEdit4(name, (float*)&colors[i], ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_AlphaPreviewHalf); + if (themeSettings.UseSimplePalette) { + ImGui::ColorEdit4("Background", (float*)&themeSettings.Palette.Background); + ImGui::ColorEdit4("Text", (float*)&themeSettings.Palette.Text); + ImGui::ColorEdit4("Border", (float*)&themeSettings.Palette.Border); + } else { + static ImGuiTextFilter filter; + filter.Draw("Filter colors", ImGui::GetFontSize() * 16); + + for (int i = 0; i < ImGuiCol_COUNT; i++) { + const char* name = ImGui::GetStyleColorName(i); + if (!filter.PassFilter(name)) + continue; + ImGui::ColorEdit4(name, (float*)&colors[i], ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_AlphaPreviewHalf); + } } + + ImGui::EndTabItem(); } - ImGui::EndTabItem(); + ImGui::EndTabBar(); } - - ImGui::EndTabBar(); + ImGui::EndTabItem(); } + ImGui::EndTabBar(); } } diff --git a/src/Menu.h b/src/Menu.h index e78a47f14f..22ed36b547 100644 --- a/src/Menu.h +++ b/src/Menu.h @@ -79,8 +79,9 @@ class Menu { float GlobalScale = REL::Module::IsVR() ? -0.5f : 0.f; // exponential - bool UseSimplePalette = true; // simple palette or full customization - bool ShowActionIcons = true; // whether to show action buttons as icons + bool UseSimplePalette = true; // simple palette or full customization + bool ShowActionIcons = true; // whether to show action buttons as icons + float TooltipHoverDelay = 0.5f; // tooltip hover delay in seconds struct PaletteColors { ImVec4 Background{ 0.f, 0.f, 0.f, 0.5882353186607361f }; diff --git a/src/Utils/UI.cpp b/src/Utils/UI.cpp index d1fd318b56..19621c5b34 100644 --- a/src/Utils/UI.cpp +++ b/src/Utils/UI.cpp @@ -22,7 +22,7 @@ namespace Util HoverTooltipWrapper::HoverTooltipWrapper() { - hovered = ImGui::IsItemHovered(); + hovered = ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal); if (hovered) { ImGui::BeginTooltip(); ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);