Skip to content

Commit

Permalink
feat: display tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
mika-f committed Jan 22, 2024
1 parent ba089ec commit ea3ca4a
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// ------------------------------------------------------------------------------------------
// Copyright (c) Natsuneko. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// ------------------------------------------------------------------------------------------

namespace NatsunekoLaboratory.Plana.Components.Abstractions
{
internal interface ITooltip
{
string TooltipValue { get; set; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace NatsunekoLaboratory.Plana.Components
{
internal class Checkbox : Control, IValueChangeNotifiable<bool>
internal class Checkbox : Control, ITooltip, IValueChangeNotifiable<bool>
{
private readonly List<Action<ChangeEvent<bool>>> _listeners;
private readonly Toggle _toggle;
Expand All @@ -30,12 +30,6 @@ public string Text
set => _toggle.text = value;
}

public bool Value
{
get => _toggle.value;
set => _toggle.value = value;
}


public Checkbox() : base(StyledComponents.Create("84651a7aeb61342438ed3151794dd07c", "9ad74141476795e4293466c737e8f6aa", "f7767e6d222c9e4489cdbc01fac94ae6", "0047e4fbe8c9cdd4788ff73418ab3b76"))
{
Expand All @@ -44,6 +38,18 @@ public Checkbox() : base(StyledComponents.Create("84651a7aeb61342438ed3151794dd0
_toggle.RegisterValueChangedCallback(OnValueChanged);
}

public string TooltipValue
{
get => _toggle.tooltip;
set => _toggle.tooltip = value;
}

public bool Value
{
get => _toggle.value;
set => _toggle.value = value;
}

public void AddValueChangedEventListener(Action<ChangeEvent<bool>> listener)
{
_listeners.Add(listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private void InflatePluginsSection(Dictionary<string, List<(string Id, string Fr
case Type s when s == typeof(bool):
var b = defaults.GetValueOrDefault(item.Id, false);

collection.Add(new Checkbox { Text = item.FriendlyName, Value = b }.Binding(item.Id, _extras, new ObjectToBooleanConverter()));
collection.Add(new Checkbox { Text = item.FriendlyName, Value = b }.Binding(item.Id, _extras, new ObjectToBooleanConverter()).WithTooltip(item.Description));
_extras.Add(item.Id, b);
break;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ------------------------------------------------------------------------------------------
// Copyright (c) Natsuneko. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// ------------------------------------------------------------------------------------------

using NatsunekoLaboratory.Plana.Components.Abstractions;

namespace NatsunekoLaboratory.Plana.Extensions
{
// ReSharper disable once InconsistentNaming
internal static class ITooltipExtensions
{
public static T WithTooltip<T>(this T obj, string value) where T : ITooltip
{
obj.TooltipValue = value;
return obj;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ea3ca4a

Please sign in to comment.