void colorDialog::setColorSelected(QRgb color, int x, int y) { curMode_->setCurrentGridSelection(pairOfInts(x, y)); colorSelected_ = color; QPixmap colorPatch = *(leftRightColorPatch_->pixmap()); QPainter painter; painter.begin(&colorPatch); painter.fillRect(LR_BORDER + LR_BOX, LR_BORDER, LR_BOX, LR_BOX, QColor(color)); painter.drawRect(LR_BORDER + LR_BOX, LR_BORDER, LR_BOX, LR_BOX); painter.end(); leftRightColorPatch_->setPixmap(colorPatch); if (x == 0 && y == 0) { leftButton_->setEnabled(false); } else { leftButton_->setEnabled(true); } if (pairOfInts(x, y) == curMode_->getMaxGridCoordinates()) { rightButton_->setEnabled(false); } else { rightButton_->setEnabled(true); } }
void detailTool::processDetailEvent(int boxX, int boxY, Qt::MouseButtons buttons) { const pairOfInts boxCoordinates(boxX, boxY); if (buttons & Qt::LeftButton) { // add if (!dragCache_.squaresVisited.contains(pixel(boxCoordinates))) { const int squareDim = parent()->curImage_->originalDimension(); QRgb squareColor = parent()->curImage_->image().pixel(boxX*squareDim, boxY*squareDim); QRgb oppositeColor = triC(squareColor).opposite().qrgb(); parent()->activeSquareLabel()->addHashSquare(pixel(oppositeColor, pairOfInts(boxX, boxY))); dragCache_.squaresVisited.insert(pixel(squareColor, boxCoordinates)); } } else if (buttons & Qt::RightButton) { // remove if (dragCache_.squaresVisited.remove(pixel(boxCoordinates))) { const int squareDim = parent()->curImage_->originalDimension(); QRgb squareColor = parent()->curImage_->image().pixel(boxX*squareDim, boxY*squareDim); parent()->activeSquareLabel()->removeHashSquare(pixel(squareColor, boxCoordinates)); if (dragCache_.squaresVisited.isEmpty()) { parent()->toolDock_->detailListIsEmpty(true); } } } }
dockListUpdate mutableSquareImageContainer:: commitChangeOneDrag(const QSet<pairOfInts>& squares, flossColor newColor) { const QRgb newRgbColor = newColor.qrgb(); const bool colorAdded = addColor(newColor); QVector<pixel> historyPixels; QVector<triC> pixelColors; for (QSet<pairOfInts>::const_iterator it = squares.begin(), end = squares.end(); it != end; ++it) { const int x = it->x() * originalDimension_; const int y = it->y() * originalDimension_; const QRgb thisColor = image_.pixel(x, y); pixelColors.push_back(thisColor); historyPixels.push_back(pixel(thisColor, pairOfInts(x, y))); } ::changeBlocks(&image_, historyPixels, newRgbColor, originalDimension_); addToHistory(historyItemPtr(new changeOneHistoryItem(newColor, colorAdded, historyPixels))); colorListCheckNeeded_ = true; return dockListUpdate(newRgbColor, colorAdded); }