From 0990dc8d64e1db96a5550db17f1f5700490ead5f Mon Sep 17 00:00:00 2001 From: s-fernandez-v Date: Wed, 10 May 2023 00:13:10 +0200 Subject: [PATCH] Updated to NoesisGUI 3.2.1 version --- Src/Noesis/Core/Src/Core/Extend.cs | 152 +++--------------- Src/Noesis/Core/Src/Core/View.cs | 12 ++ .../Core/Src/Proxies/ApplicationCommands.cs | 88 +++++----- .../Core/Src/Proxies/ComponentCommands.cs | 104 ++++++------ .../Core/Src/Proxies/NoesisGUI_PINVOKE.cs | 96 +++++------ Src/NoesisApp/Core/Src/Core/Application.cs | 2 +- .../Core/Src/Core/ApplicationProvider.cs | 28 +++- .../Core/Src/Core/EmbeddedFontProvider.cs | 22 +-- .../MTL/Src/RenderContextMTL.cs | 2 +- 9 files changed, 210 insertions(+), 296 deletions(-) diff --git a/Src/Noesis/Core/Src/Core/Extend.cs b/Src/Noesis/Core/Src/Core/Extend.cs index 13d2cc6..a1dd8d0 100644 --- a/Src/Noesis/Core/Src/Core/Extend.cs +++ b/Src/Noesis/Core/Src/Core/Extend.cs @@ -67,14 +67,6 @@ public static void Shutdown() GC.Collect(); GC.WaitForPendingFinalizers(); -#if !NETSTANDARD - _weakExtendsIndex = 0; - while (_weakExtendsIndex < _weakExtends.Count) - { - AddDestroyedExtends(); - } -#endif - // NOTE: During release of pending objects new proxies could be created and those // references will show as leaks when Noesis shuts down. // TODO: Find a way to track those objects and correctly release them. @@ -319,10 +311,6 @@ private static void ClearTables() _nativeTypes.Clear(); _managedTypes.Clear(); _extends.Clear(); -#if !NETSTANDARD - _weakExtends.Clear(); - _weakExtendsHash.Clear(); -#endif _proxies.Clear(); _pendingRelease.Clear(); @@ -5874,26 +5862,7 @@ private static void AddExtendInfo(IntPtr cPtr, object instance) if (!(instance is BaseComponent)) { -#if NETSTANDARD _weakExtends.Add(instance, new ExtendNotifier { cPtr = cPtr }); -#else - WeakInfo info = new WeakInfo - { - hash = RuntimeHelpers.GetHashCode(instance), - ptr = cPtr.ToInt64(), - weak = extend.weak - }; - - _weakExtends.Add(info); - - List extends; - if (!_weakExtendsHash.TryGetValue(info.hash, out extends)) - { - extends = new List(); - _weakExtendsHash.Add(info.hash, extends); - } - extends.Add(info); -#endif } } } @@ -5906,60 +5875,6 @@ private static void RemoveExtendInfo(IntPtr cPtr) } } - //////////////////////////////////////////////////////////////////////////////////////////////// - private static void AddDestroyedExtends() - { -#if !NETSTANDARD - lock (_extends) - { - const int ExtendRange = 100; - - int count = _weakExtends.Count; - int start = _weakExtendsIndex >= count ? 0 : _weakExtendsIndex; - int end = start + ExtendRange > count ? count : start + ExtendRange; - int index = start; - while (index < end) - { - WeakInfo info = _weakExtends[index]; - if (!info.weak.IsAlive) - { - IntPtr cPtr = new IntPtr(info.ptr); - AddPendingRelease(cPtr); - - // Fast swap-remove from the list - int last = _weakExtends.Count - 1; - _weakExtends[index] = _weakExtends[last]; - _weakExtends.RemoveAt(last); - - // Remove hashed extend - List extends = _weakExtendsHash[info.hash]; - int numExtends = extends.Count; - for (int i = 0; i < numExtends; ++i) - { - if (extends[i].ptr == info.ptr) - { - extends[i] = extends[numExtends - 1]; - extends.RemoveAt(numExtends - 1); - break; - } - } - if (extends.Count == 0) - { - _weakExtendsHash.Remove(info.hash); - } - - --end; - } - else - { - ++index; - } - } - _weakExtendsIndex = end; - } -#endif - } - //////////////////////////////////////////////////////////////////////////////////////////////// private class ExtendInfo { @@ -5970,31 +5885,40 @@ private class ExtendInfo //////////////////////////////////////////////////////////////////////////////////////////////// private static Dictionary _extends = new Dictionary(); -#if NETSTANDARD private class ExtendNotifier { public IntPtr cPtr; ~ExtendNotifier() { - AddPendingRelease(cPtr); + // There is a weird situation in NETSTANDARD (a possible bug) that destroys the + // value even when the key is still alive. The workaround is to re-register the + // key instance in the ConditionalWeakTable until the key is really destroyed + object instance = null; + lock (_extends) + { + if (_extends.TryGetValue(cPtr.ToInt64(), out ExtendInfo extend) && + extend.weak.IsAlive) + { + instance = extend.weak.Target; + } + } + + if (instance != null) + { + _weakExtends.Remove(instance); + _weakExtends.Add(instance, this); + GC.ReRegisterForFinalize(this); + } + else + { + AddPendingRelease(cPtr); + } } } private static ConditionalWeakTable _weakExtends = new ConditionalWeakTable(); -#else - private struct WeakInfo - { - public int hash; - public long ptr; - public WeakReference weak; - } - - private static List _weakExtends = new List(400); - private static Dictionary> _weakExtendsHash = new Dictionary>(); - private static int _weakExtendsIndex = 0; -#endif //////////////////////////////////////////////////////////////////////////////////////////////// private static BaseComponent GetProxyInstance(IntPtr cPtr, bool ownMemory, NativeTypeInfo info) @@ -6156,39 +6080,12 @@ private static IntPtr FindWeakInstancePtr(object instance) { IntPtr cPtr = IntPtr.Zero; -#if NETSTANDARD ExtendNotifier notifier; if (_weakExtends.TryGetValue(instance, out notifier)) { cPtr = notifier.cPtr; } -#else - lock (_extends) - { - List extends; - if (_weakExtendsHash.TryGetValue(RuntimeHelpers.GetHashCode(instance), out extends)) - { - int numExtends = extends.Count; - for (int i = 0; i < numExtends; ++i) - { - WeakInfo info = extends[i]; - if (info.weak.Target == instance) - { - if (!Initialized && !_extends.ContainsKey(info.ptr)) - { - // Extend already destroyed - cPtr = IntPtr.Zero; - } - else - { - cPtr = new IntPtr(info.ptr); - } - break; - } - } - } - } -#endif + return cPtr; } @@ -6219,7 +6116,6 @@ private static void ReleasePending() //////////////////////////////////////////////////////////////////////////////////////////////// public static void Update() { - AddDestroyedExtends(); ReleasePending(); } diff --git a/Src/Noesis/Core/Src/Core/View.cs b/Src/Noesis/Core/Src/Core/View.cs index b909eff..985c5ad 100644 --- a/Src/Noesis/Core/Src/Core/View.cs +++ b/Src/Noesis/Core/Src/Core/View.cs @@ -115,6 +115,15 @@ public void SetHoldingDistanceThreshold(uint pixels) Noesis_View_SetHoldingDistanceThreshold(CPtr, pixels); } + /// + /// Minimun distance since first contact, in pixels, to start a manipulation. Once this + /// threshold is reached, the event ManipulationStarted is sent. By default it is 10 pixels + /// + public void SetManipulationDistanceThreshold(uint pixels) + { + Noesis_View_SetManipulationDistanceThreshold(CPtr, pixels); + } + /// /// The maximum delay required for two consecutives Tapped events to be interpreted as /// a DoubleTapped event. By default it is 500 milliseconds @@ -598,6 +607,9 @@ protected override IntPtr CreateCPtr(Type type, out bool registerExtend) [DllImport(Library.Name)] static extern void Noesis_View_SetHoldingDistanceThreshold(HandleRef view, uint pixels); + [DllImport(Library.Name)] + static extern void Noesis_View_SetManipulationDistanceThreshold(HandleRef view, uint pixels); + [DllImport(Library.Name)] static extern void Noesis_View_SetDoubleTapTimeThreshold(HandleRef view, uint milliseconds); diff --git a/Src/Noesis/Core/Src/Proxies/ApplicationCommands.cs b/Src/Noesis/Core/Src/Proxies/ApplicationCommands.cs index b085b77..5e27d43 100644 --- a/Src/Noesis/Core/Src/Proxies/ApplicationCommands.cs +++ b/Src/Noesis/Core/Src/Proxies/ApplicationCommands.cs @@ -16,156 +16,156 @@ namespace Noesis { public static class ApplicationCommands { - public static RoutedUICommand CancelPrintCommand { + public static RoutedUICommand CancelPrint { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_CancelPrintCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_CancelPrint_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand CloseCommand { + public static RoutedUICommand Close { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_CloseCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Close_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand ContextMenuCommand { + public static RoutedUICommand ContextMenu { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_ContextMenuCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_ContextMenu_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand CopyCommand { + public static RoutedUICommand Copy { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_CopyCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Copy_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand CorrectionListCommand { + public static RoutedUICommand CorrectionList { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_CorrectionListCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_CorrectionList_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand CutCommand { + public static RoutedUICommand Cut { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_CutCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Cut_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand DeleteCommand { + public static RoutedUICommand Delete { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_DeleteCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Delete_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand FindCommand { + public static RoutedUICommand Find { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_FindCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Find_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand HelpCommand { + public static RoutedUICommand Help { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_HelpCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Help_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand NewCommand { + public static RoutedUICommand New { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_NewCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_New_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand OpenCommand { + public static RoutedUICommand Open { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_OpenCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Open_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand PasteCommand { + public static RoutedUICommand Paste { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_PasteCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Paste_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand PrintCommand { + public static RoutedUICommand Print { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_PrintCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Print_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand PrintPreviewCommand { + public static RoutedUICommand PrintPreview { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_PrintPreviewCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_PrintPreview_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand PropertiesCommand { + public static RoutedUICommand Properties { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_PropertiesCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Properties_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand RedoCommand { + public static RoutedUICommand Redo { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_RedoCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Redo_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand ReplaceCommand { + public static RoutedUICommand Replace { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_ReplaceCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Replace_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand SaveCommand { + public static RoutedUICommand Save { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_SaveCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Save_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand SaveAsCommand { + public static RoutedUICommand SaveAs { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_SaveAsCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_SaveAs_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand SelectAllCommand { + public static RoutedUICommand SelectAll { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_SelectAllCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_SelectAll_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand StopCommand { + public static RoutedUICommand Stop { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_StopCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Stop_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand UndoCommand { + public static RoutedUICommand Undo { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_UndoCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ApplicationCommands_Undo_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } diff --git a/Src/Noesis/Core/Src/Proxies/ComponentCommands.cs b/Src/Noesis/Core/Src/Proxies/ComponentCommands.cs index bdcee9c..0220527 100644 --- a/Src/Noesis/Core/Src/Proxies/ComponentCommands.cs +++ b/Src/Noesis/Core/Src/Proxies/ComponentCommands.cs @@ -16,184 +16,184 @@ namespace Noesis { public static class ComponentCommands { - public static RoutedUICommand ExtendSelectionDownCommand { + public static RoutedUICommand ExtendSelectionDown { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ExtendSelectionDownCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ExtendSelectionDown_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand ExtendSelectionLeftCommand { + public static RoutedUICommand ExtendSelectionLeft { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ExtendSelectionLeftCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ExtendSelectionLeft_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand ExtendSelectionRightCommand { + public static RoutedUICommand ExtendSelectionRight { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ExtendSelectionRightCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ExtendSelectionRight_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand ExtendSelectionUpCommand { + public static RoutedUICommand ExtendSelectionUp { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ExtendSelectionUpCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ExtendSelectionUp_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveDownCommand { + public static RoutedUICommand MoveDown { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveDownCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveDown_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveFocusBackCommand { + public static RoutedUICommand MoveFocusBack { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusBackCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusBack_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveFocusDownCommand { + public static RoutedUICommand MoveFocusDown { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusDownCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusDown_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveFocusForwardCommand { + public static RoutedUICommand MoveFocusForward { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusForwardCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusForward_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveFocusPageDownCommand { + public static RoutedUICommand MoveFocusPageDown { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusPageDownCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusPageDown_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveFocusPageUpCommand { + public static RoutedUICommand MoveFocusPageUp { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusPageUpCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusPageUp_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveFocusUpCommand { + public static RoutedUICommand MoveFocusUp { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusUpCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveFocusUp_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveLeftCommand { + public static RoutedUICommand MoveLeft { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveLeftCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveLeft_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveRightCommand { + public static RoutedUICommand MoveRight { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveRightCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveRight_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveToEndCommand { + public static RoutedUICommand MoveToEnd { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveToEndCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveToEnd_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveToHomeCommand { + public static RoutedUICommand MoveToHome { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveToHomeCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveToHome_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveToPageDownCommand { + public static RoutedUICommand MoveToPageDown { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveToPageDownCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveToPageDown_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveToPageUpCommand { + public static RoutedUICommand MoveToPageUp { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveToPageUpCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveToPageUp_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand MoveUpCommand { + public static RoutedUICommand MoveUp { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveUpCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_MoveUp_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand ScrollByLineCommand { + public static RoutedUICommand ScrollByLine { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ScrollByLineCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ScrollByLine_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand ScrollPageDownCommand { + public static RoutedUICommand ScrollPageDown { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ScrollPageDownCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ScrollPageDown_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand ScrollPageLeftCommand { + public static RoutedUICommand ScrollPageLeft { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ScrollPageLeftCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ScrollPageLeft_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand ScrollPageRightCommand { + public static RoutedUICommand ScrollPageRight { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ScrollPageRightCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ScrollPageRight_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand ScrollPageUpCommand { + public static RoutedUICommand ScrollPageUp { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ScrollPageUpCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_ScrollPageUp_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand SelectToEndCommand { + public static RoutedUICommand SelectToEnd { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_SelectToEndCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_SelectToEnd_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand SelectToHomeCommand { + public static RoutedUICommand SelectToHome { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_SelectToHomeCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_SelectToHome_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } - public static RoutedUICommand SelectToPageDownCommand { + public static RoutedUICommand SelectToPageDown { get { - IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_SelectToPageDownCommand_get(); + IntPtr cPtr = NoesisGUI_PINVOKE.ComponentCommands_SelectToPageDown_get(); return (RoutedUICommand)Noesis.Extend.GetProxy(cPtr, false); } } diff --git a/Src/Noesis/Core/Src/Proxies/NoesisGUI_PINVOKE.cs b/Src/Noesis/Core/Src/Proxies/NoesisGUI_PINVOKE.cs index 1573f0b..e36ebad 100644 --- a/Src/Noesis/Core/Src/Proxies/NoesisGUI_PINVOKE.cs +++ b/Src/Noesis/Core/Src/Proxies/NoesisGUI_PINVOKE.cs @@ -6677,148 +6677,148 @@ internal class NoesisGUI_PINVOKE { public static extern IntPtr AdornerDecorator_GetAdornerLayer(HandleRef jarg1); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_CancelPrintCommand_get(); + public static extern IntPtr ApplicationCommands_CancelPrint_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_CloseCommand_get(); + public static extern IntPtr ApplicationCommands_Close_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_ContextMenuCommand_get(); + public static extern IntPtr ApplicationCommands_ContextMenu_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_CopyCommand_get(); + public static extern IntPtr ApplicationCommands_Copy_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_CorrectionListCommand_get(); + public static extern IntPtr ApplicationCommands_CorrectionList_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_CutCommand_get(); + public static extern IntPtr ApplicationCommands_Cut_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_DeleteCommand_get(); + public static extern IntPtr ApplicationCommands_Delete_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_FindCommand_get(); + public static extern IntPtr ApplicationCommands_Find_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_HelpCommand_get(); + public static extern IntPtr ApplicationCommands_Help_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_NewCommand_get(); + public static extern IntPtr ApplicationCommands_New_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_OpenCommand_get(); + public static extern IntPtr ApplicationCommands_Open_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_PasteCommand_get(); + public static extern IntPtr ApplicationCommands_Paste_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_PrintCommand_get(); + public static extern IntPtr ApplicationCommands_Print_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_PrintPreviewCommand_get(); + public static extern IntPtr ApplicationCommands_PrintPreview_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_PropertiesCommand_get(); + public static extern IntPtr ApplicationCommands_Properties_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_RedoCommand_get(); + public static extern IntPtr ApplicationCommands_Redo_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_ReplaceCommand_get(); + public static extern IntPtr ApplicationCommands_Replace_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_SaveCommand_get(); + public static extern IntPtr ApplicationCommands_Save_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_SaveAsCommand_get(); + public static extern IntPtr ApplicationCommands_SaveAs_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_SelectAllCommand_get(); + public static extern IntPtr ApplicationCommands_SelectAll_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_StopCommand_get(); + public static extern IntPtr ApplicationCommands_Stop_get(); [DllImport(Library.Name)] - public static extern IntPtr ApplicationCommands_UndoCommand_get(); + public static extern IntPtr ApplicationCommands_Undo_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_ExtendSelectionDownCommand_get(); + public static extern IntPtr ComponentCommands_ExtendSelectionDown_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_ExtendSelectionLeftCommand_get(); + public static extern IntPtr ComponentCommands_ExtendSelectionLeft_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_ExtendSelectionRightCommand_get(); + public static extern IntPtr ComponentCommands_ExtendSelectionRight_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_ExtendSelectionUpCommand_get(); + public static extern IntPtr ComponentCommands_ExtendSelectionUp_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveDownCommand_get(); + public static extern IntPtr ComponentCommands_MoveDown_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveFocusBackCommand_get(); + public static extern IntPtr ComponentCommands_MoveFocusBack_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveFocusDownCommand_get(); + public static extern IntPtr ComponentCommands_MoveFocusDown_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveFocusForwardCommand_get(); + public static extern IntPtr ComponentCommands_MoveFocusForward_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveFocusPageDownCommand_get(); + public static extern IntPtr ComponentCommands_MoveFocusPageDown_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveFocusPageUpCommand_get(); + public static extern IntPtr ComponentCommands_MoveFocusPageUp_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveFocusUpCommand_get(); + public static extern IntPtr ComponentCommands_MoveFocusUp_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveLeftCommand_get(); + public static extern IntPtr ComponentCommands_MoveLeft_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveRightCommand_get(); + public static extern IntPtr ComponentCommands_MoveRight_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveToEndCommand_get(); + public static extern IntPtr ComponentCommands_MoveToEnd_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveToHomeCommand_get(); + public static extern IntPtr ComponentCommands_MoveToHome_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveToPageDownCommand_get(); + public static extern IntPtr ComponentCommands_MoveToPageDown_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveToPageUpCommand_get(); + public static extern IntPtr ComponentCommands_MoveToPageUp_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_MoveUpCommand_get(); + public static extern IntPtr ComponentCommands_MoveUp_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_ScrollByLineCommand_get(); + public static extern IntPtr ComponentCommands_ScrollByLine_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_ScrollPageDownCommand_get(); + public static extern IntPtr ComponentCommands_ScrollPageDown_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_ScrollPageLeftCommand_get(); + public static extern IntPtr ComponentCommands_ScrollPageLeft_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_ScrollPageRightCommand_get(); + public static extern IntPtr ComponentCommands_ScrollPageRight_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_ScrollPageUpCommand_get(); + public static extern IntPtr ComponentCommands_ScrollPageUp_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_SelectToEndCommand_get(); + public static extern IntPtr ComponentCommands_SelectToEnd_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_SelectToHomeCommand_get(); + public static extern IntPtr ComponentCommands_SelectToHome_get(); [DllImport(Library.Name)] - public static extern IntPtr ComponentCommands_SelectToPageDownCommand_get(); + public static extern IntPtr ComponentCommands_SelectToPageDown_get(); [DllImport(Library.Name)] public static extern IntPtr ComponentCommands_SelectToPageUp_get(); diff --git a/Src/NoesisApp/Core/Src/Core/Application.cs b/Src/NoesisApp/Core/Src/Core/Application.cs index daa8d5f..1f41668 100644 --- a/Src/NoesisApp/Core/Src/Core/Application.cs +++ b/Src/NoesisApp/Core/Src/Core/Application.cs @@ -84,7 +84,7 @@ public object FindResource(object key) public static void SetThemeProviders(XamlProvider xamlProvider = null, FontProvider fontProvider = null, TextureProvider textureProvider = null) { GUI.SetXamlProvider(new EmbeddedXamlProvider(Theme.Assembly, "", xamlProvider)); - GUI.SetFontProvider(new EmbeddedFontProvider(Theme.Assembly, "Noesis.GUI.Extensions", "", fontProvider)); + GUI.SetFontProvider(new EmbeddedFontProvider(Theme.Assembly, "Noesis.GUI.Extensions", fontProvider)); GUI.SetTextureProvider(textureProvider); GUI.SetFontFallbacks(Theme.FontFallbacks); diff --git a/Src/NoesisApp/Core/Src/Core/ApplicationProvider.cs b/Src/NoesisApp/Core/Src/Core/ApplicationProvider.cs index 9053330..5644b3d 100644 --- a/Src/NoesisApp/Core/Src/Core/ApplicationProvider.cs +++ b/Src/NoesisApp/Core/Src/Core/ApplicationProvider.cs @@ -16,7 +16,7 @@ public ApplicationProvider(Application app, XamlProvider xamlProvider, FontProvi _fontProvider = new ApplicationFontProvider(this, fontProvider); _texProvider = new ApplicationTextureProvider(this, texProvider); - // Register Noesis.Theme assembly as exposed in Blend + // Register Noesis.App.Theme assembly as exposed in Blend AddAssembly(Theme.Assembly, "Noesis.GUI.Extensions"); // Register current assemblies @@ -25,6 +25,7 @@ public ApplicationProvider(Application app, XamlProvider xamlProvider, FontProvi string name = assembly.GetName().Name; if (!assembly.IsDynamic && + name != "Noesis.App.Theme" && name != "mscorlib" && name != "netstandard" && name != "System" && !name.StartsWith("System.") && !name.StartsWith("Microsoft.")) { @@ -172,7 +173,8 @@ public override FontSource MatchFont(Uri baseUri, string familyName, } } - return base.MatchFont(baseUri, familyName, ref weight, ref stretch, ref style); + string folder = NormalizeFolder(baseUri); + return base.MatchFont(new Uri(folder, UriKind.RelativeOrAbsolute), familyName, ref weight, ref stretch, ref style); } public override bool FamilyExists(Uri baseUri, string familyName) @@ -185,7 +187,8 @@ public override bool FamilyExists(Uri baseUri, string familyName) } } - return base.FamilyExists(baseUri, familyName); + string folder = NormalizeFolder(baseUri); + return base.FamilyExists(new Uri(folder, UriKind.RelativeOrAbsolute), familyName); } public override void ScanFolder(Uri folder) @@ -209,16 +212,27 @@ public override Stream OpenFont(Uri folder, string filename) // Next try with application assembly resources if (stream == null) { - string uri = folder.OriginalString; - if (uri.Length > 0 && !uri.EndsWith("/")) uri += "/"; - uri += filename; + string path = NormalizeFolder(folder); + if (path.Length > 0 && !path.EndsWith("/")) path += "/"; + path += filename; - stream = _appProvider.GetAssemblyResource(new Uri(uri, UriKind.RelativeOrAbsolute)); + stream = _appProvider.GetAssemblyResource(new Uri(path, UriKind.RelativeOrAbsolute)); } return stream; } + private string NormalizeFolder(Uri folder) + { + string component = folder.GetAssembly(); + if (!string.IsNullOrEmpty(component)) + { + return $"/{component};component/{folder.GetPath()}"; + } + + return folder.OriginalString; + } + private ApplicationProvider _appProvider; private FontProvider _userProvider; } diff --git a/Src/NoesisApp/Core/Src/Core/EmbeddedFontProvider.cs b/Src/NoesisApp/Core/Src/Core/EmbeddedFontProvider.cs index c9650ec..bffecab 100644 --- a/Src/NoesisApp/Core/Src/Core/EmbeddedFontProvider.cs +++ b/Src/NoesisApp/Core/Src/Core/EmbeddedFontProvider.cs @@ -8,22 +8,17 @@ namespace NoesisApp public class EmbeddedFontProvider : FontProvider { public EmbeddedFontProvider(Assembly assembly, string ns) : - this(assembly, assembly?.GetName().Name, ns, null) + this(assembly, ns, null) { } - public EmbeddedFontProvider(Assembly assembly, string ns, FontProvider provider) : - this(assembly, assembly?.GetName().Name, ns, provider) - { - } - - internal EmbeddedFontProvider(Assembly assembly, string component, string ns, FontProvider provider) + public EmbeddedFontProvider(Assembly assembly, string ns, FontProvider provider) { _assembly = assembly; _namespace = ns; _provider = provider; - RegisterFontResources(component); + RegisterFontResources(); if (_provider != null) { @@ -35,7 +30,7 @@ internal EmbeddedFontProvider(Assembly assembly, string component, string ns, Fo } } - private void RegisterFontResources(string component) + private void RegisterFontResources() { if (_assembly == null) return; @@ -45,15 +40,12 @@ private void RegisterFontResources(string component) name.EndsWith(".ttc", StringComparison.OrdinalIgnoreCase) || name.EndsWith(".otf", StringComparison.OrdinalIgnoreCase)) { - string resource = string.IsNullOrEmpty(_namespace) ? name : name.Substring(_namespace.Length + 1); + string resource = !string.IsNullOrEmpty(_namespace) && name.StartsWith(_namespace) ? name.Substring(_namespace.Length + 1) : name; int lastDot = resource.LastIndexOf('.', resource.Length - 5); string folder = lastDot != -1 ? resource.Substring(0, lastDot).Replace('.', '/') : string.Empty; string filename = lastDot != -1 ? resource.Substring(lastDot + 1) : resource; RegisterFont(new Uri(folder, UriKind.RelativeOrAbsolute), filename); - - folder = $"/{component};component/{folder}"; - RegisterFont(new Uri(folder, UriKind.RelativeOrAbsolute), filename); } } } @@ -70,7 +62,7 @@ public override FontSource MatchFont(Uri baseUri, string familyName, } } - return base.MatchFont(baseUri, familyName, ref weight, ref stretch, ref style); + return base.MatchFont(new Uri(baseUri.GetPath(), UriKind.RelativeOrAbsolute), familyName, ref weight, ref stretch, ref style); } public override bool FamilyExists(Uri baseUri, string familyName) @@ -83,7 +75,7 @@ public override bool FamilyExists(Uri baseUri, string familyName) } } - return base.FamilyExists(baseUri, familyName); + return base.FamilyExists(new Uri(baseUri.GetPath(), UriKind.RelativeOrAbsolute), familyName); } public override void ScanFolder(Uri folder) diff --git a/Src/NoesisApp/RenderContexts/MTL/Src/RenderContextMTL.cs b/Src/NoesisApp/RenderContexts/MTL/Src/RenderContextMTL.cs index 30e7fe4..ccfb50f 100644 --- a/Src/NoesisApp/RenderContexts/MTL/Src/RenderContextMTL.cs +++ b/Src/NoesisApp/RenderContexts/MTL/Src/RenderContextMTL.cs @@ -57,7 +57,7 @@ public override void Init(IntPtr display, IntPtr window, uint samples, bool vsyn #else // Mac NSView view = (NSView)ObjCRuntime.Runtime.GetNSObject(window); - view.Layer.AddSublayer(_layer); + view.Layer = _layer; #endif _cmdQueue = _dev.CreateCommandQueue();