Hosted by
|
with Integer_Strings; use Integer_Strings;
with Enum_Strings; use Enum_Strings;
with Messages; use Messages;
package body Boxes.Times is
function Create
(Time : in Time_Access)
return Time_Box_Access
is
Result : Time_Box_Access := new Time_Box;
begin
Result.Time := Time;
return Result;
end Create;
function Get_Time
(This : access Time_Box)
return Time_Access is
begin
return This.Time;
end Get_Time;
procedure Layout
(This : access Time_Box;
Font : access Font_Loader) is
begin
if not Quiet then Debug("preparing time signature layout"); end if;
This.Upper_Center := (0.0, 0.0);
This.Lower_Center := (0.0, 0.0);
case Get_Symbol(This.Time) is
when Normal =>
if Get_Beats(This.Time) = 4 then
This.Upper_Center.X := 30.0;
end if;
This.Upper_Center.Y := -100.0;
This.Upper := Load_Glyph(Font, "times/upper/" & To_String(Get_Beats(This.Time)));
if Get_Beat_Type(This.Time) = 4 then
This.Lower_Center.X := 30.0;
end if;
This.Lower_Center.Y := 200.0;
This.Lower := Load_Glyph(Font, "times/lower/" & To_String(Get_Beat_Type(This.Time)));
This.Bounds := Max(
Get_Bounds(This.Upper) + This.Upper_Center,
Get_Bounds(This.Lower) + This.Lower_Center);
when Common =>
This.Lower := Load_Glyph(Font, "times/breve/breve");
This.Bounds := Get_Bounds(This.Lower);
when Cut =>
This.Lower := Load_Glyph(Font, "times/breve/breve");
This.Upper := Load_Glyph(Font, "times/breve/slash");
This.Bounds := Max(
Get_Bounds(This.Upper),
Get_Bounds(This.Lower));
when others =>
Error("unsupported time signature symbol: " & To_XML(Get_Symbol(This.Time)'Img));
end case;
end Layout;
procedure Print
(This : access Time_Box;
To : access Printer'Class;
Center : in Vector) is
begin
if not Quiet then Debug("printing time signature"); end if;
case Get_Symbol(This.Time) is
when Normal =>
Print(To, This.Upper, Center + This.Center + This.Upper_Center);
Print(To, This.Lower, Center + This.Center + This.Lower_Center);
when Common =>
Print(To, This.Lower, Center + This.Center + This.Lower_Center);
when Cut =>
Print(To, This.Upper, Center + This.Center + This.Upper_Center);
Print(To, This.Lower, Center + This.Center + This.Lower_Center);
when others =>
Error("unsupported time signature symbol: " & To_XML(Get_Symbol(This.Time)'Img));
end case;
Print_Bounds(This, To, Center);
end Print;
end Boxes.Times;
|