summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen/Renderers
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-07-10 11:11:22 +0900
commitca3b6f0f0954199156b20d88856f3c9459875a10 (patch)
treed406c642fdd4eacb0148b341726be9e795ec2bce /Xamarin.Forms.Platform.Tizen/Renderers
parentc6396783714ac901c2908381cde8d0daefe5c592 (diff)
downloadxamarin-forms-ca3b6f0f0954199156b20d88856f3c9459875a10.tar.gz
xamarin-forms-ca3b6f0f0954199156b20d88856f3c9459875a10.tar.bz2
xamarin-forms-ca3b6f0f0954199156b20d88856f3c9459875a10.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')
-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
+}