Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
11 changes: 11 additions & 0 deletions android/libpag/src/main/java/org/libpag/PAGLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@ public Matrix getTotalMatrix() {
*/
public native void setExcludedFromTimeline(boolean value);

/**
* Set the alpha of the layer, which will be concatenated to the current animation opacity for
* displaying.
*/
public native void setAlpha(float value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个属性读写要成对,把alpha读取属性也要暴露出来。


/**
* Returns the current alpha of the layer if previously set.
*/
public native float alpha();
Copy link
Collaborator

Choose a reason for hiding this comment

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

按照项目习惯,get放法一般都写在set之前。调整一下顺序。


private native void nativeRelease();

protected long nativeContext;
Expand Down
18 changes: 18 additions & 0 deletions src/platform/android/JPAGLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,22 @@ PAG_API void Java_org_libpag_PAGLayer_setExcludedFromTimeline(JNIEnv* env, jobje

pagLayer->setExcludedFromTimeline(value);
}

PAG_API void Java_org_libpag_PAGLayer_setAlpha(JNIEnv* env, jobject thiz, jfloat value) {
auto pagLayer = GetPAGLayer(env, thiz);
if (pagLayer == nullptr) {
return;
}

pagLayer->setAlpha(value);
}

PAG_API jfloat Java_org_libpag_PAGLayer_alpha(JNIEnv* env, jobject thiz) {
auto pagLayer = GetPAGLayer(env, thiz);
if (pagLayer == nullptr) {
return 0.0f;
}

return pagLayer->alpha();
}
}
11 changes: 11 additions & 0 deletions src/platform/cocoa/PAGLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,15 @@ PAG_API @interface PAGLayer : NSObject
*/
- (void)setExcludedFromTimeline:(BOOL)value;

/**
* Set the alpha of the layer, which will be concatenated to the current animation opacity for
* displaying.
*/
- (void)setAlpha:(float)value;

/**
* Returns the current alpha of the layer if previously set.
*/
- (float)alpha;

@end
8 changes: 8 additions & 0 deletions src/platform/cocoa/PAGLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ - (void)setExcludedFromTimeline:(BOOL)value {
[(PAGLayerImpl*)_impl setExcludedFromTimeline:value];
}

- (void)setAlpha:(float)value {
[(PAGLayerImpl*)_impl setAlpha:value];
}

- (float)alpha {
return [(PAGLayerImpl*)_impl alpha];
}

- (void)dealloc {
[_impl release];
[super dealloc];
Expand Down
4 changes: 4 additions & 0 deletions src/platform/cocoa/private/PAGLayerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@

- (void)setExcludedFromTimeline:(BOOL)value;

- (void)setAlpha:(float)value;

- (float)alpha;

@end
8 changes: 8 additions & 0 deletions src/platform/cocoa/private/PAGLayerImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,12 @@ - (void)setExcludedFromTimeline:(BOOL)value {
_pagLayer->setExcludedFromTimeline(value);
}

- (void)setAlpha:(float)value {
_pagLayer->setAlpha(value);
}

- (float)alpha {
return _pagLayer->alpha();
}

@end
Loading