diff options
Diffstat (limited to 'libs/pbd/pbd/base_ui.h')
-rw-r--r-- | libs/pbd/pbd/base_ui.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h index ccd4878cd9..414c9970d9 100644 --- a/libs/pbd/pbd/base_ui.h +++ b/libs/pbd/pbd/base_ui.h @@ -32,6 +32,15 @@ #include "pbd/crossthread.h" #include "pbd/event_loop.h" +/** A BaseUI is an abstraction designed to be used with any "user + * interface" (not necessarily graphical) that needs to wait on + * events/requests and dispatch/process them as they arrive. + * + * This implementation starts up a thread that runs a Glib main loop + * to wait on events/requests etc. + */ + + class BaseUI : virtual public sigc::trackable, public PBD::EventLoop { public: @@ -52,7 +61,13 @@ class BaseUI : virtual public sigc::trackable, public PBD::EventLoop static RequestType CallSlot; static RequestType Quit; + /** start up a thread to run the main loop + */ void run (); + + /** stop the thread running the main loop (and block + * until it exits) + */ void quit (); protected: @@ -62,9 +77,21 @@ class BaseUI : virtual public sigc::trackable, public PBD::EventLoop Glib::RefPtr<Glib::MainLoop> _main_loop; Glib::Thread* run_loop_thread; + /** Derived UI objects can implement thread_init() + * which will be called by the event loop thread + * immediately before it enters the event loop. + */ + virtual void thread_init () {}; + + /** Called when there input ready on the request_channel + */ bool request_handler (Glib::IOCondition); + /** Derived UI objects must implement this method, + * which will be called whenever there are requests + * to be dealt with. + */ virtual void handle_ui_requests () = 0; private: |