Skip to content

Commit

Permalink
[NUI] Prepare extra space to View to attach objects from external
Browse files Browse the repository at this point in the history
Signed-off-by: Jiyun Yang <[email protected]>
  • Loading branch information
rabbitfor committed Dec 6, 2024
1 parent 8d61266 commit cfdbcf4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Tizen.NUI/src/public/BaseComponents/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public partial class View : Container, IResourcesProvider
private LayoutTransition layoutTransition;
private TransitionOptions transitionOptions = null;
private ThemeData themeData;
private Dictionary<Type, object> attached;
private bool isThemeChanged = false;

// Collection of image-sensitive properties, and need to update C# side cache value.
Expand Down
22 changes: 22 additions & 0 deletions src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

using System;
using System.ComponentModel;
using System.Collections.Generic;
using global::System.Diagnostics;
using Tizen.NUI;

Expand Down Expand Up @@ -1342,6 +1343,24 @@ internal void SetThemeApplied()
}
}

internal T GetAttached<T>()
{
if (attached != null && attached.ContainsKey(typeof(T)))
return (T)attached[typeof(T)];
return default;
}

internal void ClearAttached<T>()
{
attached?.Remove(typeof(T));
}

internal void SetAttached<T>(T value)
{
attached ??= new Dictionary<Type, object>();
attached[typeof(T)] = value;
}

/// <summary>
/// you can override it to clean-up your own resources.
/// </summary>
Expand Down Expand Up @@ -1469,6 +1488,9 @@ protected override void Dispose(DisposeTypes type)
heightConstraint.Remove();
heightConstraint.Dispose();
}

attached?.Clear();
attached = null;
}

//Release your own unmanaged resources here.
Expand Down

0 comments on commit cfdbcf4

Please sign in to comment.