Skip to content

Commit

Permalink
Canvas: add 'applyPixelColor'
Browse files Browse the repository at this point in the history
color picker refactor part deux.
  • Loading branch information
rodlie committed Oct 22, 2024
1 parent 962452d commit af65b3e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ class CORE_EXPORT Canvas : public CanvasBase
void drawPathFinish(const qreal invScale);

const QColor pickPixelColor(const QPoint &pos);
void applyPixelColor(const QColor &color,
const bool &fill);

qreal mLastDRot = 0;
int mRotHalfCycles = 0;
Expand Down
21 changes: 21 additions & 0 deletions src/core/canvasmouseinteractions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,27 @@ const QColor Canvas::pickPixelColor(const QPoint &pos)
return QColor(img.pixel(0, 0));
}

void Canvas::applyPixelColor(const QColor &color,
const bool &fill)
{
if (!color.isValid()) { return; }
for (const auto& box : mSelectedBoxes) {
if (fill) {
auto settings = box->getFillSettings();
if (settings) {
settings->setCurrentColor(color, true);
box->fillStrokeSettingsChanged();
}
} else {
auto settings = box->getStrokeSettings();
if (settings) {
settings->setCurrentColor(color, true);
box->fillStrokeSettingsChanged();
}
}
}
}

void Canvas::handleLeftMouseRelease(const eMouseEvent &e) {
if(e.fMouseGrabbing) e.fReleaseMouse();
if(mCurrentNormalSegment.isValid()) {
Expand Down

0 comments on commit af65b3e

Please sign in to comment.