Skip to content

Commit

Permalink
Updated to NoesisGUI 3.2.0 version
Browse files Browse the repository at this point in the history
  • Loading branch information
s-fernandez-v committed Mar 20, 2023
1 parent c3e09b7 commit 805619c
Show file tree
Hide file tree
Showing 71 changed files with 3,306 additions and 647 deletions.
1 change: 1 addition & 0 deletions Src/Noesis/Core/Src/Core/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ static EventManager()
RegisterCLREvent("IsMouseDirectlyOverChanged", typeof(DependencyPropertyChangedEventHandler), DependencyPropertyChangedEventArgs.InvokeHandler);
RegisterCLREvent("IsKeyboardFocusedChanged", typeof(DependencyPropertyChangedEventHandler), DependencyPropertyChangedEventArgs.InvokeHandler);
RegisterCLREvent("IsKeyboardFocusWithinChanged", typeof(DependencyPropertyChangedEventHandler), DependencyPropertyChangedEventArgs.InvokeHandler);
RegisterCLREvent("LayoutUpdated", typeof(EventHandler), EventArgs.InvokeHandler);

// FrameworkElement
RegisterRoutedEvent(FrameworkElement.LoadedEvent, typeof(RoutedEventHandler), RoutedEventArgs.InvokeHandler);
Expand Down
280 changes: 260 additions & 20 deletions Src/Noesis/Core/Src/Core/Extend.cs

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions Src/Noesis/Core/Src/Core/ExtendBoxing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ private static Dictionary<Type, BoxDelegate> CreateBoxFunctions()
boxFunctions[typeof(Noesis.KeyTime)] = (val) => NoesisGUI_.Box_KeyTime((Noesis.KeyTime)val);
boxFunctions[typeof(System.TimeSpan)] = (val) => NoesisGUI_.Box_TimeSpan((System.TimeSpan)val);
boxFunctions[typeof(Noesis.VirtualizationCacheLength)] = (val) => NoesisGUI_.Box_VirtualizationCacheLength((Noesis.VirtualizationCacheLength)val);
boxFunctions[typeof(Noesis.Matrix)] = (val) => NoesisGUI_.Box_Matrix((Noesis.Matrix)val);
boxFunctions[typeof(Noesis.Matrix3D)] = (val) => NoesisGUI_.Box_Matrix3D((Noesis.Matrix3D)val);
boxFunctions[typeof(Noesis.Matrix4)] = (val) => NoesisGUI_.Box_Matrix4((Noesis.Matrix4)val);
boxFunctions[typeof(Noesis.AlignmentX)] = (val) => NoesisGUI_.Box_AlignmentX((Noesis.AlignmentX)val);
boxFunctions[typeof(Noesis.AlignmentY)] = (val) => NoesisGUI_.Box_AlignmentY((Noesis.AlignmentY)val);
boxFunctions[typeof(Noesis.AutoToolTipPlacement)] = (val) => NoesisGUI_.Box_AutoToolTipPlacement((Noesis.AutoToolTipPlacement)val);
Expand Down Expand Up @@ -120,7 +123,7 @@ public static IntPtr Box(object val)
else if (val.GetType().GetTypeInfo().IsEnum)
{
IntPtr nativeType = EnsureNativeType(val.GetType());
int enumValue = (int)Convert.ToInt64(val);
ulong enumValue = Convert.ToUInt64(val);
return RegisterPendingRelease(NoesisGUI_.Box_CustomEnum(nativeType, enumValue));
}
else if (val is Type)
Expand Down Expand Up @@ -171,6 +174,9 @@ private static Dictionary<Type, UnboxDelegate> CreateUnboxFunctions()
unboxFunctions[typeof(Boxed<Noesis.KeyTime>)] = (cPtr) => NoesisGUI_.Unbox_KeyTime(cPtr);
unboxFunctions[typeof(Boxed<System.TimeSpan>)] = (cPtr) => NoesisGUI_.Unbox_TimeSpan(cPtr);
unboxFunctions[typeof(Boxed<Noesis.VirtualizationCacheLength>)] = (cPtr) => NoesisGUI_.Unbox_VirtualizationCacheLength(cPtr);
unboxFunctions[typeof(Boxed<Noesis.Matrix>)] = (cPtr) => NoesisGUI_.Unbox_Matrix(cPtr);
unboxFunctions[typeof(Boxed<Noesis.Matrix3D>)] = (cPtr) => NoesisGUI_.Unbox_Matrix3D(cPtr);
unboxFunctions[typeof(Boxed<Noesis.Matrix4>)] = (cPtr) => NoesisGUI_.Unbox_Matrix4(cPtr);
unboxFunctions[typeof(Boxed<Noesis.AlignmentX>)] = (cPtr) => NoesisGUI_.Unbox_AlignmentX(cPtr);
unboxFunctions[typeof(Boxed<Noesis.AlignmentY>)] = (cPtr) => NoesisGUI_.Unbox_AlignmentY(cPtr);
unboxFunctions[typeof(Boxed<Noesis.AutoToolTipPlacement>)] = (cPtr) => NoesisGUI_.Unbox_AutoToolTipPlacement(cPtr);
Expand Down Expand Up @@ -244,7 +250,7 @@ public static object Unbox(IntPtr cPtr, bool ownMemory, NativeTypeInfo info)
}
else if (info.Type == typeof(Boxed<Enum>))
{
int enumValue = 0;
ulong enumValue = 0;
IntPtr enumType = NoesisGUI_.Unbox_CustomEnum(cPtr, ref enumValue);
NativeTypeInfo enumTypeInfo = GetNativeTypeInfo(enumType);
value = Enum.ToObject(enumTypeInfo.Type, enumValue);
Expand Down
14 changes: 14 additions & 0 deletions Src/Noesis/Core/Src/Core/ExtendImports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ internal partial class Extend
[DllImport(Library.Name)]
private static extern int Noesis_GetNativeTypes(IntPtr[] types, int capacity);

////////////////////////////////////////////////////////////////////////////////////////////////
[DllImport(Library.Name)]
private static extern IntPtr Noesis_GetTypeName(IntPtr type);

////////////////////////////////////////////////////////////////////////////////////////////////
[DllImport(Library.Name)]
private static extern IntPtr Noesis_RegisterEnumType([MarshalAs(UnmanagedType.LPStr)]string typeName,
Expand Down Expand Up @@ -56,13 +60,15 @@ static extern void Noesis_RegisterReflectionCallbacks(
Callback_VisualGetChild callback_VisualGetChild,
Callback_UIElementRender callback_UIElementRender,
Callback_FrameworkElementConnectEvent callback_FrameworkElementConnectEvent,
Callback_FrameworkElementConnectField callback_FrameworkElementConnectField,
Callback_FrameworkElementMeasure callback_FrameworkElementMeasure,
Callback_FrameworkElementArrange callback_FrameworkElementArrange,
Callback_FrameworkElementApplyTemplate callback_FrameworkElementApplyTemplate,
Callback_ItemsControlGetContainer callback_ItemsControlGetContainer,
Callback_ItemsControlIsContainer callback_ItemsControlIsContainer,
Callback_AdornerGetTransform callback_AdornerGetTransform,
Callback_FreezableClone callback_FreezableClone,
Callback_ShapeGetGeometry callback_ShapeGetGeometry,
Callback_CommandCanExecute callback_CommandCanExecute,
Callback_CommandExecute callback_CommandExecute,
Callback_ConverterConvert callback_ConverterConvert,
Expand All @@ -73,10 +79,14 @@ static extern void Noesis_RegisterReflectionCallbacks(
Callback_ListGet callback_ListGet,
Callback_ListSet callback_ListSet,
Callback_ListAdd callback_ListAdd,
Callback_ListInsert callback_ListInsert,
Callback_ListIndexOf callback_ListIndexOf,
Callback_ListRemoveAt callback_ListRemoveAt,
Callback_ListClear callback_ListClear,
Callback_DictionaryFind callback_DictionaryFind,
Callback_DictionarySet callback_DictionarySet,
Callback_DictionaryAdd callback_DictionaryAdd,
Callback_DictionaryRemove callback_DictionaryRemove,
Callback_ListIndexerTryGet callback_ListIndexerTryGet,
Callback_ListIndexerTrySet callback_ListIndexerTrySet,
Callback_DictionaryIndexerTryGet callback_DictionaryIndexerTryGet,
Expand Down Expand Up @@ -142,6 +152,8 @@ static extern void Noesis_RegisterReflectionCallbacks(
Callback_GetPropertyValue_Bool callback_GetPropertyValue_Bool,
Callback_GetPropertyValue_Float callback_GetPropertyValue_Float,
Callback_GetPropertyValue_Double callback_GetPropertyValue_Double,
Callback_GetPropertyValue_Int64 callback_GetPropertyValue_Int64,
Callback_GetPropertyValue_UInt64 callback_GetPropertyValue_UInt64,
Callback_GetPropertyValue_Int callback_GetPropertyValue_Int,
Callback_GetPropertyValue_UInt callback_GetPropertyValue_UInt,
Callback_GetPropertyValue_Short callback_GetPropertyValue_Short,
Expand All @@ -163,6 +175,8 @@ static extern void Noesis_RegisterReflectionCallbacks(
Callback_SetPropertyValue_Bool callback_SetPropertyValue_Bool,
Callback_SetPropertyValue_Float callback_SetPropertyValue_Float,
Callback_SetPropertyValue_Double callback_SetPropertyValue_Double,
Callback_SetPropertyValue_Int64 callback_SetPropertyValue_Int64,
Callback_SetPropertyValue_UInt64 callback_SetPropertyValue_UInt64,
Callback_SetPropertyValue_Int callback_SetPropertyValue_Int,
Callback_SetPropertyValue_UInt callback_SetPropertyValue_UInt,
Callback_SetPropertyValue_Short callback_SetPropertyValue_Short,
Expand Down
20 changes: 10 additions & 10 deletions Src/Noesis/Core/Src/Core/ExtendProps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,8 @@ private static Dictionary<Type, AddPropertyDelegate> AddPropertyFunctions()

addPropFunctions[typeof(long)] = (info, p, usePropertyInfo) =>
{
AddPropertyAccessor<int, long>(info, p, (v) => (int)v, (v) => (long)v, usePropertyInfo);
return CreatePropertyData(p, NativePropertyType.Int);
AddPropertyAccessor<long>(info, p, usePropertyInfo);
return CreatePropertyData(p, NativePropertyType.Long);
};

addPropFunctions[typeof(uint)] = (info, p, usePropertyInfo) =>
Expand All @@ -519,8 +519,8 @@ private static Dictionary<Type, AddPropertyDelegate> AddPropertyFunctions()

addPropFunctions[typeof(ulong)] = (info, p, usePropertyInfo) =>
{
AddPropertyAccessor<uint, ulong>(info, p, (v) => (uint)v, (v) => (ulong)v, usePropertyInfo);
return CreatePropertyData(p, NativePropertyType.UInt);
AddPropertyAccessor<ulong>(info, p, usePropertyInfo);
return CreatePropertyData(p, NativePropertyType.ULong);
};

addPropFunctions[typeof(char)] = (info, p, usePropertyInfo) =>
Expand Down Expand Up @@ -646,8 +646,8 @@ private static Dictionary<Type, AddPropertyDelegate> AddPropertyFunctions()

addPropFunctions[typeof(long?)] = (info, p, usePropertyInfo) =>
{
AddPropertyAccessorNullable<int?, long?>(info, p, (v) => (int?)v, (v) => (long?)v, usePropertyInfo);
return CreatePropertyData(p, NativePropertyType.NullableInt);
AddPropertyAccessorNullable<long?>(info, p, usePropertyInfo);
return CreatePropertyData(p, NativePropertyType.NullableLong);
};

addPropFunctions[typeof(uint?)] = (info, p, usePropertyInfo) =>
Expand All @@ -658,8 +658,8 @@ private static Dictionary<Type, AddPropertyDelegate> AddPropertyFunctions()

addPropFunctions[typeof(ulong?)] = (info, p, usePropertyInfo) =>
{
AddPropertyAccessorNullable<uint?, ulong?>(info, p, (v) => (uint?)v, (v) => (ulong?)v, usePropertyInfo);
return CreatePropertyData(p, NativePropertyType.NullableUInt);
AddPropertyAccessorNullable<ulong?>(info, p, usePropertyInfo);
return CreatePropertyData(p, NativePropertyType.NullableULong);
};

addPropFunctions[typeof(char?)] = (info, p, usePropertyInfo) =>
Expand Down Expand Up @@ -788,8 +788,8 @@ private static ExtendPropertyData AddProperty(NativeTypePropsInfo info, Property

if (p.PropertyType.GetTypeInfo().IsEnum)
{
AddPropertyAccessor<int, object>(info, p,
(v) => (int)Convert.ToInt64(v),
AddPropertyAccessor<ulong, object>(info, p,
(v) => Convert.ToUInt64(v),
(v) => Enum.ToObject(p.PropertyType, v),
true);

Expand Down
1 change: 1 addition & 0 deletions Src/Noesis/Core/Src/Core/HitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Noesis
{
public delegate HitTestFilterBehavior HitTestFilterCallback(Visual target);
public delegate HitTestResultBehavior HitTestResultCallback(HitTestResult hit);
public delegate HitTestResultBehavior HitTest3DResultCallback(HitTest3DResult hit);

/// <summary>
/// This is the base class for packing together parameters for a hit test pass.
Expand Down
24 changes: 24 additions & 0 deletions Src/Noesis/Core/Src/Core/NoesisGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ public static string GetBuildVersion()
return Extend.StringFromNativeUtf8(version);
}

/// <summary>
/// Disables Hot Reload feature. It is enabled by default and takes a bit of extra memory
/// Must be invoked before Noesis.GUI.Init()
/// </summary>
public static void DisableHotReload()
{
Noesis_DisableHotReload();
}

/// <summary>
/// If sockets are already initialized before Noesis, use this function to avoid double init
/// Must be invoked before Noesis.GUI.Init()
/// </summary>
public static void DisableSocketInit()
{
Noesis_DisableSocketInit();
}

/// <summary>
/// Disables all connections from the remote Inspector tool.
/// Must be invoked before Noesis.GUI.Init()
Expand Down Expand Up @@ -537,6 +555,12 @@ private static void OnLoadAssembly(IntPtr assemblyPtr)
[DllImport(Library.Name)]
static extern IntPtr Noesis_GetBuildVersion();

[DllImport(Library.Name)]
static extern void Noesis_DisableHotReload();

[DllImport(Library.Name)]
static extern void Noesis_DisableSocketInit();

[DllImport(Library.Name)]
static extern void Noesis_DisableInspector();

Expand Down
111 changes: 109 additions & 2 deletions Src/Noesis/Core/Src/Core/RenderDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,18 @@ public abstract RenderTarget CreateRenderTarget(string label, uint width, uint h
/// </summary>
public abstract void SetRenderTarget(RenderTarget surface);

/// <summary>
/// Indicates that until the next call to EndTile(), all drawing commands will only update
/// the contents of the render target defined by the extension of the given tile. This is a
/// good place to enable scissoring and apply optimizations for tile-based GPU architectures.
/// </summary>
public abstract void BeginTile(RenderTarget surface, Tile tile);

/// <summary>
/// Completes rendering to the tile specified by BeginTile().
/// </summary>
public abstract void EndTile(RenderTarget surface);

/// <summary>
/// Resolves multisample render target.
/// </summary>
Expand Down Expand Up @@ -656,6 +668,8 @@ static RenderDevice()
_createRenderTarget,
_cloneRenderTarget,
_setRenderTarget,
_beginTile,
_endTile,
_resolveRenderTarget,
_createTexture,
_updateTexture,
Expand Down Expand Up @@ -774,6 +788,48 @@ private static void SetRenderTarget(IntPtr cPtr, IntPtr surfacePtr)
}
}

private delegate void Callback_BeginTile(IntPtr cPtr, IntPtr surface, ref Tile tile);
private static Callback_BeginTile _beginTile = BeginTile;

[MonoPInvokeCallback(typeof(Callback_BeginTile))]
private static void BeginTile(IntPtr cPtr, IntPtr surfacePtr, ref Tile tile)
{
try
{
RenderDevice device = (RenderDevice)Noesis.Extend.GetExtendInstance(cPtr);
if (device != null)
{
RenderTarget surface = (RenderTarget)Noesis.Extend.GetExtendInstance(surfacePtr);
device.BeginTile(surface, tile);
}
}
catch (Exception e)
{
Error.UnhandledException(e);
}
}

private delegate void Callback_EndTile(IntPtr cPtr, IntPtr surface);
private static Callback_EndTile _endTile = EndTile;

[MonoPInvokeCallback(typeof(Callback_EndTile))]
private static void EndTile(IntPtr cPtr, IntPtr surfacePtr)
{
try
{
RenderDevice device = (RenderDevice)Noesis.Extend.GetExtendInstance(cPtr);
if (device != null)
{
RenderTarget surface = (RenderTarget)Noesis.Extend.GetExtendInstance(surfacePtr);
device.EndTile(surface);
}
}
catch (Exception e)
{
Error.UnhandledException(e);
}
}

private delegate void Callback_ResolveRenderTarget(IntPtr cPtr, IntPtr surface,
[In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] Tile[] tiles, int numTiles);
private static Callback_ResolveRenderTarget _resolveRenderTarget = ResolveRenderTarget;
Expand Down Expand Up @@ -1039,6 +1095,8 @@ static extern uint Noesis_RenderDevice_SetCallbacks(
Callback_CreateRenderTarget createRenderTarget,
Callback_CloneRenderTarget cloneRenderTarget,
Callback_SetRenderTarget setRenderTarget,
Callback_BeginTile beginTile,
Callback_EndTile endTile,
Callback_ResolveRenderTarget resolveRenderTarget,
Callback_CreateTexture createTexture,
Callback_UpdateTexture updateTexture,
Expand Down Expand Up @@ -1142,6 +1200,26 @@ public override void SetRenderTarget(RenderTarget surface)
Noesis_RenderDevice_SetRenderTarget(swigCPtr, BaseComponent.getCPtr(surface));
}

public override void BeginTile(RenderTarget surface, Tile tile)
{
if (surface == null)
{
throw new ArgumentNullException("surface");
}

Noesis_RenderDevice_BeginTile(swigCPtr, BaseComponent.getCPtr(surface), ref tile);
}

public override void EndTile(RenderTarget surface)
{
if (surface == null)
{
throw new ArgumentNullException("surface");
}

Noesis_RenderDevice_EndTile(swigCPtr, BaseComponent.getCPtr(surface));
}

public override void ResolveRenderTarget(RenderTarget surface, Tile[] tiles)
{
if (surface == null)
Expand Down Expand Up @@ -1264,6 +1342,13 @@ static extern IntPtr Noesis_RenderDevice_CreateRenderTarget(HandleRef device,
[DllImport(Library.Name)]
static extern void Noesis_RenderDevice_SetRenderTarget(HandleRef device, HandleRef surface);

[DllImport(Library.Name)]
static extern void Noesis_RenderDevice_BeginTile(HandleRef device, HandleRef surface,
[In] ref Tile tile);

[DllImport(Library.Name)]
static extern void Noesis_RenderDevice_EndTile(HandleRef device, HandleRef surface);

[DllImport(Library.Name)]
static extern void Noesis_RenderDevice_ResolveRenderTarget(HandleRef device, HandleRef surface,
[In, Out] Tile[] tiles, int numTiles);
Expand Down Expand Up @@ -1374,16 +1459,38 @@ public static IntPtr GetTextureNativePointer(Texture texture)
return Noesis_RenderDeviceD3D11_GetTextureNativePointer(BaseComponent.getCPtr(texture));
}

/// <summary>
/// Enables the hardware scissor rectangle
/// </summary>
public void EnableScissorRect()
{
Noesis_RenderDeviceD3D11_EnableScissorRect(swigCPtr);
}

/// <summary>
/// Disables the hardware scissor rectangle
/// </summary>
public void DisableScissorRect()
{
Noesis_RenderDeviceD3D11_DisableScissorRect(swigCPtr);
}

#region Imports
[DllImport(Library.Name)]
static extern IntPtr Noesis_RenderDeviceD3D11_Create(IntPtr deviceContext, bool sRGB);
private static extern IntPtr Noesis_RenderDeviceD3D11_Create(IntPtr deviceContext, bool sRGB);

[DllImport(Library.Name)]
static extern IntPtr Noesis_RenderDeviceD3D11_WrapTexture(IntPtr nativePointer,
private static extern IntPtr Noesis_RenderDeviceD3D11_WrapTexture(IntPtr nativePointer,
int width, int height, int numMipMaps, bool isInverted, bool hasAlpha);

[DllImport(Library.Name)]
private static extern IntPtr Noesis_RenderDeviceD3D11_GetTextureNativePointer(HandleRef texture);

[DllImport(Library.Name)]
private static extern void Noesis_RenderDeviceD3D11_EnableScissorRect(HandleRef device);

[DllImport(Library.Name)]
private static extern void Noesis_RenderDeviceD3D11_DisableScissorRect(HandleRef device);
#endregion
}

Expand Down
2 changes: 1 addition & 1 deletion Src/Noesis/Core/Src/Core/RendererNoesis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ internal Renderer(IntPtr cPtr, bool ownMemory): base(cPtr, ownMemory)
return new Renderer(cPtr, cMemoryOwn);
}

private HandleRef CPtr { get { return BaseComponent.getCPtr(this); } }
internal HandleRef CPtr { get { return BaseComponent.getCPtr(this); } }
#endregion

#region Imports
Expand Down
Loading

0 comments on commit 805619c

Please sign in to comment.