From 134c8a087894c5dd32499eb3271bc9b5ab00b997 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Tue, 24 Jan 2023 15:00:35 +0800 Subject: [PATCH 1/2] feat: add tooltip. arrow is not supported as there is not indicator of placement on tooltip control itself. --- .../Pages/ToolTipDemo.axaml | 93 +++++++++++++++++++ .../Pages/ToolTipDemo.axaml.cs | 18 ++++ demo/Semi.Avalonia.Demo/Views/MainView.axaml | 3 + src/Semi.Avalonia/Controls/Controls.axaml | 1 + src/Semi.Avalonia/Controls/Tooltip.axaml | 41 ++++++++ src/Semi.Avalonia/Themes/Light/Light.axaml | 2 + src/Semi.Avalonia/Themes/Light/Tooltip.axaml | 14 +++ 7 files changed, 172 insertions(+) create mode 100644 demo/Semi.Avalonia.Demo/Pages/ToolTipDemo.axaml create mode 100644 demo/Semi.Avalonia.Demo/Pages/ToolTipDemo.axaml.cs create mode 100644 src/Semi.Avalonia/Controls/Tooltip.axaml create mode 100644 src/Semi.Avalonia/Themes/Light/Tooltip.axaml diff --git a/demo/Semi.Avalonia.Demo/Pages/ToolTipDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/ToolTipDemo.axaml new file mode 100644 index 0000000..86080c4 --- /dev/null +++ b/demo/Semi.Avalonia.Demo/Pages/ToolTipDemo.axaml @@ -0,0 +1,93 @@ + + + + Hover Here + + + + + + ToolTip + A control which pops up a hint when a control is hovered + + + ToolTip bottom placement + + + + + + Moving offset + + + Top + + + Left + + + Right + + + Bottom + + + diff --git a/demo/Semi.Avalonia.Demo/Pages/ToolTipDemo.axaml.cs b/demo/Semi.Avalonia.Demo/Pages/ToolTipDemo.axaml.cs new file mode 100644 index 0000000..0b3a0c7 --- /dev/null +++ b/demo/Semi.Avalonia.Demo/Pages/ToolTipDemo.axaml.cs @@ -0,0 +1,18 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Semi.Avalonia.Demo.Pages; + +public partial class ToolTipDemo : UserControl +{ + public ToolTipDemo() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } +} \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Views/MainView.axaml b/demo/Semi.Avalonia.Demo/Views/MainView.axaml index aaa69f0..e526ef6 100644 --- a/demo/Semi.Avalonia.Demo/Views/MainView.axaml +++ b/demo/Semi.Avalonia.Demo/Views/MainView.axaml @@ -78,6 +78,9 @@ + + + diff --git a/src/Semi.Avalonia/Controls/Controls.axaml b/src/Semi.Avalonia/Controls/Controls.axaml index adce855..e9deabf 100644 --- a/src/Semi.Avalonia/Controls/Controls.axaml +++ b/src/Semi.Avalonia/Controls/Controls.axaml @@ -31,6 +31,7 @@ + diff --git a/src/Semi.Avalonia/Controls/Tooltip.axaml b/src/Semi.Avalonia/Controls/Tooltip.axaml new file mode 100644 index 0000000..a0809d5 --- /dev/null +++ b/src/Semi.Avalonia/Controls/Tooltip.axaml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Semi.Avalonia/Themes/Light/Light.axaml b/src/Semi.Avalonia/Themes/Light/Light.axaml index c9f723b..1716221 100644 --- a/src/Semi.Avalonia/Themes/Light/Light.axaml +++ b/src/Semi.Avalonia/Themes/Light/Light.axaml @@ -23,8 +23,10 @@ + + diff --git a/src/Semi.Avalonia/Themes/Light/Tooltip.axaml b/src/Semi.Avalonia/Themes/Light/Tooltip.axaml new file mode 100644 index 0000000..895ccee --- /dev/null +++ b/src/Semi.Avalonia/Themes/Light/Tooltip.axaml @@ -0,0 +1,14 @@ + + + M24 0V1C20 1 18.5 2 16.5 4C14.5 6 14 7 12 7C10 7 9.5 6 7.5 4C5.5 2 4 1 0 1V0H24Z + + + + 6 + 12 8 + 320 + 0 + From 4dc153303ff97962e95b22036526ad5083a5bc83 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Tue, 24 Jan 2023 15:05:11 +0800 Subject: [PATCH 2/2] fix: remove unnecessary margin. --- src/Semi.Avalonia/Controls/Tooltip.axaml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Semi.Avalonia/Controls/Tooltip.axaml b/src/Semi.Avalonia/Controls/Tooltip.axaml index a0809d5..d884026 100644 --- a/src/Semi.Avalonia/Controls/Tooltip.axaml +++ b/src/Semi.Avalonia/Controls/Tooltip.axaml @@ -18,7 +18,6 @@