Skip to content

Commit

Permalink
Updated to NoesisGUI 3.2.5 version
Browse files Browse the repository at this point in the history
  • Loading branch information
s-fernandez-v committed Oct 29, 2024
1 parent f0aef3a commit b431a89
Show file tree
Hide file tree
Showing 17 changed files with 265 additions and 447 deletions.
5 changes: 3 additions & 2 deletions Src/Noesis/Core/Src/Core/Extend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3375,12 +3375,12 @@ private static IntPtr ProviderTextureOpen(IntPtr cPtr, IntPtr filename)

////////////////////////////////////////////////////////////////////////////////////////////////
private delegate IntPtr Callback_ProviderMatchFont(IntPtr cPtr, IntPtr baseUri, IntPtr familyName,
ref int weight, ref int stretch, ref int style, ref uint index);
ref int weight, ref int stretch, ref int style, ref uint index, ref IntPtr filename);
private static Callback_ProviderMatchFont _providerMatchFont = ProviderMatchFont;

[MonoPInvokeCallback(typeof(Callback_ProviderMatchFont))]
private static IntPtr ProviderMatchFont(IntPtr cPtr, IntPtr baseUri, IntPtr familyName,
ref int weight, ref int stretch, ref int style, ref uint index)
ref int weight, ref int stretch, ref int style, ref uint index, ref IntPtr filename)
{
try
{
Expand All @@ -3400,6 +3400,7 @@ private static IntPtr ProviderMatchFont(IntPtr cPtr, IntPtr baseUri, IntPtr fami
stretch = (int)stretch_;
style = (int)style_;
index = font.faceIndex;
filename = Marshal.StringToHGlobalUni(font.filename != null ? font.filename : string.Empty);

HandleRef handle = GetInstanceHandle(font.file);
BaseComponent.AddReference(handle.Handle); // released by C++
Expand Down
4 changes: 4 additions & 0 deletions Src/Noesis/Core/Src/Core/RenderDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ public enum StencilMode
Equal_Decr,
/// <summary>Set the stencil data to 0</summary>
Clear,
/// <summary>Stencil disabled and Depth enabled</summary>
Disabled_ZTest,
/// <summary>Stencil and Depth enabled</summary>
Equal_Keep_ZTest
}

/// <summary>
Expand Down
57 changes: 39 additions & 18 deletions Src/Noesis/Core/Src/Proxies/DependencyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,57 +30,78 @@ internal static HandleRef getCPtr(DependencyObject obj) {
protected DependencyObject() {
}

public void SetCurrentValue(DependencyProperty dp, object value) {
if (dp == null) {
throw new ArgumentNullException("dp");
}
SetCurrentValueHelper(dp, value);
}

public object ReadLocalValue(DependencyProperty dp) {
if (dp == null) {
throw new ArgumentNullException("dp");
}
IntPtr cPtr = ReadLocalValueHelper(dp);
return Noesis.Extend.GetProxy(cPtr, true);
}

public void InvalidateProperty(DependencyProperty dp) {
InvalidatePropertyHelper(dp);
public void CoerceValue(DependencyProperty dp) {
if (dp == null) {
throw new ArgumentNullException("dp");
}
CoerceValueHelper(dp);
}

public Expression GetExpression(DependencyProperty dp) {
IntPtr cPtr = NoesisGUI_PINVOKE.DependencyObject_GetExpression(swigCPtr, DependencyProperty.getCPtr(dp));
Expression ret = (cPtr == IntPtr.Zero) ? null : new Expression(cPtr, false);
return ret;
public void InvalidateProperty(DependencyProperty dp) {
if (dp == null) {
throw new ArgumentNullException("dp");
}
InvalidatePropertyHelper(dp);
}

public void ClearValue(DependencyProperty dp) {
NoesisGUI_PINVOKE.DependencyObject_ClearValue(swigCPtr, DependencyProperty.getCPtr(dp));
if (dp == null) {
throw new ArgumentNullException("dp");
}
ClearValueHelper(dp);
}

public void ClearAnimation(DependencyProperty dp) {
protected void ClearAnimation(DependencyProperty dp) {
NoesisGUI_PINVOKE.DependencyObject_ClearAnimation(swigCPtr, DependencyProperty.getCPtr(dp));
}

public void CoerceValue(DependencyProperty dp) {
NoesisGUI_PINVOKE.DependencyObject_CoerceValue(swigCPtr, DependencyProperty.getCPtr(dp));
}

public bool IsSealed {
get {
bool ret = NoesisGUI_PINVOKE.DependencyObject_IsSealed_get(swigCPtr);
return ret;
}
}

private void SetCurrentValueHelper(DependencyProperty dp, object value) {
NoesisGUI_PINVOKE.DependencyObject_SetCurrentValueHelper(swigCPtr, DependencyProperty.getCPtr(dp), Noesis.Extend.GetInstanceHandle(value));
}

private IntPtr ReadLocalValueHelper(DependencyProperty dp) {
IntPtr ret = NoesisGUI_PINVOKE.DependencyObject_ReadLocalValueHelper(swigCPtr, DependencyProperty.getCPtr(dp));
return ret;
}

public void SetCurrentValue(DependencyProperty dp, object value) {
NoesisGUI_PINVOKE.DependencyObject_SetCurrentValue(swigCPtr, DependencyProperty.getCPtr(dp), Noesis.Extend.GetInstanceHandle(value));
}

protected internal void InitObject() {
NoesisGUI_PINVOKE.DependencyObject_InitObject(swigCPtr);
private void CoerceValueHelper(DependencyProperty dp) {
NoesisGUI_PINVOKE.DependencyObject_CoerceValueHelper(swigCPtr, DependencyProperty.getCPtr(dp));
}

private void InvalidatePropertyHelper(DependencyProperty dp) {
NoesisGUI_PINVOKE.DependencyObject_InvalidatePropertyHelper(swigCPtr, DependencyProperty.getCPtr(dp));
}

private void ClearValueHelper(DependencyProperty dp) {
NoesisGUI_PINVOKE.DependencyObject_ClearValueHelper(swigCPtr, DependencyProperty.getCPtr(dp));
}

protected internal void InitObject() {
NoesisGUI_PINVOKE.DependencyObject_InitObject(swigCPtr);
}

internal new static IntPtr Extend(string typeName) {
return NoesisGUI_PINVOKE.Extend_DependencyObject(Marshal.StringToHGlobalAnsi(typeName));
}
Expand Down
4 changes: 2 additions & 2 deletions Src/Noesis/Core/Src/Proxies/DependencyObjectExtend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public object GetValue(DependencyProperty dp)
{
if (dp == null)
{
throw new Exception("Can't get value, DependencyProperty is null");
throw new ArgumentNullException("dp");
}

Type dpType = dp.PropertyType;
Expand Down Expand Up @@ -41,7 +41,7 @@ public void SetValue(DependencyProperty dp, object value)
{
if (dp == null)
{
throw new Exception("Can't set value, DependencyProperty is null");
throw new ArgumentNullException("dp");
}

Type dpType = dp.PropertyType;
Expand Down
20 changes: 16 additions & 4 deletions Src/Noesis/Core/Src/Proxies/FontProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected FontProvider() {
}

public struct FontSource {
public string filename;
public Stream file;
public uint faceIndex;
}
Expand All @@ -45,11 +46,22 @@ public virtual FontSource MatchFont(Uri baseUri, string familyName,
string baseUri_ = baseUri != null ? baseUri.OriginalString : string.Empty;
int weight_ = (int)weight, stretch_ = (int)stretch, style_ = (int)style;
uint index = 0;
IntPtr filePtr = MatchFontHelper(baseUri_, familyName, ref weight_, ref stretch_, ref style_, ref index);
IntPtr filenamePtr = IntPtr.Zero;

IntPtr filePtr = MatchFontHelper(baseUri_, familyName, ref weight_, ref stretch_, ref style_, ref index, ref filenamePtr);

string filename = Noesis.Extend.StringFromNativeUtf8(filenamePtr);
NoesisGUI_PINVOKE.FreeString(filenamePtr);

weight = (FontWeight)weight_;
stretch = (FontStretch)stretch_;
style = (FontStyle)style_;
return new FontSource { file = (Stream)Noesis.Extend.GetProxy(filePtr, true), faceIndex = index };

return new FontSource {
filename = filename,
file = (Stream)Noesis.Extend.GetProxy(filePtr, true),
faceIndex = index
};
}

/// <summary>
Expand Down Expand Up @@ -107,8 +119,8 @@ private void RegisterFontHelper(string folder, string id) {
NoesisGUI_PINVOKE.FontProvider_RegisterFontHelper(swigCPtr, folder != null ? folder : string.Empty, id != null ? id : string.Empty);
}

private IntPtr MatchFontHelper(string baseUri, string familyName, ref int weight, ref int stretch, ref int style, ref uint index) {
IntPtr ret = NoesisGUI_PINVOKE.FontProvider_MatchFontHelper(swigCPtr, baseUri != null ? baseUri : string.Empty, familyName != null ? familyName : string.Empty, ref weight, ref stretch, ref style, ref index);
private IntPtr MatchFontHelper(string baseUri, string familyName, ref int weight, ref int stretch, ref int style, ref uint index, ref IntPtr filename) {
IntPtr ret = NoesisGUI_PINVOKE.FontProvider_MatchFontHelper(swigCPtr, baseUri != null ? baseUri : string.Empty, familyName != null ? familyName : string.Empty, ref weight, ref stretch, ref style, ref index, ref filename);
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions Src/Noesis/Core/Src/Proxies/Matrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ public float Determinant {
}

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

public void Invert() {
float determinant = Determinant;
if (Math.Abs(determinant) < 0.0001f) {
if (Math.Abs(determinant) <= float.Epsilon) {
throw new InvalidOperationException("Matrix is not Invertible");
}
float invdet = 1.0f / determinant;
Expand Down
4 changes: 2 additions & 2 deletions Src/Noesis/Core/Src/Proxies/Matrix3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ public float Determinant {
}

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

public void Invert() {
float determinant = Determinant;
if (Math.Abs(determinant) < 0.0001f) {
if (Math.Abs(determinant) <= float.Epsilon) {
throw new InvalidOperationException("Matrix3D is not Invertible");
}
float m11 = (_m22 * _m33 - _m23 * _m32) / determinant;
Expand Down
25 changes: 11 additions & 14 deletions Src/Noesis/Core/Src/Proxies/NoesisGUI_PINVOKE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -881,33 +881,30 @@ internal class NoesisGUI_PINVOKE {
public static extern void delete_DependencyPropertyChangedEventArgs(HandleRef jarg1);

[DllImport(Library.Name)]
public static extern IntPtr DependencyObject_GetExpression(HandleRef jarg1, HandleRef jarg2);
public static extern void DependencyObject_ClearAnimation(HandleRef jarg1, HandleRef jarg2);

[DllImport(Library.Name)]
public static extern void DependencyObject_ClearValue(HandleRef jarg1, HandleRef jarg2);
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool DependencyObject_IsSealed_get(HandleRef jarg1);

[DllImport(Library.Name)]
public static extern void DependencyObject_ClearAnimation(HandleRef jarg1, HandleRef jarg2);
public static extern void DependencyObject_SetCurrentValueHelper(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3);

[DllImport(Library.Name)]
public static extern void DependencyObject_CoerceValue(HandleRef jarg1, HandleRef jarg2);
public static extern IntPtr DependencyObject_ReadLocalValueHelper(HandleRef jarg1, HandleRef jarg2);

[DllImport(Library.Name)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool DependencyObject_IsSealed_get(HandleRef jarg1);
public static extern void DependencyObject_CoerceValueHelper(HandleRef jarg1, HandleRef jarg2);

[DllImport(Library.Name)]
public static extern IntPtr DependencyObject_ReadLocalValueHelper(HandleRef jarg1, HandleRef jarg2);
public static extern void DependencyObject_InvalidatePropertyHelper(HandleRef jarg1, HandleRef jarg2);

[DllImport(Library.Name)]
public static extern void DependencyObject_SetCurrentValue(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3);
public static extern void DependencyObject_ClearValueHelper(HandleRef jarg1, HandleRef jarg2);

[DllImport(Library.Name)]
public static extern void DependencyObject_InitObject(HandleRef jarg1);

[DllImport(Library.Name)]
public static extern void DependencyObject_InvalidatePropertyHelper(HandleRef jarg1, HandleRef jarg2);

[DllImport(Library.Name)]
public static extern void Freezable_Freeze(HandleRef jarg1);

Expand Down Expand Up @@ -1354,7 +1351,7 @@ internal class NoesisGUI_PINVOKE {
public static extern void FontProvider_RegisterFontHelper(HandleRef jarg1, [MarshalAs(UnmanagedType.LPWStr)]string jarg2, [MarshalAs(UnmanagedType.LPWStr)]string jarg3);

[DllImport(Library.Name)]
public static extern IntPtr FontProvider_MatchFontHelper(HandleRef jarg1, [MarshalAs(UnmanagedType.LPWStr)]string jarg2, [MarshalAs(UnmanagedType.LPWStr)]string jarg3, ref int jarg4, ref int jarg5, ref int jarg6, ref uint jarg7);
public static extern IntPtr FontProvider_MatchFontHelper(HandleRef jarg1, [MarshalAs(UnmanagedType.LPWStr)]string jarg2, [MarshalAs(UnmanagedType.LPWStr)]string jarg3, ref int jarg4, ref int jarg5, ref int jarg6, ref uint jarg7, ref IntPtr jarg8);

[DllImport(Library.Name)]
[return: MarshalAs(UnmanagedType.U1)]
Expand Down Expand Up @@ -3362,10 +3359,10 @@ internal class NoesisGUI_PINVOKE {
public static extern void delete_StreamGeometryContext(HandleRef jarg1);

[DllImport(Library.Name)]
public static extern IntPtr new_StreamGeometry__SWIG_0([MarshalAs(UnmanagedType.LPWStr)]string jarg1);
public static extern IntPtr new_StreamGeometry__SWIG_0();

[DllImport(Library.Name)]
public static extern IntPtr new_StreamGeometry__SWIG_1();
public static extern IntPtr new_StreamGeometry__SWIG_1([MarshalAs(UnmanagedType.LPWStr)]string jarg1);

[DllImport(Library.Name)]
public static extern void StreamGeometry_SetData(HandleRef jarg1, [MarshalAs(UnmanagedType.LPWStr)]string jarg2);
Expand Down
8 changes: 4 additions & 4 deletions Src/Noesis/Core/Src/Proxies/StreamGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public override string ToString() {
return ToStringHelper();
}

public StreamGeometry(string data) : this(NoesisGUI_PINVOKE.new_StreamGeometry__SWIG_0(data != null ? data : string.Empty), true) {
}

public StreamGeometry() {
}

protected override IntPtr CreateCPtr(Type type, out bool registerExtend) {
registerExtend = false;
return NoesisGUI_PINVOKE.new_StreamGeometry__SWIG_1();
return NoesisGUI_PINVOKE.new_StreamGeometry__SWIG_0();
}

public StreamGeometry(string data) : this(NoesisGUI_PINVOKE.new_StreamGeometry__SWIG_1(data != null ? data : string.Empty), true) {
}

public void SetData(string data) {
Expand Down
30 changes: 29 additions & 1 deletion Src/Noesis/Extensions/Src/InteractivityTriggers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ public GamepadTriggerFiredOn FiredOn
"FiredOn", typeof(GamepadTriggerFiredOn), typeof(GamepadTrigger),
new PropertyMetadata(GamepadTriggerFiredOn.ButtonDown));

/// <summary>
/// Indicates if GamepadTrigger should set gamepad button event as handled when the trigger
/// invokes its actions
/// </summary>
public bool HandleWhenFired
{
get { return (bool)GetValue(HandleWhenFiredProperty); }
set { SetValue(HandleWhenFiredProperty, value); }
}

public static readonly DependencyProperty HandleWhenFiredProperty = DependencyProperty.Register(
"HandleWhenFired", typeof(bool), typeof(GamepadTrigger),
new PropertyMetadata(false));

protected override void OnAttached()
{
base.OnAttached();
Expand Down Expand Up @@ -140,10 +154,24 @@ private void OnButtonPress(object sender, KeyEventArgs e)
const int GamepadLeft = 175;
if (Button == (GamepadButton)((int)e.Key - GamepadLeft))
{
InvokeActions(e);
_invoked = false;
PreviewInvoke += OnPreviewInvoke;
InvokeActions(0);
PreviewInvoke -= OnPreviewInvoke;

if (HandleWhenFired)
{
e.Handled = _invoked;
}
}
}

private bool _invoked;
private void OnPreviewInvoke(object sender, PreviewInvokeEventArgs e)
{
_invoked = !e.Cancelling;
}

private UIElement GetRoot(Visual current)
{
UIElement root = null;
Expand Down
Loading

0 comments on commit b431a89

Please sign in to comment.