예제 #1
0
파일: Gui10.cpp 프로젝트: haebler/Natron
void
Gui::createDefaultLayout1()
{
    ///First tab widget must be created this way
    TabWidget* mainPane = new TabWidget(this, _imp->_leftRightSplitter);
    {
        QMutexLocker l(&_imp->_panesMutex);
        _imp->_panes.push_back(mainPane);
    }

    mainPane->setObjectName_mt_safe( QString::fromUtf8("pane1") );
    mainPane->setAsAnchor(true);

    _imp->_leftRightSplitter->addWidget(mainPane);

    QList<int> sizes;
    sizes << _imp->_toolBox->sizeHint().width() << width();
    _imp->_leftRightSplitter->setSizes_mt_safe(sizes);


    TabWidget* propertiesPane = mainPane->splitHorizontally(false);
    TabWidget* workshopPane = mainPane->splitVertically(false);
    Splitter* propertiesSplitter = dynamic_cast<Splitter*>( propertiesPane->parentWidget() );
    assert(propertiesSplitter);
    sizes.clear();
    sizes << width() * 0.65 << width() * 0.35;
    propertiesSplitter->setSizes_mt_safe(sizes);

    TabWidget::moveTab(_imp->_nodeGraphArea, _imp->_nodeGraphArea, workshopPane);
    TabWidget::moveTab(_imp->_curveEditor, _imp->_curveEditor, workshopPane);
    TabWidget::moveTab(_imp->_dopeSheetEditor, _imp->_dopeSheetEditor, workshopPane);
    TabWidget::moveTab(_imp->_propertiesBin, _imp->_propertiesBin, propertiesPane);

    {
        QMutexLocker l(&_imp->_viewerTabsMutex);
        for (std::list<ViewerTab*>::iterator it2 = _imp->_viewerTabs.begin(); it2 != _imp->_viewerTabs.end(); ++it2) {
            TabWidget::moveTab(*it2, *it2, mainPane);
        }
    }
    {
        QMutexLocker l(&_imp->_histogramsMutex);
        for (std::list<Histogram*>::iterator it2 = _imp->_histograms.begin(); it2 != _imp->_histograms.end(); ++it2) {
            TabWidget::moveTab(*it2, *it2, mainPane);
        }
    }


    ///Default to NodeGraph displayed
    workshopPane->makeCurrentTab(0);
}
예제 #2
0
void TabWidget::closePane() {
    /*If it is floating we do not need to re-arrange the splitters containing the tab*/
    if (isFloating()) {
        parentWidget()->close();
        return;
    }
    
    Splitter* container = dynamic_cast<Splitter*>(parentWidget());
    if(!container) {
        return;
    }
    
    
    /*Removing it from the _panes vector*/
    _gui->removePane(this);
    
    /*Only sub-panes are closable. That means the splitter owning them must also
     have a splitter as parent*/
    Splitter* parentContainer = dynamic_cast<Splitter*>(container->parentWidget());
    if(!parentContainer) {
        return;
    }
    
    QList<int> mainContainerSizes = parentContainer->sizes();

    
    /*identifying the other tab*/
    QWidget* other = 0;
    getOtherTabWidget(container,this,other);
    assert(other);
    
    bool vertical;
    bool removeOk = false;
    
    {
        Splitter*  parentSplitter = container;
        ///The only reason becasue this is not ok is because we split this TabWidget again
        while (!removeOk && parentSplitter) {
            
            for (int i = 0; i < parentSplitter->count(); ++i) {
                TabWidget* tab = dynamic_cast<TabWidget*>(parentSplitter->widget(i));
                if (tab && tab != this) {
                    removeOk = tab->removeSplit(this,&vertical);
                    if (removeOk) {
                        break;
                    }
                }
            }
            
            parentSplitter = dynamic_cast<Splitter*>(parentSplitter->parentWidget());
        }
    }
    
    ///iterate recursively over parents splitter to find a tabwidget where to move the tabs
    TabWidget* firstParentTabWidget = NULL;
    getTabWidgetRecursively(parentContainer,firstParentTabWidget);
    assert(firstParentTabWidget);
    Splitter* firstParentSplitter = dynamic_cast<Splitter*>(firstParentTabWidget->parentWidget());
    assert(firstParentSplitter);

    ///move this tab's splits to the first parent tab widget
    for (std::map<TabWidget*,bool>::iterator it = _userSplits.begin();it != _userSplits.end();++it) {
        firstParentTabWidget->_userSplits.insert(*it);
        removeTagNameRecursively(it->first,!vertical);
    }
    
    
    
    /*Removing "what" from the container and delete it*/
    setVisible(false);
    //move all its tabs to the  firstParentTabWidget
    
    while(count() > 0) {
        moveTab(tabAt(0), firstParentTabWidget);
    }
    
    // delete what;
    
    /*Removing the container from the mainContainer*/
    int subSplitterIndex = 0;
    for (int i = 0; i < parentContainer->count(); ++i) {
        Splitter* subSplitter = dynamic_cast<Splitter*>(parentContainer->widget(i));
        if (subSplitter && subSplitter == container) {
            subSplitterIndex = i;
            container->setVisible(false);
            container->setParent(0);
            break;
        }
    }
    /*moving the other to the mainContainer*/
    parentContainer->insertWidget(subSplitterIndex, other);
    other->setVisible(true);
    other->setParent(parentContainer);
    
    ///restore the main container sizes
    parentContainer->setSizes_mt_safe(mainContainerSizes);
    
    /*deleting the subSplitter*/
    _gui->removeSplitter(container);
    delete container;
}