From: vsv Date: Tue, 15 Apr 2014 12:32:42 +0000 (+0400) Subject: Issue #24 X-Git-Tag: V_0.2~155 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=275ece832cdc1cf885819efdc18d8c52636928be;p=modules%2Fshaper.git Issue #24 --- diff --git a/src/XGUI/XGUI_ViewWindow.cpp b/src/XGUI/XGUI_ViewWindow.cpp index 3803cabea..4e4e54c72 100644 --- a/src/XGUI/XGUI_ViewWindow.cpp +++ b/src/XGUI/XGUI_ViewWindow.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -77,9 +78,11 @@ const char* imageCrossCursor[] = { "32 32 3 1", ". c None", "a c #000000", "# c "................................", "................................", "................................", "................................" }; -//************************************************************************** -void ViewerToolbar::repaintBackground() + +void ViewerToolbar::paintEvent(QPaintEvent* theEvent) { + // Paint background + QPainter aPainter(this); QRect aRect = rect(); QRect aVPRect = myVPort->rect(); QPoint aGlobPnt = mapToGlobal(aRect.topLeft()); @@ -87,13 +90,16 @@ void ViewerToolbar::repaintBackground() QRect aImgRect(QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), aRect.width(), aRect.height())); - QPainter(this).drawImage(aRect, myVPort->dumpView(aImgRect, false)); -} + aPainter.drawImage(aRect, myVPort->dumpView(aImgRect, false)); -void ViewerToolbar::paintEvent(QPaintEvent* theEvent) -{ - repaintBackground(); - //QToolBar::paintEvent(theEvent); + // Paint foreground + QStyle *style = this->style(); + QStyleOptionToolBar aOpt; + initStyleOption(&aOpt); + + aOpt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &aOpt, this); + if (aOpt.rect.isValid()) + style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &aOpt, &aPainter, this); } //************************************************************************** @@ -248,9 +254,9 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) myWindowBar->addAction(aBtn); connect(aBtn, SIGNAL(triggered()), SLOT(onClose())); - myViewBar->hide(); - myWindowBar->hide(); - myGripWgt->hide(); + //myViewBar->hide(); + //myWindowBar->hide(); + //myGripWgt->hide(); //Support copy of background on updating of viewer connect(myViewPort, SIGNAL(vpTransformed()), this, SLOT(updateToolBar())); @@ -286,24 +292,43 @@ void XGUI_ViewWindow::changeEvent(QEvent* theEvent) if (theEvent->type() == QEvent::WindowStateChange) { if (isMinimized()) { - myViewBar->hide(); - myGripWgt->hide(); - myWindowBar->hide(); - myViewPort->hide(); + myViewBar->hide(); + myGripWgt->hide(); + myWindowBar->hide(); + myViewPort->hide(); myPicture->show(); } else { myPicture->hide(); - myViewPort->show(); + myViewPort->show(); if (isMaximized()) { myMinimizeBtn->setIcon(MinimizeIco); myMaximizeBtn->setIcon(RestoreIco); } + myViewBar->setVisible(isActiveWindow()); + myWindowBar->setVisible(isActiveWindow()); + myGripWgt->setVisible(isActiveWindow() && (!isMaximized())); } } else QWidget::changeEvent(theEvent); } + +void XGUI_ViewWindow::windowActivated() +{ + myViewBar->show(); + myWindowBar->show(); + myGripWgt->setVisible(!(isMaximized() || isMinimized())); +} + +void XGUI_ViewWindow::windowDeactivated() +{ + myViewBar->hide(); + myWindowBar->hide(); + myGripWgt->hide(); +} + + //**************************************************************** void XGUI_ViewWindow::onClose() { @@ -317,7 +342,7 @@ void XGUI_ViewWindow::onClose() } //**************************************************************** -void XGUI_ViewWindow::enterEvent(QEvent* theEvent) +/*void XGUI_ViewWindow::enterEvent(QEvent* theEvent) { if (!isMinimized()) { myViewBar->show(); @@ -333,7 +358,7 @@ void XGUI_ViewWindow::leaveEvent(QEvent* theEvent) myViewBar->hide(); myGripWgt->hide(); myWindowBar->hide(); -} +}*/ //**************************************************************** void XGUI_ViewWindow::onMinimize() diff --git a/src/XGUI/XGUI_ViewWindow.h b/src/XGUI/XGUI_ViewWindow.h index 0c3ae8a17..14e5ccf52 100644 --- a/src/XGUI/XGUI_ViewWindow.h +++ b/src/XGUI/XGUI_ViewWindow.h @@ -174,14 +174,17 @@ public slots: //! Reset point of view void reset(); + void windowActivated(); + + void windowDeactivated(); protected: virtual void resizeEvent(QResizeEvent* theEvent); virtual void changeEvent(QEvent* theEvent); - virtual void enterEvent(QEvent* theEvent); - virtual void leaveEvent(QEvent* theEvent); + //virtual void enterEvent(QEvent* theEvent); + //virtual void leaveEvent(QEvent* theEvent); virtual bool eventFilter(QObject *theObj, QEvent *theEvent); @@ -299,8 +302,6 @@ public: setAttribute(Qt::WA_PaintOnScreen); } - void repaintBackground(); - protected: virtual void paintEvent(QPaintEvent* theEvent); diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp index 0f6e40282..dc5faa611 100644 --- a/src/XGUI/XGUI_Viewer.cpp +++ b/src/XGUI/XGUI_Viewer.cpp @@ -145,6 +145,10 @@ XGUI_Viewer::XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron) } // set zooming style to standard //myZoomingStyle = 0; + + QMdiArea* aMDI = myMainWindow->mdiArea(); + connect(aMDI, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(onWindowActivated(QMdiSubWindow*))); + } XGUI_Viewer::~XGUI_Viewer(void) @@ -412,5 +416,12 @@ void XGUI_Viewer::addView(QMdiSubWindow* theView) */ void XGUI_Viewer::onWindowActivated(QMdiSubWindow* view) { + if (view && (view != myActiveView)) { myActiveView = view; + ((XGUI_ViewWindow*)myActiveView->widget())->windowActivated(); + QList::iterator aIt; + for (aIt = myViews.begin(); aIt != myViews.end(); ++aIt) + if ((*aIt) != myActiveView) + ((XGUI_ViewWindow*)(*aIt)->widget())->windowDeactivated(); + } } diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h index 6afdf36ec..4b29bb1f1 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -135,9 +135,9 @@ private: double myTrihedronSize; - QList myViews; + QList myViews; - QMdiSubWindow* myActiveView; + QMdiSubWindow* myActiveView; }; #endif