Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SetFullScreen to GUI::Window and GLFWWindowSystem #5936

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cpp/open3d/visualization/gui/BitmapWindowSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class BitmapWindowSystem : public WindowSystem {

MenuBase* CreateOSMenu() override;

/// SetFullScreen is a no-op
void SetFullScreen(OSWindow, bool) override{};

private:
struct Impl;
std::unique_ptr<Impl> impl_;
Expand Down
14 changes: 14 additions & 0 deletions cpp/open3d/visualization/gui/GLFWWindowSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,20 @@ MenuBase* GLFWWindowSystem::CreateOSMenu() {
#endif
}

void GLFWWindowSystem::SetFullScreen(OSWindow w, bool bFullScreen) {
if (!bFullScreen) {
glfwSetWindowMonitor((GLFWwindow*)w, NULL, win_x_, win_y_, win_width_,
win_height_, GLFW_DONT_CARE);
} else {
glfwGetWindowSize((GLFWwindow*)w, &win_width_, &win_height_);
glfwGetWindowPos((GLFWwindow*)w, &win_x_, &win_y_);
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwSetWindowMonitor((GLFWwindow*)w, monitor, 0, 0, mode->width,
mode->height, mode->refreshRate);
}
}

} // namespace gui
} // namespace visualization
} // namespace open3d
7 changes: 7 additions & 0 deletions cpp/open3d/visualization/gui/GLFWWindowSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class GLFWWindowSystem : public WindowSystem {

MenuBase* CreateOSMenu() override;

void SetFullScreen(OSWindow w, bool bFullScreen) override;

private:
static void DrawCallback(GLFWwindow* window);
static void ResizeCallback(GLFWwindow* window, int os_width, int os_height);
Expand All @@ -86,6 +88,11 @@ class GLFWWindowSystem : public WindowSystem {
static void CharCallback(GLFWwindow* window, unsigned int utf32char);
static void DragDropCallback(GLFWwindow*, int count, const char* paths[]);
static void CloseCallback(GLFWwindow* window);

int win_width_;
int win_height_;
int win_x_;
int win_y_;
};

} // namespace gui
Expand Down
5 changes: 5 additions & 0 deletions cpp/open3d/visualization/gui/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,11 @@ void Window::ShowMenu(bool show) {
SetNeedsLayout();
}

void Window::SetFullScreen(bool bFullScreen) {
auto& ws = Application::GetInstance().GetWindowSystem();
ws.SetFullScreen(GetOSWindow(), bFullScreen);
}

LayoutContext Window::GetLayoutContext() { return {GetTheme(), impl_->imgui_}; }

void Window::Layout(const LayoutContext& context) {
Expand Down
2 changes: 2 additions & 0 deletions cpp/open3d/visualization/gui/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class Window {
/// WebRTCWindowSystem.
std::string GetWebRTCUID() const;

void SetFullScreen(bool bFullScreen);

protected:
/// Returns the preferred size of the window. The window is not
/// obligated to honor this size. If all children of the window
Expand Down
2 changes: 2 additions & 0 deletions cpp/open3d/visualization/gui/WindowSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class WindowSystem {
rendering::FilamentRenderer* renderer) = 0;

virtual MenuBase* CreateOSMenu() = 0;

virtual void SetFullScreen(OSWindow w, bool bFullScreen) = 0;
};

} // namespace gui
Expand Down
3 changes: 3 additions & 0 deletions cpp/pybind/visualization/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ void pybind_gui_classes(py::module &m) {
"show_menu(show): shows or hides the menu in the window, "
"except on macOS since the menubar is not in the window "
"and all applications must have a menubar.")
.def("set_full_screen", &PyWindow::SetFullScreen,
"Make the window fullscreen or reset to previous state.",
"fullscreen"_a = true)
.def_property_readonly(
"renderer", &PyWindow::GetRenderer,
"Gets the rendering.Renderer object for the Window");
Expand Down
5 changes: 5 additions & 0 deletions examples/python/visualization/vis_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ def __init__(self, width, height):
h.add_stretch()
view_ctrls.add_child(h)

self._fullscreen = gui.Checkbox("Fullscreen")
self._fullscreen.set_on_checked(w.set_full_screen)
view_ctrls.add_fixed(separation_height)
view_ctrls.add_child(self._fullscreen)

self._show_skybox = gui.Checkbox("Show skymap")
self._show_skybox.set_on_checked(self._on_show_skybox)
view_ctrls.add_fixed(separation_height)
Expand Down