diff --git a/framework/audio/engine/internal/fx/reverb/circularsamplebuffer.h b/framework/audio/engine/internal/fx/reverb/circularsamplebuffer.h index d74ad7c1dd..0df6a50d85 100644 --- a/framework/audio/engine/internal/fx/reverb/circularsamplebuffer.h +++ b/framework/audio/engine/internal/fx/reverb/circularsamplebuffer.h @@ -20,8 +20,7 @@ * along with this program. If not, see . */ -#ifndef MUSE_AUDIO_CIRCULARSAMPLEBUFFER_H -#define MUSE_AUDIO_CIRCULARSAMPLEBUFFER_H +#pragma once #include #include @@ -127,21 +126,21 @@ class CircularSampleBuffer public: void writeBlock(int startOffset, int n, const SampleT* sourceBlock) { - splitBlockOffsetFunction(startOffset, n, [=](int bufferOff, int sampleOff, int n) { + splitBlockOffsetFunction(startOffset, n, [this, sourceBlock](int bufferOff, int sampleOff, int n) { vo::copy(&sourceBlock[sampleOff], &m_buffer[bufferOff], n); }); } void readBlockWithGain(int startOffset, int n, SampleT* targetBlock, float gainFactor) const { - splitBlockOffsetFunction(startOffset, n, [=](int bufferOff, int sampleOff, int n) { + splitBlockOffsetFunction(startOffset, n, [this, targetBlock, gainFactor](int bufferOff, int sampleOff, int n) { vo::constantMultiply(&m_buffer[bufferOff], gainFactor, &targetBlock[sampleOff], n); }); } void readAddBlockWithGain(int startOffset, int n, SampleT* targetBlock, float gainFactor) const { - splitBlockOffsetFunction(startOffset, n, [=](int bufferOff, int sampleOff, int n) { + splitBlockOffsetFunction(startOffset, n, [this, targetBlock, gainFactor](int bufferOff, int sampleOff, int n) { vo::constantMultiplyAndAdd(&m_buffer[bufferOff], gainFactor, &targetBlock[sampleOff], n); }); } @@ -154,5 +153,3 @@ class CircularSampleBuffer int m_bufferSizeMask = 0; // 2^n-1 buffer mask }; } // namespace muse::audio::fx - -#endif // MUSE_AUDIO_CIRCULARSAMPLEBUFFER_H diff --git a/framework/draw/bufferedpaintprovider.cpp b/framework/draw/bufferedpaintprovider.cpp index ff911ae639..cd59f598cd 100644 --- a/framework/draw/bufferedpaintprovider.cpp +++ b/framework/draw/bufferedpaintprovider.cpp @@ -297,12 +297,12 @@ void BufferedPaintProvider::drawPolygon(const PointF* points, size_t pointCount, void BufferedPaintProvider::drawText(const PointF& point, const String& text) { - editableData().texts.push_back(DrawText { DrawText::Point, RectF(point, SizeF()), 0, text }); + editableData().texts.push_back(DrawText { DrawText::Point, RectF(point, SizeF()), {}, {}, text }); } -void BufferedPaintProvider::drawText(const RectF& rect, int flags, const String& text) +void BufferedPaintProvider::drawText(const RectF& rect, Alignment alignment, TextFlags textFlags, const String& text) { - editableData().texts.push_back(DrawText { DrawText::Rect, rect, flags, text }); + editableData().texts.push_back(DrawText { DrawText::Rect, rect, alignment, textFlags, text }); } void BufferedPaintProvider::drawSymbol(const PointF& point, char32_t ucs4Code) diff --git a/framework/draw/bufferedpaintprovider.h b/framework/draw/bufferedpaintprovider.h index 96b607f7de..bc44e242f2 100644 --- a/framework/draw/bufferedpaintprovider.h +++ b/framework/draw/bufferedpaintprovider.h @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef MUSE_DRAW_BUFFEREDPAINTPROVIDER_H -#define MUSE_DRAW_BUFFEREDPAINTPROVIDER_H + +#pragma once #include "ipaintprovider.h" #include "types/drawdata.h" @@ -71,7 +71,7 @@ class BufferedPaintProvider : public IPaintProvider void drawPolygon(const PointF* points, size_t pointCount, PolygonMode mode) override; void drawText(const PointF& point, const String& text) override; - void drawText(const RectF& rect, int flags, const String& text) override; + void drawText(const RectF& rect, Alignment alignment, TextFlags textFlags, const String& text) override; void drawSymbol(const PointF& point, char32_t ucs4Code) override; @@ -115,5 +115,3 @@ class BufferedPaintProvider : public IPaintProvider DrawObjectsLogger* m_drawObjectsLogger = nullptr; }; } - -#endif // MUSE_DRAW_BUFFEREDPAINTPROVIDER_H diff --git a/framework/draw/internal/qpainterprovider.cpp b/framework/draw/internal/qpainterprovider.cpp index 6d84612078..22b90c6400 100644 --- a/framework/draw/internal/qpainterprovider.cpp +++ b/framework/draw/internal/qpainterprovider.cpp @@ -242,9 +242,10 @@ void QPainterProvider::drawText(const PointF& point, const String& text) m_painter->drawText(p, t); } -void QPainterProvider::drawText(const RectF& rect, int flags, const String& text) +void QPainterProvider::drawText(const RectF& rect, Alignment alignment, TextFlags textFlags, const String& text) { - m_painter->drawText(rect.toQRectF(), flags, text); + int flags = static_cast(alignment) | static_cast(textFlags); + m_painter->drawText(rect.toQRectF(), flags, text.toQString()); } void QPainterProvider::drawSymbol(const PointF& point, char32_t ucs4Code) diff --git a/framework/draw/internal/qpainterprovider.h b/framework/draw/internal/qpainterprovider.h index e5b9421ad6..42b829b98e 100644 --- a/framework/draw/internal/qpainterprovider.h +++ b/framework/draw/internal/qpainterprovider.h @@ -75,7 +75,7 @@ class QPainterProvider : public IPaintProvider void drawPolygon(const PointF* points, size_t pointCount, PolygonMode mode) override; void drawText(const PointF& point, const String& text) override; - void drawText(const RectF& rect, int flags, const String& text) override; + void drawText(const RectF& rect, Alignment alignment, TextFlags textFlags, const String& text) override; void drawSymbol(const PointF& point, char32_t ucs4Code) override; diff --git a/framework/draw/ipaintprovider.h b/framework/draw/ipaintprovider.h index 2f442f9719..06215f96ee 100644 --- a/framework/draw/ipaintprovider.h +++ b/framework/draw/ipaintprovider.h @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef MUSE_DRAW_IPAINTPROVIDER_H -#define MUSE_DRAW_IPAINTPROVIDER_H + +#pragma once #include @@ -75,7 +75,7 @@ class IPaintProvider virtual void drawPolygon(const PointF* points, size_t pointCount, PolygonMode mode) = 0; virtual void drawText(const PointF& point, const String& text) = 0; - virtual void drawText(const RectF& rect, int flags, const String& text) = 0; + virtual void drawText(const RectF& rect, Alignment alignment, TextFlags textFlags, const String& text) = 0; virtual void drawSymbol(const PointF& point, char32_t ucs4Code) = 0; @@ -96,5 +96,3 @@ class IPaintProvider using IPaintProviderPtr = std::shared_ptr; } - -#endif // MUSE_DRAW_IPAINTPROVIDER_H diff --git a/framework/draw/painter.cpp b/framework/draw/painter.cpp index 023d327a4c..19d0f28991 100644 --- a/framework/draw/painter.cpp +++ b/framework/draw/painter.cpp @@ -444,13 +444,13 @@ void Painter::drawText(const PointF& point, const String& text) } } -void Painter::drawText(const RectF& rect, int flags, const String& text) +void Painter::drawText(const RectF& rect, Alignment alignment, TextFlags textFlags, const String& text) { applyFontSizeScaling(); - m_provider->drawText(rect, flags, text); + m_provider->drawText(rect, alignment, textFlags, text); if (extended) { - extended->drawText(rect, flags, text); + extended->drawText(rect, alignment, textFlags, text); } } diff --git a/framework/draw/painter.h b/framework/draw/painter.h index 550cd357a5..75b4879ba5 100644 --- a/framework/draw/painter.h +++ b/framework/draw/painter.h @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #pragma once #include @@ -131,7 +132,7 @@ class Painter void drawText(const PointF& point, const String& text); inline void drawText(double x, double y, const String& text); - void drawText(const RectF& rect, int flags, const String& text); + void drawText(const RectF& rect, Alignment alignment, TextFlags textFlags, const String& text); void drawSymbol(const PointF& point, char32_t ucs4Code); diff --git a/framework/draw/types/drawdata.h b/framework/draw/types/drawdata.h index 55572b99af..f2cfc5be2a 100644 --- a/framework/draw/types/drawdata.h +++ b/framework/draw/types/drawdata.h @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef MUSE_DRAW_BUFFEREDDRAWTYPES_H -#define MUSE_DRAW_BUFFEREDDRAWTYPES_H + +#pragma once #include @@ -81,11 +81,12 @@ struct DrawText { Mode mode = Mode::Undefined; RectF rect; // If mode is Point when use topLeft point - int flags = 0; + Alignment alignment = {}; + TextFlags textFlags = {}; String text; bool operator==(const DrawText& o) const { - return mode == o.mode && flags == o.flags && rect == o.rect && text == o.text; + return mode == o.mode && alignment == o.alignment && textFlags == o.textFlags && rect == o.rect && text == o.text; } bool operator!=(const DrawText& o) const { return !this->operator==(o); } @@ -175,4 +176,3 @@ struct Diff { } }; } -#endif // MUSE_DRAW_BUFFEREDDRAWTYPES_H diff --git a/framework/draw/types/drawtypes.h b/framework/draw/types/drawtypes.h index 00bcc08c01..fd908f5130 100644 --- a/framework/draw/types/drawtypes.h +++ b/framework/draw/types/drawtypes.h @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef MUSE_DRAW_DRAWTYPES_H -#define MUSE_DRAW_DRAWTYPES_H + +#pragma once #include "global/types/flags.h" @@ -86,6 +86,7 @@ enum class FillRule { WindingFill }; +// Keep in sync with Qt::AlignmentFlag (https://doc.qt.io/qt-6/qt.html#AlignmentFlag-enum) enum AlignmentFlag { AlignLeft = 0x0001, AlignLeading = AlignLeft, @@ -112,6 +113,7 @@ enum AlignmentFlag { DECLARE_FLAGS(Alignment, AlignmentFlag) DECLARE_OPERATORS_FOR_FLAGS(Alignment) +// Keep in sync with Qt::TextFlag (https://doc.qt.io/qt-6/qt.html#TextFlag-enum) enum TextFlag { TextSingleLine = 0x0100, TextDontClip = 0x0200, @@ -129,6 +131,7 @@ enum TextFlag { // size of a multi-variant string. TextLongestVariant = 0x80000 }; -} -#endif // MUSE_DRAW_DRAWTYPES_H +DECLARE_FLAGS(TextFlags, TextFlag) +DECLARE_OPERATORS_FOR_FLAGS(TextFlags) +} diff --git a/framework/draw/utils/drawdatacomp.cpp b/framework/draw/utils/drawdatacomp.cpp index 88b480a163..d2b7ff5c8c 100644 --- a/framework/draw/utils/drawdatacomp.cpp +++ b/framework/draw/utils/drawdatacomp.cpp @@ -339,7 +339,11 @@ static bool isEqual(const DrawText& v1, const DrawText& v2, DrawDataComp::Tolera return false; } - if (v1.flags != v2.flags) { + if (v1.alignment != v2.alignment) { + return false; + } + + if (v1.textFlags != v2.textFlags) { return false; } diff --git a/framework/draw/utils/drawdatajson.cpp b/framework/draw/utils/drawdatajson.cpp index 8a3df9c3d9..cfcde2af23 100644 --- a/framework/draw/utils/drawdatajson.cpp +++ b/framework/draw/utils/drawdatajson.cpp @@ -318,7 +318,8 @@ static JsonObject toObj(const DrawText& text) } else { o["rect"] = toArr(text.rect); } - o["flags"] = text.flags; + o["alignment"] = static_cast(text.alignment); + o["textFlags"] = static_cast(text.textFlags); o["text"] = text.text; return o; } @@ -334,7 +335,8 @@ static void fromObj(const JsonObject& obj, DrawText& text) fromArr(obj["rect"].toArray(), text.rect); text.mode = DrawText::Rect; } - text.flags = obj["flags"].toInt(); + text.alignment = static_cast(obj["alignment"].toInt()); + text.textFlags = static_cast(obj["textFlags"].toInt()); text.text = obj["text"].toString(); } diff --git a/framework/draw/utils/drawdatapaint.cpp b/framework/draw/utils/drawdatapaint.cpp index 4daaab495b..80c5335252 100644 --- a/framework/draw/utils/drawdatapaint.cpp +++ b/framework/draw/utils/drawdatapaint.cpp @@ -61,7 +61,7 @@ static void drawItem(IPaintProviderPtr& provider, const DrawData::Item& item, co if (t.mode == DrawText::Point) { provider->drawText(t.rect.topLeft(), t.text); } else { - provider->drawText(t.rect, t.flags, t.text); + provider->drawText(t.rect, t.alignment, t.textFlags, t.text); } } diff --git a/framework/testflow/internal/draw/abpaintprovider.cpp b/framework/testflow/internal/draw/abpaintprovider.cpp index 3b87f4887a..0643dd0df0 100644 --- a/framework/testflow/internal/draw/abpaintprovider.cpp +++ b/framework/testflow/internal/draw/abpaintprovider.cpp @@ -27,8 +27,6 @@ static const QColor REMOVED_COLOR("#cc0000"); static const QColor ADDED_COLOR("#009900"); -static const std::string NOTATION_DEFAULT_OBJ("notationview_default"); - using namespace muse::testflow; const std::shared_ptr& AbPaintProvider::instance() @@ -99,7 +97,7 @@ void AbPaintProvider::paintData(muse::draw::IPaintProviderPtr provider, const mu if (t.mode == DrawText::Point) { provider->drawText(t.rect.topLeft(), t.text); } else { - provider->drawText(t.rect, t.flags, t.text); + provider->drawText(t.rect, t.alignment, t.textFlags, t.text); } } diff --git a/framework/uicomponents/qml/Muse/UiComponents/abstracttableviewmodel.cpp b/framework/uicomponents/qml/Muse/UiComponents/abstracttableviewmodel.cpp index 188d55e75a..cfed5c4dda 100644 --- a/framework/uicomponents/qml/Muse/UiComponents/abstracttableviewmodel.cpp +++ b/framework/uicomponents/qml/Muse/UiComponents/abstracttableviewmodel.cpp @@ -128,7 +128,7 @@ void AbstractTableViewModel::insertRow(int row, const QVector& c endResetModel(); - QTimer::singleShot(100, [=](){ + QTimer::singleShot(100, [this, row](){ m_selectionModel->select(index(row, 0)); }); } @@ -154,7 +154,7 @@ void AbstractTableViewModel::removeRow(int row) emit m_selectionModel->selectionChanged(selectionItem, selectionItem); if (isRowValid(row)) { - QTimer::singleShot(100, [=](){ + QTimer::singleShot(100, [this, row](){ m_selectionModel->select(index(row, 0)); }); }