Skip to content

Commit f2e4eda

Browse files
committed
Bump to latest
- Adds the GraphicsViewHandler and ShapeViewHandler - Apply one stop shop UseMauiControls (dotnet#1157) - Implements new APIs for each IView - and so on
1 parent aeab06c commit f2e4eda

26 files changed

+352
-57
lines changed

src/Compatibility/Core/src/Forms.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !(__ANDROID__ || __IOS__ || WINDOWS || (__TIZEN__ || TIZEN))
1+
#if !(__ANDROID__ || __IOS__ || WINDOWS || TIZEN)
22
using System;
33
using System.Collections.Generic;
44
using System.Text;

src/Compatibility/Core/src/Tizen/Forms.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public static bool IsInitialized
282282

283283
public static bool UseFastLayout { get; private set; }
284284

285-
public static DisplayResolutionUnit DisplayResolutionUnit { get; private set; }
285+
public static DisplayResolutionUnit DisplayResolutionUnit { get; private set; } = DisplayResolutionUnit.Pixel();
286286

287287
public static int ScreenDPI => s_dpi.Value;
288288

@@ -394,11 +394,13 @@ public static TOut GetHandlerForObject<TOut>(object obj, params object[] args) w
394394

395395
public static void Init(IActivationState activationState) => Init(activationState.Context);
396396

397+
public static void Init(IActivationState activationState, InitializationOptions options) => Init(activationState.Context, options);
398+
397399
public static void Init(CoreApplication application) => Init(new MauiContext(CoreUIAppContext.GetInstance(application)));
398400

399-
public static void Init(IMauiContext context)
401+
public static void Init(IMauiContext context, InitializationOptions options = null)
400402
{
401-
SetupInit(context);
403+
SetupInit(context, options);
402404
}
403405

404406
public static void Init(CoreApplication application, bool useDeviceIndependentPixel)
@@ -465,6 +467,13 @@ static void SetupInit(IMauiContext context, InitializationOptions options = null
465467
IsInitialized = true;
466468
}
467469

470+
// Once we get essentials/cg converted to using startup.cs
471+
// we will delete all the renderer code inside this file
472+
internal static void RenderersRegistered()
473+
{
474+
IsInitializedRenderers = true;
475+
}
476+
468477
internal static void RegisterCompatRenderers(InitializationOptions options)
469478
{
470479
if (!IsInitializedRenderers)

src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.ComponentModel;
3+
using Microsoft.Maui.Controls.Platform;
34
using Microsoft.Maui.Controls.Internals;
45
using Microsoft.Maui.Graphics;
56
using EvasObject = ElmSharp.EvasObject;

src/Compatibility/Core/src/Tizen/Renderers/IVisualElementRenderer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using ElmSharp;
3+
using Microsoft.Maui.Controls.Platform;
34
using ERect = ElmSharp.Rect;
45

56
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen

src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using ElmSharp;
66
using ElmSharp.Accessible;
7+
using Microsoft.Maui.Controls.Platform;
78
using Microsoft.Maui.Controls.Internals;
89
using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
910
using Size = Microsoft.Maui.Graphics.Size;

src/Compatibility/Core/src/Tizen/VisualElementChangedEventArgs.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/Controls/samples/Controls.Sample.Tizen/Controls.Sample.Tizen.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>tizen40</TargetFramework>
6-
<!--<DisableImplicitFrameworkReferences>True</DisableImplicitFrameworkReferences>-->
7-
<!--<TargetIdentifier>Tizen</TargetIdentifier>-->
86
<RootNamespace>Maui.Controls.Sample.Tizen</RootNamespace>
97
<AssemblyName>Maui.Controls.Sample.Tizen</AssemblyName>
108
</PropertyGroup>

src/Controls/samples/Controls.Sample/Startup.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ public static MauiApp CreateMauiApp()
7070
//#elif WINDOWS
7171
// handlers.AddCompatibilityRenderer(typeof(CustomButton),
7272
// typeof(Microsoft.Maui.Controls.Compatibility.Platform.UWP.ButtonRenderer));
73-
//#endif
73+
// #elif TIZEN
74+
// handlers.AddCompatibilityRenderer(typeof(CustomButton),
75+
// typeof(Microsoft.Maui.Controls.Compatibility.Platform.Tizen.ButtonRenderer));
76+
// #endif
7477
//#pragma warning restore CS0618 // Type or member is obsolete
7578
// });
7679

@@ -226,7 +229,7 @@ public static MauiApp CreateMauiApp()
226229
.OnClosed((a, b) => LogEvent(nameof(WindowsLifecycle.OnClosed)))
227230
.OnLaunched((a, b) => LogEvent(nameof(WindowsLifecycle.OnLaunched)))
228231
.OnVisibilityChanged((a, b) => LogEvent(nameof(WindowsLifecycle.OnVisibilityChanged))));
229-
#elif __TIZEN__ || TIZEN
232+
#elif TIZEN
230233
events.AddTizen(tizen => tizen
231234
.OnAppControlReceived((a, b) => LogEvent(nameof(TizenLifecycle.OnAppControlReceived)))
232235
.OnCreate((a) => LogEvent(nameof(TizenLifecycle.OnCreate)))

src/Core/src/Handlers/Editor/EditorHandler.Tizen.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ public static void MapFormatting(EditorHandler handler, IEditor editor)
8282
handler.NativeView?.UpdateMaxLength(editor);
8383
}
8484

85+
public static void MapKeyboard(EditorHandler handler, IEditor editor)
86+
{
87+
handler.NativeView?.UpdateKeyboard(editor);
88+
}
89+
8590
[MissingMapper]
8691
public static void MapCharacterSpacing(EditorHandler handler, IEditor editor) { }
8792

src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using System;
22
using Tizen.UIExtensions.ElmSharp;
3+
using SmartEvent = ElmSharp.SmartEvent;
34
using EEntry = ElmSharp.Entry;
45

56
namespace Microsoft.Maui.Handlers
67
{
78
public partial class EntryHandler : ViewHandler<IEntry, Entry>
89
{
10+
911
protected override Entry CreateNativeView()
1012
{
1113
return new EditfieldEntry(NativeParent)
@@ -17,14 +19,37 @@ protected override Entry CreateNativeView()
1719
protected override void ConnectHandler(Entry nativeView)
1820
{
1921
nativeView.Activated += OnCompleted;
22+
nativeView.CursorChanged += OnCursorChanged;
23+
24+
// In order to know when the selection is cleared, "selecton,cleared" event has been used.
25+
// Because CursorChanged event is still invoked with the selected text when an user clears selection. It is an known issue in EFL.
26+
SmartEvent selectionCleared = new SmartEvent(nativeView, nativeView.RealHandle, ThemeConstants.Entry.Signals.SelectionCleared);
27+
selectionCleared.On += OnSelectionCleared;
28+
2029
nativeView.TextChanged += OnTextChanged;
30+
nativeView.EntryLayoutFocused += OnFocused;
31+
nativeView.EntryLayoutUnfocused += OnUnfocused;
32+
2133
nativeView.PrependMarkUpFilter(MaxLengthFilter);
34+
35+
// TODO: Fix me later
36+
// An initial CursorPosition is set after layouting to avoid timing issue when the EditField entry is initialized.
37+
//if (VirtualView != null)
38+
//{
39+
// MainThread.BeginInvokeOnMainThread(() =>
40+
// {
41+
// nativeView.UpdateSelectionLength(VirtualView);
42+
// });
43+
//}
2244
}
2345

2446
protected override void DisconnectHandler(Entry nativeView)
2547
{
2648
nativeView.Activated -= OnCompleted;
49+
nativeView.CursorChanged -= OnCursorChanged;
2750
nativeView.TextChanged -= OnTextChanged;
51+
nativeView.EntryLayoutFocused -= OnFocused;
52+
nativeView.EntryLayoutUnfocused -= OnUnfocused;
2853
}
2954

3055
public static void MapText(EntryHandler handler, IEntry entry)
@@ -101,6 +126,21 @@ public static void MapFormatting(EntryHandler handler, IEntry entry)
101126
handler.NativeView?.UpdateHorizontalTextAlignment(entry);
102127
}
103128

129+
public static void MapSelectionLength(EntryHandler handler, IEntry entry)
130+
{
131+
handler.NativeView?.UpdateSelectionLength(entry);
132+
}
133+
134+
public static void MapCursorPosition(EntryHandler handler, IEntry entry)
135+
{
136+
handler.NativeView?.UpdateSelectionLength(entry);
137+
}
138+
139+
public static void MapKeyboard(EditorHandler handler, IEditor editor)
140+
{
141+
handler.NativeView?.UpdateKeyboard(editor);
142+
}
143+
104144
[MissingMapper]
105145
public static void MapCharacterSpacing(EntryHandler handler, IEntry entry) { }
106146

@@ -123,6 +163,37 @@ void OnTextChanged(object? sender, EventArgs e)
123163
VirtualView.Text = NativeView.Text;
124164
}
125165

166+
void OnCursorChanged(object? sender, EventArgs e)
167+
{
168+
if (VirtualView == null || NativeView == null)
169+
return;
170+
171+
var position = NativeView.CursorPosition;
172+
173+
NativeView.GetSelectRegion(out int start, out int end);
174+
175+
if (start > -1)
176+
{
177+
position = (start < end) ? start : end;
178+
var selectionLength = Math.Abs(end - start);
179+
VirtualView.SelectionLength = selectionLength;
180+
}
181+
182+
VirtualView.CursorPosition = position;
183+
}
184+
185+
void OnSelectionCleared(object sender, EventArgs e)
186+
{
187+
if (VirtualView == null || NativeView == null)
188+
return;
189+
190+
if (NativeView.IsFocused)
191+
{
192+
VirtualView.SelectionLength = 0;
193+
VirtualView.CursorPosition = NativeView.CursorPosition;
194+
}
195+
}
196+
126197
void OnCompleted(object? sender, EventArgs e)
127198
{
128199
if (NativeView == null)

0 commit comments

Comments
 (0)