mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-06 11:52:58 +00:00
[img-editor] Fixed text orientation after rotating media.
This commit is contained in:
@@ -311,7 +311,7 @@ void Paint::applyBrush(const Brush &brush) {
|
||||
}
|
||||
|
||||
void Paint::createTextItem() {
|
||||
_scene->createTextAtCenter();
|
||||
_scene->createTextAtCenter(-_transform.angle);
|
||||
}
|
||||
|
||||
void Paint::clearSelection() {
|
||||
|
||||
@@ -584,7 +584,7 @@ void Scene::setupTextProxy(
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::createTextAtCenter() {
|
||||
void Scene::createTextAtCenter(int rotation) {
|
||||
if (_textEdit.proxy) {
|
||||
return;
|
||||
}
|
||||
@@ -626,9 +626,12 @@ void Scene::createTextAtCenter() {
|
||||
minTextWidth,
|
||||
maxTextWidth);
|
||||
proxy->setTextWidth(width);
|
||||
proxy->setPos(sceneCenter.x() - width / 2., sceneCenter.y());
|
||||
const auto anchor = QPointF(width / 2., 0.);
|
||||
proxy->setTransformOriginPoint(anchor);
|
||||
proxy->setPos(sceneCenter - anchor);
|
||||
};
|
||||
adjustWidth();
|
||||
proxy->setRotation(rotation);
|
||||
|
||||
QObject::connect(emojiDoc, &QTextDocument::contentsChanged, [=] {
|
||||
ReplaceEmoji(emojiDoc);
|
||||
@@ -758,8 +761,8 @@ void Scene::finishTextEditing(bool save) {
|
||||
? RecoverTextFromDocument(_textEdit.proxy->document()).trimmed()
|
||||
: QString();
|
||||
const auto proxyRect = _textEdit.proxy->boundingRect();
|
||||
const auto proxyCenter = _textEdit.proxy->pos()
|
||||
+ QPointF(proxyRect.width() / 2., proxyRect.height() / 2.);
|
||||
const auto proxyCenter = _textEdit.proxy->mapToScene(proxyRect.center());
|
||||
const auto proxyRotation = int(_textEdit.proxy->rotation());
|
||||
const auto lockedItem = _textEdit.item.lock();
|
||||
auto *existingItem = lockedItem
|
||||
? static_cast<ItemText*>(lockedItem.get())
|
||||
@@ -798,6 +801,7 @@ void Scene::finishTextEditing(bool save) {
|
||||
.size = size,
|
||||
.x = int(proxyCenter.x()),
|
||||
.y = int(proxyCenter.y()),
|
||||
.rotation = proxyRotation,
|
||||
.imageSize = imageSize,
|
||||
};
|
||||
auto item = std::make_shared<ItemText>(
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
void cancelDrawing();
|
||||
|
||||
void startTextEditing(ItemText *item);
|
||||
void createTextAtCenter();
|
||||
void createTextAtCenter(int rotation);
|
||||
void setTextColor(const QColor &color);
|
||||
void setSelectedTextColor(const QColor &color);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user