Skip to content

Commit

Permalink
implemented loop/loop-in/loop-out actions
Browse files Browse the repository at this point in the history
fixed rebase problems
  • Loading branch information
RomanPudashkin authored and igorkorsukov committed Feb 16, 2021
1 parent 46792a2 commit 9a5ad97
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 205 deletions.
10 changes: 0 additions & 10 deletions src/appshell/view/dockwindow/docktoolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,6 @@ bool DockToolBar::movable() const
return toolBar()->isMovable();
}

bool DockToolBar::floating() const
{
return m_floating;
}

bool DockToolBar::floatable() const
{
return toolBar()->isFloatable();
}

void DockToolBar::setMinimumHeight(int minimumHeight)
{
if (m_minimumHeight == minimumHeight) {
Expand Down
1 change: 0 additions & 1 deletion src/framework/ui/view/iconcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ class IconCode
NOTE_DOTTED_2 = 0xF395,
NOTE_DOTTED_3 = 0xF396,
NOTE_DOTTED_4 = 0xF397,
MIDI_INPUT = 0xEF98,

NOTE_PLUS = 0xF39D,
NOTE_TO_RIGHT = 0xF39E,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ PopupView {
property color fillColor: ui.theme.backgroundPrimaryColor
readonly property int borderWidth: 1

function toggleOpened() {
if (isOpened) {
close()
} else {
open()
}
}

closePolicy: PopupView.CloseOnPressOutsideParent

onAboutToShow: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ Row {

property var font: ui.theme.tabFont

signal timeEdited(var newTime)

spacing: 4

opacity: enabled ? 1 : ui.theme.itemOpacityDisabled
Expand Down
2 changes: 0 additions & 2 deletions src/notation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/view/notationcontextmenu.h
${CMAKE_CURRENT_LIST_DIR}/view/notationnavigator.cpp
${CMAKE_CURRENT_LIST_DIR}/view/notationnavigator.h
${CMAKE_CURRENT_LIST_DIR}/view/undoredomodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/undoredomodel.h
${CMAKE_CURRENT_LIST_DIR}/view/internal/abstractnoteinputbaritem.cpp
${CMAKE_CURRENT_LIST_DIR}/view/internal/abstractnoteinputbaritem.h
${CMAKE_CURRENT_LIST_DIR}/view/internal/actionnoteinputbaritem.cpp
Expand Down
9 changes: 8 additions & 1 deletion src/notation/inotationplayback.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ class INotationPlayback

virtual midi::MidiData playElementMidiData(const Element* element) const = 0;

virtual void addLoopBoundaryToSelectedNote(LoopBoundaryType boundaryType) = 0;
enum BoundaryTick: int {
FirstScoreTick = -3,
SelectedNoteTick,
LastScoreTick
};

virtual void addLoopBoundary(LoopBoundaryType boundaryType, int tick) = 0;
virtual void removeLoopBoundary() = 0;
virtual async::Channel<LoopBoundary> loopBoundaryChanged() const = 0;

virtual Tempo tempo(int tick) const = 0;
Expand Down
41 changes: 27 additions & 14 deletions src/notation/internal/notationplayback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,44 +569,58 @@ MidiData NotationPlayback::playHarmonyMidiData(const Ms::Harmony* harmony) const
return midiData;
}

void NotationPlayback::addLoopBoundaryToSelectedNote(LoopBoundaryType boundaryType)
void NotationPlayback::addLoopBoundary(LoopBoundaryType boundaryType, int tick)
{
if (tick == BoundaryTick::FirstScoreTick) {
tick = score()->firstMeasure()->tick().ticks();
} else if (tick == BoundaryTick::LastScoreTick) {
tick = score()->lastMeasure()->endTick().ticks();
}

switch (boundaryType) {
case LoopBoundaryType::LoopIn:
addLoopInToSelectedNote();
addLoopIn(tick);
break;
case LoopBoundaryType::LoopOut:
addLoopOutToSelectedNote();
addLoopOut(tick);
break;
case LoopBoundaryType::Unknown:
break;
}
}

void NotationPlayback::addLoopInToSelectedNote()
void NotationPlayback::addLoopIn(int _tick)
{
Fraction tick = score()->pos();
Fraction tick = _tick == BoundaryTick::SelectedNoteTick ? score()->pos() : Fraction::fromTicks(_tick);

if (tick >= score()->loopOutTick()) { // If In pos >= Out pos, reset Out pos to end of score
score()->setPos(Ms::POS::RIGHT, score()->lastMeasure()->endTick());
score()->setLoopOutTick(score()->lastMeasure()->endTick());
}

score()->setPos(Ms::POS::LEFT, tick);
score()->setLoopInTick(tick);
}

void NotationPlayback::addLoopOutToSelectedNote()
void NotationPlayback::addLoopOut(int _tick)
{
Fraction tick = score()->pos() + score()->inputState().ticks();
Fraction tick = _tick == BoundaryTick::SelectedNoteTick ? score()->pos() + score()->inputState().ticks() :
Fraction::fromTicks(_tick);

if (tick <= score()->loopInTick()) { // If Out pos <= In pos, reset In pos to beginning of score
score()->setPos(Ms::POS::LEFT, Fraction(0, 1));
score()->setLoopInTick(Fraction(0, 1));
} else {
if (tick > score()->lastMeasure()->endTick()) {
tick = score()->lastMeasure()->endTick();
}
}

score()->setPos(Ms::POS::RIGHT, tick);
score()->setLoopOutTick(tick);
}

void NotationPlayback::removeLoopBoundary()
{
Fraction null = Fraction::fromTicks(0);
score()->setLoopInTick(null);
score()->setLoopOutTick(null);
}

QRect NotationPlayback::loopBoundaryRectByTick(LoopBoundaryType boundaryType, int _tick) const
Expand Down Expand Up @@ -712,13 +726,12 @@ MeasureBeat NotationPlayback::measureBeat(int tick) const
{
MeasureBeat measureBeat;

int dummy = 0;

if (score() && score()->checkHasMeasures()) {
int dummy = 0;
score()->sigmap()->tickValues(tick, &measureBeat.measureIndex, &measureBeat.beatIndex, &dummy);

measureBeat.maxMeasureIndex = score()->measures()->size() - 1;
measureBeat.maxBeatIndex = 4; // TODO
measureBeat.maxBeatIndex = score()->sigmap()->timesig(Fraction::fromTicks(tick)).timesig().numerator() - 1;
}

return measureBeat;
Expand Down
7 changes: 4 additions & 3 deletions src/notation/internal/notationplayback.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class NotationPlayback : public INotationPlayback, public async::Asyncable

midi::MidiData playElementMidiData(const Element* element) const override;

void addLoopBoundaryToSelectedNote(LoopBoundaryType boundaryType) override;
void addLoopBoundary(LoopBoundaryType boundaryType, int tick) override;
void removeLoopBoundary() override;
async::Channel<LoopBoundary> loopBoundaryChanged() const override;

Tempo tempo(int tick) const override;
Expand Down Expand Up @@ -88,8 +89,8 @@ class NotationPlayback : public INotationPlayback, public async::Asyncable
midi::MidiData playChordMidiData(const Ms::Chord* chord) const;
midi::MidiData playHarmonyMidiData(const Ms::Harmony* harmony) const;

void addLoopInToSelectedNote();
void addLoopOutToSelectedNote();
void addLoopIn(int tick);
void addLoopOut(int tick);
QRect loopBoundaryRectByTick(LoopBoundaryType boundaryType, int tick) const;

IGetScore* m_getScore = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/notation/notationmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#include "view/widgets/selectdialog.h"
#include "view/widgets/tupletdialog.h"
#include "view/notationcontextmenu.h"
#include "view/undoredomodel.h"
#include "view/internal/undoredomodel.h"

using namespace mu::notation;
using namespace mu::framework;
Expand Down
5 changes: 5 additions & 0 deletions src/notation/notationtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ struct LoopBoundary

QRect loopInRect;
QRect loopOutRect;

bool isNull() const
{
return loopInTick == 0 && loopOutTick == 0;
}
};

inline QString staffTypeToString(StaffType type)
Expand Down
4 changes: 2 additions & 2 deletions src/notation/view/internal/undoredomodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
// Copyright (C) 2021 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
Expand All @@ -25,7 +25,7 @@ using namespace mu::notation;
using namespace mu::actions;
using namespace mu::uicomponents;

UndoRedoModel::UndoRedoModel(QObject *parent)
UndoRedoModel::UndoRedoModel(QObject* parent)
: QObject(parent)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/notation/view/internal/undoredomodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
// Copyright (C) 2021 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
Expand Down
4 changes: 2 additions & 2 deletions src/notation/view/notationpaintview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ void NotationPaintView::updateLoopMarkers(const LoopBoundary& boundary)
m_loopInMarker->setRect(boundary.loopInRect);
m_loopOutMarker->setRect(boundary.loopOutRect);

m_loopInMarker->setVisible(true);
m_loopOutMarker->setVisible(true);
m_loopInMarker->setVisible(!boundary.isNull());
m_loopOutMarker->setVisible(!boundary.isNull());

update();
}
Expand Down
83 changes: 0 additions & 83 deletions src/notation/view/undoredomodel.cpp

This file was deleted.

58 changes: 0 additions & 58 deletions src/notation/view/undoredomodel.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ StyledPopup {
Layout.preferredWidth: width

icon: IconCode.PLUS
hint: addButton.ToolTip.text

hint: qsTrc("palette", "Add %1 palette").arg(model.display)
Accessible.description: ToolTip.text
Expand Down
Loading

0 comments on commit 9a5ad97

Please sign in to comment.