GSoC weekly update : July 25th to July 31st
As mentioned in the last post, last week I worked on and completed the implementation for the layout and draw functionality of the range annotation as a spanner. You can find the code for the same here :
For the layout I used two different functions - layoutSystem and layoutSegment. LayoutSystem gets called in Score::collectSystem when it loops over all the spanner elements and calls layout for them, which returns a spanner segment after creation and layout. LayoutSegment is in turn called by LayoutSystem after determining the type of segment we are considering. The type of segment being considered is determined using the relative tick values. The draw function uses the values being set during layout and performs the actual drawing of the elements.
Initially we were having issues with the draw being called, and since the range annotation segment was being shown under system in the object debugger, it was apparent that it is being properly added, but the problem lies somewhere else. It turned out that the "pos" and the "bbox" were not being set correctly in the layout code. I examined Page::items and saw that it detects all the elements that lie between the rectangle which is considered to be drawn, and the bbox values that were being set then obstructed Page::items from detecting the range annotation segment as an element to be drawn. The four columns for bbox signify x, y, width, and height respectively. I still wonder why the x value for a slur segment is relatively large. The bbox values are with respect to the pos (position) values, and the position values are with respect to the system position. The x , y values are such that negative x signifies left, and negative y signifies up. Hence (0,0) signifies top left corner.
Currently I am setting the height according to the height of the complete stave, and it can be reconsidered later. I also added a margin to the range annotation. The next week I plan to work on fixing any bugs which might have crept in and add additional functionality after discussion with my mentor.