Skip to content

Commit

Permalink
Updated to NoesisGUI 3.2.3 version
Browse files Browse the repository at this point in the history
  • Loading branch information
s-fernandez-v committed Feb 8, 2024
1 parent 82bf47b commit 41b5c92
Show file tree
Hide file tree
Showing 40 changed files with 1,396 additions and 240 deletions.
22 changes: 8 additions & 14 deletions Src/Noesis/Core/Src/Core/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,20 +429,14 @@ internal static void Clear()
}
_elements.Clear();

DependencyObject._Destroyed.Clear();
Clock._Completed.Clear();
CommandBinding._PreviewCanExecute.Clear();
CommandBinding._PreviewExecuted.Clear();
CommandBinding._CanExecute.Clear();
CommandBinding._Executed.Clear();
ItemContainerGenerator._ItemsChanged.Clear();
ItemContainerGenerator._StatusChanged.Clear();
Popup._Closed.Clear();
Popup._Opened.Clear();
Timeline._Completed.Clear();
VisualStateGroup._CurrentStateChanging.Clear();
VisualStateGroup._CurrentStateChanged.Clear();
View._Rendering.Clear();
DependencyObject.ResetEvents();
Clock.ResetEvents();
CommandBinding.ResetEvents();
ItemContainerGenerator.ResetEvents();
Popup.ResetEvents();
Timeline.ResetEvents();
VisualStateGroup.ResetEvents();
View.ResetEvents();
}

private static void OnElementDestroyed(IntPtr d)
Expand Down
311 changes: 185 additions & 126 deletions Src/Noesis/Core/Src/Core/Extend.cs

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions Src/Noesis/Core/Src/Core/ExtendProps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,15 @@ private static Dictionary<Type, AddPropertyDelegate> AddPropertyFunctions()

#endregion

private static bool IsCollectionType(Type type)
{
if (typeof(System.Collections.IList).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) return true;
if (typeof(System.Collections.IDictionary).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) return true;
if (FindListIndexer(type) != null) return true;
if (FindDictIndexer(type) != null) return true;
return false;
}

private static ExtendPropertyData AddProperty(NativeTypePropsInfo info, PropertyInfo p, bool usePropertyInfo)
{
AddPropertyDelegate addPropFunction;
Expand All @@ -784,8 +793,6 @@ private static ExtendPropertyData AddProperty(NativeTypePropsInfo info, Property
return addPropFunction(info, p, usePropertyInfo);
}

IntPtr propertyType = EnsureNativeType(p.PropertyType);

if (p.PropertyType.GetTypeInfo().IsEnum)
{
if (IsSignedEnum(p.PropertyType))
Expand All @@ -803,12 +810,19 @@ private static ExtendPropertyData AddProperty(NativeTypePropsInfo info, Property
true);
}

IntPtr propertyType = EnsureNativeType(p.PropertyType);
return CreatePropertyData(p, NativePropertyType.Enum, propertyType);
}
else
{
AddPropertyAccessor<object>(info, p, true);

IntPtr propertyType = TryGetNativeType(p.PropertyType);
if (propertyType == IntPtr.Zero)
{
propertyType = IsCollectionType(p.PropertyType) ?
EnsureNativeType(p.PropertyType) : BaseComponent.GetStaticType();
}
return CreatePropertyData(p, NativePropertyType.BaseComponent, propertyType);
}
}
Expand Down
30 changes: 18 additions & 12 deletions Src/Noesis/Core/Src/Core/RenderDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,16 @@ public enum Enum
// --------------------------------------------------------------------------------
// Attr Interpolation Semantic
// --------------------------------------------------------------------------------
Pos = 1, // linear Position (xy)
Color = 2, // nointerpolation sRGB Color (rgba)
Tex0 = 4, // linear TexCoord0 (uv)
Tex1 = 8, // linear TexCoord1 (uv)
Coverage = 16, // linear Coverage (alpha)
Rect = 32, // nointerpolation Rect (x0, y0, x1, y1)
Tile = 64, // nointerpolation Rect (x, y, width, height)
ImagePos = 128, // linear Position (xy) - Scale(zw)
Pos, // linear Position (xy)
Color, // nointerpolation sRGB Color (rgba)
Tex0, // linear TexCoord0 (uv)
Tex1, // linear TexCoord1 (uv)
Coverage, // linear Coverage (alpha)
Rect, // nointerpolation Rect (x0, y0, x1, y1)
Tile, // nointerpolation Rect (x, y, width, height)
ImagePos, // linear Position (xy) - Scale(zw)

Count
}

/// <summary>
Expand Down Expand Up @@ -284,15 +286,19 @@ public static int SizeForFormat(Shader.Vertex.Format.Enum format)
return map[(int)format];
}

/// <summary>Table for getting the attribute bitmask corresponding to each vertex format</summary>
public static Shader.Vertex.Format.Attr.Enum AttributesForFormat(Shader.Vertex.Format.Enum format)
/// <summary>
/// Table for getting the attribute bitmask corresponding to each vertex format.
/// For example, to determine if Pos attribute is used by the format you would check:
/// bitmask & (1 << Shader.Vertex.Format.Attr.Enum.Pos)
/// </summary>
public static int AttributesForFormat(Shader.Vertex.Format.Enum format)
{
int[] map = new int[(int)Shader.Vertex.Format.Enum.Count]
{
1, 3, 5, 37, 101, 19, 21, 53, 117, 11, 13, 45, 109, 15, 43, 167
};

return (Shader.Vertex.Format.Attr.Enum)map[(int)format];
return map[(int)format];
}

/// <summary>
Expand All @@ -301,7 +307,7 @@ public static Shader.Vertex.Format.Attr.Enum AttributesForFormat(Shader.Vertex.F
/// </summary>
public static Shader.Vertex.Format.Attr.Type.Enum TypeForAttr(Shader.Vertex.Format.Attr.Enum attr)
{
int[] map = new int[]
int[] map = new int[(int)Shader.Vertex.Format.Attr.Enum.Count]
{
1, 3, 1, 1, 0, 4, 2, 2
};
Expand Down
26 changes: 25 additions & 1 deletion Src/Noesis/Core/Src/Core/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ public void SetProjectionMatrix(Matrix4 projection)
Noesis_View_SetProjectionMatrix(CPtr, ref projection);
}

/// <summary>
/// The projection matrix set to the view is used for determining the visual impact of nodes
/// in the offscreen phase. The stereo matrices used for rendering in VR are slightly
/// different. To account for this difference, it is recommended to apply a scale using this
/// function. For non-VR this must be 1. For VR, we recommend a value between 2 and 3.
/// </summary>
public void SetStereoOffscreenScaleFactor(float factor)
{
Noesis_View_SetStereoOffscreenScaleFactor(CPtr, factor);
}

/// <summary>
/// Indicates if touch input events are emulated by the mouse
/// </summary>
Expand Down Expand Up @@ -435,7 +446,17 @@ private static void RaiseRendering(IntPtr cPtr, IntPtr sender)
}
}

internal static Dictionary<long, RenderingEventHandler> _Rendering =
internal static void ResetEvents()
{
foreach (var kv in _Rendering)
{
IntPtr cPtr = new IntPtr(kv.Key);
Noesis_View_UnbindRenderingEvent(new HandleRef(null, cPtr), _raiseRendering);
}
_Rendering.Clear();
}

private static Dictionary<long, RenderingEventHandler> _Rendering =
new Dictionary<long, RenderingEventHandler>();
#endregion

Expand Down Expand Up @@ -619,6 +640,9 @@ protected override IntPtr CreateCPtr(Type type, out bool registerExtend)
[DllImport(Library.Name)]
static extern void Noesis_View_SetProjectionMatrix(HandleRef view, ref Matrix4 projection);

[DllImport(Library.Name)]
static extern void Noesis_View_SetStereoOffscreenScaleFactor(HandleRef view, float factor);

[DllImport(Library.Name)]
static extern void Noesis_View_SetEmulateTouch(HandleRef view, bool emulate);

Expand Down
10 changes: 9 additions & 1 deletion Src/Noesis/Core/Src/Proxies/Clock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ private static void RaiseCompleted(IntPtr cPtr, IntPtr sender, IntPtr e) {
}
}

internal static Dictionary<long, CompletedHandler> _Completed =
internal static void ResetEvents() {
foreach (var kv in _Completed) {
IntPtr cPtr = new IntPtr(kv.Key);
NoesisGUI_PINVOKE.UnbindEvent_Clock_Completed(_raiseCompleted, cPtr);
}
_Completed.Clear();
}

private static Dictionary<long, CompletedHandler> _Completed =
new Dictionary<long, CompletedHandler>();
#endregion

Expand Down
34 changes: 30 additions & 4 deletions Src/Noesis/Core/Src/Proxies/CommandBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private static void RaisePreviewCanExecute(IntPtr cPtr, IntPtr sender, IntPtr e)
}
}

internal static Dictionary<long, PreviewCanExecuteHandler> _PreviewCanExecute =
private static Dictionary<long, PreviewCanExecuteHandler> _PreviewCanExecute =
new Dictionary<long, PreviewCanExecuteHandler>();
#endregion

Expand Down Expand Up @@ -139,7 +139,7 @@ private static void RaiseCanExecute(IntPtr cPtr, IntPtr sender, IntPtr e) {
}
}

internal static Dictionary<long, CanExecuteHandler> _CanExecute =
private static Dictionary<long, CanExecuteHandler> _CanExecute =
new Dictionary<long, CanExecuteHandler>();
#endregion

Expand Down Expand Up @@ -195,7 +195,7 @@ private static void RaisePreviewExecuted(IntPtr cPtr, IntPtr sender, IntPtr e) {
}
}

internal static Dictionary<long, PreviewExecutedHandler> _PreviewExecuted =
private static Dictionary<long, PreviewExecutedHandler> _PreviewExecuted =
new Dictionary<long, PreviewExecutedHandler>();
#endregion

Expand Down Expand Up @@ -251,10 +251,36 @@ private static void RaiseExecuted(IntPtr cPtr, IntPtr sender, IntPtr e) {
}
}

internal static Dictionary<long, ExecutedHandler> _Executed =
private static Dictionary<long, ExecutedHandler> _Executed =
new Dictionary<long, ExecutedHandler>();
#endregion

internal static void ResetEvents() {
foreach (var kv in _PreviewCanExecute) {
IntPtr cPtr = new IntPtr(kv.Key);
NoesisGUI_PINVOKE.UnbindEvent_CommandBinding_PreviewCanExecute(_raisePreviewCanExecute, cPtr);
}
_PreviewCanExecute.Clear();

foreach (var kv in _CanExecute) {
IntPtr cPtr = new IntPtr(kv.Key);
NoesisGUI_PINVOKE.UnbindEvent_CommandBinding_CanExecute(_raiseCanExecute, cPtr);
}
_CanExecute.Clear();

foreach (var kv in _PreviewExecuted) {
IntPtr cPtr = new IntPtr(kv.Key);
NoesisGUI_PINVOKE.UnbindEvent_CommandBinding_PreviewExecuted(_raisePreviewExecuted, cPtr);
}
_PreviewExecuted.Clear();

foreach (var kv in _Executed) {
IntPtr cPtr = new IntPtr(kv.Key);
NoesisGUI_PINVOKE.UnbindEvent_CommandBinding_Executed(_raiseExecuted, cPtr);
}
_Executed.Clear();
}

#endregion

public ICommand Command {
Expand Down
68 changes: 68 additions & 0 deletions Src/Noesis/Core/Src/Proxies/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,34 @@ public static DependencyProperty IsFocusEngagementEnabledProperty {
}
}

public static DependencyProperty XYFocusLeftProperty {
get {
IntPtr cPtr = NoesisGUI_PINVOKE.Control_XYFocusLeftProperty_get();
return (DependencyProperty)Noesis.Extend.GetProxy(cPtr, false);
}
}

public static DependencyProperty XYFocusRightProperty {
get {
IntPtr cPtr = NoesisGUI_PINVOKE.Control_XYFocusRightProperty_get();
return (DependencyProperty)Noesis.Extend.GetProxy(cPtr, false);
}
}

public static DependencyProperty XYFocusUpProperty {
get {
IntPtr cPtr = NoesisGUI_PINVOKE.Control_XYFocusUpProperty_get();
return (DependencyProperty)Noesis.Extend.GetProxy(cPtr, false);
}
}

public static DependencyProperty XYFocusDownProperty {
get {
IntPtr cPtr = NoesisGUI_PINVOKE.Control_XYFocusDownProperty_get();
return (DependencyProperty)Noesis.Extend.GetProxy(cPtr, false);
}
}

public static RoutedEvent MouseDoubleClickEvent {
get {
IntPtr cPtr = NoesisGUI_PINVOKE.Control_MouseDoubleClickEvent_get();
Expand Down Expand Up @@ -378,6 +406,46 @@ public bool IsFocusEngagementEnabled {
}
}

public UIElement XYFocusLeft {
set {
NoesisGUI_PINVOKE.Control_XYFocusLeft_set(swigCPtr, UIElement.getCPtr(value));
}
get {
IntPtr cPtr = NoesisGUI_PINVOKE.Control_XYFocusLeft_get(swigCPtr);
return (UIElement)Noesis.Extend.GetProxy(cPtr, false);
}
}

public UIElement XYFocusRight {
set {
NoesisGUI_PINVOKE.Control_XYFocusRight_set(swigCPtr, UIElement.getCPtr(value));
}
get {
IntPtr cPtr = NoesisGUI_PINVOKE.Control_XYFocusRight_get(swigCPtr);
return (UIElement)Noesis.Extend.GetProxy(cPtr, false);
}
}

public UIElement XYFocusUp {
set {
NoesisGUI_PINVOKE.Control_XYFocusUp_set(swigCPtr, UIElement.getCPtr(value));
}
get {
IntPtr cPtr = NoesisGUI_PINVOKE.Control_XYFocusUp_get(swigCPtr);
return (UIElement)Noesis.Extend.GetProxy(cPtr, false);
}
}

public UIElement XYFocusDown {
set {
NoesisGUI_PINVOKE.Control_XYFocusDown_set(swigCPtr, UIElement.getCPtr(value));
}
get {
IntPtr cPtr = NoesisGUI_PINVOKE.Control_XYFocusDown_get(swigCPtr);
return (UIElement)Noesis.Extend.GetProxy(cPtr, false);
}
}

internal new static IntPtr Extend(string typeName) {
return NoesisGUI_PINVOKE.Extend_Control(Marshal.StringToHGlobalAnsi(typeName));
}
Expand Down
12 changes: 11 additions & 1 deletion Src/Noesis/Core/Src/Proxies/DependencyObjectExtend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,17 @@ private static void RaiseDestroyed(IntPtr cPtr)
}
}

internal static Dictionary<long, DestroyedHandler> _Destroyed =
internal static void ResetEvents()
{
foreach (var kv in _Destroyed)
{
IntPtr cPtr = new IntPtr(kv.Key);
Noesis_Dependency_Destroyed_Unbind(_raiseDestroyed, new HandleRef(null, cPtr));
}
_Destroyed.Clear();
}

private static Dictionary<long, DestroyedHandler> _Destroyed =
new Dictionary<long, DestroyedHandler>();
#endregion

Expand Down
16 changes: 15 additions & 1 deletion Src/Noesis/Core/Src/Proxies/ItemContainerGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,24 @@ private static void RaiseStatusChanged(IntPtr cPtr, IntPtr sender, IntPtr e) {
}
}

internal static Dictionary<long, StatusChangedHandler> _StatusChanged =
private static Dictionary<long, StatusChangedHandler> _StatusChanged =
new Dictionary<long, StatusChangedHandler>();
#endregion

internal static void ResetEvents() {
foreach (var kv in _ItemsChanged) {
IntPtr cPtr = new IntPtr(kv.Key);
NoesisGUI_PINVOKE.UnbindEvent_ItemContainerGenerator_ItemsChanged(_raiseItemsChanged, cPtr);
}
_ItemsChanged.Clear();

foreach (var kv in _StatusChanged) {
IntPtr cPtr = new IntPtr(kv.Key);
NoesisGUI_PINVOKE.UnbindEvent_ItemContainerGenerator_StatusChanged(_raiseStatusChanged, cPtr);
}
_StatusChanged.Clear();
}

#endregion

ItemContainerGenerator IItemContainerGenerator.GetItemContainerGeneratorForPanel(Panel panel) {
Expand Down
2 changes: 1 addition & 1 deletion Src/Noesis/Core/Src/Proxies/Matrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public float Determinant {
}

public bool HasInverse {
get { return Math.Abs(Determinant) < 0.0001f; }
get { return Math.Abs(Determinant) >= 0.0001f; }
}

public void Invert() {
Expand Down
Loading

0 comments on commit 41b5c92

Please sign in to comment.