forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tizen] Add BorderDrawable (dotnet#224)
* Move to platform specific * Fix border handler for Tizen * Rename ToDrawable method * Fix border content layout * Fix BorderView * Apply rebase
- Loading branch information
1 parent
6ffc48d
commit fbca682
Showing
7 changed files
with
175 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Microsoft.Maui.Graphics; | ||
|
||
namespace Microsoft.Maui | ||
{ | ||
public class BorderDrawable : IDrawable | ||
{ | ||
Paint _paint; | ||
IBorder _border; | ||
|
||
public BorderDrawable(Paint paint, IBorder border) | ||
{ | ||
_paint = paint; | ||
_border = border; | ||
} | ||
|
||
public void Draw(ICanvas canvas, RectangleF dirtyRect) | ||
{ | ||
canvas.SaveState(); | ||
|
||
var borderPath = _border.Shape?.PathForBounds(dirtyRect) ?? null; | ||
if (borderPath != null) | ||
{ | ||
canvas.MiterLimit = _border.StrokeMiterLimit; | ||
canvas.StrokeColor = _border.Stroke.ToColor(); | ||
canvas.StrokeDashPattern = _border.StrokeDashPattern; | ||
canvas.StrokeLineCap = _border.StrokeLineCap; | ||
canvas.StrokeLineJoin = _border.StrokeLineJoin; | ||
canvas.StrokeSize = (float)_border.StrokeThickness; | ||
|
||
canvas.DrawPath(borderPath); | ||
|
||
canvas.SetFillPaint(_paint, dirtyRect); | ||
canvas.FillPath(borderPath); | ||
} | ||
|
||
canvas.RestoreState(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System; | ||
using ElmSharp; | ||
using Microsoft.Maui.Graphics; | ||
using Microsoft.Maui.Graphics.Skia.Views; | ||
using Tizen.UIExtensions.Common; | ||
|
||
namespace Microsoft.Maui | ||
{ | ||
public class BorderView : ContentCanvas, IWrapperViewCanvas | ||
{ | ||
WrapperView _wrapperView; | ||
|
||
public BorderView(EvasObject parent, IView view) : base(parent, view) | ||
{ | ||
_wrapperView = new WrapperView(parent); | ||
_wrapperView.Show(); | ||
Children.Add(_wrapperView); | ||
_wrapperView.Lower(); | ||
Content?.RaiseTop(); | ||
|
||
LayoutUpdated += OnLayout; | ||
|
||
} | ||
|
||
public IShape? Clip | ||
{ | ||
get | ||
{ | ||
return _wrapperView.Clip; | ||
} | ||
set | ||
{ | ||
_wrapperView.Clip = value; | ||
} | ||
} | ||
|
||
|
||
public IShadow? Shadow | ||
{ | ||
get | ||
{ | ||
return _wrapperView.Shadow; | ||
} | ||
set | ||
{ | ||
_wrapperView.Shadow = value; | ||
} | ||
} | ||
|
||
public EvasObject? Content | ||
{ | ||
get | ||
{ | ||
return _wrapperView.Content; | ||
} | ||
set | ||
{ | ||
if (_wrapperView.Content != value) | ||
{ | ||
if (_wrapperView.Content != null) | ||
{ | ||
Children.Remove(_wrapperView); | ||
_wrapperView.Content = null; | ||
} | ||
_wrapperView.Content = value; | ||
if (_wrapperView.Content != null) | ||
{ | ||
Children.Add(_wrapperView); | ||
_wrapperView.RaiseTop(); | ||
} | ||
} | ||
_wrapperView.Content = value; | ||
} | ||
} | ||
|
||
public IWrapperViewDrawables Drawables => _wrapperView.Drawables; | ||
|
||
void OnLayout(object? sender, LayoutEventArgs e) | ||
{ | ||
if (Content != null) | ||
{ | ||
_wrapperView.Geometry = Geometry; | ||
} | ||
} | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...Core/src/Graphics/ShadowDrawable.Tizen.cs → ...Core/src/Platform/Tizen/ShadowDrawable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters