Hosted by
|
with Messages; use Messages;
package body Boxes.Staves is
function Create
return Stave_Box_Access
is
Result : Stave_Box_Access := new Stave_Box;
begin
Result.Measures := Measures_Lists.Create;
return Result;
end Create;
function Get_Measures
(This : access Stave_Box)
return Measures_List_Access is
begin
return This.Measures;
end Get_Measures;
procedure Add_Measure
(This : access Stave_Box;
Add : in Measure_Box_Access) is
begin
Measures_Lists.Push(This.Measures, Add);
end Add_Measure;
procedure Layout
(This : access Stave_Box;
Font : access Font_Loader)
is
Cursor : Vector;
use Measures_Lists;
Measure : Measure_Box_Access;
begin
if not Quiet then Debug("preparing stave layout"); end if;
Cursor := (0.0, 0.0);
This.Minimum_Width := 0.0;
This.Optimum_Width := 0.0;
This.Bounds := (0.0, -200.0, 0.0, 200.0);
Reset(This.Measures);
while Next(This.Measures) loop
Measure := Current(This.Measures);
Layout(Measure, Font);
Cursor.X := Cursor.X - Get_Left(Measure);
Set_Center(Measure, Cursor);
Cursor.X := Cursor.X + Get_Right(Measure);
Estimate_Width(Measure);
Add_Width(This, Measure);
Max_Bounds(This, Measure);
end loop;
end Layout;
procedure Print
(This : access Stave_Box;
To : access Printer'Class;
Center : in Vector)
is
use Measures_Lists;
begin
if not Quiet then Debug("printing measures"); end if;
Reset(This.Measures);
while Next(This.Measures) loop
Print(Current(This.Measures), To, Center);
end loop;
end Print;
end Boxes.Staves;
|