Commit f775cf4e authored by Jan Möbius's avatar Jan Möbius

Dennis: Make-active-examiner-primary-during-multiview-switch

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5967 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d30f7106
......@@ -778,20 +778,22 @@ void CoreWidget::nextViewMode() {
switch (baseLayout_->mode()) {
case QtMultiViewLayout::SingleView:
baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
baseLayout_->setMode(QtMultiViewLayout::Grid);
// Update combo box in the toolbar
viewmodeBox_->setCurrentIndex(1);
break;
case QtMultiViewLayout::Grid:
baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
baseLayout_->setMode(QtMultiViewLayout::HSplit);
// Update combo box in the toolbar
viewmodeBox_->setCurrentIndex(2);
break;
case QtMultiViewLayout::HSplit:
baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
baseLayout_->setMode(QtMultiViewLayout::SingleView);
PluginFunctions::setActiveExaminer(0);
// Update combo box in the toolbar
viewmodeBox_->setCurrentIndex(0);
......@@ -809,13 +811,15 @@ CoreWidget::setViewMode(int _idx) {
switch (_idx) {
case 0:
baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
baseLayout_->setMode(QtMultiViewLayout::SingleView);
PluginFunctions::setActiveExaminer(0);
break;
case 1:
baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
baseLayout_->setMode(QtMultiViewLayout::Grid);
break;
case 2:
baseLayout_->setPrimary (PluginFunctions::activeExaminer ());
baseLayout_->setMode(QtMultiViewLayout::HSplit);
break;
}
......
......@@ -50,7 +50,8 @@
QtMultiViewLayout::QtMultiViewLayout (QGraphicsLayoutItem * _parent) :
QGraphicsLayout (_parent),
mode_ (SingleView),
spacing_ (2)
spacing_ (2),
primary_ (0)
{
items_[0] = 0;
items_[1] = 0;
......@@ -77,6 +78,16 @@ void QtMultiViewLayout::setMode (MultiViewMode _mode)
//-----------------------------------------------------------------------------
void QtMultiViewLayout::setPrimary (unsigned int _i)
{
if ((int) _i > count ())
return;
primary_ = _i;
invalidate();
}
//-----------------------------------------------------------------------------
void QtMultiViewLayout::setSpacing (unsigned int _s)
{
spacing_ = _s;
......@@ -136,32 +147,26 @@ void QtMultiViewLayout::reLayout ()
MultiViewMode mode = mode_;
QRectF r = contentsRect ();
if (!items_[0])
if (!items_[primary_])
return;
if (count() != 4)
mode = SingleView;
if (mode == SingleView)
{
if (items_[1])
items_[1]->hide();
if (items_[2])
items_[2]->hide();
if (items_[3])
items_[3]->hide();
for (int i = 0; i < 4; i++)
items_[i]->hide();
items_[primary_]->show ();
} else {
if (items_[1])
items_[1]->show();
if (items_[2])
items_[2]->show();
if (items_[3])
items_[3]->show();
for (int i = 0; i < 4; i++)
if (items_[i])
items_[i]->show();
}
switch (mode)
{
case SingleView:
items_[0]->setGeometry (r);
items_[primary_]->setGeometry (r);
break;
case Grid:
{
......@@ -181,18 +186,23 @@ void QtMultiViewLayout::reLayout ()
break;
case HSplit:
{
int order[4];
order[0] = primary_;
for (unsigned int i = 0, j = 1; i < 4; i++)
if (i != primary_)
order[j++] = i;
int width = (r.width() - spacing_) * 3 / 4;
int ewidth = r.width() - spacing_ - width;
int eheight = (r.height() - (spacing_ * 2)) / 3;
items_[0]->resize (width, r.height());
items_[1]->resize (ewidth, eheight);
items_[2]->resize (ewidth, eheight);
items_[3]->resize (ewidth, r.height() - ((eheight + spacing_) * 2));
items_[0]->setPos (r.topLeft());
items_[1]->setPos (r.x() + width + spacing_, r.y());
items_[2]->setPos (r.x() + width + spacing_, r.y() + eheight + spacing_);
items_[3]->setPos (r.x() + width + spacing_,
r.y() + ((eheight + spacing_) * 2));
items_[order[0]]->resize (width, r.height());
items_[order[1]]->resize (ewidth, eheight);
items_[order[2]]->resize (ewidth, eheight);
items_[order[3]]->resize (ewidth, r.height() - ((eheight + spacing_) * 2));
items_[order[0]]->setPos (r.topLeft());
items_[order[1]]->setPos (r.x() + width + spacing_, r.y());
items_[order[2]]->setPos (r.x() + width + spacing_, r.y() + eheight + spacing_);
items_[order[3]]->setPos (r.x() + width + spacing_,
r.y() + ((eheight + spacing_) * 2));
}
break;
}
......
......@@ -105,6 +105,9 @@ class DLLEXPORT QtMultiViewLayout : public QGraphicsLayout
/// Sets space between items
void setSpacing (unsigned int _s);
/// Sets primary element for SingleView and HSplit
void setPrimary (unsigned int _i);
/// Pure virtual functions that have to be implemented
virtual int count() const;
......@@ -131,6 +134,9 @@ class DLLEXPORT QtMultiViewLayout : public QGraphicsLayout
/// Items
QGraphicsWidget *items_[4];
/// Primary element
unsigned int primary_;
};
//=============================================================================
......
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