|
|
@@ -43,6 +43,12 @@ package body ui is |
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
type rectangle is record |
|
|
|
x, y, width, height : integer; |
|
|
|
end record; |
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
structure_limit : constant natural := 12; |
|
|
|
|
|
|
|
sprite : array (style, element) of core.sprite; |
|
|
@@ -153,34 +159,50 @@ package body ui is |
|
|
|
------------------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
procedure draw_structure (data : in structure) is |
|
|
|
offset : constant integer := core.icon / 4; |
|
|
|
new_width : constant integer := (if data.resize then 320 else data.width); |
|
|
|
new_height : constant integer := (if data.resize then data.gui_n * (core.icon + 2 * offset) + 2 * core.icon else data.height); |
|
|
|
new_x : constant integer := (if data.center then (core.window_width - new_width) / 2 else data.x); |
|
|
|
new_y : constant integer := (if data.center then (core.window_height - new_height) / 2 else data.y); |
|
|
|
-- |
|
|
|
at_x : integer := new_x + core.icon; |
|
|
|
at_y : integer := new_y + core.icon; |
|
|
|
offset : constant integer := core.icon / 4; |
|
|
|
orients : natural := 0; |
|
|
|
-- |
|
|
|
frame_data : rectangle := (others => 0); |
|
|
|
button_data : rectangle := (others => 0); |
|
|
|
begin |
|
|
|
draw_tiny_menu (new_x, new_y, new_width, new_height); |
|
|
|
draw_title_bar (new_x, new_y, new_width, data.title); |
|
|
|
for index in 0 .. data.gui_n - 1 loop |
|
|
|
if data.gui_list (index).kind = gui_orient then |
|
|
|
orients := orients + 1; |
|
|
|
end if; |
|
|
|
end loop; |
|
|
|
-- |
|
|
|
frame_data.width := (if data.resize then 320 else data.width) * (orients + 1) - offset * orients; |
|
|
|
frame_data.height := (if data.resize then data.gui_n * (core.icon + 2 * offset) + 2 * core.icon else data.height) / (orients + 1) + offset * orients; |
|
|
|
frame_data.x := (if data.center then (core.window_width - frame_data.width) / 2 else data.x); |
|
|
|
frame_data.y := (if data.center then (core.window_height - frame_data.height) / 2 else data.y); |
|
|
|
button_data.width := frame_data.width / (orients + 1) - 2 * core.icon; |
|
|
|
button_data.height := core.icon + 2 * offset; |
|
|
|
button_data.x := frame_data.x + core.icon; |
|
|
|
button_data.y := frame_data.y + core.icon; |
|
|
|
-- |
|
|
|
draw_tiny_menu (frame_data.x, frame_data.y, frame_data.width, frame_data.height); |
|
|
|
draw_title_bar (frame_data.x, frame_data.y, frame_data.width, data.title); |
|
|
|
-- |
|
|
|
for x in 0 .. data.gui_n - 1 loop |
|
|
|
case data.gui_list (x).kind is |
|
|
|
when gui_button => |
|
|
|
draw_frame (data.gui_list (x).info, at_x, at_y, new_width - 2 * core.icon, core.icon + 2 * offset); |
|
|
|
draw_icon (data.gui_list (x).image, data.gui_list (x).info, at_x + offset, at_y + offset); |
|
|
|
write (data.gui_list (x).text, at_x + core.icon + offset, at_y + offset + 2); |
|
|
|
draw_frame (data.gui_list (x).info, button_data.x, button_data.y, button_data.width, button_data.height); |
|
|
|
draw_icon (data.gui_list (x).image, data.gui_list (x).info, button_data.x + offset, button_data.y + offset); |
|
|
|
write (data.gui_list (x).text, button_data.x + offset + core.icon, button_data.y + offset + 2); |
|
|
|
--~if cursor_inside (at_x, at_y, new_width - 2 * offset - core.icon - 2, 3 * core.icon / 2) then |
|
|
|
--~draw (cursor, at_x + new_width - 96, at_y); |
|
|
|
--~end if; |
|
|
|
at_y := at_y + core.icon + 2 * offset; |
|
|
|
button_data.y := button_data.y + button_data.height; |
|
|
|
when gui_orient => |
|
|
|
at_x := at_x + new_width - 2 * core.icon + offset; |
|
|
|
at_y := new_y + core.icon; |
|
|
|
button_data.x := button_data.x + frame_data.width / (orients + 1) - 2 * core.icon + offset; |
|
|
|
button_data.y := frame_data.y + core.icon; |
|
|
|
when others => null; |
|
|
|
end case; |
|
|
|
end loop; |
|
|
|
-- |
|
|
|
if orients > 0 then |
|
|
|
draw_scroll_bar (frame_data.x + frame_data.width - 2 * core.icon, frame_data.y + core.icon, frame_data.height - 2 * core.icon, 4); |
|
|
|
end if; |
|
|
|
end draw_structure; |
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------ |
|
|
@@ -357,7 +379,7 @@ package body ui is |
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
procedure draw_scroll_bar (x, y, height : in integer; offset : in integer) is |
|
|
|
procedure draw_scroll_bar (x, y, height, offset : in integer) is |
|
|
|
middle_height : constant integer := height - sprite (active, scroll_bar_upper).height - sprite (active, scroll_bar_lower).height; |
|
|
|
begin |
|
|
|
draw (scroll_bar_upper, x, y); |
|
|
|