void FCEFWebBrowserWindow::NotifyDocumentLoadingStateChange(bool IsLoading) { if (! IsLoading) { bIsInitialized = true; if (bRecoverFromRenderProcessCrash) { bRecoverFromRenderProcessCrash = false; // Toggle hidden/visible state to get OnPaint calls from CEF. SetIsHidden(true); SetIsHidden(false); } // Compatibility with Android script bindings: dispatch a custom ue:ready event when the document is fully loaded ExecuteJavascript(TEXT("document.dispatchEvent(new CustomEvent('ue:ready', {details: window.ue}));")); } // Ignore a load completed notification if there was an error. // For load started, reset any errors from previous page load. if (IsLoading || DocumentState != EWebBrowserDocumentState::Error) { ErrorCode = 0; DocumentState = IsLoading ? EWebBrowserDocumentState::Loading : EWebBrowserDocumentState::Completed; DocumentStateChangedEvent.Broadcast(DocumentState); } }
void Button::Reset() { SetIsHidden(true); animationOffset = gScreenWidth; pInEase->Reset(); pOutEase->Reset(); isMouseOver = false; isMouseDown = false; }
void FCEFWebBrowserWindow::SetIsDisabled(bool bValue) { if (bIsDisabled == bValue) { return; } bIsDisabled = bValue; SetIsHidden(bIsDisabled); }
void Button::Update(int delta) { isMouseOver = false; isMouseDown = false; if (pOutEase->GetIsStarted() && !pOutEase->GetIsFinished()) { pOutEase->Update(delta); animationOffset = (int)pOutEase->GetCurrentValue(); } else if (pOutEase->GetIsFinished()) { SetIsHidden(true); } else if (pInEase->GetIsStarted() && !pInEase->GetIsFinished()) { pInEase->Update(delta); animationOffset = (int)pInEase->GetCurrentValue(); } else { if (GetUnlockedLockCount() > 0 && !pUnlockingAnimation->IsFinished()) { pUnlockingAnimation->Update(delta); AnimationSound * pSoundToPlay = pUnlockingAnimation->GetSoundToPlay(); if (pSoundToPlay != NULL) { pSoundToPlay->Play(gSoundEffectsVolume); } } else if (!GetIsDisabled()) { RectangleWH positionRect = RectangleWH(GetXPosition(), GetYPosition(), pTextFont->GetWidth(GetText()), TextHeight); bool isPressed = MouseHelper::PressedAndHeldAnywhere() || MouseHelper::DoublePressedAndHeldAnywhere(); if (MouseHelper::ClickedOnRect(positionRect)) { OnClicked(); } if (MouseHelper::MouseDownOnRect(positionRect) && !isPressed) { isMouseDown = true; } else if (MouseHelper::MouseOverRect(positionRect) && !isPressed) { isMouseOver = true; } } } }
void Button::Show() { Reset(); SetIsHidden(false); if (GetUnlockedLockCount() > 0) { pUnlockingAnimation->Begin(); } pInEase->Begin(); }
void FCEFWebBrowserWindow::SetViewportSize(FIntPoint WindowSize, FIntPoint WindowPos) { // SetViewportSize is called from the browser viewport tick method, which means that since we are receiving ticks, we can mark the browser as visible. if (! bIsDisabled) { SetIsHidden(false); } bTickedLastFrame=true; // Ignore sizes that can't be seen as it forces CEF to re-render whole image if (WindowSize.X > 0 && WindowSize.Y > 0 && ViewportSize != WindowSize) { ViewportSize = WindowSize; if (IsValid()) { #if PLATFORM_WINDOWS HWND NativeHandle = InternalCefBrowser->GetHost()->GetWindowHandle(); if (NativeHandle) { HWND Parent = ::GetParent(NativeHandle); // Position is in screen coordinates, so we'll need to get the parent window location first. RECT ParentRect = { 0, 0, 0, 0 }; if (Parent) { ::GetWindowRect(Parent, &ParentRect); } // allow resizing the window by nudging the edges of the viewport by a pixel if the content extends all the way to the edge if (WindowPos.X == ParentRect.left) { WindowPos.X++; WindowSize.X--; } if (WindowPos.Y == ParentRect.top) { WindowPos.Y++; WindowSize.Y--; } if (WindowPos.X + WindowSize.X == ParentRect.right) { WindowSize.X--; } if (WindowPos.Y + WindowSize.Y == ParentRect.bottom) { WindowSize.Y--; } ::SetWindowPos(NativeHandle, 0, WindowPos.X - ParentRect.left, WindowPos.Y - ParentRect.top, WindowSize.X, WindowSize.Y, 0); } #endif InternalCefBrowser->GetHost()->WasResized(); } } }
void Button::ShowInstantly() { Reset(); SetIsHidden(false); if (GetUnlockedLockCount() > 0) { pUnlockingAnimation->Finish(); } pInEase->Finish(); animationOffset = (int)pInEase->GetCurrentValue(); }
void FCEFWebBrowserWindow::CheckTickActivity() { // Early out if we're currently hidden, not initialized or currently loading. if (bIsHidden || !IsValid() || IsLoading() || ViewportSize == FIntPoint::ZeroValue) { return; } // We clear the bTickedLastFrame flag here and set it on every Slate tick. // If it's still clear when we come back it means we're not getting ticks from slate. // Note: The BrowserSingleton object will not invoke this method if Slate itself is sleeping. // Therefore we can safely assume the widget is hidden in that case. if (!bTickedLastFrame) { SetIsHidden(true); } bTickedLastFrame = false; }