Skip to content

Commit

Permalink
Merge pull request #7580 from RomanPudashkin/notation_stabilization
Browse files Browse the repository at this point in the history
[MU4] Notation stabilization
  • Loading branch information
Eism committed Feb 20, 2021
2 parents 6196893 + 5dcb049 commit cc3c72a
Show file tree
Hide file tree
Showing 44 changed files with 559 additions and 306 deletions.
4 changes: 0 additions & 4 deletions src/appshell/qml/MainToolBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ Rectangle {
title: qsTrc("appshell", "Score"),
uri: "musescore://notation"
},
{
title: qsTrc("appshell", "Sequencer"),
uri: "musescore://sequencer"
},
{
title: qsTrc("appshell", "Publish"),
uri: "musescore://publish"
Expand Down
2 changes: 2 additions & 0 deletions src/appshell/qml/PublishPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ DockPage {
objectName: "publishCentral"

Rectangle {
color: ui.theme.backgroundSecondaryColor

StyledTextLabel {
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
Expand Down
6 changes: 3 additions & 3 deletions src/appshell/qml/Window.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ DockWindow {
toolbars: [
DockToolBar {
objectName: "mainToolBar"
minimumWidth: 376
minimumWidth: 282
minimumHeight: dockWindow.toolbarHeight

color: dockWindow.color
Expand All @@ -70,7 +70,7 @@ DockWindow {

DockToolBar {
objectName: "notationToolBar"
minimumWidth: 188
minimumWidth: 192
minimumHeight: dockWindow.toolbarHeight

color: dockWindow.color
Expand All @@ -86,7 +86,7 @@ DockWindow {
id: playbackToolBar

objectName: "playbackToolBar"
minimumWidth: floating ? 492 : 420
minimumWidth: floating ? 508 : 430
minimumHeight: floating ? 76 : dockWindow.toolbarHeight

color: dockWindow.color
Expand Down
3 changes: 2 additions & 1 deletion src/appshell/view/dockwindow/dockwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ void DockWindow::componentComplete()
togglePage(nullptr, currentPage());

m_window->show();
updateStyle();

m_isComponentComplete = true;
}
Expand Down Expand Up @@ -161,6 +160,8 @@ void DockWindow::togglePage(DockPage* old, DockPage* current)
if (current) {
showPage(current);
}

updateStyle();
}

void DockWindow::hidePage(DockPage* page)
Expand Down
5 changes: 5 additions & 0 deletions src/framework/audio/internal/worker/sequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ void Sequencer::pause()
void Sequencer::stop()
{
ONLY_AUDIO_WORKER_THREAD;

if (m_status == STOPED) {
return;
}

m_nextStatus = STOPED;
rewind();
}
Expand Down
9 changes: 7 additions & 2 deletions src/framework/ui/internal/uiconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,14 @@ std::string UiConfiguration::iconsFontFamily() const
return settings()->value(UI_ICONS_FONT_FAMILY_KEY).toString();
}

int UiConfiguration::iconsFontSize() const
int UiConfiguration::iconsFontSize(IconSizeType type) const
{
return fontSize(FontSizeType::TAB);
switch (type) {
case IconSizeType::Regular: return 16;
case IconSizeType::Toolbar: return 20;
}

return 16;
}

Notification UiConfiguration::iconsFontChanged() const
Expand Down
2 changes: 1 addition & 1 deletion src/framework/ui/internal/uiconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class UiConfiguration : public IUiConfiguration
async::Notification fontChanged() const override;

std::string iconsFontFamily() const override;
int iconsFontSize() const override;
int iconsFontSize(IconSizeType type) const override;
async::Notification iconsFontChanged() const override;

std::string musicalFontFamily() const override;
Expand Down
1 change: 1 addition & 0 deletions src/framework/ui/itheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ITheme : MODULE_EXPORT_INTERFACE
virtual QFont titleBoldFont() const = 0;

virtual QFont iconsFont() const = 0;
virtual QFont toolbarIconsFont() const = 0;
virtual QFont musicalFont() const = 0;

virtual qreal accentOpacityNormal() const = 0;
Expand Down
7 changes: 6 additions & 1 deletion src/framework/ui/iuiconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,17 @@ class IUiConfiguration : MODULE_EXPORT_INTERFACE
TITLE
};

enum class IconSizeType {
Regular,
Toolbar
};

virtual std::string fontFamily() const = 0;
virtual int fontSize(FontSizeType type) const = 0;
virtual async::Notification fontChanged() const = 0;

virtual std::string iconsFontFamily() const = 0;
virtual int iconsFontSize() const = 0;
virtual int iconsFontSize(IconSizeType type) const = 0;
virtual async::Notification iconsFontChanged() const = 0;

virtual std::string musicalFontFamily() const = 0;
Expand Down
14 changes: 12 additions & 2 deletions src/framework/ui/view/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ QFont Theme::iconsFont() const
return m_iconsFont;
}

QFont Theme::toolbarIconsFont() const
{
return m_toolbarIconsFont;
}

QFont Theme::musicalFont() const
{
return m_musicalFont;
Expand Down Expand Up @@ -335,8 +340,13 @@ void Theme::setupUiFonts()

void Theme::setupIconsFont()
{
m_iconsFont.setFamily(QString::fromStdString(configuration()->iconsFontFamily()));
m_iconsFont.setPixelSize(configuration()->iconsFontSize());
QString family = QString::fromStdString(configuration()->iconsFontFamily());

m_iconsFont.setFamily(family);
m_iconsFont.setPixelSize(configuration()->iconsFontSize(IUiConfiguration::IconSizeType::Regular));

m_toolbarIconsFont.setFamily(family);
m_toolbarIconsFont.setPixelSize(configuration()->iconsFontSize(IUiConfiguration::IconSizeType::Toolbar));
}

void Theme::setupMusicFont()
Expand Down
4 changes: 4 additions & 0 deletions src/framework/ui/view/theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class Theme : public QObject, public ITheme, public async::Asyncable
Q_PROPERTY(QFont titleBoldFont READ titleBoldFont NOTIFY dataChanged)

Q_PROPERTY(QFont iconsFont READ iconsFont NOTIFY dataChanged)
Q_PROPERTY(QFont toolbarIconsFont READ toolbarIconsFont NOTIFY dataChanged)

Q_PROPERTY(QFont musicalFont READ musicalFont NOTIFY dataChanged)

public:
Expand Down Expand Up @@ -96,6 +98,7 @@ class Theme : public QObject, public ITheme, public async::Asyncable
QFont titleBoldFont() const override;

QFont iconsFont() const override;
QFont toolbarIconsFont() const override;
QFont musicalFont() const override;

qreal accentOpacityNormal() const override;
Expand Down Expand Up @@ -138,6 +141,7 @@ class Theme : public QObject, public ITheme, public async::Asyncable
QFont m_headerBoldFont;
QFont m_titleBoldFont;
QFont m_iconsFont;
QFont m_toolbarIconsFont;
QFont m_musicalFont;

async::Notification m_themeChanged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Item {
property int maxValue: 999
property int value: 0

property bool addLeadingZeros: true
property int displayedNumberLength: maxValue.toString().length

property alias font: textField.font

signal valueEdited(var newValue)
Expand All @@ -22,12 +25,14 @@ Item {
QtObject {
id: privateProperties

property int maxNumberLength: root.maxValue.toString().length

function pad(value) {
var str = value.toString()

while (str.length < maxNumberLength) {
if (!addLeadingZeros) {
return str;
}

while (str.length < root.displayedNumberLength) {
str = "0" + str
}

Expand All @@ -48,22 +53,20 @@ Item {
text: privateProperties.pad(root.value)

onTextEdited: {
var currentValue = parseInt(text)
var currentValue = text.length > 0 ? parseInt(text) : 0
var str = currentValue.toString()
var newValue = 0

if (str.length > privateProperties.maxNumberLength || currentValue > root.maxValue) {
if (str.length > privateProperties.displayedNumberLength || currentValue > root.maxValue) {
var lastDigit = str.charAt(str.length - 1)
newValue = parseInt(lastDigit)
} else {
newValue = currentValue
}

if (newValue > root.maxValue) {
newValue = value
}

newValue = Math.min(newValue, root.maxValue)
text = privateProperties.pad(newValue)

root.valueEdited(newValue)
}

Expand All @@ -73,7 +76,6 @@ Item {
color: "transparent"
}

cursorDelegate: Item {}
selectByMouse: false

color: ui.theme.fontPrimaryColor
Expand All @@ -95,6 +97,7 @@ Item {

onClicked: {
textField.forceActiveFocus()
textField.cursorPosition = textField.text.length
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Row {
maxValue: hoursField.value === root.maxTime.getHours() ? root.maxTime.getMinutes() : 60
value: root.time.getMinutes()

displayedNumberLength: 2
font: root.font

onValueEdited: {
Expand All @@ -65,6 +66,7 @@ Row {
maxValue: minutesField.value === root.maxTime.getMinutes() ? root.maxTime.getSeconds() : 60
value: root.time.getSeconds()

displayedNumberLength: 2
font: root.font

onValueEdited: {
Expand Down
2 changes: 1 addition & 1 deletion src/libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Fraction Score::pos()
break;
}
}
return Fraction(-1, 1);
return Fraction(0, 1);
}

//---------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/notation/inotationconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class INotationConfiguration : MODULE_EXPORT_INTERFACE
virtual ValCh<bool> isNavigatorVisible() const = 0;
virtual void setNavigatorVisible(bool visible) = 0;

virtual ValCh<framework::Orientation> navigatorOrientation() const = 0;
virtual void setNavigatorOrientation(framework::Orientation orientation) = 0;
virtual ValCh<framework::Orientation> canvasOrientation() const = 0;
virtual void setCanvasOrientation(framework::Orientation orientation) = 0;
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/notation/inotationplayback.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class INotationPlayback
};

virtual void addLoopBoundary(LoopBoundaryType boundaryType, int tick) = 0;
virtual void removeLoopBoundaries() = 0;
virtual async::Channel<LoopBoundaries> loopBoundariesChanged() const = 0;
virtual void setLoopBoundariesVisible(bool visible) = 0;
virtual ValCh<LoopBoundaries> loopBoundaries() const = 0;

virtual Tempo tempo(int tick) const = 0;
virtual MeasureBeat beat(int tick) const = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/notation/internal/notation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void Notation::init()
Ms::MScore::setNudgeStep10(1.0); // Ctrl + cursor key (default 1.0)
Ms::MScore::setNudgeStep50(0.01); // Alt + cursor key (default 0.01)

bool isVertical = configuration()->navigatorOrientation().val == framework::Orientation::Vertical;
bool isVertical = configuration()->canvasOrientation().val == framework::Orientation::Vertical;
Ms::MScore::setVerticalOrientation(isVertical);

Ms::MScore::pixelRatio = Ms::DPI / QGuiApplication::primaryScreen()->logicalDotsPerInch();
Expand Down
6 changes: 6 additions & 0 deletions src/notation/internal/notationactioncontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ void NotationActionController::init()
dispatcher()->reg(this, "tempo", [this]() { addText(TextType::TEMPO); });

dispatcher()->reg(this, "toggle-navigator", this, &NotationActionController::toggleNavigator);
dispatcher()->reg(this, "toggle-mixer", this, &NotationActionController::toggleMixer);

for (int i = MIN_NOTES_INTERVAL; i <= MAX_NOTES_INTERVAL; ++i) {
if (isNotesIntervalValid(i)) {
Expand Down Expand Up @@ -984,6 +985,11 @@ void NotationActionController::toggleNavigator()
configuration()->setNavigatorVisible(!visible);
}

void NotationActionController::toggleMixer()
{
NOT_IMPLEMENTED;
}

void NotationActionController::startNoteInputIfNeed()
{
auto interaction = currentNotationInteraction();
Expand Down
1 change: 1 addition & 0 deletions src/notation/internal/notationactioncontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class NotationActionController : public actions::Actionable
void openTupletOtherDialog();

void toggleNavigator();
void toggleMixer();

bool isTextEditting() const;

Expand Down
Loading

0 comments on commit cc3c72a

Please sign in to comment.