11.08., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit a23b1e70 authored by Jakob Weiss's avatar Jakob Weiss

DataContainerInspector now default floating

* InspectorWindow immediately detaches from the MDI surface
* some swapBuffers warning on first creation of the inspector remains
parent bdcedc2b
......@@ -43,6 +43,7 @@
#include "ext/cgt/navigation/trackball.h"
#include <QWindow>
namespace campvis {
......@@ -255,6 +256,11 @@ namespace campvis {
}
void DataContainerInspectorCanvas::onInvalidated() {
// Prevent drawing when the window is not yet exposed to the window manager
QWindow* wnd = dynamic_cast<QWindow*>(window()->windowHandle());
if (!wnd || !wnd->isExposed()) return;
// only if inited
if (_quad != 0 && _paintShader != 0 && this->isVisible()) {
......
......@@ -363,6 +363,7 @@ namespace campvis {
void MainWindow::onBtnShowDataContainerInspectorClicked() {
if (_selectedPipeline != 0) {
// if there is no existing inspector window, create one
if (_dcInspectorWindow == 0) {
_dcInspectorWindow = _mdiArea->addWidget(_dcInspectorWidget);
_dcInspectorWindow->setWindowTitle(tr("Data Container Inspector"));
......@@ -371,6 +372,8 @@ namespace campvis {
_dcInspectorWidget->setDataContainer(&(_selectedPipeline->getDataContainer()));
_dcInspectorWindow->show();
_dcInspectorWindow->activateWindow();
//_dcInspectorWindow->detachDockedWindow();
}
}
......
......@@ -42,16 +42,16 @@ namespace campvis {
, _widget(widget)
, _fullScreenWidget(0)
{
this->setWindowFlags(windowFlags);
setWindowFlags(windowFlags);
_dockedWindow = this->newDockedWindow(widget);
_toggleViewAction = new QAction(this);
_toggleViewAction->setCheckable(true);
_toggleViewAction->setChecked(false);
this->connect(_toggleViewAction, SIGNAL(toggled(bool)), SLOT(toggleWindowVisibility(bool)));
connect(_toggleViewAction, &QAction::toggled, this, &MdiDockableWindow::toggleWindowVisibility);
if (dynamic_cast<cgt::QtCanvas*>(widget)) {
connect(widget, SIGNAL(fullScreenChanged(bool)), this, SLOT(handleFullScreenChanged(bool)));
if (auto canvas = dynamic_cast<cgt::QtCanvas*>(widget)) {
connect(canvas, &cgt::QtCanvas::fullScreenChanged, this, &MdiDockableWindow::handleFullScreenChanged);
}
}
......@@ -77,6 +77,63 @@ namespace campvis {
return _toggleViewAction;
}
void MdiDockableWindow::detachDockedWindow()
{
if (!_dockedWindow) {
std::cerr << "ERROR: Tried to detach a window that is already floating!" << std::endl;
return;
}
QWidget* widget = _dockedWindow->widget();
_dockedWindow->stopWindowDrag();
_dockedWindow->setWidget(0);
_mdiArea->removeSubWindow(_dockedWindow);
_floatingWindow = new MdiFloatingWindow(widget, this);
_floatingWindow->setWindowTitle(this->windowTitle());
_dockedWindow->deleteLater();
_dockedWindow = 0;
_docked = false;
_floatingWindow->show();
_floatingWindow->activateWindow();
_floatingWindow->forceWindowDrag();
/*
* Connect signals last so that the floating window's initial move events are ignored.
* They mustn't be handled because they may contain outdated position information which
* could, in extreme cases, trigger immediate re-docking of the floating window,
* leading to all sorts of problems.
*/
this->connect(_floatingWindow, &MdiFloatingWindow::s_closed, this, &MdiDockableWindow::handleWindowClosing);
this->connect(_floatingWindow, &MdiFloatingWindow::s_positionChanged, this, &MdiDockableWindow::trackFloatingWindowPosition);
}
void MdiDockableWindow::attachFloatingWindow()
{
if (!_floatingWindow) {
std::cerr << "ERROR: Tried to attach a window that is already docked!" << std::endl;
return;
}
_floatingWindow->stopWindowDrag();
_floatingWindow->hide();
QWidget* widget = _floatingWindow->widget();
_dockedWindow = this->newDockedWindow(widget);
_dockedWindow->setWindowTitle(this->windowTitle());
_floatingWindow->deleteLater();
_floatingWindow = 0;
_docked = true;
_mdiArea->addSubWindow(_dockedWindow);
// Dragging the window doesn't make sense in tabbed mode
if (_mdiArea->viewMode() == QMdiArea::SubWindowView)
_dockedWindow->forceWindowDrag();
}
void MdiDockableWindow::setVisible(bool visible) {
_toggleViewAction->setChecked(visible);
}
......@@ -85,8 +142,8 @@ namespace campvis {
MdiDockedWindow* dockedWindow = new MdiDockedWindow(_mdiArea, this->windowFlags());
dockedWindow->setWidget(widget);
this->connect(dockedWindow, SIGNAL(s_positionChanged(const QPoint&)), SLOT(trackDockedWindowPosition(QPoint)));
this->connect(dockedWindow, SIGNAL(s_closed()), SLOT(handleWindowClosing()));
this->connect(dockedWindow, &MdiDockedWindow::s_positionChanged, this, &MdiDockableWindow::trackDockedWindowPosition);
this->connect(dockedWindow, &MdiDockedWindow::s_closed, this, &MdiDockableWindow::handleWindowClosing);
return dockedWindow;
}
......@@ -120,21 +177,8 @@ namespace campvis {
// Dock the floating window's widget if at least 60% of it is over the MDI area
if (widgetGeometry.width() * widgetGeometry.height() * 3 <
intersection.width() * intersection.height() * 5) {
_floatingWindow->stopWindowDrag();
_floatingWindow->hide();
QWidget* widget = _floatingWindow->widget();
_dockedWindow = this->newDockedWindow(widget);
_dockedWindow->setWindowTitle(this->windowTitle());
attachFloatingWindow();
_floatingWindow->deleteLater();
_floatingWindow = 0;
_docked = true;
_mdiArea->addSubWindow(_dockedWindow);
// Dragging the window doesn't make sense in tabbed mode
if (_mdiArea->viewMode() == QMdiArea::SubWindowView)
_dockedWindow->forceWindowDrag();
}
}
......@@ -146,33 +190,10 @@ namespace campvis {
// Detach the docked window's widget if at least 60% of it has left the MDI area
if (subWindowGeometry.width() * subWindowGeometry.height() * 2 >
intersection.width() * intersection.height() * 5) {
QWidget* widget = _dockedWindow->widget();
_dockedWindow->stopWindowDrag();
_dockedWindow->setWidget(0);
_mdiArea->removeSubWindow(_dockedWindow);
_floatingWindow = new MdiFloatingWindow(widget, this);
_floatingWindow->setWindowTitle(this->windowTitle());
_dockedWindow->deleteLater();
_dockedWindow = 0;
_docked = false;
_floatingWindow->show();
_floatingWindow->activateWindow();
_floatingWindow->forceWindowDrag();
/*
* Connect signals last so that the floating window's initial move events are ignored.
* They mustn't be handled because they may contain outdated position information which
* could, in extreme cases, trigger immediate re-docking of the floating window,
* leading to all sorts of problems.
*/
this->connect(_floatingWindow, SIGNAL(s_closed()), SLOT(handleWindowClosing()));
this->connect(_floatingWindow, SIGNAL(s_positionChanged(const QPoint&)),
SLOT(trackFloatingWindowPosition(const QPoint&)));
detachDockedWindow();
}
}
void MdiDockableWindow::handleFullScreenChanged(bool fullscreen) {
if (_docked && _dockedWindow) {
if (fullscreen) {
......
......@@ -86,6 +86,16 @@ namespace campvis {
*/
QAction* toggleViewAction() const;
/**
* Attaches the window to the MDI area if it is floating.
*/
void attachFloatingWindow();
/**
* Detaches the window to float freely if it is docked.
*/
void detachDockedWindow();
private slots:
/**
* Track the position of the associated floating MDI window and dock it if necessary.
......@@ -94,6 +104,7 @@ namespace campvis {
*/
void trackFloatingWindowPosition(const QPoint& newPos);
/**
* Track the position of the associated docked MDI window and detach it if necessary.
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment