Open3D (C++ API)  0.13.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
GLFWWindowSystem.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2020 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
30 
31 struct GLFWwindow;
32 
33 namespace open3d {
34 namespace visualization {
35 namespace gui {
36 
38 public:
41 
42  void Initialize() override;
43  void Uninitialize() override;
44 
45  void WaitEventsTimeout(double timeout_secs) override;
46 
47  Size GetScreenSize(OSWindow w) override;
48 
50  int width,
51  int height,
52  const char* title,
53  int flags) override;
54  void DestroyWindow(OSWindow w) override;
55 
56  void PostRedrawEvent(OSWindow w) override;
57 
58  bool GetWindowIsVisible(OSWindow w) const override;
59  void ShowWindow(OSWindow w, bool show) override;
60 
61  void RaiseWindowToTop(OSWindow w) override;
62  bool IsActiveWindow(OSWindow w) const override;
63 
64  Point GetWindowPos(OSWindow w) const override;
65  void SetWindowPos(OSWindow w, int x, int y) override;
66 
67  Size GetWindowSize(OSWindow w) const override;
68  void SetWindowSize(OSWindow w, int width, int height) override;
69 
70  Size GetWindowSizePixels(OSWindow w) const override;
71  void SetWindowSizePixels(OSWindow w, const Size& size) override;
72 
73  float GetWindowScaleFactor(OSWindow w) const override;
74  float GetUIScaleFactor(OSWindow w) const override;
75 
76  void SetWindowTitle(OSWindow w, const char* title) override;
77 
78  Point GetMousePosInWindow(OSWindow w) const override;
79  int GetMouseButtons(OSWindow w) const override;
80 
81  void CancelUserClose(OSWindow w) override;
82 
83  void* GetNativeDrawable(OSWindow w) override;
84 
86 
87  void ResizeRenderer(OSWindow w,
88  rendering::FilamentRenderer* renderer) override;
89 
90  MenuBase* CreateOSMenu() override;
91 
92 private:
93  static void DrawCallback(GLFWwindow* window);
94  static void ResizeCallback(GLFWwindow* window, int os_width, int os_height);
95  static void WindowMovedCallback(GLFWwindow* window, int os_x, int os_y);
96  static void RescaleCallback(GLFWwindow* window, float xscale, float yscale);
97  static void MouseMoveCallback(GLFWwindow* window, double x, double y);
98  static void MouseButtonCallback(GLFWwindow* window,
99  int button,
100  int action,
101  int mods);
102  static void MouseScrollCallback(GLFWwindow* window, double dx, double dy);
103  static void KeyCallback(
104  GLFWwindow* window, int key, int scancode, int action, int mods);
105  static void CharCallback(GLFWwindow* window, unsigned int utf32char);
106  static void DragDropCallback(GLFWwindow*, int count, const char* paths[]);
107  static void CloseCallback(GLFWwindow* window);
108 };
109 
110 } // namespace gui
111 } // namespace visualization
112 } // namespace open3d
OSWindow CreateOSWindow(Window *o3d_window, int width, int height, const char *title, int flags) override
Definition: GLFWWindowSystem.cpp:173
Definition: GLFWWindowSystem.h:37
void RaiseWindowToTop(OSWindow w) override
Definition: GLFWWindowSystem.cpp:234
Definition: Window.h:49
void SetWindowSize(OSWindow w, int width, int height) override
Definition: GLFWWindowSystem.cpp:258
float GetWindowScaleFactor(OSWindow w) const override
Definition: GLFWWindowSystem.cpp:273
Definition: MenuBase.h:45
int size
Definition: FilePCD.cpp:59
~GLFWWindowSystem()
Definition: GLFWWindowSystem.cpp:124
Size GetWindowSizePixels(OSWindow w) const override
Definition: GLFWWindowSystem.cpp:262
MenuBase * CreateOSMenu() override
Definition: GLFWWindowSystem.cpp:560
void SetWindowTitle(OSWindow w, const char *title) override
Definition: GLFWWindowSystem.cpp:294
bool GetWindowIsVisible(OSWindow w) const override
Definition: GLFWWindowSystem.cpp:222
rendering::FilamentRenderer * CreateRenderer(OSWindow w) override
Definition: GLFWWindowSystem.cpp:544
Size GetScreenSize(OSWindow w) override
Definition: GLFWWindowSystem.cpp:150
void ShowWindow(OSWindow w, bool show) override
Definition: GLFWWindowSystem.cpp:226
int count
Definition: FilePCD.cpp:61
bool IsActiveWindow(OSWindow w) const override
Definition: GLFWWindowSystem.cpp:238
void WaitEventsTimeout(double timeout_secs) override
Definition: GLFWWindowSystem.cpp:142
GLFWWindowSystem()
Definition: GLFWWindowSystem.cpp:122
Definition: PinholeCameraIntrinsic.cpp:35
Window * o3d_window
Definition: BitmapWindowSystem.cpp:47
float GetUIScaleFactor(OSWindow w) const override
Definition: GLFWWindowSystem.cpp:288
Point GetMousePosInWindow(OSWindow w) const override
Definition: GLFWWindowSystem.cpp:298
void Initialize() override
Definition: GLFWWindowSystem.cpp:126
void * OSWindow
Definition: WindowSystem.h:48
int height
Definition: FilePCD.cpp:72
void ResizeRenderer(OSWindow w, rendering::FilamentRenderer *renderer) override
Definition: GLFWWindowSystem.cpp:550
void * GetNativeDrawable(OSWindow w) override
Definition: GLFWWindowSystem.cpp:540
void Uninitialize() override
Definition: GLFWWindowSystem.cpp:140
void PostRedrawEvent(OSWindow w) override
Definition: GLFWWindowSystem.cpp:218
void SetWindowPos(OSWindow w, int x, int y) override
Definition: GLFWWindowSystem.cpp:248
Size GetWindowSize(OSWindow w) const override
Definition: GLFWWindowSystem.cpp:252
void DestroyWindow(OSWindow w) override
Definition: GLFWWindowSystem.cpp:214
Point GetWindowPos(OSWindow w) const override
Definition: GLFWWindowSystem.cpp:242
int GetMouseButtons(OSWindow w) const override
Definition: GLFWWindowSystem.cpp:305
void CancelUserClose(OSWindow w) override
Definition: GLFWWindowSystem.cpp:320
void SetWindowSizePixels(OSWindow w, const Size &size) override
Definition: GLFWWindowSystem.cpp:268
int width
Definition: FilePCD.cpp:71
Definition: WindowSystem.h:46