Added unscrolling scroll bar...

This commit is contained in:
Ognjen Milan Robovic 2024-02-19 21:52:43 -05:00
parent 646ab4872e
commit df533dc356
3 changed files with 24 additions and 19 deletions

View File

@ -71,14 +71,6 @@ package body menu is
end if;
--
if mouse_over_menu /= none then
--~for element_index in 0 .. limitation - 1
--~loop
--~if core.cursor_y > trait (index).y + draw_offset + element_index * offset
--~and core.cursor_y < trait (index).y + draw_offset + element_index * offset + offset then
--~mouse_over_menu_element := element_index;
--~end if;
--~end loop;
--~return;
for element_index in 0 .. limitation - 1
loop
if core.cursor_x > trait (index).x + trait (index).elements (element_index).x
@ -96,8 +88,8 @@ package body menu is
------------------------------------------------------------------------------------------
procedure draw (index : in codex; x, y : in integer; center : in boolean) is
scroll_bar : constant boolean := (if trait (index).length < trait (index).height then false else true);
limitation : constant integer := (if trait (index).length < trait (index).height then trait (index).length else trait (index).height);
scroll_bar : constant boolean := (if trait (index).length > trait (index).height then true else false);
limitation : constant integer := (if trait (index).length > trait (index).height then trait (index).height else trait (index).length);
width : constant integer := 2 * draw_offset + offset + 24 * 8;
height : constant integer := limitation * offset + 2 * draw_offset;
begin
@ -118,6 +110,10 @@ package body menu is
core.draw (trait (index).elements (element_index).icon, trait (index).x + draw_offset + icon_offset, trait (index).y + draw_offset + icon_offset + element_index * offset);
core.write (trait (index).elements (element_index).text, trait (index).x + draw_offset + offset, trait (index).y + draw_offset + 2 * icon_offset + element_index * offset);
end loop;
--
if scroll_bar then
ui.draw_scroll_bar (x + width - draw_offset, y + draw_offset, height - 2 * draw_offset, 0);
end if;
end draw;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -7,14 +7,6 @@ package body ui is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
type sprite_array is array (style, codex) of core.sprite;
------------------------------------------------------------------------------------------
sprite : sprite_array;
------------------------------------------------------------------------------------------
procedure configure is
procedure load_ui (index : in style; folder_path : in string) is
begin
@ -158,6 +150,17 @@ package body ui is
------------------------------------------------------------------------------------------
procedure draw_scroll_bar (x, y, height : in integer; 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);
draw (scroll_bar_lower, x, y + middle_height + sprite (active, scroll_bar_upper).height);
--
draw_vertically (scroll_bar_middle, x, y + sprite (active, scroll_bar_upper).height, middle_height);
end draw_scroll_bar;
------------------------------------------------------------------------------------------
procedure draw_menu (x, y, width, height : in integer; background : in boolean) is
offset : constant integer := sprite (active, none).width;
begin

View File

@ -26,6 +26,11 @@ package ui is
------------------------------------------------------------------------------------------
type sprite_array is array (style, codex) of core.sprite;
------------------------------------------------------------------------------------------
sprite : sprite_array;
active : style;
------------------------------------------------------------------------------------------
@ -38,7 +43,8 @@ package ui is
procedure draw_frame (x, y, width, height : in integer);
procedure draw_title_bar (x, y, width : in integer; title : in string);
procedure draw_title_bar (x, y, width : in integer; title : in string);
procedure draw_scroll_bar (x, y, height : in integer; offset : in integer);
procedure draw_menu (x, y, width, height : in integer; background : in boolean);
procedure draw_tiny_menu (x, y, width, height : in integer; background : in boolean);