Merge pull request #11639 from RomanPudashkin/input_text_to_text_frames

[MU4] Fix #11467: Textframes Cannot be Edited or Displayed
This commit is contained in:
Elnur Ismailzada 2022-05-16 17:16:56 +03:00 committed by GitHub
commit 65fbab76c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 27 deletions

View file

@ -916,7 +916,7 @@ QString Box::accessibleExtraInfo() const
QString TBox::accessibleExtraInfo() const
{
QString rez = _text->screenReaderInfo();
QString rez = m_text->screenReaderInfo();
return rez;
}

View file

@ -673,13 +673,19 @@ EngravingObjectList TBox::scanChildren() const
{
EngravingObjectList children;
if (_text) {
children.push_back(_text);
if (m_text) {
children.push_back(m_text);
}
return children;
}
void TBox::scanElements(void* data, void (* func)(void*, EngravingItem*), bool all)
{
m_text->scanElements(data, func, all);
Box::scanElements(data, func, all);
}
//---------------------------------------------------------
// dumpScoreTree
/// for debugging purposes

View file

@ -51,20 +51,20 @@ TBox::TBox(System* parent)
: VBox(ElementType::TBOX, parent)
{
setBoxHeight(Spatium(1));
_text = Factory::createText(this, TextStyleType::FRAME);
_text->setLayoutToParentWidth(true);
_text->setParent(this);
m_text = Factory::createText(this, TextStyleType::FRAME);
m_text->setLayoutToParentWidth(true);
m_text->setParent(this);
}
TBox::TBox(const TBox& tbox)
: VBox(tbox)
{
_text = Factory::copyText(*(tbox._text));
m_text = Factory::copyText(*(tbox.m_text));
}
TBox::~TBox()
{
delete _text;
delete m_text;
}
//---------------------------------------------------------
@ -77,16 +77,16 @@ void TBox::layout()
{
setPos(PointF()); // !?
bbox().setRect(0.0, 0.0, system()->width(), 0);
_text->layout();
m_text->layout();
qreal h = 0.;
if (_text->empty()) {
h = mu::draw::FontMetrics::ascent(_text->font());
if (m_text->empty()) {
h = mu::draw::FontMetrics::ascent(m_text->font());
} else {
h = _text->height();
h = m_text->height();
}
qreal y = topMargin() * DPMM;
_text->setPos(leftMargin() * DPMM, y);
m_text->setPos(leftMargin() * DPMM, y);
h += topMargin() * DPMM + bottomMargin() * DPMM;
bbox().setRect(0.0, 0.0, system()->width(), h);
@ -101,7 +101,7 @@ void TBox::write(XmlWriter& xml) const
{
xml.startObject(this);
Box::writeProperties(xml);
_text->write(xml);
m_text->write(xml);
xml.endObject();
}
@ -114,7 +114,7 @@ void TBox::read(XmlReader& e)
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "Text") {
_text->read(e);
m_text->read(e);
} else if (Box::readProperties(e)) {
} else {
e.unknown();
@ -131,9 +131,9 @@ EngravingItem* TBox::drop(EditData& data)
EngravingItem* e = data.dropElement;
switch (e->type()) {
case ElementType::TEXT:
_text->undoChangeProperty(Pid::TEXT, toText(e)->xmlText());
m_text->undoChangeProperty(Pid::TEXT, toText(e)->xmlText());
delete e;
return _text;
return m_text;
default:
return VBox::drop(data);
}
@ -148,7 +148,7 @@ void TBox::add(EngravingItem* e)
{
if (e->isText()) {
// does not normally happen, since drop() handles this directly
_text->undoChangeProperty(Pid::TEXT, toText(e)->xmlText());
m_text->undoChangeProperty(Pid::TEXT, toText(e)->xmlText());
e->added();
} else {
VBox::add(e);
@ -161,15 +161,15 @@ void TBox::add(EngravingItem* e)
void TBox::remove(EngravingItem* el)
{
if (el == _text) {
if (el == m_text) {
// does not normally happen, since Score::deleteItem() handles this directly
// but if it does:
// replace with new empty text element
// this keeps undo/redo happier than just clearing the text
LOGD("TBox::remove() - replacing _text");
_text = Factory::createText(this, TextStyleType::FRAME);
_text->setLayoutToParentWidth(true);
_text->setParent(this);
m_text = Factory::createText(this, TextStyleType::FRAME);
m_text->setLayoutToParentWidth(true);
m_text->setParent(this);
el->removed();
} else {
VBox::remove(el);

View file

@ -35,18 +35,17 @@ class Text;
class TBox : public VBox
{
Text* _text;
public:
TBox(System* parent);
TBox(const TBox&);
~TBox();
~TBox() override;
Text* text() const { return _text; }
Text* text() const { return m_text; }
// Score Tree functions
EngravingObject* scanParent() const override;
EngravingObjectList scanChildren() const override;
void scanElements(void* data, void (* func)(void*, EngravingItem*), bool all = true) override;
TBox* clone() const override { return new TBox(*this); }
@ -65,6 +64,9 @@ public:
Grip defaultGrip() const override;
bool needStartEditingAfterSelecting() const override { return false; }
private:
Text* m_text = nullptr;
};
} // namespace Ms
#endif

View file

@ -731,7 +731,7 @@ void NotationViewInputController::handleLeftClickRelease(const QPointF& releaseP
return;
}
if (interaction->isTextSelected() && interaction->textEditingAllowed(ctx.element)) {
if (interaction->textEditingAllowed(ctx.element)) {
dispatcher()->dispatch("edit-text", ActionData::make_arg1<PointF>(m_beginPoint));
}
}