Skip to content

Commit

Permalink
[NUI.Scene3D] Support SceneView CornerRadius/Borderline Property applied
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunki, Hong authored and hinohie committed Oct 10, 2024
1 parent bcfa847 commit e4804ef
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 15 deletions.
16 changes: 16 additions & 0 deletions src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.SceneView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ internal static partial class SceneView

[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_CaptureFinishedSignal_Disconnect")]
public static extern void CaptureFinishedDisconnect(global::System.Runtime.InteropServices.HandleRef actor, global::System.Runtime.InteropServices.HandleRef handler);

/// Property enum get
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_Property_CornerRadius_get")]
public static extern int CornerRadiusGet();

[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_Property_CornerRadiusPolicy_get")]
public static extern int CornerRadiusPolicyGet();

[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_Property_BorderlineWidth_get")]
public static extern int BorderlineWidthGet();

[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_Property_BorderlineColor_get")]
public static extern int BorderlineColorGet();

[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_Property_BorderlineOffset_get")]
public static extern int BorderlineOffsetGet();
}
}
}
53 changes: 53 additions & 0 deletions src/Tizen.NUI.Scene3D/src/public/Controls/SceneView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,59 @@ private Rotation GetSkyboxOrientation()
return ret;
}

/// <summary>
/// Callback when CornerRadius property changed.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ApplyCornerRadius()
{
base.ApplyCornerRadius();

if (backgroundExtraData == null) return;

// Update corner radius properties to image by ActionUpdateProperty
if (backgroundExtraDataUpdatedFlag.HasFlag(BackgroundExtraDataUpdatedFlag.ContentsCornerRadius))
{
if (backgroundExtraData.CornerRadius != null)
{
using var setValue = new Tizen.NUI.PropertyValue(backgroundExtraData.CornerRadius);
SetProperty(Interop.SceneView.CornerRadiusGet(), setValue);
}
{
using var setValue = new Tizen.NUI.PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
SetProperty(Interop.SceneView.CornerRadiusPolicyGet(), setValue);
}
}
}

/// <summary>
/// Callback when Borderline property changed.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ApplyBorderline()
{
base.ApplyBorderline();

if (backgroundExtraData == null) return;

// Update corner radius properties to image by ActionUpdateProperty
if (backgroundExtraDataUpdatedFlag.HasFlag(BackgroundExtraDataUpdatedFlag.ContentsBorderline))
{
{
using var setValue = new Tizen.NUI.PropertyValue(backgroundExtraData.BorderlineWidth);
SetProperty(Interop.SceneView.BorderlineWidthGet(), setValue);
}
{
using var setValue = new Tizen.NUI.PropertyValue((backgroundExtraData.BorderlineColor ?? Color.Black));
SetProperty(Interop.SceneView.BorderlineColorGet(), setValue);
}
{
using var setValue = new Tizen.NUI.PropertyValue(backgroundExtraData.BorderlineOffset);
SetProperty(Interop.SceneView.BorderlineOffsetGet(), setValue);
}
}
}

/// <summary>
/// Release swigCPtr.
/// </summary>
Expand Down
6 changes: 4 additions & 2 deletions src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1923,7 +1923,8 @@ internal ViewResourceReadySignal ResourceReadySignal(View view)
return ret;
}

internal override void ApplyCornerRadius()
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ApplyCornerRadius()
{
base.ApplyCornerRadius();

Expand All @@ -1940,7 +1941,8 @@ internal override void ApplyCornerRadius()
}
}

internal override void ApplyBorderline()
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ApplyBorderline()
{
base.ApplyBorderline();

Expand Down
8 changes: 4 additions & 4 deletions src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,8 +1258,8 @@ internal virtual void UpdateBackgroundExtraData()
backgroundExtraDataUpdatedFlag = BackgroundExtraDataUpdatedFlag.None;
}

/// TODO open as a protected level
internal virtual void ApplyCornerRadius()
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void ApplyCornerRadius()
{
if (backgroundExtraData == null) return;

Expand All @@ -1282,8 +1282,8 @@ internal virtual void ApplyCornerRadius()
}
}

/// TODO open as a protected level
internal virtual void ApplyBorderline()
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void ApplyBorderline()
{
if (backgroundExtraData == null) return;

Expand Down
4 changes: 2 additions & 2 deletions src/Tizen.NUI/src/public/WebView/WebView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2982,8 +2982,8 @@ internal WebView Assign(WebView webView)
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

internal override void ApplyCornerRadius()
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ApplyCornerRadius()
{
base.ApplyCornerRadius();

Expand Down
36 changes: 29 additions & 7 deletions test/Tizen.NUI.Scene3D.Sample/Scene3DSample.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Samsung Electronics Co., Ltd.
* Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,6 +30,8 @@ class Scene3DSample : NUIApplication
Window mWindow;
Vector2 mWindowSize;

private float mSceneViewSizeRate = 0.95f; // The scene view size relation as window size.

SceneView mSceneView;
Model mModel;
Animation mModelAnimation;
Expand Down Expand Up @@ -130,13 +132,16 @@ protected void CreateSceneView()
{
mSceneView = new SceneView()
{
SizeWidth = mWindowSize.Width,
SizeHeight = mWindowSize.Height,
SizeWidth = mWindowSize.Width * mSceneViewSizeRate,
SizeHeight = mWindowSize.Height * mSceneViewSizeRate,
PositionX = 0.0f,
PositionY = 0.0f,
PivotPoint = PivotPoint.TopLeft,
ParentOrigin = ParentOrigin.TopLeft,
PivotPoint = PivotPoint.Center,
ParentOrigin = ParentOrigin.Center,
PositionUsesPivotPoint = true,

UseFramebuffer = true,
BackgroundColor = Color.DarkOrchid,
};

mSceneView.CameraTransitionFinished += (o, e) =>
Expand Down Expand Up @@ -480,6 +485,18 @@ void OnKeyEvent(object source, Window.KeyEventArgs e)
}
break;
}
case "c":
{
if (mSceneView != null)
{
mSceneView.CornerRadius = new Vector4(40.0f, 40.0f, 40.0f, 40.0f);
mSceneView.CornerRadiusPolicy = VisualTransformPolicyType.Absolute;
mSceneView.BorderlineWidth = 20.0f;
mSceneView.BorderlineColor = new Vector4(1.0f, 1.0f, 1.0f, 0.2f);
mSceneView.BorderlineOffset = -1.0f;
}
break;
}
}

FullGC();
Expand All @@ -501,19 +518,24 @@ void OnKeyEvent(object source, Window.KeyEventArgs e)
mModelAnimation.Play();
}
}
if (mSceneView != null)
{
mSceneView.CornerRadius = Vector4.Zero;
mSceneView.BorderlineWidth = 0.0f;
}
}
}

public void Activate()
{
mWindow = Window.Default;
mWindow.BackgroundColor = Color.DarkOrchid;
mWindow.BackgroundColor = Color.Blue;
mWindowSize = mWindow.WindowSize;

mWindow.Resized += (o, e) =>
{
mWindowSize = mWindow.WindowSize;
mSceneView.Size = new Size(mWindowSize);
mSceneView.Size = new Size(mWindowSize * mSceneViewSizeRate);
};

mWindow.KeyEvent += OnKeyEvent;
Expand Down

0 comments on commit e4804ef

Please sign in to comment.