diff --git a/.editorconfig b/.editorconfig
index a7ae2aa81..8816a8511 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -72,6 +72,8 @@ resharper_align_multiline_for_stmt = true
resharper_align_multline_type_parameter_constrains = true
resharper_align_multline_type_parameter_list = true
resharper_apply_on_completion = true
+resharper_auto_property_can_be_made_get_only_global_highlighting = none
+resharper_auto_property_can_be_made_get_only_local_highlighting = none
resharper_autodetect_indent_settings = true
resharper_braces_for_ifelse = required_for_multiline
resharper_can_use_global_alias = false
@@ -82,6 +84,8 @@ resharper_csharp_int_align_comments = true
resharper_csharp_new_line_before_while = true
resharper_csharp_wrap_after_declaration_lpar = true
resharper_enforce_line_ending_style = true
+resharper_member_can_be_private_global_highlighting = none
+resharper_member_can_be_private_local_highlighting = none
resharper_new_line_before_finally = false
resharper_place_accessorholder_attribute_on_same_line = false
resharper_place_field_attribute_on_same_line = false
diff --git a/Dalamud/Interface/Components/ComponentDemoWindow.cs b/Dalamud/Interface/Components/ComponentDemoWindow.cs
index 244a43222..082c13550 100644
--- a/Dalamud/Interface/Components/ComponentDemoWindow.cs
+++ b/Dalamud/Interface/Components/ComponentDemoWindow.cs
@@ -1,32 +1,40 @@
+using System.Collections.Generic;
+using System.Linq;
using System.Numerics;
using Dalamud.Interface.Windowing;
+using Dalamud.Plugin;
using ImGuiNET;
namespace Dalamud.Interface.Components
{
-
+ ///
+ /// Component Demo Window to view custom components.
+ ///
internal class ComponentDemoWindow : Window
{
- private readonly IComponent[] components =
- {
- new TestComponent(),
- };
+ private List components = new List();
+ ///
+ /// Initializes a new instance of the class.
+ ///
public ComponentDemoWindow()
: base("Dalamud Components Demo")
{
this.Size = new Vector2(600, 500);
this.SizeCondition = ImGuiCond.FirstUseEver;
+ this.AddComponents();
+ this.SortComponents();
}
+ ///
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++)
+ for (var i = 0; i < this.components.Count; i++)
{
var thisComp = this.components[i];
@@ -38,5 +46,22 @@ namespace Dalamud.Interface.Components
ImGui.EndChild();
}
+
+ private void AddComponents()
+ {
+ this.components.Add(new TestComponent());
+ this.components.Add(new HelpMarkerComponent("help me!")
+ {
+ SameLine = false,
+ });
+ var iconButtonComponent = new IconButtonComponent(1, FontAwesomeIcon.Carrot);
+ iconButtonComponent.OnButtonClicked += id => PluginLog.Log("Button#{0} clicked!", id);
+ this.components.Add(iconButtonComponent);
+ }
+
+ private void SortComponents()
+ {
+ this.components = this.components.OrderBy(component => component.Name).ToList();
+ }
}
}
diff --git a/Dalamud/Interface/Components/HelpMarkerComponent.cs b/Dalamud/Interface/Components/HelpMarkerComponent.cs
new file mode 100644
index 000000000..f559c8ef2
--- /dev/null
+++ b/Dalamud/Interface/Components/HelpMarkerComponent.cs
@@ -0,0 +1,61 @@
+using ImGuiNET;
+
+namespace Dalamud.Interface.Components
+{
+ ///
+ /// HelpMarker component to add a help icon with text on hover.
+ ///
+ public class HelpMarkerComponent : IComponent
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The text to display on hover.
+ public HelpMarkerComponent(string helpText)
+ {
+ this.HelpText = helpText;
+ }
+
+ ///
+ /// Gets component name.
+ ///
+ public string Name { get; } = "HelpMarker Component";
+
+ ///
+ /// Gets or sets a value indicating whether the help text should display on same line as previous element.
+ ///
+ public bool SameLine { get; set; } = true;
+
+ ///
+ /// Gets or sets the help text.
+ ///
+ public string HelpText { get; set; }
+
+ ///
+ /// Gets or sets the help marker icon.
+ ///
+ public FontAwesomeIcon HelpIcon { get; set; } = FontAwesomeIcon.InfoCircle;
+
+ ///
+ /// Gets or sets the help text size modifier.
+ ///
+ public float HelpTextModifier { get; set; } = 35.0f;
+
+ ///
+ /// Draw HelpMarker component.
+ ///
+ public void Draw()
+ {
+ if (this.SameLine) ImGui.SameLine();
+ ImGui.PushFont(UiBuilder.IconFont);
+ ImGui.TextDisabled(this.HelpIcon.ToIconString());
+ ImGui.PopFont();
+ if (!ImGui.IsItemHovered()) return;
+ ImGui.BeginTooltip();
+ ImGui.PushTextWrapPos(ImGui.GetFontSize() * this.HelpTextModifier);
+ ImGui.TextUnformatted(this.HelpText);
+ ImGui.PopTextWrapPos();
+ ImGui.EndTooltip();
+ }
+ }
+}
diff --git a/Dalamud/Interface/Components/IComponent.cs b/Dalamud/Interface/Components/IComponent.cs
index 02784000c..9a7ac55b6 100644
--- a/Dalamud/Interface/Components/IComponent.cs
+++ b/Dalamud/Interface/Components/IComponent.cs
@@ -6,7 +6,7 @@ namespace Dalamud.Interface.Components
public interface IComponent
{
///
- /// Gets or sets the name of the component.
+ /// Gets the name of the component.
///
public string Name { get; }
diff --git a/Dalamud/Interface/Components/IconButtonComponent.cs b/Dalamud/Interface/Components/IconButtonComponent.cs
new file mode 100644
index 000000000..7faa4623c
--- /dev/null
+++ b/Dalamud/Interface/Components/IconButtonComponent.cs
@@ -0,0 +1,82 @@
+using System.Numerics;
+
+using ImGuiNET;
+
+namespace Dalamud.Interface.Components
+{
+ ///
+ /// IconButton component to use an icon as a button.
+ ///
+ public class IconButtonComponent : IComponent
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The id for the button.
+ /// The icon for the button.
+ public IconButtonComponent(int buttonId, FontAwesomeIcon buttonIcon)
+ {
+ this.ButtonId = buttonId;
+ this.ButtonIcon = buttonIcon;
+ }
+
+ ///
+ /// Delegate for the event that occurs when the button is clicked.
+ ///
+ /// The id of the button that was clicked.
+ public delegate void IsButtonClickedDelegate(int buttonId);
+
+ ///
+ /// Event that occurs when the button is clicked.
+ ///
+ public event IsButtonClickedDelegate OnButtonClicked;
+
+ ///
+ /// Gets component name.
+ ///
+ public string Name { get; } = "IconButton Component";
+
+ ///
+ /// Gets or sets the id for the button.
+ ///
+ public int ButtonId { get; set; }
+
+ ///
+ /// Gets or sets the icon to use for the button.
+ ///
+ public FontAwesomeIcon ButtonIcon { get; set; }
+
+ ///
+ /// Gets or sets the button color.
+ ///
+ public Vector4 ButtonColor { get; set; } = Vector4.Zero;
+
+ ///
+ /// Gets or sets the active button color.
+ ///
+ public Vector4 ButtonColorActive { get; set; } = Vector4.Zero;
+
+ ///
+ /// Gets or sets the hovered button color.
+ ///
+ public Vector4 ButtonColorHovered { get; set; } = Vector4.Zero;
+
+ ///
+ /// Draw IconButton component.
+ ///
+ public void Draw()
+ {
+ ImGui.PushStyleColor(ImGuiCol.Button, this.ButtonColor);
+ ImGui.PushStyleColor(ImGuiCol.ButtonActive, this.ButtonColorActive);
+ ImGui.PushStyleColor(ImGuiCol.ButtonHovered, this.ButtonColorHovered);
+ ImGui.PushFont(UiBuilder.IconFont);
+ if (ImGui.Button($"{this.ButtonIcon.ToIconString()}{this.ButtonId}"))
+ {
+ this.OnButtonClicked?.Invoke(this.ButtonId);
+ }
+
+ ImGui.PopFont();
+ ImGui.PopStyleColor(3);
+ }
+ }
+}
diff --git a/Dalamud/Interface/Components/TestComponent.cs b/Dalamud/Interface/Components/TestComponent.cs
index 587f3757a..30412be8b 100644
--- a/Dalamud/Interface/Components/TestComponent.cs
+++ b/Dalamud/Interface/Components/TestComponent.cs
@@ -1,16 +1,20 @@
-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
+ ///
+ /// Test component to demonstrate how ImGui components work.
+ ///
+ public class TestComponent : IComponent
{
+ ///
+ /// Gets component name.
+ ///
public string Name { get; } = "Test Component";
+ ///
+ /// Draw test component.
+ ///
public void Draw()
{
ImGui.Text("You are viewing the test component. The test was a success.");