Implemented "system-break", "page-break" and "section-break" actions

This commit is contained in:
Casper Jeukendrup 2021-06-22 00:10:46 +02:00 committed by Igor Korsukov
parent be18a0a7ab
commit 64080dac85
8 changed files with 43 additions and 3 deletions

View file

@ -4534,9 +4534,6 @@ void Score::cmd(const QString& cmd, EditData& ed)
{ "toggle-hide-empty", [](Score* cs, EditData&) { cs->cmdToggleHideEmpty(); } },
{ "set-visible", [](Score* cs, EditData&) { cs->cmdSetVisible(); } },
{ "unset-visible", [](Score* cs, EditData&) { cs->cmdUnsetVisible(); } },
{ "system-break", [](Score* cs, EditData&) { cs->cmdToggleLayoutBreak(LayoutBreak::Type::LINE); } },
{ "page-break", [](Score* cs, EditData&) { cs->cmdToggleLayoutBreak(LayoutBreak::Type::PAGE); } },
{ "section-break", [](Score* cs, EditData&) { cs->cmdToggleLayoutBreak(LayoutBreak::Type::SECTION); } },
{ "relayout", [](Score* cs, EditData&) { cs->cmdRelayout(); } },
{ "toggle-autoplace", [](Score* cs, EditData&) { cs->cmdToggleAutoplace(false); } },
{ "autoplace-enabled", [](Score* cs, EditData&) { cs->cmdToggleAutoplace(true); } },

View file

@ -128,6 +128,7 @@ public:
virtual void addTupletToSelectedChordRests(const TupletOptions& options) = 0;
virtual void addBeamToSelectedChordRests(BeamMode mode) = 0;
virtual void toggleLayoutBreak(LayoutBreakType breakType) = 0;
virtual void setBreaksSpawnInterval(BreaksSpawnIntervalType intervalType, int interval = 0) = 0;
virtual bool transpose(const TransposeOptions& options) = 0;
virtual void swapVoices(int voiceIndex1, int voiceIndex2) = 0;

View file

@ -165,6 +165,10 @@ void NotationActionController::init()
dispatcher()->reg(this, "first-element", this, &NotationActionController::firstElement);
dispatcher()->reg(this, "last-element", this, &NotationActionController::lastElement);
dispatcher()->reg(this, "system-break", [this]() { toggleLayoutBreak(LayoutBreakType::LINE); });
dispatcher()->reg(this, "page-break", [this]() { toggleLayoutBreak(LayoutBreakType::PAGE); });
dispatcher()->reg(this, "section-break", [this]() { toggleLayoutBreak(LayoutBreakType::SECTION); });
dispatcher()->reg(this, "split-measure", this, &NotationActionController::splitMeasure);
dispatcher()->reg(this, "join-measures", this, &NotationActionController::joinSelectedMeasures);
dispatcher()->reg(this, "insert-measures", this, &NotationActionController::selectMeasuresCountAndInsert);
@ -1071,6 +1075,16 @@ void NotationActionController::selectAll()
interaction->selectAll();
}
void NotationActionController::toggleLayoutBreak(LayoutBreakType breakType)
{
auto interaction = currentNotationInteraction();
if (!interaction) {
return;
}
interaction->toggleLayoutBreak(breakType);
}
void NotationActionController::splitMeasure()
{
auto interaction = currentNotationInteraction();

View file

@ -115,6 +115,8 @@ private:
void firstElement();
void lastElement();
void toggleLayoutBreak(LayoutBreakType breakType);
void splitMeasure();
void joinSelectedMeasures();
void selectMeasuresCountAndInsert();

View file

@ -2467,6 +2467,15 @@ void NotationInteraction::addBeamToSelectedChordRests(BeamMode mode)
notifyAboutNotationChanged();
}
void NotationInteraction::toggleLayoutBreak(LayoutBreakType breakType)
{
startEdit();
score()->cmdToggleLayoutBreak(breakType);
apply();
notifyAboutNotationChanged();
}
void NotationInteraction::setBreaksSpawnInterval(BreaksSpawnIntervalType intervalType, int interval)
{
interval = intervalType == BreaksSpawnIntervalType::MeasuresInterval ? interval : 0;

View file

@ -143,6 +143,7 @@ public:
void addTupletToSelectedChordRests(const TupletOptions& options) override;
void addBeamToSelectedChordRests(BeamMode mode) override;
void toggleLayoutBreak(LayoutBreakType breakType) override;
void setBreaksSpawnInterval(BreaksSpawnIntervalType intervalType, int interval = 0) override;
bool transpose(const TransposeOptions& options) override;
void swapVoices(int voiceIndex1, int voiceIndex2) override;

View file

@ -370,6 +370,21 @@ const UiActionList NotationUiActions::m_actions = {
QT_TRANSLATE_NOOP("action", "Exchange Voice 3-4"),
QT_TRANSLATE_NOOP("action", "Exchange voice 3-4")
),
UiAction("system-break",
mu::context::UiCtxNotationOpened,
QT_TRANSLATE_NOOP("action", "Toggle System Break"),
QT_TRANSLATE_NOOP("action", "Toggle 'System Break'")
),
UiAction("page-break",
mu::context::UiCtxNotationOpened,
QT_TRANSLATE_NOOP("action", "Toggle Page Break"),
QT_TRANSLATE_NOOP("action", "Toggle 'Page Break'")
),
UiAction("section-break",
mu::context::UiCtxNotationOpened,
QT_TRANSLATE_NOOP("action", "Toggle Section Break"),
QT_TRANSLATE_NOOP("action", "Toggle 'Section Break'")
),
UiAction("split-measure",
mu::context::UiCtxNotationOpened,
QT_TRANSLATE_NOOP("action", "Split Measure Before Selected Note/Rest"),

View file

@ -94,6 +94,7 @@ using TupletNumberType = Ms::TupletNumberType;
using TupletBracketType = Ms::TupletBracketType;
using GraceNoteType = Ms::NoteType;
using BeamMode = Ms::Beam::Mode;
using LayoutBreakType = Ms::LayoutBreak::Type;
using PageList = std::vector<const Page*>;
using StaffList = QList<const Staff*>;