summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
diff options
context:
space:
mode:
authorKangho Hur <kangho.hur@samsung.com>2017-04-13 15:51:26 +0900
committerKangho Hur <kangho.hur@samsung.com>2017-10-23 13:34:32 +0900
commit352b49d8c3d38c73ebf2d96d2c9120594a92b271 (patch)
tree82663aae054039eaa391bf3f0b0aca1c425ada34 /Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
parent9ac375ada8930513d5c374d79f581b4ca1e8bb5d (diff)
downloadxamarin-forms-352b49d8c3d38c73ebf2d96d2c9120594a92b271.tar.gz
xamarin-forms-352b49d8c3d38c73ebf2d96d2c9120594a92b271.tar.bz2
xamarin-forms-352b49d8c3d38c73ebf2d96d2c9120594a92b271.zip
Add Focus related properties for VE
TASK=TCAPI-2264 - Make sure that all these API should be invoked after all renderers are created. (e.g. use it inside Page.OnAppearing()) Change-Id: Ie441a067d5a7b94af120985b0a691fad6ce8250f
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs135
1 files changed, 132 insertions, 3 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
index 6baff194..51170bd6 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
@@ -3,11 +3,10 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.ComponentModel;
using ElmSharp;
-using EColor = ElmSharp.Color;
using ESize = ElmSharp.Size;
using ERect = ElmSharp.Rect;
-using ERectangle = ElmSharp.Rectangle;
using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement;
+using XFocusDirection = Xamarin.Forms.PlatformConfiguration.TizenSpecific.FocusDirection;
namespace Xamarin.Forms.Platform.Tizen
{
@@ -55,6 +54,14 @@ namespace Xamarin.Forms.Platform.Tizen
RegisterPropertyHandler(VisualElement.InputTransparentProperty, UpdateInputTransparent);
RegisterPropertyHandler(VisualElement.BackgroundColorProperty, UpdateBackgroundColor);
RegisterPropertyHandler(Specific.StyleProperty, UpdateThemeStyle);
+ RegisterPropertyHandler(Specific.IsFocusAllowedProperty, UpdateFocusAllowed);
+ RegisterPropertyHandler(Specific.NextFocusDirectionProperty, UpdateFocusDirection);
+ RegisterPropertyHandler(Specific.NextFocusUpViewProperty, UpdateFocusUpView);
+ RegisterPropertyHandler(Specific.NextFocusDownViewProperty, UpdateFocusDownView);
+ RegisterPropertyHandler(Specific.NextFocusLeftViewProperty, UpdateFocusLeftView);
+ RegisterPropertyHandler(Specific.NextFocusRightViewProperty, UpdateFocusRightView);
+ RegisterPropertyHandler(Specific.NextFocusBackViewProperty, UpdateFocusBackView);
+ RegisterPropertyHandler(Specific.NextFocusForwardViewProperty, UpdateFocusForwardView);
RegisterPropertyHandler(VisualElement.AnchorXProperty, ApplyTransformation);
RegisterPropertyHandler(VisualElement.AnchorYProperty, ApplyTransformation);
@@ -778,6 +785,128 @@ namespace Xamarin.Forms.Platform.Tizen
{
}
+ void UpdateFocusAllowed(bool initialize)
+ {
+ if (!initialize)
+ {
+ var widget = NativeView as Widget;
+ if (widget != null)
+ {
+ widget.AllowFocus(Specific.IsFocusAllowed(Element));
+ }
+ else
+ {
+ Log.Warn("{0} uses {1} which does not support Focus management", this, NativeView);
+ }
+ }
+ }
+
+ void UpdateFocusDirection(bool initialize)
+ {
+ var direction = Specific.GetNextFocusDirection(Element);
+ if (!initialize && direction != XFocusDirection.None)
+ {
+ var widget = NativeView as Widget;
+ if (widget != null)
+ {
+ widget.FocusNext(direction.ToNative());
+ }
+ else
+ {
+ Log.Warn("{0} uses {1} which does not support Focus management", this, NativeView);
+ }
+ }
+ }
+
+ void SetNextFocusViewInternal(XFocusDirection direction)
+ {
+ var widget = NativeView as Widget;
+ if (widget != null)
+ {
+ EvasObject nativeControl;
+ switch (direction)
+ {
+ case XFocusDirection.Back:
+ nativeControl = Platform.GetRenderer(Specific.GetNextFocusBackView(Element))?.NativeView;
+ break;
+ case XFocusDirection.Forward:
+ nativeControl = Platform.GetRenderer(Specific.GetNextFocusForwardView(Element))?.NativeView;
+ break;
+ case XFocusDirection.Up:
+ nativeControl = Platform.GetRenderer(Specific.GetNextFocusUpView(Element))?.NativeView;
+ break;
+ case XFocusDirection.Down:
+ nativeControl = Platform.GetRenderer(Specific.GetNextFocusDownView(Element))?.NativeView;
+ break;
+ case XFocusDirection.Right:
+ nativeControl = Platform.GetRenderer(Specific.GetNextFocusRightView(Element))?.NativeView;
+ break;
+ case XFocusDirection.Left:
+ nativeControl = Platform.GetRenderer(Specific.GetNextFocusLeftView(Element))?.NativeView;
+ break;
+ default:
+ nativeControl = null;
+ break;
+ }
+ if (nativeControl != null)
+ {
+ widget.SetNextFocusObject(nativeControl, direction.ToNative());
+ }
+ }
+ else
+ {
+ Log.Warn("{0} uses {1} which does not support Focus management", this, NativeView);
+ }
+ }
+
+ void UpdateFocusUpView(bool initialize)
+ {
+ if (!initialize && Specific.GetNextFocusUpView(Element) != null)
+ {
+ SetNextFocusViewInternal(XFocusDirection.Up);
+ }
+ }
+
+ void UpdateFocusDownView(bool initialize)
+ {
+ if (!initialize && Specific.GetNextFocusDownView(Element) != null)
+ {
+ SetNextFocusViewInternal(XFocusDirection.Down);
+ }
+ }
+
+ void UpdateFocusLeftView(bool initialize)
+ {
+ if (!initialize && Specific.GetNextFocusLeftView(Element) != null)
+ {
+ SetNextFocusViewInternal(XFocusDirection.Left);
+ }
+ }
+
+ void UpdateFocusRightView(bool initialize)
+ {
+ if (!initialize && Specific.GetNextFocusRightView(Element) != null)
+ {
+ SetNextFocusViewInternal(XFocusDirection.Right);
+ }
+ }
+
+ void UpdateFocusBackView(bool initialize)
+ {
+ if (!initialize && Specific.GetNextFocusBackView(Element) != null)
+ {
+ SetNextFocusViewInternal(XFocusDirection.Back);
+ }
+ }
+
+ void UpdateFocusForwardView(bool initialize)
+ {
+ if (!initialize && Specific.GetNextFocusForwardView(Element) != null)
+ {
+ SetNextFocusViewInternal(XFocusDirection.Forward);
+ }
+ }
+
void ApplyRotation(EvasMap map, ERect geometry, ref bool changed)
{
var rotationX = Element.RotationX;
@@ -890,4 +1019,4 @@ namespace Xamarin.Forms.Platform.Tizen
--s_ignoreCount;
}
}
-} \ No newline at end of file
+}