1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#pragma once
#include "imodule.h"
#include "iusercontrol.h"
namespace ui
{
/**
* @brief Module responsible for creating all dockable UI panels.
*
* This is a dynamically populated factory object which maintains a map of
* IUserControlCreator objects indexed by name, each of which can create a dock widget of a
* specific type. Any part of the code (including plugins) can register new control
* creators.
*/
class IUserInterfaceModule: public RegisterableModule
{
public:
~IUserInterfaceModule() override {}
// Runs the specified action in the UI thread
// this happens when the application has a chance to, usually during event processing
// This method is safe to be called from any thread.
virtual void dispatch(const std::function<void()>& action) = 0;
/**
* @brief Register a new control
*
* After registration, clients can acquire the control by invoking the findControl()
* method.
*/
virtual void registerControl(IUserControlCreator::Ptr control) = 0;
/**
* @brief Lookup a control creator by name
*
* @param name
* The name of the control creator, which was exposed via the
* IUserControlCreator::getControlName() method.
*
* @return IUserControlCreator::Ptr
* Pointer to the matching control creator, or null if no control creator with this name
* could be found.
*/
virtual IUserControlCreator::Ptr findControl(const std::string& name) = 0;
/**
* Unregisters the named control. Does nothing if the name is not registered.
*/
virtual void unregisterControl(const std::string& controlName) = 0;
/**
* Iterate over all registered control names
*/
virtual void foreachControl(const std::function<void(const std::string&)>& functor) = 0;
};
}
constexpr const char* const MODULE_USERINTERFACE = "UserInterfaceModule";
// The accessor function
inline ui::IUserInterfaceModule& GlobalUserInterface()
{
static module::InstanceReference<ui::IUserInterfaceModule> _reference(MODULE_USERINTERFACE);
return _reference;
}
|