Hosted by
 |
with Enum_Strings; use Enum_Strings;
package body Boxes.Note_Heads is
function Create
(Note_Head : in Note_Head_Enum;
Filled : in Boolean;
Position : in Integer)
return Note_Head_Box_Access
is
Result : Note_Head_Box_Access := new Note_Head_Box;
begin
Result.Note_Head := Note_Head;
Result.Filled := Filled;
Result.Position := Position;
return Result;
end Create;
function Get_Note_Head
(This : access Note_Head_Box)
return Note_Head_Enum is
begin
return This.Note_Head;
end Get_Note_Head;
function Get_Filled
(This : access Note_Head_Box)
return Boolean is
begin
return This.Filled;
end Get_Filled;
function Get_Position
(This : access Note_Head_Box)
return Integer is
begin
return This.Position;
end Get_Position;
procedure Set_Stem_Side
(This : access Note_Head_Box;
Stem_Side : in Stem_Side_Enum) is
begin
This.Stem_Side := Stem_Side;
end Set_Stem_Side;
function Get_Stem_Side
(This : access Note_Head_Box)
return Stem_Side_Enum is
begin
return This.Stem_Side;
end Get_Stem_Side;
function Get_Name
(This : access Note_Head_Box)
return String is
begin
if This.Note_Head = Normal and not This.Filled
then return "hollow";
else return To_XML(This.Note_Head'Img);
end if;
end Get_Name;
procedure Layout
(This : access Note_Head_Box;
Font : access Font_Loader) is
begin
This.Glyph := Load_Glyph(Font,
"noteheads/stem-" & To_XML(This.Stem_Side'Img) & "/" &
Get_Name(This));
This.Bounds := Get_Bounds(This.Glyph);
end Layout;
procedure Add_Dots
(This : access Note_Head_Box;
Font : access Font_Loader;
Dots : in Positive;
Offset : in Vector)
is
Cursor : Vector := Offset;
begin
This.Dot_Offset := Offset;
for Index in 1 .. Dots loop
This.Dots(Index) := Load_Glyph(Font, "dots/augment");
This.Bounds := Max(This.Bounds, Get_Bounds(This.Dots(Index)) + Cursor);
Cursor := Cursor + (50.0, 0.0);
end loop;
end Add_Dots;
procedure Print
(This : access Note_Head_Box;
To : access Printer'Class;
Center : in Vector)
is
Cursor : Vector;
begin
Print(To, This.Glyph, Center + This.Center);
Cursor := This.Dot_Offset;
for Index in Dot_Range loop
exit when This.Dots(Index) = null;
Print(To, This.Dots(Index), Center + This.Center + Cursor);
Cursor := Cursor + (50.0, 0.0);
end loop;
end Print;
end Boxes.Note_Heads;
|