mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 20:24:17 +01:00
Make collection combo mousewheel-scrollable with ctrl.
This commit is contained in:
parent
6e351aa68b
commit
3135d5e7e6
1 changed files with 18 additions and 5 deletions
|
|
@ -1,14 +1,15 @@
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
using OtterGui;
|
||||||
using OtterGui.Raii;
|
using OtterGui.Raii;
|
||||||
|
using OtterGui.Text;
|
||||||
using OtterGui.Widgets;
|
using OtterGui.Widgets;
|
||||||
using Penumbra.Collections;
|
using Penumbra.Collections;
|
||||||
using Penumbra.Collections.Manager;
|
using Penumbra.Collections.Manager;
|
||||||
using Penumbra.GameData.Actors;
|
|
||||||
|
|
||||||
namespace Penumbra.UI.CollectionTab;
|
namespace Penumbra.UI.CollectionTab;
|
||||||
|
|
||||||
public sealed class CollectionCombo(CollectionManager manager, Func<IReadOnlyList<ModCollection>> items)
|
public sealed class CollectionCombo(CollectionManager manager, Func<IReadOnlyList<ModCollection>> items)
|
||||||
: FilterComboCache<ModCollection>(items, MouseWheelType.None, Penumbra.Log)
|
: FilterComboCache<ModCollection>(items, MouseWheelType.Control, Penumbra.Log)
|
||||||
{
|
{
|
||||||
private readonly ImRaii.Color _color = new();
|
private readonly ImRaii.Color _color = new();
|
||||||
|
|
||||||
|
|
@ -20,14 +21,26 @@ public sealed class CollectionCombo(CollectionManager manager, Func<IReadOnlyLis
|
||||||
|
|
||||||
public void Draw(string label, float width, uint color)
|
public void Draw(string label, float width, uint color)
|
||||||
{
|
{
|
||||||
var current = manager.Active.ByType(CollectionType.Current, ActorIdentifier.Invalid);
|
var current = manager.Active.Current;
|
||||||
_color.Push(ImGuiCol.FrameBg, color).Push(ImGuiCol.FrameBgHovered, color);
|
if (current != CurrentSelection)
|
||||||
|
{
|
||||||
|
CurrentSelectionIdx = Items.IndexOf(current);
|
||||||
|
UpdateSelection(current);
|
||||||
|
}
|
||||||
|
|
||||||
if (Draw(label, current?.Name ?? string.Empty, string.Empty, width, ImGui.GetTextLineHeightWithSpacing()) && CurrentSelection != null)
|
_color.Push(ImGuiCol.FrameBg, color).Push(ImGuiCol.FrameBgHovered, color);
|
||||||
|
if (Draw(label, current.Name, string.Empty, width, ImGui.GetTextLineHeightWithSpacing()) && CurrentSelection != null)
|
||||||
manager.Active.SetCollection(CurrentSelection, CollectionType.Current);
|
manager.Active.SetCollection(CurrentSelection, CollectionType.Current);
|
||||||
_color.Dispose();
|
_color.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string ToString(ModCollection obj)
|
protected override string ToString(ModCollection obj)
|
||||||
=> obj.Name;
|
=> obj.Name;
|
||||||
|
|
||||||
|
protected override void DrawCombo(string label, string preview, string tooltip, int currentSelected, float previewWidth, float itemHeight,
|
||||||
|
ImGuiComboFlags flags)
|
||||||
|
{
|
||||||
|
base.DrawCombo(label, preview, tooltip, currentSelected, previewWidth, itemHeight, flags);
|
||||||
|
ImUtf8.HoverTooltip("Control and mouse wheel to scroll."u8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue