feat: add imgui color helper

This commit is contained in:
kalilistic 2021-04-10 23:26:13 -04:00
parent f5054f5274
commit bb3006d0c8
6 changed files with 166 additions and 17 deletions

View file

@ -0,0 +1,61 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Dalamud.Interface.Windowing;
using ImGuiNET;
namespace Dalamud.Interface.Colors
{
/// <summary>
/// color Demo Window to view custom ImGui colors.
/// </summary>
internal class ColorDemoWindow : Window
{
private readonly List<KeyValuePair<string, Vector4>> colors;
/// <summary>
/// Initializes a new instance of the <see cref="ColorDemoWindow"/> class.
/// </summary>
public ColorDemoWindow()
: base("Dalamud Colors Demo")
{
this.Size = new Vector2(600, 500);
this.SizeCondition = ImGuiCond.FirstUseEver;
this.colors = new List<KeyValuePair<string, Vector4>>
{
Demo("White", ImGuiColors.White),
Demo("DalamudRed", ImGuiColors.DalamudRed),
Demo("DalamudGrey", ImGuiColors.DalamudGrey),
Demo("DalamudGrey2", ImGuiColors.DalamudGrey2),
Demo("DalamudGrey3", ImGuiColors.DalamudGrey3),
Demo("DalamudWhite", ImGuiColors.DalamudWhite),
Demo("DalamudWhite2", ImGuiColors.DalamudWhite2),
Demo("DalamudOrange", ImGuiColors.DalamudOrange),
Demo("TankBlue", ImGuiColors.TankBlue),
Demo("HealerGreen", ImGuiColors.HealerGreen),
Demo("DPSRed", ImGuiColors.DPSRed),
};
this.colors = this.colors.OrderBy(colorDemo => colorDemo.Key).ToList();
}
/// <inheritdoc/>
public override void Draw()
{
ImGui.BeginChild("color_scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.AlwaysVerticalScrollbar | ImGuiWindowFlags.HorizontalScrollbar);
ImGui.Text("This is a collection of UI colors you can use in your plugin.");
ImGui.Separator();
foreach (var color in this.colors)
{
ImGui.TextColored(color.Value, color.Key);
}
ImGui.EndChild();
}
private static KeyValuePair<string, Vector4> Demo(string name, Vector4 color)
{
return new KeyValuePair<string, Vector4>(name, color);
}
}
}

View file

@ -0,0 +1,65 @@
using System.Numerics;
namespace Dalamud.Interface.Colors
{
/// <summary>
/// Class containing frequently used colors for easier reference.
/// </summary>
public static class ImGuiColors
{
/// <summary>
/// Gets white color.
/// </summary>
public static Vector4 White { get; } = new Vector4(255, 255, 255, 1);
/// <summary>
/// Gets red used in dalamud.
/// </summary>
public static Vector4 DalamudRed { get; } = new Vector4(1f, 0f, 0f, 1f);
/// <summary>
/// Gets grey used in dalamud.
/// </summary>
public static Vector4 DalamudGrey { get; } = new Vector4(0.70f, 0.70f, 0.70f, 1.00f);
/// <summary>
/// Gets grey used in dalamud.
/// </summary>
public static Vector4 DalamudGrey2 { get; } = new Vector4(0.7f, 0.7f, 0.7f, 1.0f);
/// <summary>
/// Gets grey used in dalamud.
/// </summary>
public static Vector4 DalamudGrey3 { get; } = new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
/// <summary>
/// Gets white used in dalamud.
/// </summary>
public static Vector4 DalamudWhite { get; } = new Vector4(1f, 1f, 1f, 1f);
/// <summary>
/// Gets white used in dalamud.
/// </summary>
public static Vector4 DalamudWhite2 { get; } = new Vector4(0.878f, 0.878f, 0.878f, 1f);
/// <summary>
/// Gets orange used in dalamud.
/// </summary>
public static Vector4 DalamudOrange { get; } = new Vector4(1f, 0.709f, 0f, 1f);
/// <summary>
/// Gets tank blue (UIColor37).
/// </summary>
public static Vector4 TankBlue { get; } = new Vector4(0, 0.6f, 1, 1);
/// <summary>
/// Gets healer green (UIColor504).
/// </summary>
public static Vector4 HealerGreen { get; } = new Vector4(0, 0.8f, 0.1333333f, 1);
/// <summary>
/// Gets dps red (UIColor545).
/// </summary>
public static Vector4 DPSRed { get; } = new Vector4(0.7058824f, 0, 0, 1);
}
}