DolphinWX: Add a progress dialog host command

Allows feedback from backends to be communicated to the user when
long-running operation are performed (e.g. shader compilation).
This commit is contained in:
Stenzek 2017-06-26 01:35:24 +10:00
parent 334e117da7
commit 1fccbd5be3
9 changed files with 59 additions and 0 deletions

View File

@ -148,6 +148,10 @@ void Host_YieldToUI()
{ {
} }
void Host_UpdateProgressDialog(const char* caption, int position, int total)
{
}
static bool MsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/) static bool MsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/)
{ {
__android_log_print(ANDROID_LOG_ERROR, DOLPHIN_TAG, "%s:%s", caption, text); __android_log_print(ANDROID_LOG_ERROR, DOLPHIN_TAG, "%s:%s", caption, text);

View File

@ -35,6 +35,7 @@ void Host_UpdateMainFrame();
void Host_UpdateTitle(const std::string& title); void Host_UpdateTitle(const std::string& title);
void Host_ShowVideoConfig(void* parent, const std::string& backend_name); void Host_ShowVideoConfig(void* parent, const std::string& backend_name);
void Host_YieldToUI(); void Host_YieldToUI();
void Host_UpdateProgressDialog(const char* caption, int position, int total);
// TODO (neobrain): Remove this from host! // TODO (neobrain): Remove this from host!
void* Host_GetRenderHandle(); void* Host_GetRenderHandle();

View File

@ -136,6 +136,10 @@ void Host_YieldToUI()
{ {
} }
void Host_UpdateProgressDialog(const char* caption, int position, int total)
{
}
#if HAVE_X11 #if HAVE_X11
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/keysym.h> #include <X11/keysym.h>

View File

@ -84,6 +84,9 @@ void Host_YieldToUI()
{ {
qApp->processEvents(QEventLoop::ExcludeUserInputEvents); qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
} }
void Host_UpdateProgressDialog(const char* caption, int position, int total)
{
}
// We ignore these, and their purpose should be questioned individually. // We ignore these, and their purpose should be questioned individually.
// In particular, RequestRenderWindowSize, RequestFullscreen, and // In particular, RequestRenderWindowSize, RequestFullscreen, and

View File

@ -20,6 +20,7 @@
#include <wx/menu.h> #include <wx/menu.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/progdlg.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statusbr.h> #include <wx/statusbr.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
@ -817,6 +818,37 @@ void CFrame::OnHostMessage(wxCommandEvent& event)
case IDM_STOPPED: case IDM_STOPPED:
OnStopped(); OnStopped();
break; break;
case IDM_UPDATE_PROGRESS_DIALOG:
{
int current = event.GetInt();
int total = static_cast<int>(event.GetExtraLong());
if (total < 0 || current >= total)
{
if (m_progress_dialog)
{
delete m_progress_dialog;
m_progress_dialog = nullptr;
}
}
else if (total > 0 && current < total)
{
if (!m_progress_dialog)
{
m_progress_dialog = new wxProgressDialog(
_("Operation in progress..."), event.GetString(), total, m_render_frame,
wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_SMOOTH | wxPD_REMAINING_TIME);
m_progress_dialog->Show();
}
else
{
if (m_progress_dialog->GetRange() != total)
m_progress_dialog->SetRange(total);
m_progress_dialog->Update(current, event.GetString());
}
}
}
break;
} }
} }

View File

@ -49,6 +49,7 @@ class wxAuiNotebook;
class wxAuiNotebookEvent; class wxAuiNotebookEvent;
class wxListEvent; class wxListEvent;
class wxMenuItem; class wxMenuItem;
class wxProgressDialog;
class CRenderFrame : public wxFrame class CRenderFrame : public wxFrame
{ {
@ -154,6 +155,7 @@ private:
FifoPlayerDlg* m_fifo_player_dialog = nullptr; FifoPlayerDlg* m_fifo_player_dialog = nullptr;
std::array<TASInputDlg*, 8> m_tas_input_dialogs{}; std::array<TASInputDlg*, 8> m_tas_input_dialogs{};
wxCheatsWindow* m_cheats_window = nullptr; wxCheatsWindow* m_cheats_window = nullptr;
wxProgressDialog* m_progress_dialog = nullptr;
bool m_use_debugger = false; bool m_use_debugger = false;
bool m_batch_mode = false; bool m_batch_mode = false;
bool m_editing_perspectives = false; bool m_editing_perspectives = false;

View File

@ -307,6 +307,7 @@ enum
IDM_WINDOW_SIZE_REQUEST, IDM_WINDOW_SIZE_REQUEST,
IDM_STOPPED, IDM_STOPPED,
IDM_HOST_MESSAGE, IDM_HOST_MESSAGE,
IDM_UPDATE_PROGRESS_DIALOG,
IDM_MPANEL, IDM_MPANEL,
ID_STATUSBAR, ID_STATUSBAR,

View File

@ -488,3 +488,12 @@ void Host_YieldToUI()
{ {
wxGetApp().GetMainLoop()->YieldFor(wxEVT_CATEGORY_UI); wxGetApp().GetMainLoop()->YieldFor(wxEVT_CATEGORY_UI);
} }
void Host_UpdateProgressDialog(const char* caption, int position, int total)
{
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATE_PROGRESS_DIALOG);
event.SetString(caption);
event.SetInt(position);
event.SetExtraLong(total);
main_frame->GetEventHandler()->AddPendingEvent(event);
}

View File

@ -57,6 +57,9 @@ void Host_ShowVideoConfig(void*, const std::string&)
void Host_YieldToUI() void Host_YieldToUI()
{ {
} }
void Host_UpdateProgressDialog(const char* caption, int position, int total)
{
}
std::unique_ptr<cInterfaceBase> HostGL_CreateGLInterface() std::unique_ptr<cInterfaceBase> HostGL_CreateGLInterface()
{ {
return nullptr; return nullptr;