payload: {"action":"created","issue":{"url":"https://api.github.com/repos/musescore/MuseScore/issues/4769","repository_url":"https://api.github.com/repos/musescore/MuseScore","labels_url":"https://api.github.com/repos/musescore/MuseScore/issues/4769/labels{/name}","comments_url":"https://api.github.com/repos/musescore/MuseScore/issues/4769/comments","events_url":"https://api.github.com/repos/musescore/MuseScore/issues/4769/events","html_url":"https://github.com/musescore/MuseScore/pull/4769","id":417485993,"node_id":"MDExOlB1bGxSZXF1ZXN0MjU4NDcyOTQ5","number":4769,"title":"fix #281024: invisible staves affect spacing","user":{"login":"MarcSabatella","id":1799936,"node_id":"MDQ6VXNlcjE3OTk5MzY=","avatar_url":"https://avatars3.githubusercontent.com/u/1799936?v=4","gravatar_id":"","url":"https://api.github.com/users/MarcSabatella","html_url":"https://github.com/MarcSabatella","followers_url":"https://api.github.com/users/MarcSabatella/followers","following_url":"https://api.github.com/users/MarcSabatella/following{/other_user}","gists_url":"https://api.github.com/users/MarcSabatella/gists{/gist_id}","starred_url":"https://api.github.com/users/MarcSabatella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarcSabatella/subscriptions","organizations_url":"https://api.github.com/users/MarcSabatella/orgs","repos_url":"https://api.github.com/users/MarcSabatella/repos","events_url":"https://api.github.com/users/MarcSabatella/events{/privacy}","received_events_url":"https://api.github.com/users/MarcSabatella/received_events","type":"User","site_admin":false},"labels":[{"id":1254459281,"node_id":"MDU6TGFiZWwxMjU0NDU5Mjgx","url":"https://api.github.com/repos/musescore/MuseScore/labels/Bugfix","name":"Bugfix","color":"b22050","default":false},{"id":279077680,"node_id":"MDU6TGFiZWwyNzkwNzc2ODA=","url":"https://api.github.com/repos/musescore/MuseScore/labels/work%20in%20progress","name":"work in progress","color":"eb6420","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-03-05T20:25:09Z","updated_at":"2019-03-07T15:46:57Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/musescore/MuseScore/pulls/4769","html_url":"https://github.com/musescore/MuseScore/pull/4769","diff_url":"https://github.com/musescore/MuseScore/pull/4769.diff","patch_url":"https://github.com/musescore/MuseScore/pull/4769.patch"},"body":"See https://musescore.org/en/node/281024 for a clear description of the problem.  If you use anextra staff to write out some complex passage for playback and then set it invisible, it unfortunately still affects the layout of the score, which it did *not* do in 2.3.2.  That renders this common technique essentially useless - you end up with crazy spacing due to the notes on the invisible staves.\r\n\r\nAlthough I feared at first the solution would require deep changes, I think now this isn't so.  I am considering my PR work in progress in that I rather doubt I've actually handled everything that we would need to, and I am also not sure what people will think of the overall approach I am using here.  But my code *is* quite simple, and it should have next to no performance implication, or really much impact at all other than on what it is actually dealing with - layout in the presence of invisible staves.\r\n\r\nThe main problem is that when we calculate the distance from one segment to the next, we are looking at *all* segments instead of just the ones that actually contain elements on visible staves.  And we do the same when calculating the *width* of each segment, and again when calculating the *duration* (ticks aka Fractions).\r\n\r\nSo, what I am doing is finding the corresponding places in layout where we were looping through segments using next() or nextEnabled(), and adjusting things to be sure we skip segments with no elements on visible staves.  To simplify this process and keep it efficient, I am setting or clearing the \"visible\" flag on the segment itself during Segment::createShapes() according to whether we encountered any shapes on visible staves (and, btw, I'm skipping adding shapes on invisible staves to the segment).  So when looping through the segments, all we need to do is check this flag to know if a segment is worth looking at.  I wrote a helper function nextActive() that is like nextEnabled() but checks both enabled & visible flags.\r\n\r\nAnd that's really all there is to it.  I imagine there are possibly additional places where I need to add similar checks, or places where we do need to at least partially process \"invisible\" segments in order for the playback to work completely, but it does seem to work in the cases I've tried, which is highly encouraging.\r\n\r\nAs an example, here is a score:\r\n\r\n![image](https://user-images.githubusercontent.com/1799936/53834902-6ae3fe80-3f49-11e9-9e7e-7267e89584dc.png)\r\n\r\nHere is how it looks in 3.0 with the bottom staff invisible:\r\n\r\n![image](https://user-images.githubusercontent.com/1799936/53834967-8bac5400-3f49-11e9-80cf-d13d3d5c209d.png)\r\n\r\nAnd here it is with my changes:\r\n\r\n![image](https://user-images.githubusercontent.com/1799936/53835243-3886d100-3f4a-11e9-9934-f79fc142fa43.png)\r\n\r\nwhich is the same as it looks if I simply delete the second staff.\r\n\r\nI welcome more eyes on this.  @wschweer especially...\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/musescore/MuseScore/issues/comments/470578338","html_url":"https://github.com/musescore/MuseScore/pull/4769#issuecomment-470578338","issue_url":"https://api.github.com/repos/musescore/MuseScore/issues/4769","id":470578338,"node_id":"MDEyOklzc3VlQ29tbWVudDQ3MDU3ODMzOA==","user":{"login":"MarcSabatella","id":1799936,"node_id":"MDQ6VXNlcjE3OTk5MzY=","avatar_url":"https://avatars3.githubusercontent.com/u/1799936?v=4","gravatar_id":"","url":"https://api.github.com/users/MarcSabatella","html_url":"https://github.com/MarcSabatella","followers_url":"https://api.github.com/users/MarcSabatella/followers","following_url":"https://api.github.com/users/MarcSabatella/following{/other_user}","gists_url":"https://api.github.com/users/MarcSabatella/gists{/gist_id}","starred_url":"https://api.github.com/users/MarcSabatella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarcSabatella/subscriptions","organizations_url":"https://api.github.com/users/MarcSabatella/orgs","repos_url":"https://api.github.com/users/MarcSabatella/repos","events_url":"https://api.github.com/users/MarcSabatella/events{/privacy}","received_events_url":"https://api.github.com/users/MarcSabatella/received_events","type":"User","site_admin":false},"created_at":"2019-03-07T15:46:57Z","updated_at":"2019-03-07T15:46:57Z","author_association":"CONTRIBUTOR","body":"See also #4773, which touches on this same code in Segment::createShape().  I will update this to be consistent with that PR in a way that should allow them to be merged independently.  And now that I more fully understand what is going on here, I can also update that \"whats left\" comment (not mine) to reflect the actual situation: annotation not excluded in that list get added to the segment shape thus allowing collisions to be detected and avoided by respacing the segments themselves.  Lyrics are really the main reason for this currently.  I will also look to make sure there are no issues with adding them directly to the segment shape as there were for chord symbols; I don't think I want to change anything here unless I can reproduce a problem."}}
other: {"actor":{"display_login":"MarcSabatella"}}