Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generic dynamic context menu + reel gallery integration #3071

Merged
merged 45 commits into from
Jan 20, 2025
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8523506
wip
lorenzo-ranciaffi Jan 3, 2025
e3ab563
wip
lorenzo-ranciaffi Jan 3, 2025
5943bbd
wip
lorenzo-ranciaffi Jan 3, 2025
e1bc7fc
fix scriptable objects
lorenzo-ranciaffi Jan 3, 2025
b52e8d2
improved SO
lorenzo-ranciaffi Jan 3, 2025
ac6c09d
fix and integration into reel gallery
lorenzo-ranciaffi Jan 3, 2025
5d0e5ad
extension and initial values
lorenzo-ranciaffi Jan 6, 2025
06caf8c
moved all SO in own classes
lorenzo-ranciaffi Jan 6, 2025
abfb65f
fix toggle graphics
lorenzo-ranciaffi Jan 6, 2025
278bc57
added readonly serialized attribute drawer
lorenzo-ranciaffi Jan 6, 2025
aae1e1e
context menu conversion test
lorenzo-ranciaffi Jan 6, 2025
e0b2e48
Merge branch 'dev' into feat/dynamic-context-menu
lorenzo-ranciaffi Jan 6, 2025
2039858
fix custom property naming
lorenzo-ranciaffi Jan 6, 2025
2fc3279
more test conversion
lorenzo-ranciaffi Jan 6, 2025
682984a
fix context menu position
lorenzo-ranciaffi Jan 6, 2025
22ae88b
avoid layout rebuild for height calculation
lorenzo-ranciaffi Jan 6, 2025
18aed20
restructured components
lorenzo-ranciaffi Jan 6, 2025
939556f
more generic management of components
lorenzo-ranciaffi Jan 7, 2025
d5484f3
reference lambdas and values by config instead of indexes
lorenzo-ranciaffi Jan 7, 2025
e25937d
more generic pool manager
lorenzo-ranciaffi Jan 7, 2025
41121a5
expose elements spacing in context menu config
lorenzo-ranciaffi Jan 7, 2025
c03f7d0
exposed layout settings
lorenzo-ranciaffi Jan 7, 2025
d73b1cc
fix reel gallery context menu behavior
lorenzo-ranciaffi Jan 7, 2025
2bb9953
removed unused import
lorenzo-ranciaffi Jan 7, 2025
660b442
ported camera reel gallery context menu to new generic architecture
lorenzo-ranciaffi Jan 8, 2025
f694ec9
fix asmdef pointers
lorenzo-ranciaffi Jan 8, 2025
8cfd7d3
Merge branch 'dev' into feat/dynamic-context-menu
lorenzo-ranciaffi Jan 8, 2025
cf7e072
add required component
lorenzo-ranciaffi Jan 8, 2025
7b56cb9
changed class names
lorenzo-ranciaffi Jan 9, 2025
9d76599
Merge branch 'dev' into feat/dynamic-context-menu
lorenzo-ranciaffi Jan 9, 2025
18c2b99
use asset references instead of indexes
lorenzo-ranciaffi Jan 9, 2025
6c262a0
Merge branch 'dev' into feat/dynamic-context-menu
lorenzo-ranciaffi Jan 9, 2025
8b49855
added generic types for component configure method
lorenzo-ranciaffi Jan 10, 2025
06dbf24
Merge branch 'dev' into feat/dynamic-context-menu
lorenzo-ranciaffi Jan 10, 2025
dfae86e
moved scriptable object logic to code builder
lorenzo-ranciaffi Jan 14, 2025
53a71a1
Merge branch 'dev' into feat/dynamic-context-menu
lorenzo-ranciaffi Jan 14, 2025
07ce827
Merge branch 'dev' into feat/dynamic-context-menu
lorenzo-ranciaffi Jan 16, 2025
b3e145a
suggested modifications
lorenzo-ranciaffi Jan 16, 2025
98829f0
removed unnecessary abstraction layer in components
lorenzo-ranciaffi Jan 16, 2025
f5ad975
refactored context menu closing task
lorenzo-ranciaffi Jan 16, 2025
2e59aee
removed background button click event and used onClickAsync directly …
lorenzo-ranciaffi Jan 16, 2025
a60cde0
prevent double Hide invocation
lorenzo-ranciaffi Jan 16, 2025
b3a0421
Merge branch 'dev' into feat/dynamic-context-menu
lorenzo-ranciaffi Jan 16, 2025
c6bdcf7
Merge branch 'dev' into feat/dynamic-context-menu
lorenzo-ranciaffi Jan 20, 2025
c71845d
removed generic Delegate and initial value. Moved everything as typed…
lorenzo-ranciaffi Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoid layout rebuild for height calculation
  • Loading branch information
lorenzo-ranciaffi committed Jan 6, 2025
commit 22ae88b272f90df9a0958645d6c632d756b6cd9b
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ namespace DCL.UI.GenericContextMenu.Controls
{
public class GenericContextMenuButtonWithTextView : MonoBehaviour, IGenericContextMenuComponent
{
[field: SerializeField] public RectTransform RectTransformComponent { get; private set; }
[field: SerializeField] public Button ButtonComponent { get; private set; }
[field: SerializeField] public TMP_Text TextComponent { get; private set; }
[field: SerializeField] public Image ImageComponent { get; private set; }
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ namespace DCL.UI.GenericContextMenu.Controls
{
public class GenericContextMenuToggleView : MonoBehaviour, IGenericContextMenuComponent
{
[field: SerializeField] public RectTransform RectTransformComponent { get; private set; }
[field: SerializeField] public ToggleView ToggleComponent { get; private set; }
[field: SerializeField] public TMP_Text TextComponent { get; private set; }

Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ protected override void OnViewShow()

private void ConfigureContextMenu()
{
viewInstance!.ControlsContainer.sizeDelta = new Vector2(inputData.Config.Width, viewInstance!.ControlsContainer.sizeDelta.y);
float totalHeight = 0;

for (var i = 0; i < inputData.Config.ContextMenuSettings.Count; i++)
{
@@ -75,22 +75,30 @@ private void ConfigureContextMenu()
switch (config.ControlTypeType)
{
case ContextMenuControlTypes.SEPARATOR:
controlsPoolManager.GetSeparator(config as SeparatorContextMenuControlSettings, i);
GenericContextMenuSeparatorView separatorView = controlsPoolManager.GetSeparator(config as SeparatorContextMenuControlSettings, i);
totalHeight += separatorView.RectTransformComponent.rect.height;
break;
case ContextMenuControlTypes.BUTTON_WITH_TEXT_AND_ICON:
GenericContextMenuButtonWithTextView button = controlsPoolManager.GetButton(config as ButtonContextMenuControlSettings, i);
button.ButtonComponent.onClick.AddListener(new UnityAction((Action)inputData.ControlsActions[i]));
button.ButtonComponent.onClick.AddListener(TriggerContextMenuClose);
totalHeight += button.RectTransformComponent.rect.height;
break;
case ContextMenuControlTypes.TOGGLE_WITH_TEXT:
GenericContextMenuToggleView toggle = controlsPoolManager.GetToggle(config as ToggleContextMenuControlSettings, controlInitialValue != null && (bool)controlInitialValue , i);
toggle.ToggleComponent.Toggle.onValueChanged.AddListener(new UnityAction<bool>((Action<bool>)inputData.ControlsActions[i]));
toggle.ToggleComponent.Toggle.onValueChanged.AddListener(toggleValue => TriggerContextMenuClose());
totalHeight += toggle.RectTransformComponent.rect.height;
break;
}
}
Canvas.ForceUpdateCanvases();
LayoutRebuilder.ForceRebuildLayoutImmediate(viewInstance!.ControlsContainer);

viewInstance!.ControlsContainer.sizeDelta = new Vector2(inputData.Config.Width,
totalHeight
+ viewInstance!.ControlsLayoutGroup.padding.bottom
+ viewInstance!.ControlsLayoutGroup.padding.top
+ (viewInstance!.ControlsLayoutGroup.spacing * (inputData.Config.ContextMenuSettings.Count - 1)));

viewInstance!.ControlsContainer.localPosition = GetControlsPosition(inputData.AnchorPosition, inputData.Config.OffsetFromTarget, inputData.OverlapRect);
}

Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ namespace DCL.UI.GenericContextMenu
public class GenericContextMenuView : ViewBase, IView, IDisposable
{
[field: SerializeField] public RectTransform ControlsContainer { get; private set; }
[field: SerializeField] public VerticalLayoutGroup ControlsLayoutGroup { get; private set; }
[field: SerializeField] public Button BackgroundCloseButton { get; private set; }

public event Action BackgroundCloseButtonClicked;
Original file line number Diff line number Diff line change
@@ -346,6 +346,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d0cb01ddb93349c98fd84395a98b77f9, type: 3}
m_Name:
m_EditorClassIdentifier:
<RectTransformComponent>k__BackingField: {fileID: 5856922699228769623}
<ButtonComponent>k__BackingField: {fileID: 4754064954679370281}
<TextComponent>k__BackingField: {fileID: 8655627310085805794}
<ImageComponent>k__BackingField: {fileID: 6260016763612421407}
Original file line number Diff line number Diff line change
@@ -119,6 +119,7 @@ MonoBehaviour:
<canvas>k__BackingField: {fileID: 6591100080399325240}
<raycaster>k__BackingField: {fileID: 8522526520946479007}
<ControlsContainer>k__BackingField: {fileID: 2932465032679087180}
<ControlsLayoutGroup>k__BackingField: {fileID: 5384044999603412779}
<BackgroundCloseButton>k__BackingField: {fileID: 3243245791156245727}
--- !u!1 &7170495978923432429
GameObject:
Original file line number Diff line number Diff line change
@@ -90,6 +90,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e8f35c553d944f99854691517619b0e3, type: 3}
m_Name:
m_EditorClassIdentifier:
<RectTransformComponent>k__BackingField: {fileID: 891560713975722788}
<ToggleComponent>k__BackingField: {fileID: 3675667337910807093}
<TextComponent>k__BackingField: {fileID: 7042733739484598958}
--- !u!1 &4204936758877281454