Commit b036cadd authored by Mike Kremer's avatar Mike Kremer

Made removal and insertion of logger widget into split view of core widget...

Made removal and insertion of logger widget into split view of core widget work properly without dummy widget.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11981 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0e2751cd
......@@ -259,7 +259,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// ======================================================================
slidingLogger_ = new QtSlideWindow (tr("Log Viewer"), centerWidget_);
tempLogWidget = new QWidget;
logWidget_ = new LoggerWidget(splitter_);
logWidget_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) );
......@@ -268,27 +267,25 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
originalLoggerSize_ = 0;
loggerState_ = OpenFlipper::Options::Normal;
QList<int> wsizes( splitter_->sizes() );
QList<int> wsizes(splitter_->sizes());
// Set initial values to have a usable state
wsizes[0] = 480;
wsizes[1] = 240;
splitter_->setSizes(wsizes);
if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene) {
slidingLogger_->attachWidget (logWidget_);
splitter_->insertWidget (1, tempLogWidget);
wsizes[0] = 1;
wsizes[1] = 0;
splitter_->setSizes(wsizes);
showLoggerInSplitView(false);
loggerState_ = OpenFlipper::Options::InScene;
baseLayout_->setContentsMargins (0, 0, 0, 16);
} else if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::Hidden) {
splitter_->insertWidget (1, tempLogWidget);
wsizes[0] = 1;
wsizes[1] = 0;
splitter_->setSizes(wsizes);
showLoggerInSplitView(true);
loggerState_ = OpenFlipper::Options::Hidden;
} else {
// Set initial values to have a usable state
wsizes[0] = 480;
wsizes[1] = 240;
splitter_->setSizes(wsizes);
showLoggerInSplitView(true);
}
......@@ -728,153 +725,6 @@ CoreWidget::showViewModeControls(bool _show) {
}
//-----------------------------------------------------------------------------
/** Hide or show logger
*/
void
CoreWidget::toggleLogger() {
switch (OpenFlipper::Options::loggerState ())
{
case OpenFlipper::Options::InScene:
OpenFlipper::Options::loggerState(OpenFlipper::Options::Normal);
break;
case OpenFlipper::Options::Normal:
OpenFlipper::Options::loggerState(OpenFlipper::Options::Hidden);
break;
case OpenFlipper::Options::Hidden:
OpenFlipper::Options::loggerState(OpenFlipper::Options::InScene);
break;
}
// Hide/Show Logger
showLogger( OpenFlipper::Options::loggerState() );
}
/** Hide or show logger
*/
void
CoreWidget::showLogger(OpenFlipper::Options::LoggerState _state) {
//Hide Logger
if (_state == loggerState_)
return;
qreal left, top, right, bottom;
baseLayout_->getContentsMargins (&left, &top, &right, &bottom);
switch (_state)
{
case OpenFlipper::Options::InScene:
{
QList<int> wsizes( splitter_->sizes() );
// Remember old size
if (loggerState_ == OpenFlipper::Options::Normal)
originalLoggerSize_ = wsizes[1];
if ( originalLoggerSize_ == 0)
originalLoggerSize_ = 240;
splitter_->insertWidget (1, tempLogWidget);
wsizes[0] = wsizes[0]+wsizes[1];
wsizes[1] = 0;
splitter_->setSizes(wsizes);
logWidget_->resize (logWidget_->width (), originalLoggerSize_);
slidingLogger_->attachWidget (logWidget_);
baseLayout_->setContentsMargins (left, top, right, 16);
}
break;
case OpenFlipper::Options::Normal:
{
if ( originalLoggerSize_ == 0)
originalLoggerSize_ = 240;
QList<int> wsizes( splitter_->sizes() );
if (loggerState_ == OpenFlipper::Options::InScene)
originalLoggerSize_ = logWidget_->height ();
slidingLogger_->detachWidget ();
splitter_->insertWidget (1, logWidget_);
logWidget_->show ();
wsizes[0] = wsizes[0]+wsizes[1] - originalLoggerSize_;
wsizes[1] = originalLoggerSize_;
splitter_->setSizes(wsizes);
baseLayout_->setContentsMargins (left, top, right, 0);
}
break;
case OpenFlipper::Options::Hidden:
{
QList<int> wsizes( splitter_->sizes() );
// Remember old size
if (loggerState_ == OpenFlipper::Options::Normal)
originalLoggerSize_ = wsizes[1];
if (loggerState_ == OpenFlipper::Options::InScene)
{
slidingLogger_->detachWidget ();
originalLoggerSize_ = logWidget_->height ();
}
splitter_->insertWidget (1, tempLogWidget);
wsizes[0] = wsizes[0]+wsizes[1];
wsizes[1] = 0;
splitter_->setSizes(wsizes);
baseLayout_->setContentsMargins (left, top, right, 0);
}
break;
}
loggerState_ = _state;
/*
if ( !_state ) {
QList<int> wsizes( splitter_->sizes() );
// Remember old size
originalLoggerSize_ = wsizes[1];
int height = logWidget_->height ();
splitter_->insertWidget (1, tempLogWidget);
wsizes[0] = wsizes[0]+wsizes[1];
wsizes[1] = 0;
splitter_->setSizes(wsizes);
logWidget_->resize (logWidget_->width (), height);
slidingLogger_->attachWidget (logWidget_);
} else if (splitter_->widget (1) == logWidget_) {
if ( originalLoggerSize_ == 0)
originalLoggerSize_ = 240;
QList<int> wsizes( splitter_->sizes() );
if (wsizes[0] == 0)
wsizes[0] = height();
wsizes[0] = wsizes[0]+wsizes[1] - originalLoggerSize_;
wsizes[1] = originalLoggerSize_;
splitter_->setSizes(wsizes);
} else {
QList<int> wsizes( splitter_->sizes() );
int height = logWidget_->height ();
slidingLogger_->detachWidget ();
splitter_->insertWidget (1, logWidget_);
wsizes[0] = wsizes[0]+wsizes[1] - height;
wsizes[1] = height;
splitter_->setSizes(wsizes);
}
*/
}
//-----------------------------------------------------------------------------
/** Hide or show toolbox
......
......@@ -35,8 +35,8 @@
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
......@@ -470,6 +470,9 @@ public:
/// Change visibility of the logger
void showLogger(OpenFlipper::Options::LoggerState _state);
/// Show logger in splitter or not
void showLoggerInSplitView(bool _show);
/// Hide or show toolbox area
void toggleToolbox();
......@@ -643,9 +646,6 @@ public:
/// Class that holds the animated log widget
QtSlideWindow* slidingLogger_;
/// Temporary widget
QWidget* tempLogWidget;
/// Widget for toolBox
QWidget* toolBoxArea_;
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include <OpenFlipper/widgets/coreWidget/CoreWidget.hh>
/** Hide or show logger
*/
void CoreWidget::toggleLogger() {
switch (OpenFlipper::Options::loggerState()) {
case OpenFlipper::Options::InScene:
OpenFlipper::Options::loggerState(OpenFlipper::Options::Normal);
break;
case OpenFlipper::Options::Normal:
OpenFlipper::Options::loggerState(OpenFlipper::Options::Hidden);
break;
case OpenFlipper::Options::Hidden:
OpenFlipper::Options::loggerState(OpenFlipper::Options::InScene);
break;
}
// Hide/Show Logger
showLogger(OpenFlipper::Options::loggerState());
}
//-----------------------------------------------------------------------------
/** Hide or show logger
*/
void CoreWidget::showLogger(OpenFlipper::Options::LoggerState _state) {
//Hide Logger
if (_state == loggerState_)
return;
switch (_state) {
case OpenFlipper::Options::InScene: {
showLoggerInSplitView(false);
logWidget_->resize(logWidget_->width(), originalLoggerSize_);
slidingLogger_->attachWidget(logWidget_);
break;
}
case OpenFlipper::Options::Normal: {
slidingLogger_->detachWidget();
showLoggerInSplitView(true);
logWidget_->show();
break;
}
case OpenFlipper::Options::Hidden: {
showLoggerInSplitView(false);
break;
}
} // End switch
loggerState_ = _state;
}
//-----------------------------------------------------------------------------
void CoreWidget::showLoggerInSplitView(bool _show) {
if(!_show) {
QList<int> wsizes = splitter_->sizes();
// Remember old size
if (loggerState_ == OpenFlipper::Options::Normal)
originalLoggerSize_ = wsizes[1];
if (originalLoggerSize_ == 0)
originalLoggerSize_ = 240;
logWidget_->setParent(0);
wsizes[0] = 1;
splitter_->setSizes(wsizes);
} else {
if (loggerState_ == OpenFlipper::Options::InScene)
originalLoggerSize_ = logWidget_->height();
if (originalLoggerSize_ == 0)
originalLoggerSize_ = 240;
logWidget_->setParent(splitter_);
splitter_->insertWidget(1, logWidget_);
QList<int> wsizes = splitter_->sizes();
int totalHeight = wsizes[0] + wsizes[1];
wsizes[1] = originalLoggerSize_;
wsizes[0] = totalHeight - originalLoggerSize_;
splitter_->setSizes(wsizes);
}
}
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