partially working, but really… not so
authormirabilos <tg@debian.org>
Sun, 2 Jun 2019 22:18:39 +0000 (00:18 +0200)
committermirabilos <mirabilos@evolvis.org>
Sun, 2 Jun 2019 22:18:39 +0000 (00:18 +0200)
debian/patches/experiments/factor-out-statusbar.diff
debian/patches/experiments/revert-restriking-patch.diff

index 0cbbb32..c86df60 100644 (file)
@@ -1,21 +1,55 @@
-Description: Factor out getInfoForElement()
+Description: Factor out Element::getFullAccessibleInfo() and barbeat()
 Author: mirabilos <m@mirbsd.org>
 Forwarded: no
 
---- a/mscore/scoreaccessibility.cpp
-+++ b/mscore/scoreaccessibility.cpp
-@@ -94,6 +94,44 @@ void ScoreAccessibility::clearAccessibil
-             }
+--- a/libmscore/element.cpp
++++ b/libmscore/element.cpp
+@@ -1998,4 +1998,79 @@ bool Element::isUserModified() const
+       return !visible() || !userOff().isNull() || (color() != MScore::defaultColor);
        }
  
-+QString ScoreAccessibility::getInfoForElement(Element* e)
++//---------------------------------------------------------
++//   barbeat
++//---------------------------------------------------------
++
++std::pair<int, float> Element::barbeat()
++      {
++      int bar = 0;
++      int beat = 0;
++      int ticks = 0;
++      TimeSigMap* tsm = this->score()->sigmap();
++      Element* p = this;
++      while(p && p->type() != Element::Type::SEGMENT && p->type() != Element::Type::MEASURE)
++            p = p->parent();
++
++      if (!p) {
++            return std::pair<int, float>(0, 0);
++            }
++      else if (p->type() == Element::Type::SEGMENT) {
++            Segment* seg = static_cast<Segment*>(p);
++            tsm->tickValues(seg->tick(), &bar, &beat, &ticks);
++            }
++      else if (p->type() == Element::Type::MEASURE) {
++            Measure* m = static_cast<Measure*>(p);
++            bar = m->no();
++            beat = -1;
++            ticks = 0;
++            }
++      return std::pair<int,float>(bar + 1, beat + 1 + ticks / static_cast<float>(MScore::division));
++      }
++
++//---------------------------------------------------------
++//   getFullAccessibleInfo
++//---------------------------------------------------------
++
++std::pair<QString, QString> Element::getFullAccessibleInfo(Score* score)
 +      {
-+      Element* el = e->isSpannerSegment() ? static_cast<SpannerSegment*>(e)->spanner() : e;
++      Element* el = this->isSpannerSegment() ? static_cast<SpannerSegment*>(this)->spanner() : this;
 +      QString barsAndBeats = "";
 +      std::pair<int, float> bar_beat;
 +      if (el->isSpanner()){
 +            Spanner* s = static_cast<Spanner*>(el);
-+            bar_beat = barbeat(s->startSegment());
++            bar_beat = s->startSegment()->barbeat();
 +            barsAndBeats += tr("Start Measure: %1; Start Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second));
 +            Segment* seg = s->endSegment();
 +            if(!seg)
@@ -26,11 +60,11 @@ Forwarded: no
 +                s->type() != Element::Type::TIE                                                )
 +                  seg = seg->prev1MM(Segment::Type::ChordRest);
 +
-+            bar_beat = barbeat(seg);
++            bar_beat = seg->barbeat();
 +            barsAndBeats += "; " + tr("End Measure: %1; End Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second));
 +            }
 +      else {
-+            std::pair<int, float>bar_beat = barbeat(el);
++            std::pair<int, float>bar_beat = el->barbeat();
 +            if (bar_beat.first) {
 +                  barsAndBeats += " " + tr("Measure: %1").arg(QString::number(bar_beat.first));
 +                  if (bar_beat.second)
@@ -38,18 +72,32 @@ Forwarded: no
 +                  }
 +            }
 +
-+      QString rez = e->accessibleInfo();
++      QString rez = this->accessibleInfo();
 +      if (!barsAndBeats.isEmpty())
 +            rez += "; " + barsAndBeats;
-+      if (e->staffIdx() + 1)
-+            rez += "; " + tr("Staff: %1").arg(QString::number(e->staffIdx() + 1));
-+      return rez;
++      QString staff = "";
++      if (this->staffIdx() + 1) {
++            rez += "; " + tr("Staff: %1").arg(QString::number(this->staffIdx() + 1));
++            staff = tr("Staff %1").arg(QString::number(this->staffIdx() + 1));
++            }
++      QString screenReaderRez = QString("%1%2 %3 %4").arg(this->screenReaderInfo()).arg(barsAndBeats).arg(staff).arg(this->accessibleExtraInfo());
++      return std::pair<QString, QString>(rez, screenReaderRez);
 +      }
-+
- void ScoreAccessibility::currentInfoChanged()
-       {
-       clearAccessibilityInfo();
-@@ -105,42 +143,11 @@ void ScoreAccessibility::currentInfoChan
+ }
+--- a/libmscore/element.h
++++ b/libmscore/element.h
+@@ -327,6 +327,8 @@ class Element : public QObject, public S
+       Element* findMeasure();
+       qreal spatium() const;
++      std::pair<int, float>barbeat();
++      std::pair<QString, QString>getFullAccessibleInfo(Score* score);
+       bool selected() const                   { return _selected;   }
+       virtual void setSelected(bool f)        { _selected = f;      }
+--- a/mscore/scoreaccessibility.cpp
++++ b/mscore/scoreaccessibility.cpp
+@@ -105,53 +105,15 @@ void ScoreAccessibility::currentInfoChan
              if (!e) {
                    return;
                    }
@@ -84,22 +132,80 @@ Forwarded: no
 -            QString rez = e->accessibleInfo();
 -            if (!barsAndBeats.isEmpty())
 -                  rez += "; " + barsAndBeats;
-+            QString rez = getInfoForElement(e);
-             QString staff = "";
-             if (e->staffIdx() + 1) {
-                   staff = tr("Staff %1").arg(QString::number(e->staffIdx() + 1));
+-
+-            QString staff = "";
+-            if (e->staffIdx() + 1) {
+-                  staff = tr("Staff %1").arg(QString::number(e->staffIdx() + 1));
 -                  rez = QString("%1; %2").arg(rez).arg(staff);
-                   }
+-                  }
+-
+-            statusBarLabel->setText(rez);
+-            QString screenReaderRez = QString("%1%2 %3 %4").arg(e->screenReaderInfo()).arg(barsAndBeats).arg(staff).arg(e->accessibleExtraInfo());
+-            score->setAccessibleInfo(screenReaderRez);
++            std::pair<QString, QString> rez = e->getFullAccessibleInfo(score);
++            statusBarLabel->setText(rez.first);
++            score->setAccessibleInfo(rez.second);
+             }
+       else if (score->selection().isRange()) {
+             QString barsAndBeats = "";
+             std::pair<int, float> bar_beat;
  
-             statusBarLabel->setText(rez);
+-            bar_beat = barbeat(score->selection().startSegment());
++            bar_beat = score->selection().startSegment()->barbeat();
+             barsAndBeats += " " + tr("Start Measure: %1; Start Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second));
+             Segment* endSegment = score->selection().endSegment();
+@@ -160,7 +122,7 @@ void ScoreAccessibility::currentInfoChan
+             else
+                   endSegment = endSegment->prev1MM();
+-            bar_beat = barbeat(endSegment);
++            bar_beat = endSegment->barbeat();
+             barsAndBeats += " " + tr("End Measure: %1; End Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second));
+             statusBarLabel->setText(tr("Range Selection") + barsAndBeats);
+             score->setAccessibleInfo(tr("Range Selection") + barsAndBeats);
+@@ -204,34 +166,4 @@ void ScoreAccessibility::updateAccessibi
+       QAccessibleValueChangeEvent ev(obj, w->score()->accessibleInfo());
+       QAccessible::updateAccessibility(&ev);
+       }
+-
+-std::pair<int, float> ScoreAccessibility::barbeat(Element *e)
+-      {
+-      if (!e) {
+-            return std::pair<int, float>(0, 0);
+-            }
+-
+-      int bar = 0;
+-      int beat = 0;
+-      int ticks = 0;
+-      TimeSigMap* tsm = e->score()->sigmap();
+-      Element* p = e;
+-      while(p && p->type() != Element::Type::SEGMENT && p->type() != Element::Type::MEASURE)
+-            p = p->parent();
+-
+-      if (!p) {
+-            return std::pair<int, float>(0, 0);
+-            }
+-      else if (p->type() == Element::Type::SEGMENT) {
+-            Segment* seg = static_cast<Segment*>(p);
+-            tsm->tickValues(seg->tick(), &bar, &beat, &ticks);
+-            }
+-      else if (p->type() == Element::Type::MEASURE) {
+-            Measure* m = static_cast<Measure*>(p);
+-            bar = m->no();
+-            beat = -1;
+-            ticks = 0;
+-            }
+-      return pair<int,float>(bar + 1, beat + 1 + ticks / static_cast<float>(MScore::division));
+-      }
+ }
 --- a/mscore/scoreaccessibility.h
 +++ b/mscore/scoreaccessibility.h
-@@ -36,6 +36,7 @@ public:
+@@ -30,7 +30,6 @@ private:
+       QMainWindow* mainWindow;
+       QLabel* statusBarLabel;
+       ScoreAccessibility(QMainWindow* statusBar);
+-      std::pair<int, float>barbeat(Element* e);
+ public:
        ~ScoreAccessibility();
-       void updateAccessibilityInfo();
-       void clearAccessibilityInfo();
-+      QString getInfoForElement(Element* e);
-       static void createInstance(QMainWindow* statusBar);
-       static ScoreAccessibility* instance();
-       void currentInfoChanged();
index 68d2320..28cff1a 100644 (file)
@@ -215,28 +215,31 @@ Forwarded: https://github.com/musescore/MuseScore/pull/3797
              out << qSetFieldWidth(5) << "   Type  = ";
 --- a/synthesizer/event.cpp
 +++ b/synthesizer/event.cpp
-@@ -375,6 +375,29 @@ void EventList::insert(const Event& e)
+@@ -14,6 +14,7 @@
+ #include "libmscore/xml.h"
+ #include "libmscore/note.h"
+ #include "libmscore/sig.h"
++#include "libmscore/tie.h"
+ #include "event.h"
+ namespace Ms {
+@@ -375,6 +376,24 @@ void EventList::insert(const Event& e)
  //   class EventMap::fixupMIDI
  //---------------------------------------------------------
  
-+static void logCollisionNote(ScoreAccessibility *sa, const Note *note, unsigned int indent)
++static void logCollisionNote(const Note *note, unsigned int indent)
 +      {
-+      fprintf(stderr, "%*s%s\n", indent, "- ", qPrintable(sa->getInfoForElement(note)));
++      fprintf(stderr, "%*s%s\n", indent, "- ", qPrintable(note->getFullAccessibleInfo(note->score()).first));
 +      }
 +
-+static void logCollisionNotes(ScoreAccessibility *sa, NPlayEvent *event)
++static void logCollisionNotes(NPlayEvent *event)
 +      {
 +      for (auto it = event->notes.cbegin(); it != event->notes.cend(); ++it) {
 +            const Note* note1 = *it;
 +            unsigned int indent = /* initial */ 2;
 +            while (note1) {
-+                  logCollisionNote(sa, note1, indent);
-+                  indent += /* linked */ 4;
-+                  for (ScoreElement* se : note1->linkList()) {
-+                        if (se != note1 && se->isNote())
-+                              logCollisionNote(sa, toNote(se), indent);
-+                        }
-+                  indent -= (/* linked */ 4 - /* next level */ 2);
++                  logCollisionNote(note1, indent);
++                  indent += /* next level */ 2;
 +                  note1 = note1->tieFor() ? note1->tieFor()->endNote() : 0;
 +                  }
 +            }
@@ -245,13 +248,8 @@ Forwarded: https://github.com/musescore/MuseScore/pull/3797
  void EventMap::fixupMIDI()
        {
        /* track info for each of the 128 possible MIDI notes */
-@@ -388,30 +411,48 @@ void EventMap::fixupMIDI()
-       /* track info for each channel (on the heap, 0-initialised) */
-       struct channelInfo *info = (struct channelInfo *)calloc(_highestChannel + 1, sizeof(struct channelInfo));
+@@ -390,28 +409,43 @@ void EventMap::fixupMIDI()
  
-+      /* needed to log collision info */
-+      ScoreAccessibility *sa = ScoreAccessibility::instance();
-+
        auto it = begin();
        while (it != end()) {
 +            bool discard = false;
@@ -281,9 +279,9 @@ Forwarded: https://github.com/musescore/MuseScore/pull/3797
 +                        discard = true;
 +                        /* log the collision */
 +                        fprintf(stderr, "MIDI collision detected: newly played...\n");
-+                        logCollisionNotes(sa, &(it->second));
++                        logCollisionNotes(&(it->second));
 +                        fprintf(stderr, "... interfere with already playing...\n");
-+                        logCollisionNotes(sa, info[it->second.channel()].event[it->second.pitch()]);
++                        logCollisionNotes(info[it->second.channel()].event[it->second.pitch()]);
 +                        fprintf(stderr, "... which, as resolution, will continue to sound.\n");
 +                        /* carry over the corresponding score notes */
 +                        info[it->second.channel()].event[it->second.pitch()]->notes.insert(info[it->second.channel()].event[it->second.pitch()]->notes.end(), it->second.notes.begin(), it->second.notes.end());