Fixed ability to draw blank lines in photo editor.

This commit is contained in:
23rd 2021-05-08 17:17:30 +03:00
parent a631a28092
commit a91efd9164
4 changed files with 13 additions and 23 deletions

View file

@ -66,11 +66,6 @@ Paint::Paint(
_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
_view->setStyleSheet(kViewStyle.utf8());
_scene->addsItem(
) | rpl::start_with_next([=] {
updateUndoState();
}, lifetime());
// Undo / Redo.
controllers->undoController->performRequestChanges(
) | rpl::start_with_next([=](const Undo &command) {
@ -138,10 +133,10 @@ Paint::Paint(
? controllers->stickersPanelController->stickerChosen(
) | rpl::to_empty
: rpl::never<>(),
_scene->mousePresses()
_scene->addsItem()
) | rpl::start_with_next([=] {
_hasUndo = true;
clearRedoList();
updateUndoState();
}, lifetime());
}

View file

@ -71,7 +71,6 @@ void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event) {
return;
}
_canvas->handleMousePressEvent(event);
_mousePresses.fire({});
}
void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
@ -94,10 +93,6 @@ void Scene::applyBrush(const QColor &color, float size) {
_canvas->applyBrush(color, size);
}
rpl::producer<> Scene::mousePresses() const {
return _mousePresses.events();
}
rpl::producer<> Scene::addsItem() const {
return _addsItem.events();
}

View file

@ -36,7 +36,6 @@ public:
void removeItem(not_null<QGraphicsItem*> item);
void removeItem(const ItemPtr &item);
[[nodiscard]] rpl::producer<> addsItem() const;
[[nodiscard]] rpl::producer<> mousePresses() const;
[[nodiscard]] std::vector<MTPInputDocument> attachedStickers() const;
protected:
@ -51,7 +50,6 @@ private:
float64 _lastLineZ = 0.;
int _itemNumber = 0;
rpl::event_stream<> _mousePresses;
rpl::event_stream<> _addsItem;
rpl::lifetime _lifetime;

View file

@ -168,16 +168,18 @@ void ItemCanvas::handleMouseReleaseEvent(
}
_drawing = false;
const auto scaledContentRect = QRectF(
_contentRect.x() * cRetinaFactor(),
_contentRect.y() * cRetinaFactor(),
_contentRect.width() * cRetinaFactor(),
_contentRect.height() * cRetinaFactor());
if (_contentRect.isValid()) {
const auto scaledContentRect = QRectF(
_contentRect.x() * cRetinaFactor(),
_contentRect.y() * cRetinaFactor(),
_contentRect.width() * cRetinaFactor(),
_contentRect.height() * cRetinaFactor());
_grabContentRequests.fire({
.pixmap = _pixmap.copy(scaledContentRect.toRect()),
.position = _contentRect.topLeft(),
});
_grabContentRequests.fire({
.pixmap = _pixmap.copy(scaledContentRect.toRect()),
.position = _contentRect.topLeft(),
});
}
clearPixmap();
update();
}