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:
[legend]

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 Theme & GetTheme () const
 
visualization::rendering::Renderer & GetRenderer () 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
 

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().

◆ 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().

◆ Window() [3/3]

◆ ~Window()

Window::~Window ( )
virtual

References DestroyWindow().

Member Function Documentation

◆ AddChild()

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

◆ 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.

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.

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

◆ GetContentRect()

◆ GetLayoutContext()

LayoutContext Window::GetLayoutContext ( )
protected

References GetTheme().

Referenced by CalcPreferredSize(), and ShowDialog().

◆ GetMouseMods()

int Window::GetMouseMods ( ) const

◆ GetOSFrame()

Rect Window::GetOSFrame ( ) const

◆ GetOSWindow()

WindowSystem::OSWindow Window::GetOSWindow ( ) const

◆ 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.

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

◆ 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::GuiVisualizer, and cloudViewer::visualization::visualizer::O3DVisualizer.

References context, and GetContentRect().

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

◆ OnDragDropped()

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

◆ OnDraw()

◆ OnKeyEvent()

◆ OnMenuItemSelected()

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

◆ OnMouseEvent()

◆ OnResize()

◆ OnTextInput()

void Window::OnTextInput ( const TextInputEvent &  e)

References e, and PostRedraw().

◆ OnTickEvent()

void Window::OnTickEvent ( const TickEvent &  e)

◆ PostRedraw()

◆ RaiseToTop()

◆ SetFocusWidget()

void Window::SetFocusWidget ( Widget *  w)

Sets.

Parameters
was widget with text focus.

Referenced by CloseDialog(), OnMouseEvent(), and cloudViewer::visualization::GuiVisualizer::Impl::SetMouseControls().

◆ 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.

References callback.

◆ 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.

References callback.

◆ 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.

References callback.

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

◆ 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.

References callback.

◆ SetOSFrame()

◆ SetSize()

void Window::SetSize ( const Size &  size)

◆ SetTitle()

◆ SetTopmost()

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

◆ Show()

◆ ShowDialog()

void Window::ShowDialog ( std::shared_ptr< Dialog >  dlg)

◆ ShowMenu()

void Window::ShowMenu ( bool  show)

References SetNeedsLayout().

◆ 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.

References CalcPreferredSize(), and SetSize().

Member Data Documentation

◆ FLAG_HIDDEN

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

Referenced by Window().

◆ FLAG_TOPMOST

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

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