Skip to content

Commit

Permalink
ImageDisplay: toggle fullscreen button
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke committed Sep 16, 2023
1 parent d560273 commit 767911c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/rviz/default_plugin/image_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@
#include <OgreTechnique.h>
#include <OgreCamera.h>

#include <QToolButton>
#include <QHBoxLayout>

#include <rviz/display_context.h>
#include <rviz/frame_manager.h>
#include <rviz/panel_dock_widget.h>
#include <rviz/ogre_helpers/compatibility.h>
#include <rviz/render_panel.h>
#include <rviz/validate_floats.h>
Expand Down Expand Up @@ -126,6 +130,14 @@ void ImageDisplay::onInitialize()

setAssociatedWidget(render_panel_);

// fullscreen button
QToolButton* fullscreen_button = new QToolButton();
fullscreen_button->setText("FullScreen");
fullscreen_button->setIconSize(QSize(10, 10));
connect(fullscreen_button, &QToolButton::clicked, this, &ImageDisplay::toggleFullScreen);
dynamic_cast<QHBoxLayout*>(getAssociatedWidgetPanel()->titleBarWidget()->layout())
->insertWidget(2, fullscreen_button);

render_panel_->setAutoRender(false);
render_panel_->setOverlaysEnabled(false);
render_panel_->getCamera()->setNearClipDistance(0.01f);
Expand Down Expand Up @@ -156,6 +168,21 @@ void ImageDisplay::onDisable()
reset();
}

void ImageDisplay::toggleFullScreen()
{
auto* panel = getAssociatedWidgetPanel();
if (panel->windowState() & Qt::WindowFullScreen)
{
panel->setFloating(false);
panel->showNormal();
}
else
{
panel->setFloating(true);
panel->showFullScreen();
}
}

void ImageDisplay::updateNormalizeOptions()
{
if (got_float_image_)
Expand Down
1 change: 1 addition & 0 deletions src/rviz/default_plugin/image_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ImageDisplay : public ImageDisplayBase

public Q_SLOTS:
virtual void updateNormalizeOptions();
virtual void toggleFullScreen();

protected:
// overrides from Display
Expand Down

0 comments on commit 767911c

Please sign in to comment.