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

Adding first pieces needed in LottieToWinCompTranslator to enable image layer. #105

Merged
merged 10 commits into from
Apr 30, 2019

Conversation

plaiMS
Copy link
Contributor

@plaiMS plaiMS commented Apr 29, 2019

Changes protected under #define EnableImageLayer.

@simeoncran
Copy link
Contributor

simeoncran commented Apr 29, 2019

// This code was generated by a tool.

This code is generated.... don't modify it directly. The source is in source\Issues. Add a new .md file there for LT0028.md, then run the GenerateISsuesClasses.cmd script which will regenerate this file. #Closed


Refers to: source/LottieToWinComp/TranslationIssues.cs:7 in dc91f49. [](commit_id = dc91f49, deletion_comment = False)

Copy link
Contributor

@simeoncran simeoncran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

case Asset.AssetType.Image:
var imageAsset = (ImageAsset)referencedLayersAsset;
content.Size = new Sn.Vector2((float)imageAsset.Width, (float)imageAsset.Height);
var brush = CreateColorBrush(LottieData.Color.FromArgb(1, 1, 0, 0));
Copy link
Contributor

@sohchatt sohchatt Apr 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a comment that explains the intentions of using a colorbrush? #Closed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment should explain the intention of the brush. There should be comments in this method explaining why you're doing what you're doing - the brush is not the only weird thing in here.


In reply to: 279561955 [](ancestors = 279561955)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the other weird things here?


In reply to: 279590537 [](ancestors = 279590537,279561955)

@@ -694,7 +737,16 @@ Visual TranslatePreCompLayerToVisual(TranslationContext context, PreCompLayer la
AddTranslatedLayersToContainerVisual(contentsNode, subContext, referencedLayers, $"{layer.Name}:{layerCollectionAsset.Id}");
break;
case Asset.AssetType.Image:
#if EnableImageLayer
Copy link
Contributor

@sohchatt sohchatt Apr 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be done twice? Shouldn't this case be handled by regular translation above? #Resolved

@simeoncran
Copy link
Contributor

simeoncran commented Apr 30, 2019

�[�c�o�m�m�e�n�t�]�:� �#� �(�t�e�x�t�:�I�m�a�g�e� �l�a�y�e�r�s� �i�s� �n�o�t� �s�u�p�p�o�r�t�e�d�)�

Remove the s or make it "Image layers are not supported". #Closed


Refers to: source/Issues/LT0009.md:5 in b43759e. [](commit_id = b43759e, deletion_comment = False)

@simeoncran
Copy link
Contributor

simeoncran commented Apr 30, 2019

�[�c�o�m�m�e�n�t�]�:� �#� �(�t�e�x�t�:�R�e�f�e�r�e�n�c�e�d�A�s�s�e�t�D�o�e�s�N�o�t�E�x�i�s�t�)�

This shouldn't be smoooshed together.
Also, do you think this should/could have have the asset reference id in the text? #Closed


Refers to: source/Issues/LT0008.md:5 in b43759e. [](commit_id = b43759e, deletion_comment = False)

@simeoncran
Copy link
Contributor

simeoncran commented Apr 30, 2019

�[�c�o�m�m�e�n�t�]�:� �#� �(�t�e�x�t�:�{�c�u�r�r�e�n�t�L�a�y�e�r�T�y�p�e�}� �r�e�f�e�r�e�n�c�e�d� �a�s�s�e�t� �{�a�s�s�e�t�R�e�f�I�d�}� �o�f� �t�y�p�e� �{�a�s�s�e�t�T�y�p�e�}� �w�h�i�c�h� �i�s� �i�n�v�a�l�i�d�.� �E�x�p�e�c�t�e�d� �a�s�s�e�t� �o�f� �t�y�p�e� �{�e�x�p�e�c�t�e�d�A�s�s�e�t�T�y�p�e�}�.�)�

...Expected an asset... #Closed


Refers to: source/Issues/LT0029.md:5 in b43759e. [](commit_id = b43759e, deletion_comment = False)

@simeoncran
Copy link
Contributor

simeoncran commented Apr 30, 2019

�#� �L�o�t�t�i�e�-�W�i�n�d�o�w�s� �W�a�r�n�i�n�g� �L�T�0�0�0�4�

Wrong number #Closed


Refers to: source/Issues/LT0029.md:9 in b43759e. [](commit_id = b43759e, deletion_comment = False)

yield return shapeVisual;
shapeVisual = null;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this code is intended to achieve. It looks like you'd get the same result if you just added SpriteVisual to the list of cases in the previous case (case ContainerVisual: case ShapeVisual: case SpriteVisual:).
#Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.


In reply to: 279589809 [](ancestors = 279589809)

}

// Translation currently does not support having multiple paths for masks.
// If possible users should combine masks when exporting to json.
if (layer.Masks.Length > 1)
{
_unsupported.MultipleShapeMasks();
_issues.MultipleShapeMasks();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MultipleShapeMasks [](start = 28, length = 18)

This is an unsupported case (as per the comments) so that name of the issue should be updated to reflect that. Should be done for all the issue types that are saying that things are unsupported. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much all of them are issues because they are unsupported. They might look silly if all issues say "NotSupported"?


In reply to: 279590031 [](ancestors = 279590031)

var referencedLayersAsset = _lc.Assets.GetAssetById(layer.RefId);
if (referencedLayersAsset == null)
{
_issues.ReferencedAssetDoesNotExist();
Copy link
Contributor

@simeoncran simeoncran Apr 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReferencedAssetDoesNotExist [](start = 24, length = 27)

Because this is done twice now, it should be moved to a method on this class: GetAssetById(...) that either return the asset or reports the problem and returns null.
Can that method do the check for the asset type and report the invalid asset type as well? So: GetAssetById(Asset.AssetType, id).
#Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with GetAssetById() without the type checking because I think that makes the code easier to follow.


In reply to: 279590241 [](ancestors = 279590241)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how it makes the code harder to follow. Maybe it's about choosing a better name for GetAssetById. Or maybe it's just a matter of using named parameters to make it clear from the caller: GetAssetById(id: layer.RefId, expectedAssetType: Asset.AssetType.Image);
But I do see that the Image and Precomp layers now have slightly different behavior when given the wrong type of asset, so we already have introduced a bug because we've violated DRY.


In reply to: 279607824 [](ancestors = 279607824,279590241)

@@ -703,6 +740,18 @@ Visual TranslatePreCompLayerToVisual(TranslationContext context, PreCompLayer la
return result;
}

internal Asset GetAssetById(string assetId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think needs to be internal. #Closed

@@ -682,7 +718,8 @@ Visual TranslatePreCompLayerToVisual(TranslationContext context, PreCompLayer la
#endif

// TODO - the animations produced inside a PreComp need to be time-mapped.
var referencedLayersAsset = _lc.Assets.GetAssetById(layer.RefId);
var referencedLayersAsset = GetAssetById(layer.RefId);

switch (referencedLayersAsset.Type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

referencedLayersAsset [](start = 20, length = 21)

What if GetAssetById returns null? #Closed

if (referencedAsset == null)
{
_issues.ReferencedAssetDoesNotExist(assetId);
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return null; [](start = 15, length = 13)

This return is redundant, and unnecessarily violates the principle of avoiding multiple exit points in a method. #Closed


var referencedLayersAsset = GetAssetById(layer.RefId);

switch (referencedLayersAsset.Type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

referencedLayersAsset [](start = 20, length = 21)

What is GetAssetById returned null? #Closed

content.Brush = brush;
break;
default:
_issues.InvalidAssetReferenceFromCurrentLayer(layer.Type.ToString(), layer.RefId, referencedLayersAsset.Type.ToString(), Asset.AssetType.Image.ToString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word "Current" doesn't belong here. Current only makes sense in the context of this method. When people see the error they don't have a concept of "current". #Closed

@@ -694,7 +731,7 @@ Visual TranslatePreCompLayerToVisual(TranslationContext context, PreCompLayer la
AddTranslatedLayersToContainerVisual(contentsNode, subContext, referencedLayers, $"{layer.Name}:{layerCollectionAsset.Id}");
break;
case Asset.AssetType.Image:
_unsupported.ImageAssets();
_issues.InvalidAssetReferenceFromCurrentLayer(layer.Type.ToString(), layer.RefId, referencedLayersAsset.Type.ToString(), Asset.AssetType.LayerCollection.ToString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InvalidAssetReferenceFromCurrentLayer [](start = 28, length = 37)

Move this into the default and remove the InvalidOperationException(). We don't need to test for Image here. #Closed

@simeoncran
Copy link
Contributor

simeoncran commented Apr 30, 2019

�#� �L�o�t�t�i�e�-�W�i�n�d�o�w�s� �W�a�r�n�i�n�g� �L�T�0�0�0�8�

This file is showing up in CodeFlow as a rename of LT0008.md. That means LT0008.md not longer exists. That's suspicious. I think you've done this by accident, and LT00028 is not a new error. #Closed


Refers to: source/Issues/LT0008.md:9 in b44898e. [](commit_id = b44898e, deletion_comment = True)

@plaiMS
Copy link
Contributor Author

plaiMS commented Apr 30, 2019

�#� �L�o�t�t�i�e�-�W�i�n�d�o�w�s� �W�a�r�n�i�n�g� �L�T�0�0�0�8�

LT0008 is the ImageAsset() warning that we said no longer needed and can remove. Somehow Codeflow is treating LT0028 as rename of the LT0008 but it's not.


In reply to: 488055213 [](ancestors = 488055213)


Refers to: source/Issues/LT0008.md:9 in b44898e. [](commit_id = b44898e, deletion_comment = True)

Copy link
Contributor

@simeoncran simeoncran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@plaiMS plaiMS merged commit 96af58f into master Apr 30, 2019
@delete-merged-branch delete-merged-branch bot deleted the EnableImageLayer branch April 30, 2019 20:18
@michael-hawker michael-hawker added this to the 6.0 milestone Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants