Skip to content

Commit

Permalink
Fix musescore#7819 - adjustment to previous page-clipping fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryArefiev authored and wizofaus committed Sep 23, 2024
2 parents dd5ba30 + d0e01a7 commit 3e6e49c
Show file tree
Hide file tree
Showing 9 changed files with 440 additions and 435 deletions.
26 changes: 13 additions & 13 deletions src/appshell/internal/applicationuiactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ const UiActionList ApplicationUiActions::m_actions = {

// Toolbars
UiAction("toggle-transport",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "&Playback controls"),
TranslatableString("action", "Show/hide playback controls"),
Checkable::Yes
),
UiAction("toggle-noteinput",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_ANY,
TranslatableString("action", "&Note input"),
TranslatableString("action", "Show/hide note input toolbar"),
Expand All @@ -118,28 +118,28 @@ const UiActionList ApplicationUiActions::m_actions = {

// Vertical panels
UiAction("toggle-palettes",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_ANY,
TranslatableString("action", "&Palettes"),
TranslatableString("action", "Show/hide palettes"),
Checkable::Yes
),
UiAction("toggle-instruments",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_ANY,
TranslatableString("action", "Instr&uments"),
TranslatableString("action", "Open instruments dialog…"),
Checkable::Yes
),
UiAction("inspector",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_ANY,
TranslatableString("action", "Propert&ies"),
TranslatableString("action", "Show/hide properties"),
Checkable::Yes
),
UiAction("toggle-selection-filter",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "Se&lection filter"),
TranslatableString("action", "Show/hide selection filter"),
Expand All @@ -148,7 +148,7 @@ const UiActionList ApplicationUiActions::m_actions = {

// Navigator
UiAction(TOGGLE_NAVIGATOR_ACTION_CODE,
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_ANY,
TranslatableString("action", "&Navigator"),
TranslatableString("action", "Show/hide navigator"),
Expand All @@ -157,7 +157,7 @@ const UiActionList ApplicationUiActions::m_actions = {

// Braille panel
UiAction(TOGGLE_BRAILLE_ACTION_CODE,
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_ANY,
TranslatableString("action", "&Braille"),
TranslatableString("action", "Show/hide braille panel"),
Expand All @@ -166,22 +166,22 @@ const UiActionList ApplicationUiActions::m_actions = {

// Horizontal panels
UiAction("toggle-timeline",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_ANY,
TranslatableString("action", "Tim&eline"),
TranslatableString("action", "Show/hide timeline"),
Checkable::Yes
),
UiAction("toggle-mixer",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_ANY,
TranslatableString("action", "Mixer"),
TranslatableString("action", "Show/hide mixer"),
IconCode::Code::MIXER,
Checkable::Yes
),
UiAction("toggle-piano-keyboard",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_ANY,
TranslatableString("action", "Piano &keyboard"),
TranslatableString("action", "Show/hide piano keyboard"),
Expand All @@ -196,15 +196,15 @@ const UiActionList ApplicationUiActions::m_actions = {
// Checkable::Yes
// ),
UiAction("toggle-scorecmp-tool",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "Score comparison tool"),
Checkable::Yes
),

// Status bar
UiAction("toggle-statusbar",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "&Status bar"),
TranslatableString("action", "Show/hide status bar"),
Expand Down
19 changes: 9 additions & 10 deletions src/context/internal/uicontextresolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ UiContext UiContextResolver::currentUiContext() const
INavigationPanel* activePanel = navigationController()->activePanel();
if (activePanel) {
if (activePanel->name() == NOTATION_NAVIGATION_PANEL) {
return context::UiCtxNotationFocused;
return context::UiCtxProjectFocused;
}
}

return context::UiCtxNotationOpened;
return context::UiCtxProjectOpened;
}

return context::UiCtxUnknown;
Expand All @@ -128,8 +128,7 @@ bool UiContextResolver::match(const muse::ui::UiContext& currentCtx, const muse:
return true;
}

//! NOTE If the current context is `UiCtxNotationFocused`, then we allow `UiCtxNotationOpened` too
if (currentCtx == context::UiCtxNotationFocused && actCtx == context::UiCtxNotationOpened) {
if (actCtx == context::UiCtxProjectOpened && globalContext()->currentNotation()) {
return true;
}

Expand Down Expand Up @@ -164,13 +163,13 @@ bool UiContextResolver::isShortcutContextAllowed(const std::string& scContext) c
//! NotationStaffTab

if (CTX_NOTATION_OPENED == scContext) {
return matchWithCurrent(context::UiCtxNotationOpened);
return matchWithCurrent(context::UiCtxProjectOpened);
} else if (CTX_NOTATION_FOCUSED == scContext) {
return matchWithCurrent(context::UiCtxNotationFocused);
return matchWithCurrent(context::UiCtxProjectFocused);
} else if (CTX_NOT_NOTATION_FOCUSED == scContext) {
return !matchWithCurrent(context::UiCtxNotationFocused);
return !matchWithCurrent(context::UiCtxProjectFocused);
} else if (CTX_NOTATION_NOT_NOTE_INPUT_STAFF_TAB == scContext) {
if (!matchWithCurrent(context::UiCtxNotationFocused)) {
if (!matchWithCurrent(context::UiCtxProjectFocused)) {
return false;
}
auto notation = globalContext()->currentNotation();
Expand All @@ -180,7 +179,7 @@ bool UiContextResolver::isShortcutContextAllowed(const std::string& scContext) c
auto noteInput = notation->interaction()->noteInput();
return !noteInput->isNoteInputMode() || noteInput->state().staffGroup != mu::engraving::StaffGroup::TAB;
} else if (CTX_NOTATION_NOTE_INPUT_STAFF_TAB == scContext) {
if (!matchWithCurrent(context::UiCtxNotationFocused)) {
if (!matchWithCurrent(context::UiCtxProjectFocused)) {
return false;
}
auto notation = globalContext()->currentNotation();
Expand All @@ -190,7 +189,7 @@ bool UiContextResolver::isShortcutContextAllowed(const std::string& scContext) c
auto noteInput = notation->interaction()->noteInput();
return noteInput->isNoteInputMode() && noteInput->state().staffGroup == mu::engraving::StaffGroup::TAB;
} else if (CTX_NOTATION_TEXT_EDITING == scContext) {
if (!matchWithCurrent(context::UiCtxNotationFocused)) {
if (!matchWithCurrent(context::UiCtxProjectFocused)) {
return false;
}
auto notation = globalContext()->currentNotation();
Expand Down
4 changes: 2 additions & 2 deletions src/context/uicontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ static constexpr muse::ui::UiContext UiCtxUnknown = muse::ui::UiCtxUnknown;
static constexpr muse::ui::UiContext UiCtxAny = muse::ui::UiCtxAny;

static constexpr muse::ui::UiContext UiCtxHomeOpened = muse::ui::UiCtxHomeOpened;
static constexpr muse::ui::UiContext UiCtxNotationOpened = muse::ui::UiCtxProjectOpened;
static constexpr muse::ui::UiContext UiCtxNotationFocused = muse::ui::UiCtxProjectFocused;
static constexpr muse::ui::UiContext UiCtxProjectOpened = muse::ui::UiCtxProjectOpened;
static constexpr muse::ui::UiContext UiCtxProjectFocused = muse::ui::UiCtxProjectFocused;
}

#endif // MU_CONTEXT_UICONTEXT_H
6 changes: 6 additions & 0 deletions src/engraving/rendering/score/paint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ void Paint::paintScore(Painter* painter, Score* score, const IScoreRenderer::Pai

painter->beginObject("page_" + std::to_string(pi));

if (painter->hasClipping() && (drawRect.top() < pageAbsRect.top() || drawRect.bottom() > pageAbsRect.bottom()
|| drawRect.left() < pageAbsRect.left() || drawRect.right() > pageAbsRect.right())) {
// prevent elements from being drawn off the edge of the page (e.g. too many staves)
painter->setClipRect(pageAbsRect.intersected(drawRect));
}

if (opt.isMultiPage) {
painter->translate(pagePos);
} else if (opt.trimMarginPixelSize >= 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/instrumentsscene/internal/instrumentsuiactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ using namespace muse::actions;

const UiActionList InstrumentsUiActions::m_actions = {
UiAction("instruments",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_ANY,
TranslatableString("action", "Add/remove instruments…"),
TranslatableString("action", "Add/remove instruments…")
),
UiAction("change-instrument",
mu::context::UiCtxNotationOpened,
mu::context::UiCtxProjectOpened,
mu::context::CTX_NOTATION_OPENED,
TranslatableString("action", "Select instrument…"),
TranslatableString("action", "Select instrument…")
Expand Down
2 changes: 1 addition & 1 deletion src/notation/internal/notationactioncontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,7 @@ bool NotationActionController::canRedo() const

bool NotationActionController::isNotationPage() const
{
return uiContextResolver()->matchWithCurrent(context::UiCtxNotationOpened);
return uiContextResolver()->matchWithCurrent(context::UiCtxProjectOpened);
}

bool NotationActionController::isStandardStaff() const
Expand Down
Loading

0 comments on commit 3e6e49c

Please sign in to comment.