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.
Refactor WrapperView to draw drawable features (#186)
* Refactor WrapperView to draw drawable features * Update class names and devide files * Override NeesContainer to remove duplicated code * Update class names
- Loading branch information
1 parent
1d0c27c
commit 8929b2d
Showing
7 changed files
with
116 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
| ||
namespace Microsoft.Maui | ||
{ | ||
public interface IWrapperViewCanvas | ||
{ | ||
public IWrapperViewDrawables Drawables { get; } | ||
} | ||
} |
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,13 @@ | ||
using Microsoft.Maui.Graphics; | ||
|
||
namespace Microsoft.Maui | ||
{ | ||
public interface IWrapperViewDrawables : IDrawable | ||
{ | ||
IDrawable? ShadowDrawable { get; set; } | ||
|
||
IDrawable? BackgroundDrawable { get; set; } | ||
|
||
IDrawable? BorderDrawable { get; set; } | ||
} | ||
} |
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,65 @@ | ||
using System; | ||
using Microsoft.Maui.Graphics; | ||
|
||
namespace Microsoft.Maui | ||
{ | ||
public class WrapperViewDrawables : IWrapperViewDrawables | ||
{ | ||
public event EventHandler? Invalidated; | ||
|
||
IDrawable? _shadowDrawable; | ||
IDrawable? _backgroundDrawable; | ||
IDrawable? _borderDrawable; | ||
|
||
public IDrawable? ShadowDrawable | ||
{ | ||
get | ||
{ | ||
return _shadowDrawable; | ||
} | ||
set | ||
{ | ||
_shadowDrawable = value; | ||
SendInvalidated(); | ||
} | ||
} | ||
|
||
public IDrawable? BackgroundDrawable | ||
{ | ||
get | ||
{ | ||
return _backgroundDrawable; | ||
} | ||
set | ||
{ | ||
_backgroundDrawable = value; | ||
SendInvalidated(); | ||
} | ||
} | ||
|
||
public IDrawable? BorderDrawable | ||
{ | ||
get | ||
{ | ||
return _borderDrawable; | ||
} | ||
set | ||
{ | ||
_borderDrawable = value; | ||
SendInvalidated(); | ||
} | ||
} | ||
|
||
public void Draw(ICanvas canvas, RectangleF dirtyRect) | ||
{ | ||
_shadowDrawable?.Draw(canvas, dirtyRect); | ||
_backgroundDrawable?.Draw(canvas, dirtyRect); | ||
_borderDrawable?.Draw(canvas, dirtyRect); | ||
} | ||
|
||
public void SendInvalidated() | ||
{ | ||
Invalidated?.Invoke(this, EventArgs.Empty); | ||
} | ||
} | ||
} |