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

View file

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

View file

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

View file

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