mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-01 05:13:40 +01:00
feat: add component library
This commit is contained in:
parent
7d5680badd
commit
841e452aa2
4 changed files with 100 additions and 0 deletions
42
Dalamud/Interface/Components/ComponentDemoWindow.cs
Normal file
42
Dalamud/Interface/Components/ComponentDemoWindow.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using System.Numerics;
|
||||
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Components
|
||||
{
|
||||
|
||||
internal class ComponentDemoWindow : Window
|
||||
{
|
||||
private readonly IComponent[] components =
|
||||
{
|
||||
new TestComponent(),
|
||||
};
|
||||
|
||||
public ComponentDemoWindow()
|
||||
: base("Dalamud Components Demo")
|
||||
{
|
||||
this.Size = new Vector2(600, 500);
|
||||
this.SizeCondition = ImGuiCond.FirstUseEver;
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
ImGui.BeginChild("comp_scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.AlwaysVerticalScrollbar | ImGuiWindowFlags.HorizontalScrollbar);
|
||||
|
||||
ImGui.Text("This is a collection of UI components you can use in your plugin.");
|
||||
|
||||
for (var i = 0; i < this.components.Length; i++)
|
||||
{
|
||||
var thisComp = this.components[i];
|
||||
|
||||
if (ImGui.CollapsingHeader($"{thisComp.Name} ({thisComp.GetType().FullName})###comp{i}"))
|
||||
{
|
||||
thisComp.Draw();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndChild();
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Dalamud/Interface/Components/IComponent.cs
Normal file
18
Dalamud/Interface/Components/IComponent.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
namespace Dalamud.Interface.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Base interface implementing a modular interface component.
|
||||
/// </summary>
|
||||
public interface IComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the component.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Draw the component via ImGui.
|
||||
/// </summary>
|
||||
public void Draw();
|
||||
}
|
||||
}
|
||||
19
Dalamud/Interface/Components/TestComponent.cs
Normal file
19
Dalamud/Interface/Components/TestComponent.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Components
|
||||
{
|
||||
class TestComponent : IComponent
|
||||
{
|
||||
public string Name { get; } = "Test Component";
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
ImGui.Text("You are viewing the test component. The test was a success.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue