Skip to content
Snippets Groups Projects
Commit 185e66ca authored by BATON Theau's avatar BATON Theau
Browse files

Amélioration de Pixeleraiser

parent da1b6ce4
Branches
No related tags found
No related merge requests found
......@@ -2,18 +2,26 @@
namespace tool {
Pixeleraiser::Pixeleraiser(const ColorPickerWidget & cp)
: Editable(cp, "Gomme Pixel", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-eraser.png")), _leftButton(false) {}
: Editable(cp, "Gomme Pixel", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-eraser.png")), _leftButton(false), _rightButton(false) {}
void Pixeleraiser::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) {
if(e.button() == Qt::LeftButton) {
this->_leftButton = true;
}
if(e.button() == Qt::RightButton) {
this->_rightButton = true;
}
}
void Pixeleraiser::onMouseReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) {
if(e.button() == Qt::LeftButton) {
this->_leftButton = false;
}
if(e.button() == Qt::RightButton) {
this->_rightButton = false;
}
}
void Pixeleraiser::onMouseMoved(ui::ImageArea & a, QImage &, const QPoint & p, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget &, bool hold) {
......@@ -25,5 +33,13 @@ namespace tool {
a.setColor(p, QColor(0, 0, 0, 0));
}
}
else if(hold && this->_rightButton) {
if(s.empty()) {
a.setColor(p, QColorConstants::White);
}
else if(s.contain(p)) {
a.setColor(p, QColorConstants::White);
}
}
}
}
......@@ -6,6 +6,7 @@ namespace tool {
class Pixeleraiser : public Editable {
private:
bool _leftButton;
bool _rightButton;
public:
Pixeleraiser(const ColorPickerWidget &);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment