-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NUI] Implement VisualObject feature for View using Visual feature
It was hard to use Visual feature for `BaseComponents.View` We only allow to use `VisualBase` only for `VisualView`, with name. But there was some user side hardness when they want to use it 1. Subclass of View cannot use Visual feature 2. Some ImageVisual feature doesn't allow to used another visuals. To resolve this issue, let we make new class, named `Visuals.VisualBase` and let View use it. Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
- Loading branch information
Eunki, Hong
committed
May 29, 2024
1 parent
d1c4d91
commit f89c480
Showing
24 changed files
with
4,043 additions
and
18 deletions.
There are no files selected for viewing
223 changes: 223 additions & 0 deletions
223
src/Tizen.NUI/src/internal/Common/VisualObjectsContainer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
// 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. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
using System; | ||
using System.Text; | ||
using System.Runtime.InteropServices; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.ComponentModel; | ||
|
||
namespace Tizen.NUI.Visuals | ||
{ | ||
/// <summary> | ||
/// VisualObjectsContainer is a container for visual objects. | ||
/// For each VisualObjectContainer, there is a corresponding view. | ||
/// Each view can has only one VisualObjectsContainer. | ||
/// </summary> | ||
/// <remarks> | ||
/// To avoid the collision between Dali toolkit logic and NUI specific policy, | ||
/// this container has a internal limitation of the number of visual objects. | ||
/// If user try to add visual object over the limitation, it will be ignored. | ||
/// </remarks> | ||
internal class VisualObjectsContainer : BaseHandle | ||
{ | ||
private List<Tizen.NUI.Visuals.VisualBase> visuals = new List<Tizen.NUI.Visuals.VisualBase>(); // Keep visual object reference. | ||
|
||
/// <summary> | ||
/// Range of visual for the container. | ||
/// </summary> | ||
public struct ContainerRangeType | ||
{ | ||
/// <summary> | ||
/// Visual will be rendered under the shadow. | ||
/// </summary> | ||
public static readonly int Shadow = Interop.VisualObjectsContainer.ContainerRangeTypeBackgroundEffectGet(); | ||
|
||
/// <summary> | ||
/// Visual will be rendered under the background. | ||
/// </summary> | ||
public static readonly int Background = Interop.VisualObjectsContainer.ContainerRangeTypeBackgroundGet(); | ||
|
||
/// <summary> | ||
/// Visual will be rendered under the content. | ||
/// It is default value. | ||
/// </summary> | ||
public static readonly int Content = Interop.VisualObjectsContainer.ContainerRangeTypeContentGet(); | ||
|
||
/// <summary> | ||
/// Visual will be rendered under the decoration. | ||
/// </summary> | ||
public static readonly int Decoration = Interop.VisualObjectsContainer.ContainerRangeTypeDecorationGet(); | ||
|
||
/// <summary> | ||
/// Visual will be rendered above the decoration. | ||
/// </summary> | ||
public static readonly int ForegroundEffect = Interop.VisualObjectsContainer.ContainerRangeTypeForegroundEffectGet(); | ||
}; | ||
|
||
/// <summary> | ||
/// Creates an empty visual object handle. | ||
/// </summary> | ||
public VisualObjectsContainer() : this(Interop.VisualObjectsContainer.NewVisualObjectsContainer(), true, false) | ||
{ | ||
NDalicPINVOKE.ThrowExceptionIfExists(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates an visual object with VisualObjectsContainer. | ||
/// </summary> | ||
public VisualObjectsContainer(Tizen.NUI.BaseComponents.View view, int rangeType) : this(Interop.VisualObjectsContainer.VisualObjectsContainerNew(Tizen.NUI.BaseComponents.View.getCPtr(view), rangeType), true) | ||
{ | ||
NDalicPINVOKE.ThrowExceptionIfExists(); | ||
} | ||
|
||
internal VisualObjectsContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) | ||
{ | ||
} | ||
|
||
internal VisualObjectsContainer(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) | ||
{ | ||
} | ||
|
||
public Tizen.NUI.BaseComponents.View GetView() | ||
{ | ||
global::System.IntPtr cPtr = Interop.VisualObjectsContainer.GetOwner(SwigCPtr); | ||
|
||
Tizen.NUI.BaseComponents.View ret = null; | ||
if (Interop.RefObject.GetRefObjectPtr(cPtr) == global::System.IntPtr.Zero) | ||
{ | ||
// Visual container don't have owner. Return null. | ||
Interop.BaseHandle.DeleteBaseHandle(new global::System.Runtime.InteropServices.HandleRef(this, cPtr)); | ||
} | ||
else | ||
{ | ||
ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Tizen.NUI.BaseComponents.View; | ||
if (ret != null) | ||
{ | ||
Interop.BaseHandle.DeleteBaseHandle(new global::System.Runtime.InteropServices.HandleRef(this, cPtr)); | ||
} | ||
else | ||
{ | ||
ret = new Tizen.NUI.BaseComponents.View(cPtr, true); | ||
} | ||
} | ||
NDalicPINVOKE.ThrowExceptionIfExists(); | ||
return ret; | ||
} | ||
|
||
public int GetContainerRangeType() | ||
{ | ||
return Interop.VisualObjectsContainer.GetContainerRangeType(SwigCPtr); | ||
} | ||
|
||
public Tizen.NUI.Visuals.VisualBase this[uint index] | ||
{ | ||
get | ||
{ | ||
return GetVisualObjectAt(index); | ||
} | ||
} | ||
|
||
public uint GetVisualObjectsCount() | ||
{ | ||
uint ret = Interop.VisualObjectsContainer.GetVisualObjectsCount(SwigCPtr); | ||
NDalicPINVOKE.ThrowExceptionIfExists(); | ||
return ret; | ||
} | ||
|
||
public bool AddVisualObject(Tizen.NUI.Visuals.VisualBase visualObject) | ||
{ | ||
// Detach from previous container first. | ||
var previousContainer = visualObject.GetVisualContainer(); | ||
if (previousContainer != null) | ||
{ | ||
if (previousContainer == this) | ||
{ | ||
// Already added to this container. | ||
return false; | ||
} | ||
visualObject.Detach(); | ||
} | ||
|
||
visuals.Add(visualObject); | ||
|
||
bool ret = Interop.VisualObjectsContainer.AddVisualObject(SwigCPtr, Tizen.NUI.Visuals.VisualBase.getCPtr(visualObject)); | ||
NDalicPINVOKE.ThrowExceptionIfExists(); | ||
return ret; | ||
} | ||
|
||
public void RemoveVisualObject(Tizen.NUI.Visuals.VisualBase visualObject) | ||
{ | ||
visuals.Remove(visualObject); | ||
|
||
Interop.VisualObjectsContainer.RemoveVisualObject(SwigCPtr, Tizen.NUI.Visuals.VisualBase.getCPtr(visualObject)); | ||
NDalicPINVOKE.ThrowExceptionIfExists(); | ||
} | ||
|
||
public Tizen.NUI.Visuals.VisualBase FindVisualObjectByName(string name) | ||
{ | ||
Tizen.NUI.Visuals.VisualBase ret = null; | ||
if(!string.IsNullOrEmpty(name)) | ||
{ | ||
foreach (var visual in visuals) | ||
{ | ||
if (visual?.Name == name) | ||
{ | ||
return visual; | ||
} | ||
} | ||
} | ||
return ret; | ||
} | ||
|
||
private Tizen.NUI.Visuals.VisualBase GetVisualObjectAt(uint index) | ||
{ | ||
global::System.IntPtr cPtr = Interop.VisualObjectsContainer.GetVisualObjectAt(SwigCPtr, index); | ||
Visuals.VisualBase ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Visuals.VisualBase; | ||
if (ret != null) | ||
{ | ||
Interop.BaseHandle.DeleteBaseHandle(new global::System.Runtime.InteropServices.HandleRef(this, cPtr)); | ||
} | ||
else | ||
{ | ||
ret = new Visuals.VisualBase(cPtr, true); | ||
} | ||
NDalicPINVOKE.ThrowExceptionIfExists(); | ||
return ret; | ||
} | ||
|
||
/// <summary> | ||
/// Dispose for VisualObjectsContainer | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
protected override void Dispose(DisposeTypes type) | ||
{ | ||
if (disposed) | ||
{ | ||
return; | ||
} | ||
|
||
if (type == DisposeTypes.Explicit) | ||
{ | ||
//Called by User | ||
//Release your own managed resources here. | ||
//You should release all of your own disposable objects here. | ||
} | ||
|
||
base.Dispose(type); | ||
} | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
src/Tizen.NUI/src/internal/Interop/Interop.VisualObject.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
namespace Tizen.NUI | ||
{ | ||
internal static partial class Interop | ||
{ | ||
internal static partial class VisualObject | ||
{ | ||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_New")] | ||
public static extern global::System.IntPtr VisualObjectNew(); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_GetContainer")] | ||
public static extern global::System.IntPtr GetContainer(global::System.Runtime.InteropServices.HandleRef visualObject); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_CreateVisual")] | ||
public static extern void CreateVisual(global::System.Runtime.InteropServices.HandleRef visualObject, global::System.Runtime.InteropServices.HandleRef propertyMap); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_RetrieveVisualPropertyMap")] | ||
public static extern void RetrieveVisualPropertyMap(global::System.Runtime.InteropServices.HandleRef visualObject, global::System.Runtime.InteropServices.HandleRef propertyMap); | ||
|
||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_DoAction_UpdatePropertyMap")] | ||
public static extern void UpdateVisualPropertyMap(global::System.Runtime.InteropServices.HandleRef visualObject, global::System.Runtime.InteropServices.HandleRef propertyMap); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_DoActionWithEmptyAttributes")] | ||
public static extern void DoActionWithEmptyAttributes(global::System.Runtime.InteropServices.HandleRef visualObject, int actionId); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_DoActionWithSingleIntAttributes")] | ||
public static extern void DoActionWithSingleIntAttributes(global::System.Runtime.InteropServices.HandleRef visualObject, int actionId, int actionValue); | ||
|
||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_SetSiblingOrder")] | ||
public static extern void SetSiblingOrder(global::System.Runtime.InteropServices.HandleRef visualObject, uint siblingOrder); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_GetSiblingOrder")] | ||
public static extern uint GetSiblingOrder(global::System.Runtime.InteropServices.HandleRef visualObject); | ||
|
||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_DetachFromContainer")] | ||
public static extern void Detach(global::System.Runtime.InteropServices.HandleRef visualObject); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_Raise")] | ||
public static extern uint Raise(global::System.Runtime.InteropServices.HandleRef visualObject); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_Lower")] | ||
public static extern uint Lower(global::System.Runtime.InteropServices.HandleRef visualObject); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_RaiseToTop")] | ||
public static extern uint RaiseToTop(global::System.Runtime.InteropServices.HandleRef visualObject); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_LowerToBottom")] | ||
public static extern uint LowerToBottom(global::System.Runtime.InteropServices.HandleRef visualObject); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_RaiseAbove")] | ||
public static extern uint RaiseAbove(global::System.Runtime.InteropServices.HandleRef visualObject, global::System.Runtime.InteropServices.HandleRef target); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_LowerBelow")] | ||
public static extern uint LowerBelow(global::System.Runtime.InteropServices.HandleRef visualObject, global::System.Runtime.InteropServices.HandleRef target); | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/Tizen.NUI/src/internal/Interop/Interop.VisualObjectsContainer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
namespace Tizen.NUI | ||
{ | ||
internal static partial class Interop | ||
{ | ||
internal static partial class VisualObjectsContainer | ||
{ | ||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_ContainerRangeTypeBackgroundEffectGet")] | ||
public static extern int ContainerRangeTypeBackgroundEffectGet(); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_ContainerRangeTypeBackgroundGet")] | ||
public static extern int ContainerRangeTypeBackgroundGet(); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_ContainerRangeTypeContentGet")] | ||
public static extern int ContainerRangeTypeContentGet(); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_ContainerRangeTypeDecorationGet")] | ||
public static extern int ContainerRangeTypeDecorationGet(); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_ContainerRangeTypeForegroundEffectGet")] | ||
public static extern int ContainerRangeTypeForegroundEffectGet(); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_VisualObjectsContainer__SWIG_0")] | ||
public static extern global::System.IntPtr NewVisualObjectsContainer(); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_VisualObjectsContainer")] | ||
public static extern void DeleteVisualObjectsContainer(global::System.Runtime.InteropServices.HandleRef container); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_New")] | ||
public static extern global::System.IntPtr VisualObjectsContainerNew(global::System.Runtime.InteropServices.HandleRef view, int rangeType); | ||
|
||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_GetOwner")] | ||
public static extern global::System.IntPtr GetOwner(global::System.Runtime.InteropServices.HandleRef container); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_GetContainerRangeType")] | ||
public static extern int GetContainerRangeType(global::System.Runtime.InteropServices.HandleRef container); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_GetVisualObjectsCount")] | ||
public static extern uint GetVisualObjectsCount(global::System.Runtime.InteropServices.HandleRef container); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_GetVisualObjectAt")] | ||
public static extern global::System.IntPtr GetVisualObjectAt(global::System.Runtime.InteropServices.HandleRef container, uint index); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_AddVisualObject")] | ||
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] | ||
public static extern bool AddVisualObject(global::System.Runtime.InteropServices.HandleRef container, global::System.Runtime.InteropServices.HandleRef viewObject); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_RemoveVisualObject")] | ||
public static extern void RemoveVisualObject(global::System.Runtime.InteropServices.HandleRef container, global::System.Runtime.InteropServices.HandleRef viewObject); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.