ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::visualization::gui::Window Class Reference

#include <Window.h>

Inheritance diagram for cloudViewer::visualization::gui::Window:

Classes

struct  Impl
 

Public Member Functions

 Window (const std::string &title, int flags=0)
 
 Window (const std::string &title, int width, int height, int flags=0)
 
 Window (const std::string &title, int x, int y, int width, int height, int flags=0)
 
virtual ~Window ()
 
const ThemeGetTheme () const
 
visualization::rendering::RendererGetRenderer () const
 
Rect GetOSFrame () const
 
void SetOSFrame (const Rect &r)
 
const char * GetTitle () const
 
void SetTitle (const char *title)
 
void SizeToFit ()
 
void SetSize (const Size &size)
 Sets the size of the window in pixels. Includes menubar on Linux. More...
 
Size GetSize () const
 
Rect GetContentRect () const
 
float GetScaling () const
 Returns the scaling factor from OS pixels to device pixels. More...
 
Point GlobalToWindowCoord (int global_x, int global_y)
 Returns the global point (in OS pixels) in window local coordinates. More...
 
bool IsVisible () const
 
void Show (bool vis=true)
 
void Close ()
 
void SetNeedsLayout ()
 Instructs the window to relayout before the next draw. More...
 
void PostRedraw ()
 
void SetTopmost (bool topmost)
 
void RaiseToTop () const
 
bool IsActiveWindow () const
 
void SetFocusWidget (Widget *w)
 Sets. More...
 
void AddChild (std::shared_ptr< Widget > w)
 
void SetOnMenuItemActivated (Menu::ItemId item_id, std::function< void()> callback)
 
void SetOnTickEvent (std::function< bool()> callback)
 
void SetOnClose (std::function< bool()> callback)
 
void SetOnKeyEvent (std::function< bool(const KeyEvent &)> callback)
 
void ShowDialog (std::shared_ptr< Dialog > dlg)
 
void CloseDialog ()
 Closes the dialog. More...
 
void ShowMessageBox (const char *title, const char *message)
 
void DestroyWindow ()
 
virtual void OnMenuItemSelected (Menu::ItemId item_id)
 
virtual void OnDragDropped (const char *path)
 
void ShowMenu (bool show)
 
int GetMouseMods () const
 
std::string GetWebRTCUID () const
 
void OnDraw ()
 
void OnResize ()
 
void OnMouseEvent (const MouseEvent &e)
 
void OnKeyEvent (const KeyEvent &e)
 
void OnTextInput (const TextInputEvent &e)
 
void OnTickEvent (const TickEvent &e)
 
WindowSystem::OSWindow GetOSWindow () const
 

Static Public Attributes

static const int FLAG_HIDDEN = (1 << 0)
 
static const int FLAG_TOPMOST = (1 << 1)
 

Protected Member Functions

virtual Size CalcPreferredSize ()
 
virtual void Layout (const LayoutContext &context)
 
LayoutContext GetLayoutContext ()
 
const std::vector< std::shared_ptr< Widget > > & GetChildren () const
 

Detailed Description

Definition at line 30 of file Window.h.

Constructor & Destructor Documentation

◆ Window() [1/3]

Window::Window ( const std::string &  title,
int  flags = 0 
)
explicit

Creates a Window that is auto-sized and centered. Window creation is NOT thread-safe. Window must be created on the same thread that calls Application::Run().

Definition at line 237 of file Window.cpp.

◆ Window() [2/3]

Window::Window ( const std::string &  title,
int  width,
int  height,
int  flags = 0 
)

Creates a Window that is centered. Window creation is NOT thread-safe. Window must be created on the same thread that calls Application::Run().

Definition at line 240 of file Window.cpp.

◆ Window() [3/3]

◆ ~Window()

Window::~Window ( )
virtual

Definition at line 400 of file Window.cpp.

References DestroyWindow().

Member Function Documentation

◆ AddChild()

void Window::AddChild ( std::shared_ptr< Widget w)

Definition at line 597 of file Window.cpp.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes().

◆ CalcPreferredSize()

Size Window::CalcPreferredSize ( )
protectedvirtual

Returns the preferred size of the window. The window is not obligated to honor this size. If all children of the window are layouts, this function does not need to be overridden. This function can only be called after MakeDrawContextCurrent() has been called.

Definition at line 475 of file Window.cpp.

References cloudViewer::visualization::gui::Rect::GetBottom(), GetLayoutContext(), cloudViewer::visualization::gui::Rect::GetRight(), and cloudViewer::visualization::gui::Rect::UnionedWith().

Referenced by OnResize(), and SizeToFit().

◆ Close()

◆ CloseDialog()

◆ DestroyWindow()

void Window::DestroyWindow ( )

This is for internal use in rare circumstances when the destructor will not be called in a timely fashion.

Definition at line 409 of file Window.cpp.

References cloudViewer::visualization::gui::WindowSystem::DestroyWindow(), cloudViewer::visualization::gui::Application::GetInstance(), and cloudViewer::visualization::gui::Application::GetWindowSystem().

Referenced by ~Window().

◆ GetChildren()

const std::vector< std::shared_ptr< Widget > > & Window::GetChildren ( ) const
protected

Definition at line 431 of file Window.cpp.

Referenced by cloudViewer::visualization::gui::PyWindow::Layout().

◆ GetContentRect()

◆ GetLayoutContext()

LayoutContext Window::GetLayoutContext ( )
protected

Definition at line 679 of file Window.cpp.

References GetTheme().

Referenced by CalcPreferredSize(), and ShowDialog().

◆ GetMouseMods()

int Window::GetMouseMods ( ) const

Definition at line 416 of file Window.cpp.

◆ GetOSFrame()

◆ GetOSWindow()

WindowSystem::OSWindow Window::GetOSWindow ( ) const

Definition at line 701 of file Window.cpp.

◆ GetRenderer()

◆ GetScaling()

◆ GetSize()

◆ GetTheme()

◆ GetTitle()

const char * Window::GetTitle ( ) const

◆ GetWebRTCUID()

std::string Window::GetWebRTCUID ( ) const

Returns the window's unique identifier when WebRTCWindowSystem is in use. Returns "window_undefined" if the window system is not WebRTCWindowSystem.

Definition at line 418 of file Window.cpp.

References cloudViewer::visualization::gui::Application::GetInstance().

Referenced by cloudViewer::visualization::pybind_o3dvisualizer().

◆ GlobalToWindowCoord()

Point Window::GlobalToWindowCoord ( int  global_x,
int  global_y 
)

◆ IsActiveWindow()

◆ IsVisible()

◆ Layout()

void Window::Layout ( const LayoutContext context)
protectedvirtual

Lays out all the widgets in the window. If all children of the window are layouts, this function does not need to be overridden.

Reimplemented in cloudViewer::visualization::gui::PyWindow, cloudViewer::visualization::GuiVisualizer, and cloudViewer::visualization::visualizer::O3DVisualizer.

Definition at line 681 of file Window.cpp.

References context, and GetContentRect().

Referenced by cloudViewer::visualization::visualizer::O3DVisualizer::Layout(), cloudViewer::visualization::GuiVisualizer::Layout(), and cloudViewer::visualization::gui::PyWindow::Layout().

◆ OnDragDropped()

void Window::OnDragDropped ( const char *  path)
virtual

Reimplemented in cloudViewer::visualization::GuiVisualizer.

Definition at line 1224 of file Window.cpp.

◆ OnDraw()

◆ OnKeyEvent()

◆ OnMenuItemSelected()

void Window::OnMenuItemSelected ( Menu::ItemId  item_id)
virtual

Reimplemented in cloudViewer::visualization::GuiVisualizer.

Definition at line 693 of file Window.cpp.

References callback, and PostRedraw().

◆ OnMouseEvent()

◆ OnResize()

◆ OnTextInput()

void Window::OnTextInput ( const TextInputEvent e)

◆ OnTickEvent()

void Window::OnTickEvent ( const TickEvent e)

Definition at line 1204 of file Window.cpp.

References PostRedraw(), and cloudViewer::visualization::gui::Widget::REDRAW.

◆ PostRedraw()

◆ RaiseToTop()

◆ SetFocusWidget()

void Window::SetFocusWidget ( Widget w)

◆ SetNeedsLayout()

void Window::SetNeedsLayout ( )

◆ SetOnClose()

void Window::SetOnClose ( std::function< bool()>  callback)

Sets a callback that will be called immediately before the window is closed. Callback should return true if the window should continue closing or false to cancel the close.

Definition at line 611 of file Window.cpp.

References callback.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes(), and cloudViewer::visualization::pybind_o3dvisualizer().

◆ SetOnKeyEvent()

void Window::SetOnKeyEvent ( std::function< bool(const KeyEvent &)>  callback)

Sets a callback that will intercept key event dispatching to focused widget. Callback should return true to stop more dispatching or false to dispatch to focused widget.

Definition at line 615 of file Window.cpp.

References callback.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes().

◆ SetOnMenuItemActivated()

void Window::SetOnMenuItemActivated ( Menu::ItemId  item_id,
std::function< void()>  callback 
)

Sets a callback for menu items. If you inherit from Window you can also override OnMenuItemSelected(); however, you should choose one or the other, but don't use both.

Definition at line 602 of file Window.cpp.

References callback.

Referenced by cloudViewer::visualization::visualizer::O3DVisualizer::AddAction(), cloudViewer::visualization::visualizer::O3DVisualizer::O3DVisualizer(), and cloudViewer::visualization::gui::pybind_gui_classes().

◆ SetOnTickEvent()

void Window::SetOnTickEvent ( std::function< bool()>  callback)

Sets a callback that will be called on every UI tick (about 10 msec). Callback should return true if a redraw is required (i.e. the UI or a 3D scene has changed), false otherwise.

Definition at line 607 of file Window.cpp.

References callback.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes().

◆ SetOSFrame()

◆ SetSize()

◆ SetTitle()

◆ SetTopmost()

void cloudViewer::visualization::gui::Window::SetTopmost ( bool  topmost)

◆ Show()

◆ ShowDialog()

◆ ShowMenu()

void Window::ShowMenu ( bool  show)

◆ ShowMessageBox()

◆ SizeToFit()

void Window::SizeToFit ( )

Auto-sizes the window to the results of CalcPreferredSize(), which by default is the size that the layouts of the window want.

Definition at line 500 of file Window.cpp.

References CalcPreferredSize(), and SetSize().

Referenced by cloudViewer::visualization::gui::pybind_gui_classes(), and cloudViewer::visualization::pybind_o3dvisualizer().

Member Data Documentation

◆ FLAG_HIDDEN

const int Window::FLAG_HIDDEN = (1 << 0)
static

Definition at line 35 of file Window.h.

Referenced by Window().

◆ FLAG_TOPMOST

const int Window::FLAG_TOPMOST = (1 << 1)
static

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