Files
UnrealEngineUWP/Engine/Source/Developer/DesktopPlatform/Private/Windows/WindowsNativeFeedbackContext.h
Andrew Rodham 4ad1b987fc Improved progress reporting in the editor
FScopedSlowTask has been refactored to better allow for nesting of slow operations. This allows us to cascade nested scopes and provide accurate feedback on slow tasks. FScopedSlowTasks now work together when nested inside sub functions. Break up long functions that contain calls to multiple nested FScopedSlowTasks with FScopedSlowTask::EnterProgressFrame().

Example Usage:
void DoSlowWork()
{
    FScopedSlowTask Progress(2.f, LOCTEXT("DoingSlowWork", "Doing Slow Work..."));
    // Optionally make this show a dialog if not already shown
    Progress.MakeDialog();

    // Indicate that we are entering a frame representing 1 unit of work
    Progress.EnterProgressFrame(1.f);

    // DoFirstThing() can follow a similar pattern of creating a scope divided into frames. These contribute to their parent's progress frame proportionately.
    DoFirstThing();

    Progress.EnterProgressFrame(1.f);
    DoSecondThing();
}

This addresses TTP#338602 - NEEDS REVIEW: Editor progress bars nearly always just show 100%, don't offer useful indication of progress

[CL 2322391 by Andrew Rodham in Main branch]
2014-10-08 04:42:34 -04:00

74 lines
1.9 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "AllowWindowsPlatformTypes.h"
#include <CommCtrl.h>
/**
* Feedback context implementation for windows.
*/
class FWindowsNativeFeedbackContext : public FFeedbackContext
{
public:
// Constructor.
FWindowsNativeFeedbackContext();
virtual ~FWindowsNativeFeedbackContext();
virtual void Serialize( const TCHAR* V, ELogVerbosity::Type Verbosity, const class FName& Category ) override;
VARARG_BODY( bool, YesNof, const TCHAR*, VARARG_NONE );
virtual bool ReceivedUserCancel() override;
virtual void StartSlowTask( const FText& Task, bool bShowCancelButton=false ) override;
virtual void FinalizeSlowTask( ) override;
virtual void ProgressReported( const float TotalProgressInterp, FText DisplayMessage ) override;
FContextSupplier* GetContext() const;
void SetContext( FContextSupplier* InSupplier );
private:
struct FBufferedLine
{
FString Text;
ELogVerbosity::Type Verbosity;
FName Category;
};
struct FWindowParams
{
FWindowsNativeFeedbackContext* Context;
int32 ScaleX;
int32 ScaleY;
int32 StandardW;
int32 StandardH;
bool bLogVisible;
};
static const uint16 StatusCtlId = 200;
static const uint16 ProgressCtlId = 201;
static const uint16 ShowLogCtlId = 202;
static const uint16 LogOutputCtlId = 203;
FContextSupplier* Context;
HANDLE hThread;
HANDLE hCloseEvent;
HANDLE hUpdateEvent;
FCriticalSection CriticalSection;
FString Status;
float Progress;
FString LogOutput;
bool bReceivedUserCancel;
bool bShowCancelButton;
void CreateSlowTaskWindow(const FText &InStatus, bool bInShowCancelButton);
void DestroySlowTaskWindow();
static DWORD WINAPI SlowTaskThreadProc(void *Params);
static LRESULT CALLBACK SlowTaskWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
static void LayoutControls(HWND hWnd, const FWindowParams* Params);
};
#include "HideWindowsPlatformTypes.h"