Make design selector resizable.

This commit is contained in:
Ottermandias 2025-05-21 17:16:55 +02:00
parent 081ac6bf8b
commit aa1ac29182
3 changed files with 29 additions and 4 deletions

View file

@ -20,6 +20,10 @@ public class EphemeralConfig : ISavable
public Guid SelectedQuickDesign { get; set; } = Guid.Empty;
public int LastSeenVersion { get; set; } = GlamourerChangelog.LastChangelogVersion;
public float CurrentDesignSelectorWidth { get; set; } = 200f;
public float DesignSelectorMinimumScale { get; set; } = 0.1f;
public float DesignSelectorMaximumScale { get; set; } = 0.5f;
[JsonIgnore]
private readonly SaveService _saveService;

View file

@ -12,6 +12,7 @@ using OtterGui.Filesystem;
using OtterGui.FileSystem.Selector;
using OtterGui.Log;
using OtterGui.Raii;
using OtterGui.Text;
namespace Glamourer.Gui.Tabs.DesignTab;
@ -45,6 +46,29 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
public record struct DesignState(uint Color)
{ }
protected override float CurrentWidth
=> _config.Ephemeral.CurrentDesignSelectorWidth * ImUtf8.GlobalScale;
protected override float MinimumAbsoluteRemainder
=> 470 * ImUtf8.GlobalScale;
protected override float MinimumScaling
=> _config.Ephemeral.DesignSelectorMinimumScale;
protected override float MaximumScaling
=> _config.Ephemeral.DesignSelectorMaximumScale;
protected override void SetSize(Vector2 size)
{
base.SetSize(size);
var adaptedSize = MathF.Round(size.X / ImUtf8.GlobalScale);
if (adaptedSize == _config.Ephemeral.CurrentDesignSelectorWidth)
return;
_config.Ephemeral.CurrentDesignSelectorWidth = adaptedSize;
_config.Ephemeral.Save();
}
public DesignFileSystemSelector(DesignManager designManager, DesignFileSystem fileSystem, IKeyState keyState, DesignChanged @event,
Configuration config, DesignConverter converter, TabSelected selectionEvent, Logger log, DesignColors designColors,
DesignApplier designApplier)

View file

@ -16,7 +16,7 @@ public class DesignTab(DesignFileSystemSelector _selector, DesignPanel _panel, I
public void DrawContent()
{
_selector.Draw(GetDesignSelectorSize());
_selector.Draw();
if (_importService.CreateCharaTarget(out var designBase, out var name))
{
var newDesign = _manager.CreateClone(designBase, name, true);
@ -27,7 +27,4 @@ public class DesignTab(DesignFileSystemSelector _selector, DesignPanel _panel, I
_panel.Draw();
_importService.CreateCharaSource();
}
public float GetDesignSelectorSize()
=> 200f * ImGuiHelpers.GlobalScale;
}