mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Make design selector resizable.
This commit is contained in:
parent
081ac6bf8b
commit
aa1ac29182
3 changed files with 29 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue