class mrpt::gui::CDisplayWindowGUI¶
A window with powerful GUI capabilities, via the nanogui library.
You can add a background mrpt::opengl::COpenGLScene object rendered on the background of the entire window by setting an object in field background_scene
, locking its mutex background_scene_mtx
.
Refer to nanogui API docs or MRPT examples for further usage examples. A typical lifecycle of a GUI app with this class might look like:
nanogui::init(); {mrpt::gui::CDisplayWindowGUI win; win.drawAll(); win.setVisible(true); nanogui::mainloop(); } nanogui::shutdown();
Create managed subwindows with createManagedSubWindow(), with built-in support for minimize and restore. See demo video in: https://www.youtube.com/watch?v=QKMzdlZRW50
#include <mrpt/gui/CDisplayWindowGUI.h> class CDisplayWindowGUI: public Screen { public: // typedefs typedef std::shared_ptr<CDisplayWindowGUI> Ptr; typedef std::shared_ptr<const CDisplayWindowGUI> ConstPtr; // structs struct SubWindows; // classes class SubWindow; // fields mrpt::opengl::COpenGLScene::Ptr background_scene; std::mutex background_scene_mtx; // construction CDisplayWindowGUI( const std::string& caption = std::string(), unsigned int width = 400, unsigned int height = 300, const CDisplayWindowGUI_Params& p = CDisplayWindowGUI_Params() ); // methods void resize(unsigned int width, unsigned int height); void setPos(int x, int y); void setWindowTitle(const std::string& str); void setLoopCallback(const std::function<void(void)>& callback); const auto& loopCallback() const; void setDropFilesCallback(const std::function<bool(const std::vector<std::string>&)>& callback); const auto& dropFilesCallback() const; void setKeyboardCallback(const std::function<bool(int, int, int, int)>& callback); const auto& keyboardCallback() const; template <typename... Args> static Ptr Create(Args&&... args); nanogui::Window* createManagedSubWindow(const std::string& title); nanogui::Window* getSubWindowsUI(); const nanogui::Window* getSubWindowsUI() const; CGlCanvasBase& camera(); const CGlCanvasBase& camera() const; nanogui::Screen* nanogui_screen(); };
Methods¶
void resize(unsigned int width, unsigned int height)
Resizes the window.
void setPos(int x, int y)
Changes the position of the window on the screen.
void setWindowTitle(const std::string& str)
Changes the window title.
void setLoopCallback(const std::function<void(void)>& callback)
Every time the window is about to be repainted, an optional callback can be called, if provided via this method.
void setDropFilesCallback(const std::function<bool(const std::vector<std::string>&)>& callback)
Sets a handle for file drop events.
template <typename... Args> static Ptr Create(Args&&... args)
Class factory returning a smart pointer.
nanogui::Window* createManagedSubWindow(const std::string& title)
Creates and return a nanogui::Window, adds to it basic minimize/restore tool buttons and add it to the list of handled subwindows so it gets listed in the subwindows control UI.
User should set a layout manager, width, height, etc. in the returned window as desired.
The returned object is owned by the nanogui system, you should NOT delete it.
The first time this is called, an additional subWindow will be created (default position:bottom left corner) to hold minimized windows. You can access and modify this windows via getSubWindowsUI().
[New in MRPT 2.1.1]