Degree RollLayout::GetScrollDirection() const { Degree scrollDirection(0.0f); if (mOrientation == ControlOrientation::Up) { scrollDirection = 0.0f; } else if (mOrientation == ControlOrientation::Left) { scrollDirection = 90.0f; } else if (mOrientation == ControlOrientation::Down) { scrollDirection = 180.0f; } else // mOrientation == ControlOrientation::Right { scrollDirection = 270.0f; } return scrollDirection; }
void HgGridContainer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { HgContainer::paint(painter, option, widget); // Draw these only while pinching if(mPinchingOngoing) { const QPen& oldPen = painter->pen(); // dim the background, i.e. draw trasparent black screen-sized rect (alpha is 100 of 255) painter->fillRect(rect(), QColor(0, 0, 0, 100)); QPen pen = painter->pen(); pen.setColor(Qt::white); pen.setWidth(4); painter->setPen(pen); int imageXCount; int imageYCount; int widthSpacingPlusImage; int heightSpacingPlusImage; // Use temp values that are updated during pinching QSize imageSize(mTempImageHeightForLineGrid, mTempImageHeightForLineGrid); if (scrollDirection() == Qt::Horizontal ) //landscape mode { imageXCount = rect().width() / imageSize.width(); imageYCount = mTempRowCount; widthSpacingPlusImage = mRenderer->getSpacing().height() + imageSize.height(); heightSpacingPlusImage = mRenderer->getSpacing().width() + imageSize.width(); } else //portrait mode { imageXCount = mTempRowCount; imageYCount = rect().height() / imageSize.height(); widthSpacingPlusImage = mRenderer->getSpacing().width() + imageSize.width(); heightSpacingPlusImage = mRenderer->getSpacing().height() + imageSize.height(); } int yOffset(0); if (scrollDirection() == Qt::Horizontal ) { yOffset = (rect().height() - (mUserItemSize.height()*mHorizontalRowCount))/2; } for (int xCounter = 0; xCounter < (imageXCount+1); ++xCounter) { for (int yCounter = 0; yCounter < (imageYCount+1); ++yCounter) { painter->drawLine(QPoint(0, yOffset + yCounter * heightSpacingPlusImage), QPoint(rect().width(), yOffset + yCounter * heightSpacingPlusImage)); } painter->drawLine(QPoint(xCounter * widthSpacingPlusImage, yOffset), QPoint(xCounter * widthSpacingPlusImage, rect().height()-yOffset)); } painter->setPen(oldPen); } updateSelectedItem(); }