-
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][WIP] 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 `VisualObject` and let View use it. Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
- Loading branch information
Eunki, Hong
committed
Apr 17, 2024
1 parent
f7e7709
commit ed3110b
Showing
6 changed files
with
321 additions
and
0 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
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,85 @@ | ||
// Copyright (c) 2019 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> | ||
/// TODO : Summary description for VisualObjectsContainer. | ||
/// </summary> | ||
internal class VisualObjectsContainer : BaseHandle | ||
{ | ||
/// <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) : this(Interop.VisualObjectsContainer.VisualObjectsContainerNew(Tizen.NUI.BaseComponents.View.getCPtr(view)), 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 void AddVisualObject(Tizen.NUI.Visuals.VisualObject visualObject) | ||
{ | ||
Interop.VisualObjectsContainer.AddVisualObject(SwigCPtr, Tizen.NUI.Visuals.VisualObject.getCPtr(visualObject)); | ||
} | ||
|
||
public void RemoveVisualObject(Tizen.NUI.Visuals.VisualObject visualObject) | ||
{ | ||
Interop.VisualObjectsContainer.RemoveVisualObject(SwigCPtr, Tizen.NUI.Visuals.VisualObject.getCPtr(visualObject)); | ||
} | ||
|
||
/// <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); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
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,34 @@ | ||
/* | ||
* Copyright(c) 2021 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_new_VisualObject__SWIG_0")] | ||
public static extern global::System.IntPtr NewVisualObject(); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_VisualObject")] | ||
public static extern void DeleteVisualObject(global::System.Runtime.InteropServices.HandleRef jarg1); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObject_New")] | ||
public static extern global::System.IntPtr VisualObjectNew(global::System.Runtime.InteropServices.HandleRef container); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
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,40 @@ | ||
/* | ||
* Copyright(c) 2021 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_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); | ||
|
||
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualObjectsContainer_AddVisualObject")] | ||
public static extern void 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
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) 2022 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.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Runtime.InteropServices; | ||
using Tizen.NUI.Binding; | ||
|
||
namespace Tizen.NUI.BaseComponents | ||
{ | ||
/// <summary> | ||
/// View is the base class for all views. | ||
/// </summary> | ||
/// <since_tizen> 3 </since_tizen> | ||
public partial class View | ||
{ | ||
private Tizen.NUI.Visuals.VisualObjectsContainer visualContainer = null; | ||
|
||
/// <summary> | ||
/// Add a visual object to the view. | ||
/// </summary> | ||
/// <remarks> | ||
/// The visual is added to the top of the visuals. | ||
/// </remarks> | ||
/// <param name="visualObject">The visual object to add.</param> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public void AddVisualObject(Tizen.NUI.Visuals.VisualObject visualObject) | ||
{ | ||
EnsureVisualContainer(); | ||
visualContainer.AddVisualObject(visualObject); | ||
} | ||
|
||
/// <summary> | ||
/// Remove a visual object from the view. | ||
/// </summary> | ||
/// <remarks> | ||
/// The all other VisualObject's SiblingOrder value will be changed automatically. | ||
/// </remarks> | ||
/// <param name="visualObject">The visual object to remove.</param> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public void RemoveVisualObject(Tizen.NUI.Visuals.VisualObject visualObject) | ||
{ | ||
EnsureVisualContainer(); | ||
visualContainer.AddVisualObject(visualObject); | ||
} | ||
|
||
private void EnsureVisualContainer() | ||
{ | ||
if(visualContainer == null) | ||
{ | ||
visualContainer = new Visuals.VisualObjectsContainer(this); | ||
} | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/Tizen.NUI/src/public/Visuals/VisualObject/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,90 @@ | ||
// Copyright (c) 2019 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> | ||
/// TODO : Summary description for VisualObject. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public class VisualObject : BaseHandle | ||
{ | ||
/// <summary> | ||
/// Creates an empty visual object handle. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public VisualObject() : this(Interop.VisualObject.NewVisualObject(), true, false) | ||
{ | ||
NDalicPINVOKE.ThrowExceptionIfExists(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates an visual object with VisualObjectsContainer. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public VisualObject(VisualObjectsContainer container) : this(Interop.VisualObject.VisualObjectNew(VisualObjectsContainer.getCPtr(container)), true) | ||
{ | ||
NDalicPINVOKE.ThrowExceptionIfExists(); | ||
} | ||
|
||
internal VisualObject(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) | ||
{ | ||
} | ||
|
||
internal VisualObject(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) | ||
{ | ||
} | ||
|
||
public uint SiblingOrder | ||
{ | ||
set | ||
{ | ||
|
||
} | ||
get | ||
{ | ||
return Interop.VisualObject.GetSiblingOrder(SwigCPtr); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Dispose for VisualObject | ||
/// </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); | ||
} | ||
} | ||
} |