Skip to content

Commit d3bcfb6

Browse files
authored
Merge pull request #25762 from cbjeukendrup/copy-by-dragging/prototype
Move by dragging, copy by alt+dragging
2 parents b92057c + fa8cf4a commit d3bcfb6

16 files changed

+937
-397
lines changed

src/engraving/dom/anchors.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ TimeTickAnchor::TimeTickAnchor(Segment* parent)
161161
TimeTickAnchor::DrawRegion TimeTickAnchor::drawRegion() const
162162
{
163163
const ShowAnchors& showAnchors = score()->showAnchors();
164-
Fraction thisTick = segment()->tick();
164+
const staff_idx_t thisStaffIdx = staffIdx();
165+
const Fraction thisTick = segment()->tick();
165166

166-
bool trackOutOfRange = staffIdx() != showAnchors.staffIdx;
167-
bool tickOutOfRange = thisTick < showAnchors.startTickExtendedRegion || thisTick >= showAnchors.endTickExtendedRegion;
167+
const bool trackOutOfRange = thisStaffIdx < showAnchors.staffIdx || thisStaffIdx >= showAnchors.endStaffIdx;
168+
const bool tickOutOfRange = thisTick < showAnchors.startTickExtendedRegion || thisTick >= showAnchors.endTickExtendedRegion;
168169
if (trackOutOfRange || tickOutOfRange) {
169170
return DrawRegion::OUT_OF_RANGE;
170171
}

src/engraving/dom/anchors.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,23 @@
2727
#include "score.h"
2828

2929
namespace mu::engraving {
30+
class Factory;
31+
3032
class EditTimeTickAnchors
3133
{
3234
public:
3335
static void updateAnchors(const EngravingItem* item, track_idx_t track);
36+
static void updateAnchors(Measure* measure, staff_idx_t staffIdx);
3437
static TimeTickAnchor* createTimeTickAnchor(Measure* measure, Fraction relTick, staff_idx_t staffIdx);
3538
static void updateLayout(Measure* measure);
36-
37-
private:
38-
static void updateAnchors(Measure* measure, staff_idx_t staffIdx);
3939
};
4040

4141
class TimeTickAnchor : public EngravingItem
4242
{
43-
public:
4443
TimeTickAnchor(Segment* parent);
44+
friend class Factory;
4545

46+
public:
4647
Segment* segment() const { return toSegment(parentItem()); }
4748

4849
TimeTickAnchor* clone() const override { return new TimeTickAnchor(*this); }

src/engraving/dom/cmd.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,11 +1431,13 @@ Fraction Score::makeGap(Segment* segment, track_idx_t track, const Fraction& _sd
14311431

14321432
bool Score::makeGap1(const Fraction& baseTick, staff_idx_t staffIdx, const Fraction& len, int voiceOffset[VOICES])
14331433
{
1434-
Segment* seg = tick2segment(baseTick, true, SegmentType::ChordRest);
1435-
if (!seg) {
1436-
LOGD("no segment to paste at tick %d", baseTick.ticks());
1434+
Measure* m = tick2measure(baseTick);
1435+
if (!m) {
1436+
LOGD() << "No measure to paste at tick " << baseTick.toString();
14371437
return false;
14381438
}
1439+
1440+
Segment* seg = m->undoGetSegment(SegmentType::ChordRest, baseTick);
14391441
track_idx_t strack = staffIdx * VOICES;
14401442
for (track_idx_t track = strack; track < strack + VOICES; track++) {
14411443
if (voiceOffset[track - strack] == -1) {

src/engraving/dom/score.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,11 @@ struct ShowAnchors {
217217
ShowAnchors() = default;
218218
ShowAnchors(voice_idx_t vIdx, staff_idx_t stfIdx, const Fraction& sTickMain, const Fraction& eTickMain,
219219
const Fraction& sTickExt, const Fraction& eTickExt)
220-
: voiceIdx(vIdx), staffIdx(stfIdx), startTickMainRegion(sTickMain), endTickMainRegion(eTickMain),
220+
: voiceIdx(vIdx), staffIdx(stfIdx), endStaffIdx(stfIdx + 1), startTickMainRegion(sTickMain), endTickMainRegion(eTickMain),
221+
startTickExtendedRegion(sTickExt), endTickExtendedRegion(eTickExt) {}
222+
ShowAnchors(voice_idx_t vIdx, staff_idx_t stfIdx, staff_idx_t endStfIdx, const Fraction& sTickMain, const Fraction& eTickMain,
223+
const Fraction& sTickExt, const Fraction& eTickExt)
224+
: voiceIdx(vIdx), staffIdx(stfIdx), endStaffIdx(endStfIdx), startTickMainRegion(sTickMain), endTickMainRegion(eTickMain),
221225
startTickExtendedRegion(sTickExt), endTickExtendedRegion(eTickExt) {}
222226

223227
void reset()
@@ -232,6 +236,7 @@ struct ShowAnchors {
232236

233237
voice_idx_t voiceIdx = muse::nidx;
234238
staff_idx_t staffIdx = muse::nidx;
239+
staff_idx_t endStaffIdx = muse::nidx;
235240
Fraction startTickMainRegion = Fraction(-1, 1);
236241
Fraction endTickMainRegion = Fraction(-1, 1);
237242
Fraction startTickExtendedRegion = Fraction(-1, 1);
@@ -536,6 +541,8 @@ class Score : public EngravingObject, public muse::Injectable
536541
void restoreInitialKeySigAndTimeSig();
537542
void reconnectSlurs(MeasureBase* mbStart, MeasureBase* mbLast);
538543
void cmdDeleteSelection();
544+
std::vector<ChordRest*> deleteRange(Segment* segStart, Segment* segEnd, track_idx_t trackStart, track_idx_t trackEnd,
545+
const SelectionFilter& filter);
539546
void cmdFullMeasureRest();
540547

541548
muse::Ret putNote(const PointF&, bool replace, bool insert);
@@ -1099,8 +1106,6 @@ class Score : public EngravingObject, public muse::Injectable
10991106
const SelectionFilter& filter);
11001107
void deleteAnnotationsFromRange(Segment* segStart, Segment* segEnd, track_idx_t trackStart, track_idx_t trackEnd,
11011108
const SelectionFilter& filter);
1102-
std::vector<ChordRest*> deleteRange(Segment* segStart, Segment* segEnd, track_idx_t trackStart, track_idx_t trackEnd,
1103-
const SelectionFilter& filter);
11041109

11051110
void update(bool resetCmdState, bool layoutAllParts = false);
11061111

src/engraving/rw/read410/read410.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ bool Read410::readScore410(Score* score, XmlReader& e, ReadContext& ctx)
305305

306306
bool Read410::pasteStaff(XmlReader& e, Segment* dst, staff_idx_t dstStaff, Fraction scale)
307307
{
308-
assert(dst->isChordRestType());
308+
assert(dst->isType(Segment::CHORD_REST_OR_TIME_TICK_TYPE));
309309

310310
Score* score = dst->score();
311311
ReadContext ctx(score);

src/notation/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ set(MODULE_SRC
203203
${CMAKE_CURRENT_LIST_DIR}/utilities/engravingitempreviewpainter.h
204204
${CMAKE_CURRENT_LIST_DIR}/utilities/percussionutilities.cpp
205205
${CMAKE_CURRENT_LIST_DIR}/utilities/percussionutilities.h
206+
${CMAKE_CURRENT_LIST_DIR}/utilities/scorerangeutilities.cpp
207+
${CMAKE_CURRENT_LIST_DIR}/utilities/scorerangeutilities.h
206208

207209
${WIDGETS_SRC}
208210
${STYLEDIALOG_SRC}

src/notation/inotationinteraction.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
* You should have received a copy of the GNU General Public License
2020
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2121
*/
22-
#ifndef MU_NOTATION_INOTATIONINTERACTION_H
23-
#define MU_NOTATION_INOTATIONINTERACTION_H
22+
#pragma once
2423

2524
#include <functional>
2625

@@ -29,7 +28,6 @@
2928
#include "notationtypes.h"
3029
#include "inotationnoteinput.h"
3130
#include "inotationselection.h"
32-
#include "actions/actiontypes.h"
3331

3432
class QKeyEvent;
3533
class QInputMethodEvent;
@@ -95,17 +93,21 @@ class INotationInteraction
9593
virtual void endDrag() = 0;
9694
virtual muse::async::Notification dragChanged() const = 0;
9795

98-
virtual bool isDragCopyStarted() const = 0;
99-
virtual bool dragCopyAllowed(const EngravingItem* element) const = 0;
100-
virtual void startDragCopy(const EngravingItem* element, QObject* dragSource) = 0;
101-
virtual void endDragCopy() = 0;
96+
virtual bool isOutgoingDragElementAllowed(const EngravingItem* element) const = 0;
97+
virtual void startOutgoingDragElement(const EngravingItem* element, QObject* dragSource) = 0;
98+
virtual void startOutgoingDragRange(QObject* dragSource) = 0;
99+
virtual bool isOutgoingDragStarted() const = 0;
100+
virtual void endOutgoingDrag() = 0;
102101

103102
// Drop
104103
//! TODO Change KeyboardModifiers to modes
105-
virtual void startDrop(const QByteArray& edata) = 0;
106-
virtual bool startDrop(const QUrl& url) = 0;
107-
virtual bool isDropAccepted(const muse::PointF& pos, Qt::KeyboardModifiers modifiers) = 0; //! NOTE Also may set drop target
108-
virtual bool drop(const muse::PointF& pos, Qt::KeyboardModifiers modifiers) = 0;
104+
virtual bool startDropSingle(const QByteArray& edata) = 0;
105+
virtual bool startDropRange(const QByteArray& data) = 0;
106+
virtual bool startDropImage(const QUrl& url) = 0;
107+
virtual bool isDropSingleAccepted(const muse::PointF& pos, Qt::KeyboardModifiers modifiers) = 0; //! NOTE Also may set drop target
108+
virtual bool isDropRangeAccepted(const muse::PointF& pos) = 0;
109+
virtual bool dropSingle(const muse::PointF& pos, Qt::KeyboardModifiers modifiers) = 0;
110+
virtual bool dropRange(const QByteArray& data, const muse::PointF& pos, bool deleteSourceMaterial) = 0;
109111
virtual void setDropTarget(EngravingItem* item, bool notify = true) = 0;
110112
virtual void setDropRect(const muse::RectF& rect) = 0;
111113
virtual void endDrop() = 0;
@@ -317,5 +319,3 @@ using INotationInteractionPtr = std::shared_ptr<INotationInteraction>;
317319

318320
EngravingItem* contextItem(INotationInteractionPtr);
319321
}
320-
321-
#endif // MU_NOTATION_INOTATIONINTERACTION_H

0 commit comments

Comments
 (0)