Skip to content

Commit

Permalink
[NUI] remove unnecessary PInvoke calls related with axis
Browse files Browse the repository at this point in the history
  • Loading branch information
Woochan Lee committed Jan 9, 2025
1 parent e414820 commit 58cbd9f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 331 deletions.
79 changes: 19 additions & 60 deletions src/Tizen.NUI/src/public/Common/NUIConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1616,96 +1616,55 @@ public static Position BottomRight
}
}
}

/// <summary>
/// PositionAxis constants.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public struct PositionAxis
{
private static readonly Position xaxis = new Position(1.0f, 0.0f, 0.0f);
private static readonly Position yaxis = new Position(0.0f, 1.0f, 0.0f);
private static readonly Position zaxis = new Position(0.0f, 0.0f, 1.0f);
private static readonly Position negativeXaxis = new Position(-1.0f, 0.0f, 0.0f);
private static readonly Position negativeYaxis = new Position(0.0f, -1.0f, 0.0f);
private static readonly Position negativeZaxis = new Position(0.0f, 0.0f, -1.0f);

/// <summary>
/// The X axis
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Position X
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.XaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Position X => xaxis;

/// <summary>
/// The Y axis
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Position Y
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.YaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Position Y => yaxis;

/// <summary>
/// The Z axis
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Position Z
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.ZaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Position Z => zaxis;

/// <summary>
/// The Negative X axis
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Position NegativeX
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.NegativeXaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Position NegativeX => negativeXaxis;

/// <summary>
/// The Negative Y axis
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Position NegativeY
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.NegativeYaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Position NegativeY => negativeYaxis;

/// <summary>
/// The Negative Z axis
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Position NegativeZ
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.NegativeZaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Position NegativeZ => negativeZaxis;
}

/// <summary>
Expand Down
90 changes: 10 additions & 80 deletions src/Tizen.NUI/src/public/Common/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace Tizen.NUI
[Tizen.NUI.Binding.TypeConverter(typeof(PositionTypeConverter))]
public class Position : Disposable, ICloneable
{
private static readonly Position one = new Position(1.0f, 1.0f, 1.0f);
private static readonly Position zero = new Position(0.0f, 0.0f, 0.0f);

/// <summary>
/// The constructor.
Expand Down Expand Up @@ -491,31 +493,13 @@ public static Position PivotPointBottomRight
/// Constant ( 1.0f, 1.0f, 1.0f ).
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Position One
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.OneGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Position One => one;

/// <summary>
/// Constant ( 0.0f, 0.0f, 0.0f ).
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Position Zero
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.ZeroGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Position Zero => zero;

/// <summary>
/// The x component.
Expand Down Expand Up @@ -616,71 +600,17 @@ public float Z
}
}

internal static Position XAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.XaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
internal static Position XAxis => PositionAxis.X;

internal static Position YAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.YaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
internal static Position YAxis => PositionAxis.Y;

internal static Position ZAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.ZaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
internal static Position ZAxis => PositionAxis.Z;

internal static Position NegativeXAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.NegativeXaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
internal static Position NegativeXAxis => PositionAxis.NegativeX;

internal static Position NegativeYAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.NegativeYaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
internal static Position NegativeYAxis => PositionAxis.NegativeY;

internal static Position NegativeZAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector3.NegativeZaxisGet();
Position ret = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
internal static Position NegativeZAxis => PositionAxis.NegativeZ;

/// <summary>
/// The const array subscript operator overload. Should be 0, 1, or 2.
Expand Down
72 changes: 12 additions & 60 deletions src/Tizen.NUI/src/public/Common/Vector2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ namespace Tizen.NUI
[Binding.TypeConverter(typeof(Vector2TypeConverter))]
public class Vector2 : Disposable, ICloneable
{
private static readonly Vector2 one = new Vector2(1.0f, 1.0f);
private static readonly Vector2 zero = new Vector2(0.0f, 0.0f);
private static readonly Vector2 xaxis = new Vector2(1.0f, 0.0f);
private static readonly Vector2 yaxis = new Vector2(0.0f, 1.0f);
private static readonly Vector2 negativeXaxis = new Vector2(-1.0f, 0.0f);
private static readonly Vector2 negativeYaxis = new Vector2(0.0f, -1.0f);

/// <summary>
/// The default constructor initializes the vector to 0.
Expand Down Expand Up @@ -111,92 +117,38 @@ internal Vector2(Vector2ChangedCallback cb, Vector2 other) : this(cb, other.X, o
/// Actual value is (1.0f,1.0f).
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Vector2 One
{
get
{
global::System.IntPtr cPtr = Interop.Vector2.OneGet();
Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Vector2 One => one;

/// <summary>
/// The vector representing the x-axis.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Vector2 XAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector2.XaxisGet();
Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Vector2 XAxis => xaxis;

/// <summary>
/// The vector representing the y-axis.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Vector2 YAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector2.YaxisGet();
Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Vector2 YAxis => yaxis;

/// <summary>
/// The vector representing the negative x-axis.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Vector2 NegativeXAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector2.NegativeXaxisGet();
Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Vector2 NegativeXAxis => negativeXaxis;

/// <summary>
/// The vector representing the negative y-axis.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Vector2 NegativeYAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector2.NegativeYaxisGet();
Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Vector2 NegativeYAxis => negativeYaxis;

/// <summary>
/// A Vector2 object representing the zero vector.
/// Actual value is (0.0f, 0.0f).
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static Vector2 Zero
{
get
{
global::System.IntPtr cPtr = Interop.Vector2.ZeroGet();
Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
public static Vector2 Zero => zero;

/// <summary>
/// The x component.
Expand Down
Loading

0 comments on commit 58cbd9f

Please sign in to comment.