Button size schenanigans
This commit is contained in:
@@ -9,6 +9,9 @@ namespace Craftimizer.Plugin;
|
|||||||
|
|
||||||
internal static class ImGuiUtils
|
internal static class ImGuiUtils
|
||||||
{
|
{
|
||||||
|
public static float ButtonHeight =>
|
||||||
|
ImGui.CalcTextSize("A").Y + (ImGui.GetStyle().FramePadding.Y * 2);
|
||||||
|
|
||||||
private static readonly Stack<(Vector2 Min, Vector2 Max)> GroupPanelLabelStack = new();
|
private static readonly Stack<(Vector2 Min, Vector2 Max)> GroupPanelLabelStack = new();
|
||||||
|
|
||||||
// Adapted from https://github.com/ocornut/imgui/issues/1496#issuecomment-655048353
|
// Adapted from https://github.com/ocornut/imgui/issues/1496#issuecomment-655048353
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Craftimizer.Plugin.Utils;
|
using Craftimizer.Plugin.Utils;
|
||||||
using Craftimizer.Utils;
|
using Craftimizer.Utils;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
|
using Dalamud.Interface.Components;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
@@ -17,7 +18,9 @@ public sealed unsafe partial class Craft : Window, IDisposable
|
|||||||
| ImGuiWindowFlags.NoFocusOnAppearing
|
| ImGuiWindowFlags.NoFocusOnAppearing
|
||||||
| ImGuiWindowFlags.NoNavFocus;
|
| ImGuiWindowFlags.NoNavFocus;
|
||||||
|
|
||||||
public static readonly Vector2 CraftProgressBarSize = new(300, 15);
|
private const float WindowWidth = 300;
|
||||||
|
private const int ActionsPerRow = 5;
|
||||||
|
private static readonly Vector2 CraftProgressBarSize = new(WindowWidth, 15);
|
||||||
|
|
||||||
private static Configuration Config => Service.Configuration;
|
private static Configuration Config => Service.Configuration;
|
||||||
|
|
||||||
@@ -50,18 +53,23 @@ public sealed unsafe partial class Craft : Window, IDisposable
|
|||||||
|
|
||||||
ImGuiHelpers.ScaledDummy(5);
|
ImGuiHelpers.ScaledDummy(5);
|
||||||
|
|
||||||
|
ImGui.PushFont(UiBuilder.IconFont);
|
||||||
|
var cogWidth = ImGui.CalcTextSize(FontAwesomeIcon.Cog.ToIconString()).X;
|
||||||
|
ImGui.PopFont();
|
||||||
|
|
||||||
ImGui.BeginDisabled(!(SolverTask?.IsCompleted ?? true));
|
ImGui.BeginDisabled(!(SolverTask?.IsCompleted ?? true));
|
||||||
if (ImGui.Button("Retry"))
|
if (ImGui.Button("Retry", new(WindowWidth - ImGui.GetStyle().ItemSpacing.X - cogWidth, ImGuiUtils.ButtonHeight)))
|
||||||
QueueSolve(GetNextState()!.Value);
|
QueueSolve(GetNextState()!.Value);
|
||||||
ImGui.EndDisabled();
|
ImGui.EndDisabled();
|
||||||
|
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (ImGuiComponents.IconButton("synthSettingsButton", FontAwesomeIcon.Cog))
|
||||||
|
Service.Plugin.OpenSettingsWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawActions()
|
private void DrawActions()
|
||||||
{
|
{
|
||||||
var totalWidth = 300f;
|
var actionSize = new Vector2((WindowWidth / ActionsPerRow) - (ImGui.GetStyle().ItemSpacing.X * ((ActionsPerRow - 1f) / ActionsPerRow)));
|
||||||
var actionsPerRow = 5;
|
|
||||||
|
|
||||||
var actionSize = new Vector2((totalWidth / actionsPerRow) - (ImGui.GetStyle().ItemSpacing.X * ((actionsPerRow - 1f) / actionsPerRow)));
|
|
||||||
ImGui.PushStyleColor(ImGuiCol.Button, Vector4.Zero);
|
ImGui.PushStyleColor(ImGuiCol.Button, Vector4.Zero);
|
||||||
ImGui.PushStyleColor(ImGuiCol.ButtonActive, Vector4.Zero);
|
ImGui.PushStyleColor(ImGuiCol.ButtonActive, Vector4.Zero);
|
||||||
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, Vector4.Zero);
|
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, Vector4.Zero);
|
||||||
@@ -87,7 +95,7 @@ public sealed unsafe partial class Craft : Window, IDisposable
|
|||||||
ImGui.EndTooltip();
|
ImGui.EndTooltip();
|
||||||
}
|
}
|
||||||
ImGui.PopID();
|
ImGui.PopID();
|
||||||
if (i % actionsPerRow != (actionsPerRow - 1))
|
if (i % ActionsPerRow != (ActionsPerRow - 1))
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ public class Settings : Window
|
|||||||
{
|
{
|
||||||
private static Configuration Config => Service.Configuration;
|
private static Configuration Config => Service.Configuration;
|
||||||
|
|
||||||
|
private const int OptionWidth = 200;
|
||||||
|
private static Vector2 OptionButtonSize => new(OptionWidth, ImGuiUtils.ButtonHeight);
|
||||||
|
|
||||||
public Settings() : base("Craftimizer Settings")
|
public Settings() : base("Craftimizer Settings")
|
||||||
{
|
{
|
||||||
Service.WindowSystem.AddWindow(this);
|
Service.WindowSystem.AddWindow(this);
|
||||||
@@ -37,7 +40,7 @@ public class Settings : Window
|
|||||||
|
|
||||||
private static void DrawOption(string label, string tooltip, int val, Action<int> setter, ref bool isDirty)
|
private static void DrawOption(string label, string tooltip, int val, Action<int> setter, ref bool isDirty)
|
||||||
{
|
{
|
||||||
ImGui.SetNextItemWidth(200);
|
ImGui.SetNextItemWidth(OptionWidth);
|
||||||
if (ImGui.InputInt(label, ref val))
|
if (ImGui.InputInt(label, ref val))
|
||||||
{
|
{
|
||||||
setter(val);
|
setter(val);
|
||||||
@@ -49,7 +52,7 @@ public class Settings : Window
|
|||||||
|
|
||||||
private static void DrawOption(string label, string tooltip, float val, Action<float> setter, ref bool isDirty)
|
private static void DrawOption(string label, string tooltip, float val, Action<float> setter, ref bool isDirty)
|
||||||
{
|
{
|
||||||
ImGui.SetNextItemWidth(200);
|
ImGui.SetNextItemWidth(OptionWidth);
|
||||||
if (ImGui.InputFloat(label, ref val))
|
if (ImGui.InputFloat(label, ref val))
|
||||||
{
|
{
|
||||||
setter(val);
|
setter(val);
|
||||||
@@ -137,14 +140,13 @@ public class Settings : Window
|
|||||||
|
|
||||||
ImGuiUtils.BeginGroupPanel("General");
|
ImGuiUtils.BeginGroupPanel("General");
|
||||||
|
|
||||||
ImGui.SetNextItemWidth(200);
|
if (ImGui.Button("Reset to Default", OptionButtonSize))
|
||||||
if (ImGui.Button("Reset to Default"))
|
|
||||||
{
|
{
|
||||||
config = defaultConfig;
|
config = defaultConfig;
|
||||||
isDirty = true;
|
isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SetNextItemWidth(200);
|
ImGui.SetNextItemWidth(OptionWidth);
|
||||||
if (ImGui.BeginCombo("Algorithm", GetAlgorithmName(config.Algorithm)))
|
if (ImGui.BeginCombo("Algorithm", GetAlgorithmName(config.Algorithm)))
|
||||||
{
|
{
|
||||||
foreach (var alg in Enum.GetValues<SolverAlgorithm>())
|
foreach (var alg in Enum.GetValues<SolverAlgorithm>())
|
||||||
@@ -321,8 +323,7 @@ public class Settings : Window
|
|||||||
ref isDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
ImGui.SetNextItemWidth(200);
|
if (ImGui.Button("Normalize Weights", OptionButtonSize))
|
||||||
if (ImGui.Button("Normalize Weights"))
|
|
||||||
{
|
{
|
||||||
var total = config.ScoreProgressBonus +
|
var total = config.ScoreProgressBonus +
|
||||||
config.ScoreQualityBonus +
|
config.ScoreQualityBonus +
|
||||||
|
|||||||
@@ -309,8 +309,8 @@ public sealed partial class Simulator : Window, IDisposable
|
|||||||
var totalWidth = drawParams.Total;
|
var totalWidth = drawParams.Total;
|
||||||
var halfWidth = (totalWidth - ImGui.GetStyle().ItemSpacing.X) / 2f;
|
var halfWidth = (totalWidth - ImGui.GetStyle().ItemSpacing.X) / 2f;
|
||||||
var quarterWidth = (halfWidth - ImGui.GetStyle().ItemSpacing.X) / 2f;
|
var quarterWidth = (halfWidth - ImGui.GetStyle().ItemSpacing.X) / 2f;
|
||||||
var halfButtonSize = new Vector2(halfWidth, ImGui.CalcTextSize("A").Y + ImGui.GetStyle().FramePadding.Y * 2);
|
var halfButtonSize = new Vector2(halfWidth, ImGuiUtils.ButtonHeight);
|
||||||
var quarterButtonSize = new Vector2(quarterWidth, ImGui.CalcTextSize("A").Y + ImGui.GetStyle().FramePadding.Y * 2);
|
var quarterButtonSize = new Vector2(quarterWidth, ImGuiUtils.ButtonHeight);
|
||||||
|
|
||||||
var conditionRandomnessText = "Condition Randomness";
|
var conditionRandomnessText = "Condition Randomness";
|
||||||
var conditionRandomness = Config.ConditionRandomness;
|
var conditionRandomness = Config.ConditionRandomness;
|
||||||
@@ -343,7 +343,6 @@ public sealed partial class Simulator : Window, IDisposable
|
|||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
ImGui.SetNextItemWidth(halfWidth);
|
|
||||||
DrawSimulationGenerateButton(halfButtonSize);
|
DrawSimulationGenerateButton(halfButtonSize);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user