void ContentWindowGraphicsItem::drawMovieControls_( QPainter* painter ) { ContentWindowManagerPtr contentWindowManager = getContentWindowManager(); float buttonWidth, buttonHeight; getButtonDimensions(buttonWidth, buttonHeight); QPen pen; if( contentWindowManager->getContent()->getType() == CONTENT_TYPE_MOVIE && g_configuration->getOptions()->getShowMovieControls( )) { // play/pause QRectF playPauseRect(coordinates_.x() + coordinates_.width()/2 - buttonWidth, coordinates_.y() + coordinates_.height() - buttonHeight, buttonWidth, buttonHeight); pen.setColor(QColor(contentWindowManager->getControlState() & STATE_PAUSED ? 128 :200,0,0)); painter->setPen(pen); painter->fillRect(playPauseRect, pen.color()); // loop QRectF loopRect(coordinates_.x() + coordinates_.width()/2, coordinates_.y() + coordinates_.height() - buttonHeight, buttonWidth, buttonHeight); pen.setColor(QColor(0,contentWindowManager->getControlState() & STATE_LOOP ? 200 :128,0)); painter->setPen(pen); painter->fillRect(loopRect, pen.color()); } }
void MovieContent::advance(FactoriesPtr factories, ContentWindowManagerPtr window, const boost::posix_time::time_duration timeSinceLastFrame) { // Stop decoding when the window is moving to avoid saccades when reaching a new GLWindow // The decoding resumes when the movement is finished if( blockAdvance_ ) return; boost::shared_ptr< Movie > movie = factories->getMovieFactory().getObject(getURI()); // skip a frame if the Content rectangle is not visible in any window; otherwise decode normally const bool skipDecoding = !movie->getRenderContext()->isRegionVisible(window->getCoordinates()); movie->setPause( window->getControlState() & STATE_PAUSED ); movie->setLoop( window->getControlState() & STATE_LOOP ); movie->nextFrame(timeSinceLastFrame, skipDecoding); }
void ContentWindowGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent * event) { // on Mac we've seen that mouse events can go to the wrong graphics item // this is due to the bug: https://bugreports.qt.nokia.com/browse/QTBUG-20493 // here we ignore the event if it shouldn't have been sent to us, which ensures // it will go to the correct item... if(boundingRect().contains(event->pos()) == false) { event->ignore(); return; } // button dimensions float buttonWidth, buttonHeight; getButtonDimensions(buttonWidth, buttonHeight); // item rectangle and event position QRectF r = boundingRect(); QPointF eventPos = event->pos(); // check to see if user clicked on the close button if(fabs((r.x()+r.width()) - eventPos.x()) <= buttonWidth && fabs(r.y() - eventPos.y()) <= buttonHeight) { close(); return; } // move to the front of the GUI display moveToFront(); ContentWindowManagerPtr contentWindow = getContentWindowManager(); if (!contentWindow) return; if (selected()) { contentWindow->getInteractionDelegate().mousePressEvent(event); return; } contentWindow->getContent()->blockAdvance( true ); // check to see if user clicked on the resize button if(fabs((r.x()+r.width()) - eventPos.x()) <= buttonWidth && fabs((r.y()+r.height()) - eventPos.y()) <= buttonHeight) { resizing_ = true; } // check to see if user clicked on the fullscreen button else if(fabs(r.x() - eventPos.x()) <= buttonWidth && fabs((r.y()+r.height()) - eventPos.y()) <= buttonHeight) { toggleFullscreen(); } else if(fabs(((r.x()+r.width())/2) - eventPos.x() - buttonWidth) <= buttonWidth && fabs((r.y()+r.height()) - eventPos.y()) <= buttonHeight && g_configuration->getOptions()->getShowMovieControls( )) { contentWindow->setControlState( ControlState(contentWindow->getControlState() ^ STATE_PAUSED) ); } else if(fabs(((r.x()+r.width())/2) - eventPos.x()) <= buttonWidth && fabs((r.y()+r.height()) - eventPos.y()) <= buttonHeight && g_configuration->getOptions()->getShowMovieControls( )) { contentWindow->setControlState( ControlState(contentWindow->getControlState() ^ STATE_LOOP) ); } else moving_ = true; QGraphicsItem::mousePressEvent(event); }