ScummVM API documentation
GUI::MidiDeviceScanDialog Class Reference

#include <message.h>

Inheritance diagram for GUI::MidiDeviceScanDialog:
GUI::MessageDialog GUI::Dialog GUI::GuiObject GUI::CommandReceiver

Public Member Functions

void handleTickle () override
 
void handleKeyDown (Common::KeyState state) override
 
- Public Member Functions inherited from GUI::MessageDialog
 MessageDialog (const Common::U32String &message)
 
 MessageDialog (const Common::String &message)
 
 MessageDialog (const Common::U32String &message, const Common::U32String &defaultButton, const Common::U32String &altButton=Common::U32String(), Graphics::TextAlign alignment=Graphics::kTextAlignCenter, const char *url=nullptr, const Common::U32String &extraMessage=Common::U32String())
 
 MessageDialog (const Common::String &message, const Common::String &defaultButton, const Common::String &altButton=Common::String(), Graphics::TextAlign alignment=Graphics::kTextAlignCenter, const char *url=nullptr)
 
 MessageDialog (const Common::U32String &message, const Common::U32String &defaultButton, const Common::U32StringArray &altButtons, Graphics::TextAlign alignment=Graphics::kTextAlignCenter)
 
void handleCommand (CommandSender *sender, uint32 cmd, uint32 data) override
 
void reflowLayout () override
 
- Public Member Functions inherited from GUI::Dialog
 Dialog (int x, int y, int w, int h, bool scale=false)
 
 Dialog (const Common::String &name)
 
virtual int runModal ()
 
bool isVisible () const override
 
void releaseFocus () override
 
void setFocusWidget (Widget *widget)
 
Widget * getFocusWidget ()
 
bool isDragging () const
 
void reflowLayout () override
 
virtual void lostFocus ()
 
virtual void receivedFocus (int x=-1, int y=-1)
 
virtual void open ()
 
virtual void close ()
 
Widget * findWidget (uint32 type)
 
- Public Member Functions inherited from GUI::GuiObject
 GuiObject (int x, int y, int w, int h, bool scale=false)
 
 GuiObject (const Common::String &name)
 
virtual void setTextDrawableArea (const Common::Rect &r)
 
virtual void resize (int x, int y, int w, int h, bool scale=true)
 
virtual Widget * addChild (Widget *newChild)
 
virtual int16 getRelX () const
 
virtual int16 getRelY () const
 
virtual int16 getAbsX () const
 
virtual int16 getAbsY () const
 
virtual int16 getChildX () const
 
virtual int16 getChildY () const
 
virtual uint16 getWidth () const
 
virtual uint16 getHeight () const
 
virtual bool isVisible () const =0
 
virtual void reflowLayout ()
 
virtual void removeWidget (Widget *widget)
 
virtual bool isPointIn (int x, int y)
 
virtual Common::Rect getClipRect () const
 

Static Public Member Functions

static bool waitForCompletion (const Common::Functor0< bool > &isComplete)
 

Protected Member Functions

 MidiDeviceScanDialog (const Common::Functor0< bool > &isComplete)
 
- Protected Member Functions inherited from GUI::Dialog
void markWidgetsAsDirty ()
 
Common::Rect getMaxDirtyRect () const
 
virtual void drawDialog (DrawLayer layerToDraw, bool resetClipping=true)
 
void drawWidgets ()
 
virtual void handleTickle ()
 
virtual void handleMouseDown (int x, int y, int button, int clickCount)
 
virtual void handleMouseUp (int x, int y, int button, int clickCount)
 
virtual void handleMouseWheel (int x, int y, int direction) override
 
virtual void handleKeyDown (Common::KeyState state)
 
virtual void handleKeyUp (Common::KeyState state)
 
virtual void handleMouseMoved (int x, int y, int button)
 
virtual void handleMouseLeft (int button)
 
virtual void handleOtherEvent (const Common::Event &evt)
 
void handleCommand (CommandSender *sender, uint32 cmd, uint32 data) override
 
Widget * findWidget (int x, int y)
 
Widget * findWidget (const char *name)
 
void removeWidget (Widget *widget) override
 
void setDefaultFocusedWidget ()
 
void registerTickleWidget (Widget *widget) override
 
void unregisterTickleWidget (Widget *widget) override
 
void setResult (int result)
 
int getResult () const
 
virtual void handleMouseWheel (int x, int y, int direction)=0
 
virtual void releaseFocus ()=0
 
virtual void registerTickleWidget (Widget *widget)=0
 
virtual void unregisterTickleWidget (Widget *widget)
 
virtual void handleCommand (CommandSender *sender, uint32 cmd, uint32 data)
 

Protected Attributes

const Common::Functor0< bool > & _isComplete
 
- Protected Attributes inherited from GUI::MessageDialog
Common::U32String _message
 
Graphics::TextAlign _alignment
 
Common::Array< StaticTextWidget * > _lines
 
Common::Array< ButtonWidget * > _buttons
 
StaticTextWidget * _extraMessage
 
- Protected Attributes inherited from GUI::Dialog
Widget * _mouseWidget
 
Widget * _focusedWidget
 
Widget * _dragWidget
 
Widget * _dragHookWidget
 
Widget * _tickleWidget
 
bool _visible
 
ThemeEngine::DialogBackground _backgroundType
 
- Protected Attributes inherited from GUI::GuiObject
Common::Rect _textDrawableArea
 
int16 _x
 
int16 _y
 
uint16 _w
 
uint16 _h
 
bool _useRTL
 
const Common::String _name
 
Widget * _firstWidget
 

Detailed Description

Display a progress message until MIDI device detection finishes.

Remarks
Some MIDI backends takes long time when scanning the MIDI devices for first time. e.g., Windows MIDI Services on Windows 11 25H2 or later.

Those backends will try to warm-up the MIDI backend to avoid this issue, but the player may request any MIDI APIs before the warm-up is finished. If it happens, the UI thread may be blocked, inducing OS to mark the process as unresponsive.

In that case, this dialog would be spawned to:

  • Let player know the reason what is happening: MIDI device scan is taking a lot of time.
  • Keep UI events processed to prevent process marked as unresponsive.

Constructor & Destructor Documentation

◆ MidiDeviceScanDialog()

GUI::MidiDeviceScanDialog::MidiDeviceScanDialog ( const Common::Functor0< bool > &  isComplete)
explicitprotected

Construct a progress dialog with a completion predicate.

Parameters
isCompletePredicate returning true once MIDI backend warm-up finishes. Polled on the UI thread and must return promptly without blocking.

Member Function Documentation

◆ waitForCompletion()

static bool GUI::MidiDeviceScanDialog::waitForCompletion ( const Common::Functor0< bool > &  isComplete)
static

Show a modal progress dialog while the MIDI backend warm-up is pending and the GUI is active. Return immediately if isComplete already reports completion. Call this function on the UI thread.

Parameters
isCompletePredicate returning true once MIDI backend warm-up finishes. Polled on the UI thread and must return promptly without blocking.
Returns
True if completion was observed, false if the GUI is inactive or the dialog closed before completion.

◆ handleTickle()

void GUI::MidiDeviceScanDialog::handleTickle ( )
overridevirtual

Process a dialog tick. Close the dialog when the completion predicate returns true.

Reimplemented from GUI::Dialog.

◆ handleKeyDown()

void GUI::MidiDeviceScanDialog::handleKeyDown ( Common::KeyState  state)
overridevirtual

Ignore Escape key to prevent dismissing the dialog while warm-up is running. Forward other keys to GUI::Dialog::handleKeyDown.

Parameters
stateThe pressed key and its modifier flags.

Reimplemented from GUI::Dialog.

Member Data Documentation

◆ _isComplete

const Common::Functor0<bool>& GUI::MidiDeviceScanDialog::_isComplete
protected

This predicate must be valid for the dialog's lifetime.


The documentation for this class was generated from the following file: