mirror of https://github.com/axmolengine/axmol.git
Merge pull request #15651 from zilongshanren/fixNativeCotnrolIssuesV2
fix UI native control onEnter issue
This commit is contained in:
commit
9203630583
|
@ -234,7 +234,7 @@ void VideoPlayer::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
cocos2d::ui::Widget::setVisible(visible);
|
cocos2d::ui::Widget::setVisible(visible);
|
||||||
|
|
||||||
if (! _videoURL.empty())
|
if (!visible || isRunning())
|
||||||
{
|
{
|
||||||
JniHelper::callStaticVoidMethod(videoHelperClassName, "setVideoVisible", _videoPlayerIndex, visible);
|
JniHelper::callStaticVoidMethod(videoHelperClassName, "setVideoVisible", _videoPlayerIndex, visible);
|
||||||
}
|
}
|
||||||
|
@ -243,13 +243,16 @@ void VideoPlayer::setVisible(bool visible)
|
||||||
void VideoPlayer::onEnter()
|
void VideoPlayer::onEnter()
|
||||||
{
|
{
|
||||||
Widget::onEnter();
|
Widget::onEnter();
|
||||||
this->setVisible(true);
|
if (isVisible() && !_videoURL.empty())
|
||||||
|
{
|
||||||
|
JniHelper::callStaticVoidMethod(videoHelperClassName, "setVideoVisible", _videoPlayerIndex, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoPlayer::onExit()
|
void VideoPlayer::onExit()
|
||||||
{
|
{
|
||||||
Widget::onExit();
|
Widget::onExit();
|
||||||
this->setVisible(false);
|
JniHelper::callStaticVoidMethod(videoHelperClassName, "setVideoVisible", _videoPlayerIndex, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoPlayer::addEventListener(const VideoPlayer::ccVideoPlayerCallback& callback)
|
void VideoPlayer::addEventListener(const VideoPlayer::ccVideoPlayerCallback& callback)
|
||||||
|
|
|
@ -46,10 +46,10 @@ using namespace cocos2d::experimental::ui;
|
||||||
- (void) resume;
|
- (void) resume;
|
||||||
- (void) stop;
|
- (void) stop;
|
||||||
- (void) seekTo:(float) sec;
|
- (void) seekTo:(float) sec;
|
||||||
- (void) setVisible:(bool) visible;
|
- (void) setVisible:(BOOL) visible;
|
||||||
- (void) setKeepRatioEnabled:(bool) enabled;
|
- (void) setKeepRatioEnabled:(BOOL) enabled;
|
||||||
- (void) setFullScreenEnabled:(bool) enabled;
|
- (void) setFullScreenEnabled:(BOOL) enabled;
|
||||||
- (bool) isFullScreenEnabled;
|
- (BOOL) isFullScreenEnabled;
|
||||||
|
|
||||||
-(id) init:(void*) videoPlayer;
|
-(id) init:(void*) videoPlayer;
|
||||||
|
|
||||||
|
@ -106,14 +106,14 @@ using namespace cocos2d::experimental::ui;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) setFullScreenEnabled:(bool) enabled
|
-(void) setFullScreenEnabled:(BOOL) enabled
|
||||||
{
|
{
|
||||||
if (self.moviePlayer != nullptr) {
|
if (self.moviePlayer != nullptr) {
|
||||||
[self.moviePlayer setFullscreen:enabled animated:(true)];
|
[self.moviePlayer setFullscreen:enabled animated:(true)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(bool) isFullScreenEnabled
|
-(BOOL) isFullScreenEnabled
|
||||||
{
|
{
|
||||||
if (self.moviePlayer != nullptr) {
|
if (self.moviePlayer != nullptr) {
|
||||||
return [self.moviePlayer isFullscreen];
|
return [self.moviePlayer isFullscreen];
|
||||||
|
@ -208,14 +208,14 @@ using namespace cocos2d::experimental::ui;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) setVisible:(bool)visible
|
-(void) setVisible:(BOOL)visible
|
||||||
{
|
{
|
||||||
if (self.moviePlayer != NULL) {
|
if (self.moviePlayer != NULL) {
|
||||||
[self.moviePlayer.view setHidden:!visible];
|
[self.moviePlayer.view setHidden:!visible];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) setKeepRatioEnabled:(bool)enabled
|
-(void) setKeepRatioEnabled:(BOOL)enabled
|
||||||
{
|
{
|
||||||
_keepRatioEnabled = enabled;
|
_keepRatioEnabled = enabled;
|
||||||
if (self.moviePlayer != NULL) {
|
if (self.moviePlayer != NULL) {
|
||||||
|
@ -343,18 +343,6 @@ bool VideoPlayer::isFullScreenEnabled()const
|
||||||
return [((UIVideoViewWrapperIos*)_videoView) isFullScreenEnabled];
|
return [((UIVideoViewWrapperIos*)_videoView) isFullScreenEnabled];
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoPlayer::onEnter()
|
|
||||||
{
|
|
||||||
Widget::onEnter();
|
|
||||||
[((UIVideoViewWrapperIos*)_videoView) setVisible:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
void VideoPlayer::onExit()
|
|
||||||
{
|
|
||||||
Widget::onExit();
|
|
||||||
[((UIVideoViewWrapperIos*)_videoView) setVisible:NO];
|
|
||||||
}
|
|
||||||
|
|
||||||
void VideoPlayer::setFullScreenEnabled(bool enabled)
|
void VideoPlayer::setFullScreenEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
[((UIVideoViewWrapperIos*)_videoView) setFullScreenEnabled:enabled];
|
[((UIVideoViewWrapperIos*)_videoView) setFullScreenEnabled:enabled];
|
||||||
|
@ -418,10 +406,29 @@ void VideoPlayer::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
cocos2d::ui::Widget::setVisible(visible);
|
cocos2d::ui::Widget::setVisible(visible);
|
||||||
|
|
||||||
if (! _videoURL.empty())
|
if (!visible)
|
||||||
{
|
{
|
||||||
[((UIVideoViewWrapperIos*)_videoView) setVisible:visible];
|
[((UIVideoViewWrapperIos*)_videoView) setVisible:NO];
|
||||||
}
|
}
|
||||||
|
else if(isRunning())
|
||||||
|
{
|
||||||
|
[((UIVideoViewWrapperIos*)_videoView) setVisible:YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoPlayer::onEnter()
|
||||||
|
{
|
||||||
|
Widget::onEnter();
|
||||||
|
if (isVisible())
|
||||||
|
{
|
||||||
|
[((UIVideoViewWrapperIos*)_videoView) setVisible: YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoPlayer::onExit()
|
||||||
|
{
|
||||||
|
Widget::onExit();
|
||||||
|
[((UIVideoViewWrapperIos*)_videoView) setVisible: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoPlayer::addEventListener(const VideoPlayer::ccVideoPlayerCallback& callback)
|
void VideoPlayer::addEventListener(const VideoPlayer::ccVideoPlayerCallback& callback)
|
||||||
|
|
|
@ -137,8 +137,26 @@ namespace experimental{
|
||||||
void WebView::setVisible(bool visible)
|
void WebView::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
Node::setVisible(visible);
|
Node::setVisible(visible);
|
||||||
|
if (!visible || isRunning())
|
||||||
|
{
|
||||||
_impl->setVisible(visible);
|
_impl->setVisible(visible);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebView::onEnter()
|
||||||
|
{
|
||||||
|
Widget::onEnter();
|
||||||
|
if(isVisible())
|
||||||
|
{
|
||||||
|
_impl->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebView::onExit()
|
||||||
|
{
|
||||||
|
Widget::onExit();
|
||||||
|
_impl->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
cocos2d::ui::Widget* WebView::createCloneInstance()
|
cocos2d::ui::Widget* WebView::createCloneInstance()
|
||||||
{
|
{
|
||||||
|
@ -198,18 +216,6 @@ namespace experimental{
|
||||||
return _onJSCallback;
|
return _onJSCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::onEnter()
|
|
||||||
{
|
|
||||||
Widget::onEnter();
|
|
||||||
_impl->setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebView::onExit()
|
|
||||||
{
|
|
||||||
Widget::onExit();
|
|
||||||
_impl->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
} // namespace experimental
|
} // namespace experimental
|
||||||
} //namespace cocos2d
|
} //namespace cocos2d
|
||||||
|
|
|
@ -203,7 +203,6 @@ public:
|
||||||
* Toggle visibility of WebView.
|
* Toggle visibility of WebView.
|
||||||
*/
|
*/
|
||||||
virtual void setVisible(bool visible) override;
|
virtual void setVisible(bool visible) override;
|
||||||
|
|
||||||
virtual void onEnter() override;
|
virtual void onEnter() override;
|
||||||
virtual void onExit() override;
|
virtual void onExit() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue