-
Notifications
You must be signed in to change notification settings - Fork 73
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
Conversation
…/Lottie-Windows into EnableImageLayer
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) |
There was a problem hiding this 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)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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 |
There was a problem hiding this comment.
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
This shouldn't be smoooshed together. Refers to: source/Issues/LT0008.md:5 in b43759e. [](commit_id = b43759e, deletion_comment = False) |
...Expected an asset... #Closed Refers to: source/Issues/LT0029.md:5 in b43759e. [](commit_id = b43759e, deletion_comment = False) |
yield return shapeVisual; | ||
shapeVisual = null; | ||
} | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
// 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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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
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) |
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes protected under #define EnableImageLayer.