Skip to content

Commit

Permalink
Display::associated_widget_visible_ -> suppress_hiding_associated_wid…
Browse files Browse the repository at this point in the history
…get_panel_

We need the flag just to suppress hiding of the associated widget if
it became an unselected tab
  • Loading branch information
rhaschke committed Apr 24, 2022
1 parent 5f6aa04 commit 4455043
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/rviz/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Display::Display()
, visibility_bits_(0xFFFFFFFF)
, associated_widget_(nullptr)
, associated_widget_panel_(nullptr)
, associated_widget_visible_(false)
, suppress_hiding_associated_widget_panel_(false)
{
// Needed for timeSignal (see header) to work across threads
qRegisterMetaType<ros::Time>();
Expand Down Expand Up @@ -311,10 +311,7 @@ void Display::onEnableChanged()
scene_node_->setVisible(true);

if (associated_widget_panel_)
{
if (!associated_widget_visible_)
associated_widget_panel_->show();
}
associated_widget_panel_->show();
else if (associated_widget_)
associated_widget_->show();

Expand All @@ -327,7 +324,7 @@ void Display::onEnableChanged()

if (associated_widget_panel_)
{
if (associated_widget_visible_)
if (!suppress_hiding_associated_widget_panel_)
associated_widget_panel_->hide();
}
else if (associated_widget_)
Expand Down Expand Up @@ -366,7 +363,6 @@ void Display::setAssociatedWidget(QWidget* widget)
if (wm)
{
associated_widget_panel_ = wm->addPane(getName(), associated_widget_);
associated_widget_visible_ = true;
connect(associated_widget_panel_, SIGNAL(visibilityChanged(bool)), this,
SLOT(associatedPanelVisibilityChange(bool)));
connect(associated_widget_panel_, SIGNAL(closed()), this, SLOT(disable()));
Expand All @@ -386,9 +382,10 @@ void Display::setAssociatedWidget(QWidget* widget)

void Display::associatedPanelVisibilityChange(bool visible)
{
associated_widget_visible_ = visible;
// If something external makes the panel visible/invisible, make sure to enable/disable the display
suppress_hiding_associated_widget_panel_ = true;
setEnabled(visible);
suppress_hiding_associated_widget_panel_ = false;
// Remark: vice versa, in Display::onEnableChanged(),
// the panel is made visible/invisible when the display is enabled/disabled
}
Expand Down
2 changes: 1 addition & 1 deletion src/rviz/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private Q_SLOTS:
uint32_t visibility_bits_;
QWidget* associated_widget_;
PanelDockWidget* associated_widget_panel_;
bool associated_widget_visible_;
bool suppress_hiding_associated_widget_panel_;
};

} // end namespace rviz
Expand Down

0 comments on commit 4455043

Please sign in to comment.