Use spaces to match Ooui
This commit is contained in:
parent
e3627b5b90
commit
a887133288
|
@ -9,12 +9,12 @@ using Xamarin.Forms.Internals;
|
|||
|
||||
namespace Ooui.Forms
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)]
|
||||
public sealed class ExportRendererAttribute : HandlerAttribute
|
||||
{
|
||||
public ExportRendererAttribute (Type handler, Type target)
|
||||
: base (handler, target)
|
||||
{
|
||||
}
|
||||
}
|
||||
[AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)]
|
||||
public sealed class ExportRendererAttribute : HandlerAttribute
|
||||
{
|
||||
public ExportRendererAttribute (Type handler, Type target)
|
||||
: base (handler, target)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,101 +11,101 @@ using Ooui;
|
|||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
public static class Forms
|
||||
{
|
||||
public static bool IsInitialized { get; private set; }
|
||||
public static class Forms
|
||||
{
|
||||
public static bool IsInitialized { get; private set; }
|
||||
|
||||
public static void Init ()
|
||||
{
|
||||
if (IsInitialized)
|
||||
return;
|
||||
IsInitialized = true;
|
||||
public static void Init ()
|
||||
{
|
||||
if (IsInitialized)
|
||||
return;
|
||||
IsInitialized = true;
|
||||
|
||||
Log.Listeners.Add (new DelegateLogListener ((c, m) => Trace.WriteLine (m, c)));
|
||||
Log.Listeners.Add (new DelegateLogListener ((c, m) => Trace.WriteLine (m, c)));
|
||||
|
||||
Device.SetIdiom (TargetIdiom.Desktop);
|
||||
Device.PlatformServices = new OouiPlatformServices ();
|
||||
Device.Info = new OouiDeviceInfo ();
|
||||
Device.SetIdiom (TargetIdiom.Desktop);
|
||||
Device.PlatformServices = new OouiPlatformServices ();
|
||||
Device.Info = new OouiDeviceInfo ();
|
||||
|
||||
Registrar.RegisterAll (new[] {
|
||||
typeof(ExportRendererAttribute),
|
||||
Registrar.RegisterAll (new[] {
|
||||
typeof(ExportRendererAttribute),
|
||||
//typeof(ExportCellAttribute),
|
||||
//typeof(ExportImageSourceHandlerAttribute),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static event EventHandler<ViewInitializedEventArgs> ViewInitialized;
|
||||
public static event EventHandler<ViewInitializedEventArgs> ViewInitialized;
|
||||
|
||||
public static void SendViewInitialized (this VisualElement self, Ooui.Element nativeView)
|
||||
{
|
||||
ViewInitialized?.Invoke (self, new ViewInitializedEventArgs { View = self, NativeView = nativeView });
|
||||
}
|
||||
public static void SendViewInitialized (this VisualElement self, Ooui.Element nativeView)
|
||||
{
|
||||
ViewInitialized?.Invoke (self, new ViewInitializedEventArgs { View = self, NativeView = nativeView });
|
||||
}
|
||||
|
||||
class OouiDeviceInfo : DeviceInfo
|
||||
{
|
||||
public override Size PixelScreenSize => new Size (640, 480);
|
||||
class OouiDeviceInfo : DeviceInfo
|
||||
{
|
||||
public override Size PixelScreenSize => new Size (640, 480);
|
||||
|
||||
public override Size ScaledScreenSize => PixelScreenSize;
|
||||
public override Size ScaledScreenSize => PixelScreenSize;
|
||||
|
||||
public override double ScalingFactor => 1;
|
||||
}
|
||||
public override double ScalingFactor => 1;
|
||||
}
|
||||
|
||||
class OouiPlatformServices : IPlatformServices
|
||||
{
|
||||
public bool IsInvokeRequired => false;
|
||||
class OouiPlatformServices : IPlatformServices
|
||||
{
|
||||
public bool IsInvokeRequired => false;
|
||||
|
||||
public string RuntimePlatform => "Ooui";
|
||||
public string RuntimePlatform => "Ooui";
|
||||
|
||||
public void BeginInvokeOnMainThread (Action action)
|
||||
{
|
||||
Task.Run (action);
|
||||
}
|
||||
public void BeginInvokeOnMainThread (Action action)
|
||||
{
|
||||
Task.Run (action);
|
||||
}
|
||||
|
||||
public Ticker CreateTicker ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public Ticker CreateTicker ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public Assembly[] GetAssemblies ()
|
||||
{
|
||||
return AppDomain.CurrentDomain.GetAssemblies ();
|
||||
}
|
||||
public Assembly[] GetAssemblies ()
|
||||
{
|
||||
return AppDomain.CurrentDomain.GetAssemblies ();
|
||||
}
|
||||
|
||||
public string GetMD5Hash (string input)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public string GetMD5Hash (string input)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public double GetNamedSize (NamedSize size, Type targetElementType, bool useOldSizes)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public double GetNamedSize (NamedSize size, Type targetElementType, bool useOldSizes)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public Task<Stream> GetStreamAsync (Uri uri, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public Task<Stream> GetStreamAsync (Uri uri, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public IIsolatedStorageFile GetUserStoreForApplication ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public IIsolatedStorageFile GetUserStoreForApplication ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void OpenUriAction (Uri uri)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public void OpenUriAction (Uri uri)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void StartTimer (TimeSpan interval, Func<bool> callback)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
public void StartTimer (TimeSpan interval, Func<bool> callback)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public class ViewInitializedEventArgs
|
||||
{
|
||||
public VisualElement View { get; set; }
|
||||
public Ooui.Element NativeView { get; set; }
|
||||
}
|
||||
}
|
||||
public class ViewInitializedEventArgs
|
||||
{
|
||||
public VisualElement View { get; set; }
|
||||
public Ooui.Element NativeView { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,13 @@
|
|||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType></DebugType>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Xamarin.Forms" Version="2.4.0.38779" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -3,36 +3,36 @@ using Xamarin.Forms;
|
|||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
public static class PageExtensions
|
||||
{
|
||||
public static void Publish (this Xamarin.Forms.Page page, string path)
|
||||
{
|
||||
Ooui.UI.Publish (path, () => page.CreateElement ());
|
||||
}
|
||||
public static class PageExtensions
|
||||
{
|
||||
public static void Publish (this Xamarin.Forms.Page page, string path)
|
||||
{
|
||||
Ooui.UI.Publish (path, () => page.CreateElement ());
|
||||
}
|
||||
|
||||
public static void PublishShared (this Xamarin.Forms.Page page, string path)
|
||||
{
|
||||
var lazyPage = new Lazy<Ooui.Element> ((() => page.CreateElement ()), true);
|
||||
Ooui.UI.Publish (path, () => lazyPage.Value);
|
||||
}
|
||||
public static void PublishShared (this Xamarin.Forms.Page page, string path)
|
||||
{
|
||||
var lazyPage = new Lazy<Ooui.Element> ((() => page.CreateElement ()), true);
|
||||
Ooui.UI.Publish (path, () => lazyPage.Value);
|
||||
}
|
||||
|
||||
public static Ooui.Element CreateElement (this Xamarin.Forms.Page page)
|
||||
{
|
||||
if (!Xamarin.Forms.Forms.IsInitialized)
|
||||
throw new InvalidOperationException ("call Forms.Init() before this");
|
||||
public static Ooui.Element CreateElement (this Xamarin.Forms.Page page)
|
||||
{
|
||||
if (!Xamarin.Forms.Forms.IsInitialized)
|
||||
throw new InvalidOperationException ("call Forms.Init() before this");
|
||||
|
||||
if (!(page.RealParent is Application)) {
|
||||
var app = new DefaultApplication ();
|
||||
app.MainPage = page;
|
||||
}
|
||||
if (!(page.RealParent is Application)) {
|
||||
var app = new DefaultApplication ();
|
||||
app.MainPage = page;
|
||||
}
|
||||
|
||||
var result = new Ooui.Forms.Platform ();
|
||||
result.SetPage (page);
|
||||
return result.Element;
|
||||
}
|
||||
var result = new Ooui.Forms.Platform ();
|
||||
result.SetPage (page);
|
||||
return result.Element;
|
||||
}
|
||||
|
||||
class DefaultApplication : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
class DefaultApplication : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,167 +7,167 @@ using Xamarin.Forms.Internals;
|
|||
|
||||
namespace Ooui.Forms
|
||||
{
|
||||
public class Platform : BindableObject, IPlatform, INavigation, IDisposable
|
||||
{
|
||||
bool _disposed;
|
||||
public class Platform : BindableObject, IPlatform, INavigation, IDisposable
|
||||
{
|
||||
bool _disposed;
|
||||
|
||||
readonly PlatformRenderer _renderer;
|
||||
|
||||
public Ooui.Element Element => _renderer;
|
||||
|
||||
public Page Page { get; private set; }
|
||||
readonly PlatformRenderer _renderer;
|
||||
|
||||
IReadOnlyList<Page> INavigation.ModalStack => throw new NotImplementedException ();
|
||||
public Ooui.Element Element => _renderer;
|
||||
|
||||
IReadOnlyList<Page> INavigation.NavigationStack => throw new NotImplementedException ();
|
||||
|
||||
public static readonly BindableProperty RendererProperty = BindableProperty.CreateAttached ("Renderer", typeof (IVisualElementRenderer), typeof (Platform), default (IVisualElementRenderer),
|
||||
propertyChanged: (bindable, oldvalue, newvalue) => {
|
||||
var view = bindable as VisualElement;
|
||||
if (view != null)
|
||||
view.IsPlatformEnabled = newvalue != null;
|
||||
});
|
||||
|
||||
public Platform ()
|
||||
{
|
||||
_renderer = new PlatformRenderer (this);
|
||||
}
|
||||
public Page Page { get; private set; }
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
_disposed = true;
|
||||
|
||||
MessagingCenter.Unsubscribe<Page, ActionSheetArguments>(this, Page.ActionSheetSignalName);
|
||||
MessagingCenter.Unsubscribe<Page, AlertArguments>(this, Page.AlertSignalName);
|
||||
MessagingCenter.Unsubscribe<Page, bool>(this, Page.BusySetSignalName);
|
||||
}
|
||||
|
||||
public static IVisualElementRenderer CreateRenderer (VisualElement element)
|
||||
{
|
||||
var renderer = Registrar.Registered.GetHandler<IVisualElementRenderer> (element.GetType ()) ?? new DefaultRenderer ();
|
||||
renderer.SetElement (element);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
public static IVisualElementRenderer GetRenderer (VisualElement bindable)
|
||||
{
|
||||
return (IVisualElementRenderer)bindable.GetValue (RendererProperty);
|
||||
}
|
||||
|
||||
public static void SetRenderer (VisualElement bindable, IVisualElementRenderer value)
|
||||
{
|
||||
bindable.SetValue (RendererProperty, value);
|
||||
}
|
||||
|
||||
protected override void OnBindingContextChanged ()
|
||||
{
|
||||
SetInheritedBindingContext (Page, BindingContext);
|
||||
|
||||
base.OnBindingContextChanged ();
|
||||
}
|
||||
IReadOnlyList<Page> INavigation.ModalStack => throw new NotImplementedException ();
|
||||
|
||||
public SizeRequest GetNativeSize(VisualElement view, double widthConstraint, double heightConstraint)
|
||||
{
|
||||
return new SizeRequest(new Size(100, 100));
|
||||
}
|
||||
IReadOnlyList<Page> INavigation.NavigationStack => throw new NotImplementedException ();
|
||||
|
||||
public void SetPage (Page newRoot)
|
||||
{
|
||||
if (newRoot == null)
|
||||
return;
|
||||
if (Page != null)
|
||||
throw new NotImplementedException ();
|
||||
Page = newRoot;
|
||||
|
||||
Page.Platform = this;
|
||||
AddChild (Page);
|
||||
|
||||
Page.DescendantRemoved += HandleChildRemoved;
|
||||
|
||||
Application.Current.NavigationProxy.Inner = this;
|
||||
}
|
||||
public static readonly BindableProperty RendererProperty = BindableProperty.CreateAttached ("Renderer", typeof (IVisualElementRenderer), typeof (Platform), default (IVisualElementRenderer),
|
||||
propertyChanged: (bindable, oldvalue, newvalue) => {
|
||||
var view = bindable as VisualElement;
|
||||
if (view != null)
|
||||
view.IsPlatformEnabled = newvalue != null;
|
||||
});
|
||||
|
||||
void HandleChildRemoved (object sender, ElementEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public Platform ()
|
||||
{
|
||||
_renderer = new PlatformRenderer (this);
|
||||
}
|
||||
|
||||
void AddChild (VisualElement view)
|
||||
{
|
||||
if (!Application.IsApplicationOrNull (view.RealParent))
|
||||
Console.Error.WriteLine ("Tried to add parented view to canvas directly");
|
||||
|
||||
if (GetRenderer (view) == null) {
|
||||
var viewRenderer = CreateRenderer (view);
|
||||
SetRenderer (view, viewRenderer);
|
||||
|
||||
_renderer.AppendChild (viewRenderer.NativeView);
|
||||
viewRenderer.SetElementSize (new Size (640, 480));
|
||||
}
|
||||
else
|
||||
Console.Error.WriteLine ("Potential view double add");
|
||||
}
|
||||
void IDisposable.Dispose ()
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
_disposed = true;
|
||||
|
||||
void INavigation.InsertPageBefore (Page page, Page before)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
MessagingCenter.Unsubscribe<Page, ActionSheetArguments> (this, Page.ActionSheetSignalName);
|
||||
MessagingCenter.Unsubscribe<Page, AlertArguments> (this, Page.AlertSignalName);
|
||||
MessagingCenter.Unsubscribe<Page, bool> (this, Page.BusySetSignalName);
|
||||
}
|
||||
|
||||
Task<Page> INavigation.PopAsync ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public static IVisualElementRenderer CreateRenderer (VisualElement element)
|
||||
{
|
||||
var renderer = Registrar.Registered.GetHandler<IVisualElementRenderer> (element.GetType ()) ?? new DefaultRenderer ();
|
||||
renderer.SetElement (element);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
Task<Page> INavigation.PopAsync (bool animated)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public static IVisualElementRenderer GetRenderer (VisualElement bindable)
|
||||
{
|
||||
return (IVisualElementRenderer)bindable.GetValue (RendererProperty);
|
||||
}
|
||||
|
||||
Task<Page> INavigation.PopModalAsync ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public static void SetRenderer (VisualElement bindable, IVisualElementRenderer value)
|
||||
{
|
||||
bindable.SetValue (RendererProperty, value);
|
||||
}
|
||||
|
||||
Task<Page> INavigation.PopModalAsync (bool animated)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
protected override void OnBindingContextChanged ()
|
||||
{
|
||||
SetInheritedBindingContext (Page, BindingContext);
|
||||
|
||||
Task INavigation.PopToRootAsync ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
base.OnBindingContextChanged ();
|
||||
}
|
||||
|
||||
Task INavigation.PopToRootAsync (bool animated)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public SizeRequest GetNativeSize (VisualElement view, double widthConstraint, double heightConstraint)
|
||||
{
|
||||
return new SizeRequest (new Size (100, 100));
|
||||
}
|
||||
|
||||
Task INavigation.PushAsync (Page page)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public void SetPage (Page newRoot)
|
||||
{
|
||||
if (newRoot == null)
|
||||
return;
|
||||
if (Page != null)
|
||||
throw new NotImplementedException ();
|
||||
Page = newRoot;
|
||||
|
||||
Task INavigation.PushAsync (Page page, bool animated)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
Page.Platform = this;
|
||||
AddChild (Page);
|
||||
|
||||
Task INavigation.PushModalAsync (Page page)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
Page.DescendantRemoved += HandleChildRemoved;
|
||||
|
||||
Task INavigation.PushModalAsync (Page page, bool animated)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
Application.Current.NavigationProxy.Inner = this;
|
||||
}
|
||||
|
||||
void INavigation.RemovePage (Page page)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
void HandleChildRemoved (object sender, ElementEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
void AddChild (VisualElement view)
|
||||
{
|
||||
if (!Application.IsApplicationOrNull (view.RealParent))
|
||||
Console.Error.WriteLine ("Tried to add parented view to canvas directly");
|
||||
|
||||
if (GetRenderer (view) == null) {
|
||||
var viewRenderer = CreateRenderer (view);
|
||||
SetRenderer (view, viewRenderer);
|
||||
|
||||
_renderer.AppendChild (viewRenderer.NativeView);
|
||||
viewRenderer.SetElementSize (new Size (640, 480));
|
||||
}
|
||||
else
|
||||
Console.Error.WriteLine ("Potential view double add");
|
||||
}
|
||||
|
||||
void INavigation.InsertPageBefore (Page page, Page before)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
Task<Page> INavigation.PopAsync ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
Task<Page> INavigation.PopAsync (bool animated)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
Task<Page> INavigation.PopModalAsync ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
Task<Page> INavigation.PopModalAsync (bool animated)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
Task INavigation.PopToRootAsync ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
Task INavigation.PopToRootAsync (bool animated)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
Task INavigation.PushAsync (Page page)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
Task INavigation.PushAsync (Page page, bool animated)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
Task INavigation.PushModalAsync (Page page)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
Task INavigation.PushModalAsync (Page page, bool animated)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
void INavigation.RemovePage (Page page)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@ using Xamarin.Forms;
|
|||
|
||||
namespace Ooui.Forms.Renderers
|
||||
{
|
||||
public class ButtonRenderer : ViewRenderer<Xamarin.Forms.Button, Ooui.Button>
|
||||
{
|
||||
public ButtonRenderer()
|
||||
{
|
||||
}
|
||||
}
|
||||
public class ButtonRenderer : ViewRenderer<Xamarin.Forms.Button, Ooui.Button>
|
||||
{
|
||||
public ButtonRenderer ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@ using Xamarin.Forms;
|
|||
|
||||
namespace Ooui.Forms.Renderers
|
||||
{
|
||||
public class DefaultRenderer : VisualElementRenderer<VisualElement>
|
||||
{
|
||||
public DefaultRenderer ()
|
||||
{
|
||||
}
|
||||
}
|
||||
public class DefaultRenderer : VisualElementRenderer<VisualElement>
|
||||
{
|
||||
public DefaultRenderer ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace Ooui.Forms.Renderers
|
|||
if (Element == null || Control == null)
|
||||
return;
|
||||
|
||||
var uiControl = Control as Ooui.Element;
|
||||
var uiControl = Control as Ooui.FormControl;
|
||||
if (uiControl == null)
|
||||
return;
|
||||
uiControl.IsDisabled = !Element.IsEnabled;
|
||||
|
|
|
@ -19,8 +19,9 @@ namespace Ooui.Forms
|
|||
{
|
||||
readonly ConcurrentDictionary<string, object> values =
|
||||
new ConcurrentDictionary<string, object> ();
|
||||
|
||||
#pragma warning disable 67
|
||||
public event EventHandler<ResourcesChangedEventArgs> ValuesChanged;
|
||||
#pragma warning restore 67
|
||||
|
||||
public bool TryGetValue (string key, out object value)
|
||||
{
|
||||
|
|
|
@ -6,145 +6,145 @@ using Xamarin.Forms;
|
|||
|
||||
namespace Ooui.Forms
|
||||
{
|
||||
public class VisualElementRenderer<TElement> : Ooui.Element, IVisualElementRenderer where TElement : VisualElement
|
||||
{
|
||||
bool disposedValue = false; // To detect redundant calls
|
||||
VisualElementTracker _tracker;
|
||||
public class VisualElementRenderer<TElement> : Ooui.Element, IVisualElementRenderer where TElement : VisualElement
|
||||
{
|
||||
bool disposedValue = false; // To detect redundant calls
|
||||
VisualElementTracker _tracker;
|
||||
|
||||
readonly Color _defaultColor = Color.Clear;
|
||||
readonly Color _defaultColor = Color.Clear;
|
||||
|
||||
readonly PropertyChangedEventHandler _propertyChangedHandler;
|
||||
readonly PropertyChangedEventHandler _propertyChangedHandler;
|
||||
|
||||
public TElement Element { get; private set; }
|
||||
public TElement Element { get; private set; }
|
||||
|
||||
VisualElement IVisualElementRenderer.Element => Element;
|
||||
VisualElement IVisualElementRenderer.Element => Element;
|
||||
|
||||
public Element NativeView => this;
|
||||
public Element NativeView => this;
|
||||
|
||||
event EventHandler<VisualElementChangedEventArgs> IVisualElementRenderer.ElementChanged {
|
||||
add { _elementChangedHandlers.Add (value); }
|
||||
remove { _elementChangedHandlers.Remove (value); }
|
||||
}
|
||||
event EventHandler<VisualElementChangedEventArgs> IVisualElementRenderer.ElementChanged {
|
||||
add { _elementChangedHandlers.Add (value); }
|
||||
remove { _elementChangedHandlers.Remove (value); }
|
||||
}
|
||||
|
||||
readonly List<EventHandler<VisualElementChangedEventArgs>> _elementChangedHandlers =
|
||||
new List<EventHandler<VisualElementChangedEventArgs>> ();
|
||||
readonly List<EventHandler<VisualElementChangedEventArgs>> _elementChangedHandlers =
|
||||
new List<EventHandler<VisualElementChangedEventArgs>> ();
|
||||
|
||||
public VisualElementRenderer () : base ("div")
|
||||
{
|
||||
_propertyChangedHandler = OnElementPropertyChanged;
|
||||
}
|
||||
public VisualElementRenderer () : base ("div")
|
||||
{
|
||||
_propertyChangedHandler = OnElementPropertyChanged;
|
||||
}
|
||||
|
||||
protected virtual void OnElementChanged (ElementChangedEventArgs<TElement> e)
|
||||
{
|
||||
var args = new VisualElementChangedEventArgs (e.OldElement, e.NewElement);
|
||||
for (int i = 0; i < _elementChangedHandlers.Count; i++) {
|
||||
_elementChangedHandlers[i] (this, args);
|
||||
}
|
||||
protected virtual void OnElementChanged (ElementChangedEventArgs<TElement> e)
|
||||
{
|
||||
var args = new VisualElementChangedEventArgs (e.OldElement, e.NewElement);
|
||||
for (int i = 0; i < _elementChangedHandlers.Count; i++) {
|
||||
_elementChangedHandlers[i] (this, args);
|
||||
}
|
||||
|
||||
var changed = ElementChanged;
|
||||
if (changed != null)
|
||||
changed (this, e);
|
||||
}
|
||||
var changed = ElementChanged;
|
||||
if (changed != null)
|
||||
changed (this, e);
|
||||
}
|
||||
|
||||
public event EventHandler<ElementChangedEventArgs<TElement>> ElementChanged;
|
||||
public event EventHandler<ElementChangedEventArgs<TElement>> ElementChanged;
|
||||
|
||||
void IVisualElementRenderer.SetElement (VisualElement element)
|
||||
{
|
||||
SetElement ((TElement)element);
|
||||
}
|
||||
void IVisualElementRenderer.SetElement (VisualElement element)
|
||||
{
|
||||
SetElement ((TElement)element);
|
||||
}
|
||||
|
||||
public void SetElement (TElement element)
|
||||
{
|
||||
var oldElement = Element;
|
||||
Element = element;
|
||||
public void SetElement (TElement element)
|
||||
{
|
||||
var oldElement = Element;
|
||||
Element = element;
|
||||
|
||||
if (oldElement != null)
|
||||
oldElement.PropertyChanged -= _propertyChangedHandler;
|
||||
if (oldElement != null)
|
||||
oldElement.PropertyChanged -= _propertyChangedHandler;
|
||||
|
||||
if (element != null) {
|
||||
if (element.BackgroundColor != Xamarin.Forms.Color.Default || (oldElement != null && element.BackgroundColor != oldElement.BackgroundColor))
|
||||
SetBackgroundColor (element.BackgroundColor);
|
||||
if (element != null) {
|
||||
if (element.BackgroundColor != Xamarin.Forms.Color.Default || (oldElement != null && element.BackgroundColor != oldElement.BackgroundColor))
|
||||
SetBackgroundColor (element.BackgroundColor);
|
||||
|
||||
if (_tracker == null) {
|
||||
_tracker = new VisualElementTracker (this);
|
||||
_tracker.NativeControlUpdated += (sender, e) => UpdateNativeWidget ();
|
||||
}
|
||||
if (_tracker == null) {
|
||||
_tracker = new VisualElementTracker (this);
|
||||
_tracker.NativeControlUpdated += (sender, e) => UpdateNativeWidget ();
|
||||
}
|
||||
|
||||
//if (AutoPackage && _packager == null) {
|
||||
// _packager = new VisualElementPackager (this);
|
||||
// _packager.Load ();
|
||||
//}
|
||||
//if (AutoPackage && _packager == null) {
|
||||
// _packager = new VisualElementPackager (this);
|
||||
// _packager.Load ();
|
||||
//}
|
||||
|
||||
//if (AutoTrack && _events == null) {
|
||||
// _events = new EventTracker (this);
|
||||
// _events.LoadEvents (this);
|
||||
//}
|
||||
//if (AutoTrack && _events == null) {
|
||||
// _events = new EventTracker (this);
|
||||
// _events.LoadEvents (this);
|
||||
//}
|
||||
|
||||
element.PropertyChanged += _propertyChangedHandler;
|
||||
}
|
||||
element.PropertyChanged += _propertyChangedHandler;
|
||||
}
|
||||
|
||||
OnElementChanged (new ElementChangedEventArgs<TElement> (oldElement, element));
|
||||
OnElementChanged (new ElementChangedEventArgs<TElement> (oldElement, element));
|
||||
|
||||
if (element != null)
|
||||
SendVisualElementInitialized (element, this);
|
||||
if (element != null)
|
||||
SendVisualElementInitialized (element, this);
|
||||
|
||||
if (Element != null && !string.IsNullOrEmpty (Element.AutomationId))
|
||||
SetAutomationId (Element.AutomationId);
|
||||
}
|
||||
if (Element != null && !string.IsNullOrEmpty (Element.AutomationId))
|
||||
SetAutomationId (Element.AutomationId);
|
||||
}
|
||||
|
||||
public void SetElementSize (Size size)
|
||||
{
|
||||
Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Element, new Rectangle (Element.X, Element.Y, size.Width, size.Height));
|
||||
}
|
||||
public void SetElementSize (Size size)
|
||||
{
|
||||
Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Element, new Rectangle (Element.X, Element.Y, size.Width, size.Height));
|
||||
}
|
||||
|
||||
protected virtual void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName) {
|
||||
SetBackgroundColor (Element.BackgroundColor);
|
||||
}
|
||||
else if (e.PropertyName == Layout.IsClippedToBoundsProperty.PropertyName) {
|
||||
//UpdateClipToBounds ();
|
||||
}
|
||||
}
|
||||
protected virtual void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName) {
|
||||
SetBackgroundColor (Element.BackgroundColor);
|
||||
}
|
||||
else if (e.PropertyName == Layout.IsClippedToBoundsProperty.PropertyName) {
|
||||
//UpdateClipToBounds ();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnRegisterEffect (PlatformEffect effect)
|
||||
{
|
||||
//effect.Container = this;
|
||||
}
|
||||
protected virtual void OnRegisterEffect (PlatformEffect effect)
|
||||
{
|
||||
//effect.Container = this;
|
||||
}
|
||||
|
||||
protected virtual void SetAutomationId (string id)
|
||||
{
|
||||
}
|
||||
protected virtual void SetAutomationId (string id)
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void SetBackgroundColor (Xamarin.Forms.Color color)
|
||||
{
|
||||
if (color == Xamarin.Forms.Color.Default)
|
||||
Style.BackgroundColor = _defaultColor;
|
||||
else
|
||||
Style.BackgroundColor = color.ToOouiColor ();
|
||||
}
|
||||
protected virtual void SetBackgroundColor (Xamarin.Forms.Color color)
|
||||
{
|
||||
if (color == Xamarin.Forms.Color.Default)
|
||||
Style.BackgroundColor = _defaultColor;
|
||||
else
|
||||
Style.BackgroundColor = color.ToOouiColor ();
|
||||
}
|
||||
|
||||
protected virtual void UpdateNativeWidget ()
|
||||
{
|
||||
}
|
||||
protected virtual void UpdateNativeWidget ()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void SendVisualElementInitialized (VisualElement element, Element nativeView)
|
||||
{
|
||||
element.SendViewInitialized (nativeView);
|
||||
}
|
||||
protected virtual void SendVisualElementInitialized (VisualElement element, Element nativeView)
|
||||
{
|
||||
element.SendViewInitialized (nativeView);
|
||||
}
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
if (!disposedValue) {
|
||||
if (disposing) {
|
||||
}
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
if (!disposedValue) {
|
||||
if (disposing) {
|
||||
}
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
}
|
||||
}
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,213 +6,214 @@ using Xamarin.Forms.Internals;
|
|||
|
||||
namespace Ooui.Forms
|
||||
{
|
||||
public class VisualElementTracker
|
||||
{
|
||||
readonly EventHandler<EventArg<VisualElement>> _batchCommittedHandler;
|
||||
public class VisualElementTracker
|
||||
{
|
||||
readonly EventHandler<EventArg<VisualElement>> _batchCommittedHandler;
|
||||
|
||||
readonly PropertyChangedEventHandler _propertyChangedHandler;
|
||||
readonly EventHandler _sizeChangedEventHandler;
|
||||
bool _disposed;
|
||||
VisualElement _element;
|
||||
readonly PropertyChangedEventHandler _propertyChangedHandler;
|
||||
readonly EventHandler _sizeChangedEventHandler;
|
||||
bool _disposed;
|
||||
VisualElement _element;
|
||||
|
||||
// Track these by hand because the calls down into iOS are too expensive
|
||||
bool _isInteractive;
|
||||
Rectangle _lastBounds;
|
||||
// Track these by hand because the calls down into iOS are too expensive
|
||||
bool _isInteractive;
|
||||
Rectangle _lastBounds;
|
||||
#if !__MOBILE__
|
||||
Rectangle _lastParentBounds;
|
||||
Rectangle _lastParentBounds;
|
||||
#endif
|
||||
int _updateCount;
|
||||
int _updateCount;
|
||||
|
||||
public VisualElementTracker (IVisualElementRenderer renderer)
|
||||
{
|
||||
if (renderer == null)
|
||||
throw new ArgumentNullException (nameof (renderer));
|
||||
public VisualElementTracker (IVisualElementRenderer renderer)
|
||||
{
|
||||
if (renderer == null)
|
||||
throw new ArgumentNullException (nameof (renderer));
|
||||
|
||||
_propertyChangedHandler = HandlePropertyChanged;
|
||||
_sizeChangedEventHandler = HandleSizeChanged;
|
||||
_batchCommittedHandler = HandleRedrawNeeded;
|
||||
_propertyChangedHandler = HandlePropertyChanged;
|
||||
_sizeChangedEventHandler = HandleSizeChanged;
|
||||
_batchCommittedHandler = HandleRedrawNeeded;
|
||||
|
||||
Renderer = renderer;
|
||||
renderer.ElementChanged += OnRendererElementChanged;
|
||||
SetElement (null, renderer.Element);
|
||||
}
|
||||
Renderer = renderer;
|
||||
renderer.ElementChanged += OnRendererElementChanged;
|
||||
SetElement (null, renderer.Element);
|
||||
}
|
||||
|
||||
IVisualElementRenderer Renderer { get; set; }
|
||||
IVisualElementRenderer Renderer { get; set; }
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
}
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
}
|
||||
|
||||
public event EventHandler NativeControlUpdated;
|
||||
public event EventHandler NativeControlUpdated;
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
_disposed = true;
|
||||
_disposed = true;
|
||||
|
||||
if (disposing) {
|
||||
SetElement (_element, null);
|
||||
if (disposing) {
|
||||
SetElement (_element, null);
|
||||
|
||||
Renderer.ElementChanged -= OnRendererElementChanged;
|
||||
Renderer = null;
|
||||
}
|
||||
}
|
||||
Renderer.ElementChanged -= OnRendererElementChanged;
|
||||
Renderer = null;
|
||||
}
|
||||
}
|
||||
|
||||
void HandlePropertyChanged (object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == VisualElement.XProperty.PropertyName || e.PropertyName == VisualElement.YProperty.PropertyName || e.PropertyName == VisualElement.WidthProperty.PropertyName ||
|
||||
e.PropertyName == VisualElement.HeightProperty.PropertyName || e.PropertyName == VisualElement.AnchorXProperty.PropertyName || e.PropertyName == VisualElement.AnchorYProperty.PropertyName ||
|
||||
e.PropertyName == VisualElement.TranslationXProperty.PropertyName || e.PropertyName == VisualElement.TranslationYProperty.PropertyName || e.PropertyName == VisualElement.ScaleProperty.PropertyName ||
|
||||
e.PropertyName == VisualElement.RotationProperty.PropertyName || e.PropertyName == VisualElement.RotationXProperty.PropertyName || e.PropertyName == VisualElement.RotationYProperty.PropertyName ||
|
||||
e.PropertyName == VisualElement.IsVisibleProperty.PropertyName || e.PropertyName == VisualElement.IsEnabledProperty.PropertyName ||
|
||||
e.PropertyName == VisualElement.InputTransparentProperty.PropertyName || e.PropertyName == VisualElement.OpacityProperty.PropertyName)
|
||||
UpdateNativeControl (); // poorly optimized
|
||||
}
|
||||
void HandlePropertyChanged (object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == VisualElement.XProperty.PropertyName || e.PropertyName == VisualElement.YProperty.PropertyName || e.PropertyName == VisualElement.WidthProperty.PropertyName ||
|
||||
e.PropertyName == VisualElement.HeightProperty.PropertyName || e.PropertyName == VisualElement.AnchorXProperty.PropertyName || e.PropertyName == VisualElement.AnchorYProperty.PropertyName ||
|
||||
e.PropertyName == VisualElement.TranslationXProperty.PropertyName || e.PropertyName == VisualElement.TranslationYProperty.PropertyName || e.PropertyName == VisualElement.ScaleProperty.PropertyName ||
|
||||
e.PropertyName == VisualElement.RotationProperty.PropertyName || e.PropertyName == VisualElement.RotationXProperty.PropertyName || e.PropertyName == VisualElement.RotationYProperty.PropertyName ||
|
||||
e.PropertyName == VisualElement.IsVisibleProperty.PropertyName || e.PropertyName == VisualElement.IsEnabledProperty.PropertyName ||
|
||||
e.PropertyName == VisualElement.InputTransparentProperty.PropertyName || e.PropertyName == VisualElement.OpacityProperty.PropertyName)
|
||||
UpdateNativeControl (); // poorly optimized
|
||||
}
|
||||
|
||||
void HandleRedrawNeeded (object sender, EventArgs e)
|
||||
{
|
||||
UpdateNativeControl ();
|
||||
}
|
||||
void HandleRedrawNeeded (object sender, EventArgs e)
|
||||
{
|
||||
UpdateNativeControl ();
|
||||
}
|
||||
|
||||
void HandleSizeChanged (object sender, EventArgs e)
|
||||
{
|
||||
UpdateNativeControl ();
|
||||
}
|
||||
void HandleSizeChanged (object sender, EventArgs e)
|
||||
{
|
||||
UpdateNativeControl ();
|
||||
}
|
||||
|
||||
void OnRendererElementChanged (object s, VisualElementChangedEventArgs e)
|
||||
{
|
||||
if (_element == e.NewElement)
|
||||
return;
|
||||
void OnRendererElementChanged (object s, VisualElementChangedEventArgs e)
|
||||
{
|
||||
if (_element == e.NewElement)
|
||||
return;
|
||||
|
||||
SetElement (_element, e.NewElement);
|
||||
}
|
||||
SetElement (_element, e.NewElement);
|
||||
}
|
||||
|
||||
void OnUpdateNativeControl ()
|
||||
{
|
||||
var view = Renderer.Element;
|
||||
var uiview = Renderer.NativeView;
|
||||
void OnUpdateNativeControl ()
|
||||
{
|
||||
var view = Renderer.Element;
|
||||
var uiview = Renderer.NativeView;
|
||||
|
||||
if (view == null || view.Batched)
|
||||
return;
|
||||
if (view == null || view.Batched)
|
||||
return;
|
||||
|
||||
var shouldInteract = !view.InputTransparent && view.IsEnabled;
|
||||
if (_isInteractive != shouldInteract) {
|
||||
_isInteractive = shouldInteract;
|
||||
}
|
||||
var shouldInteract = !view.InputTransparent && view.IsEnabled;
|
||||
if (_isInteractive != shouldInteract) {
|
||||
_isInteractive = shouldInteract;
|
||||
}
|
||||
|
||||
var boundsChanged = _lastBounds != view.Bounds;
|
||||
var viewParent = view.RealParent as VisualElement;
|
||||
var parentBoundsChanged = _lastParentBounds != (viewParent == null ? Rectangle.Zero : viewParent.Bounds);
|
||||
var thread = !boundsChanged;
|
||||
var boundsChanged = _lastBounds != view.Bounds;
|
||||
var viewParent = view.RealParent as VisualElement;
|
||||
var parentBoundsChanged = _lastParentBounds != (viewParent == null ? Rectangle.Zero : viewParent.Bounds);
|
||||
var thread = !boundsChanged;
|
||||
|
||||
var anchorX = (float)view.AnchorX;
|
||||
var anchorY = (float)view.AnchorY;
|
||||
var translationX = (float)view.TranslationX;
|
||||
var translationY = (float)view.TranslationY;
|
||||
var rotationX = (float)view.RotationX;
|
||||
var rotationY = (float)view.RotationY;
|
||||
var rotation = (float)view.Rotation;
|
||||
var scale = (float)view.Scale;
|
||||
var width = (float)view.Width;
|
||||
var height = (float)view.Height;
|
||||
var x = (float)view.X;
|
||||
var y = (float)view.Y;
|
||||
var opacity = (float)view.Opacity;
|
||||
var isVisible = view.IsVisible;
|
||||
var anchorX = (float)view.AnchorX;
|
||||
var anchorY = (float)view.AnchorY;
|
||||
var translationX = (float)view.TranslationX;
|
||||
var translationY = (float)view.TranslationY;
|
||||
var rotationX = (float)view.RotationX;
|
||||
var rotationY = (float)view.RotationY;
|
||||
var rotation = (float)view.Rotation;
|
||||
var scale = (float)view.Scale;
|
||||
var width = (float)view.Width;
|
||||
var height = (float)view.Height;
|
||||
var x = (float)view.X;
|
||||
var y = (float)view.Y;
|
||||
var opacity = (float)view.Opacity;
|
||||
var isVisible = view.IsVisible;
|
||||
|
||||
var updateTarget = Interlocked.Increment (ref _updateCount);
|
||||
var updateTarget = Interlocked.Increment (ref _updateCount);
|
||||
|
||||
if (updateTarget != _updateCount)
|
||||
return;
|
||||
var parent = view.RealParent;
|
||||
if (updateTarget != _updateCount)
|
||||
return;
|
||||
var parent = view.RealParent;
|
||||
|
||||
if (isVisible && uiview.IsHidden) {
|
||||
uiview.IsHidden = false;
|
||||
}
|
||||
if (isVisible && uiview.IsHidden) {
|
||||
uiview.IsHidden = false;
|
||||
}
|
||||
|
||||
if (!isVisible && !uiview.IsHidden) {
|
||||
uiview.IsHidden = true;
|
||||
}
|
||||
if (!isVisible && !uiview.IsHidden) {
|
||||
uiview.IsHidden = true;
|
||||
}
|
||||
|
||||
parentBoundsChanged = true;
|
||||
bool shouldUpdate = width > 0 && height > 0 && parent != null && (boundsChanged || parentBoundsChanged);
|
||||
if (shouldUpdate) {
|
||||
var visualParent = parent as VisualElement;
|
||||
float newY = visualParent == null ? y : Math.Max (0, (float)(visualParent.Height - y - view.Height));
|
||||
var target = new Rectangle (x, newY, width, height);
|
||||
parentBoundsChanged = true;
|
||||
bool shouldUpdate = width > 0 && height > 0 && parent != null && (boundsChanged || parentBoundsChanged);
|
||||
if (shouldUpdate) {
|
||||
var visualParent = parent as VisualElement;
|
||||
float newY = visualParent == null ? y : Math.Max (0, (float)(visualParent.Height - y - view.Height));
|
||||
var target = new Rectangle (x, newY, width, height);
|
||||
|
||||
uiview.Style.Left = x;
|
||||
uiview.Style.Top = newY;
|
||||
uiview.Style.Width = width;
|
||||
uiview.Style.Height = height;
|
||||
}
|
||||
else if (width <= 0 || height <= 0) {
|
||||
return;
|
||||
}
|
||||
uiview.Style.Opacity = opacity;
|
||||
uiview.Style.Position = "absolute";
|
||||
uiview.Style.Left = x;
|
||||
uiview.Style.Top = newY;
|
||||
uiview.Style.Right = x + width;
|
||||
uiview.Style.Bottom = newY + height;
|
||||
}
|
||||
else if (width <= 0 || height <= 0) {
|
||||
return;
|
||||
}
|
||||
uiview.Style.Opacity = opacity;
|
||||
|
||||
//var transform = 0;
|
||||
//const double epsilon = 0.001;
|
||||
//caLayer.AnchorPoint = new PointF (anchorX - 0.5f, anchorY - 0.5f);
|
||||
//var transform = 0;
|
||||
//const double epsilon = 0.001;
|
||||
//caLayer.AnchorPoint = new PointF (anchorX - 0.5f, anchorY - 0.5f);
|
||||
|
||||
//// position is relative to anchor point
|
||||
//if (Math.Abs (anchorX - .5) > epsilon)
|
||||
// transform = transform.Translate ((anchorX - .5f) * width, 0, 0);
|
||||
//if (Math.Abs (anchorY - .5) > epsilon)
|
||||
// transform = transform.Translate (0, (anchorY - .5f) * height, 0);
|
||||
//// position is relative to anchor point
|
||||
//if (Math.Abs (anchorX - .5) > epsilon)
|
||||
// transform = transform.Translate ((anchorX - .5f) * width, 0, 0);
|
||||
//if (Math.Abs (anchorY - .5) > epsilon)
|
||||
// transform = transform.Translate (0, (anchorY - .5f) * height, 0);
|
||||
|
||||
//if (Math.Abs (translationX) > epsilon || Math.Abs (translationY) > epsilon)
|
||||
// transform = transform.Translate (translationX, translationY, 0);
|
||||
//if (Math.Abs (translationX) > epsilon || Math.Abs (translationY) > epsilon)
|
||||
// transform = transform.Translate (translationX, translationY, 0);
|
||||
|
||||
//if (Math.Abs (scale - 1) > epsilon)
|
||||
// transform = transform.Scale (scale);
|
||||
//if (Math.Abs (scale - 1) > epsilon)
|
||||
// transform = transform.Scale (scale);
|
||||
|
||||
//// not just an optimization, iOS will not "pixel align" a view which has m34 set
|
||||
//if (Math.Abs (rotationY % 180) > epsilon || Math.Abs (rotationX % 180) > epsilon)
|
||||
// transform.m34 = 1.0f / -400f;
|
||||
//// not just an optimization, iOS will not "pixel align" a view which has m34 set
|
||||
//if (Math.Abs (rotationY % 180) > epsilon || Math.Abs (rotationX % 180) > epsilon)
|
||||
// transform.m34 = 1.0f / -400f;
|
||||
|
||||
//if (Math.Abs (rotationX % 360) > epsilon)
|
||||
// transform = transform.Rotate (rotationX * (float)Math.PI / 180.0f, 1.0f, 0.0f, 0.0f);
|
||||
//if (Math.Abs (rotationY % 360) > epsilon)
|
||||
// transform = transform.Rotate (rotationY * (float)Math.PI / 180.0f, 0.0f, 1.0f, 0.0f);
|
||||
//if (Math.Abs (rotationX % 360) > epsilon)
|
||||
// transform = transform.Rotate (rotationX * (float)Math.PI / 180.0f, 1.0f, 0.0f, 0.0f);
|
||||
//if (Math.Abs (rotationY % 360) > epsilon)
|
||||
// transform = transform.Rotate (rotationY * (float)Math.PI / 180.0f, 0.0f, 1.0f, 0.0f);
|
||||
|
||||
//transform = transform.Rotate (rotation * (float)Math.PI / 180.0f, 0.0f, 0.0f, 1.0f);
|
||||
//caLayer.Transform = transform;
|
||||
//transform = transform.Rotate (rotation * (float)Math.PI / 180.0f, 0.0f, 0.0f, 1.0f);
|
||||
//caLayer.Transform = transform;
|
||||
|
||||
_lastBounds = view.Bounds;
|
||||
_lastParentBounds = viewParent?.Bounds ?? Rectangle.Zero;
|
||||
}
|
||||
_lastBounds = view.Bounds;
|
||||
_lastParentBounds = viewParent?.Bounds ?? Rectangle.Zero;
|
||||
}
|
||||
|
||||
void SetElement (VisualElement oldElement, VisualElement newElement)
|
||||
{
|
||||
if (oldElement != null) {
|
||||
oldElement.PropertyChanged -= _propertyChangedHandler;
|
||||
oldElement.SizeChanged -= _sizeChangedEventHandler;
|
||||
oldElement.BatchCommitted -= _batchCommittedHandler;
|
||||
}
|
||||
void SetElement (VisualElement oldElement, VisualElement newElement)
|
||||
{
|
||||
if (oldElement != null) {
|
||||
oldElement.PropertyChanged -= _propertyChangedHandler;
|
||||
oldElement.SizeChanged -= _sizeChangedEventHandler;
|
||||
oldElement.BatchCommitted -= _batchCommittedHandler;
|
||||
}
|
||||
|
||||
_element = newElement;
|
||||
_element = newElement;
|
||||
|
||||
if (newElement != null) {
|
||||
newElement.BatchCommitted += _batchCommittedHandler;
|
||||
newElement.SizeChanged += _sizeChangedEventHandler;
|
||||
newElement.PropertyChanged += _propertyChangedHandler;
|
||||
if (newElement != null) {
|
||||
newElement.BatchCommitted += _batchCommittedHandler;
|
||||
newElement.SizeChanged += _sizeChangedEventHandler;
|
||||
newElement.PropertyChanged += _propertyChangedHandler;
|
||||
|
||||
UpdateNativeControl ();
|
||||
}
|
||||
}
|
||||
UpdateNativeControl ();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateNativeControl ()
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
void UpdateNativeControl ()
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
OnUpdateNativeControl ();
|
||||
OnUpdateNativeControl ();
|
||||
|
||||
NativeControlUpdated?.Invoke (this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
NativeControlUpdated?.Invoke (this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1
Ooui.sln
1
Ooui.sln
|
@ -79,6 +79,7 @@ Global
|
|||
$1.FileWidth = 128
|
||||
$1.NoTabsAfterNonTabs = True
|
||||
$1.scope = text/x-csharp
|
||||
$1.TabsToSpaces = True
|
||||
$0.CSharpFormattingPolicy = $2
|
||||
$2.scope = text/x-csharp
|
||||
$2.NewLinesForBracesInProperties = False
|
||||
|
|
|
@ -25,12 +25,6 @@ namespace Ooui
|
|||
set => SetProperty (ref hidden, value, "hidden");
|
||||
}
|
||||
|
||||
bool disabled = false;
|
||||
public bool IsDisabled {
|
||||
get => disabled;
|
||||
set => SetProperty (ref disabled, value, "disabled");
|
||||
}
|
||||
|
||||
public event TargetEventHandler Clicked {
|
||||
add => AddEventListener ("click", value);
|
||||
remove => RemoveEventListener ("click", value);
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Ooui
|
|||
|
||||
readonly Dictionary<string, Value> properties =
|
||||
new Dictionary<string, Value> ();
|
||||
|
||||
|
||||
public Value AlignSelf {
|
||||
get => this["align-self"];
|
||||
set => this["align-self"] = value;
|
||||
|
@ -232,10 +232,10 @@ namespace Ooui
|
|||
}
|
||||
}
|
||||
|
||||
public Value Opacity {
|
||||
get => this["opacity"];
|
||||
set => this["opacity"] = value;
|
||||
}
|
||||
public Value Opacity {
|
||||
get => this["opacity"];
|
||||
set => this["opacity"] = value;
|
||||
}
|
||||
|
||||
public Value Order {
|
||||
get => this["order"];
|
||||
|
@ -272,6 +272,11 @@ namespace Ooui
|
|||
}
|
||||
}
|
||||
|
||||
public Value Position {
|
||||
get => this["position"];
|
||||
set => this["position"] = value;
|
||||
}
|
||||
|
||||
public Value Right {
|
||||
get => this["right"];
|
||||
set => this["right"] = value;
|
||||
|
@ -307,8 +312,7 @@ namespace Ooui
|
|||
set => this["width"] = value;
|
||||
}
|
||||
|
||||
public Value this [string propertyName]
|
||||
{
|
||||
public Value this[string propertyName] {
|
||||
get {
|
||||
lock (properties) {
|
||||
Value p;
|
||||
|
|
Loading…
Reference in New Issue