Improve window dragging and add fetcher animation

Signed-off-by: TalonFox <105325988+TalonFox@users.noreply.github.com>
This commit is contained in:
TalonFox 2023-07-12 12:41:11 -05:00
parent e6293f1e28
commit aa60133fe0
No known key found for this signature in database
GPG Key ID: A27B2C7BDFBC079D
6 changed files with 88 additions and 12 deletions

View File

@ -1,11 +1,12 @@
MODULE Browser; MODULE Browser;
IMPORT OS; IMPORT OS, Desktop;
VAR browserRunning: CHAR; VAR browserRunning: CHAR;
browserWindow: ARRAY 36 OF CHAR; browserWindow: ARRAY 36 OF CHAR;
browserIcons: ARRAY 31 OF Fox32OSButtonWidget; browserIcons: ARRAY 31 OF Fox32OSButtonWidget;
PROCEDURE BrowserMain(diskId: INT;); PROCEDURE BrowserMain(diskId, iconX, iconY: INT; desktopWin: PTR;);
VAR i, x, y, w, h: INT;
BEGIN BEGIN
browserRunning := 1; browserRunning := 1;
@ -22,6 +23,21 @@ MODULE Browser;
IF (eventArgs[1] <| 8) & (eventArgs[2] <| 16) THEN IF (eventArgs[1] <| 8) & (eventArgs[2] <| 16) THEN
destroy_window(PTROF(browserWindow)); destroy_window(PTROF(browserWindow));
browserRunning := 0; browserRunning := 0;
IF desktopWin # 0 THEN
(* Draw the retracting box animation *)
i := 0;
WHILE i < 16 DO
x := RSH(GETSHORT(PTROF(browserWindow) + 20) *| (16 - i) + iconX *| i,4);
y := RSH(GETSHORT(PTROF(browserWindow) + 22) *| (16 - i) + iconY *| i,4);
w := RSH(384 *| (16 - i) + 32 *| i,4);
h := RSH(192 *| (16 - i) + 32 *| i,4);
DrawWireframeBox(get_window_overlay_number(desktopWin),x,y,w,h,20F0F0F0H);
Eep(5);
draw_filled_rectangle_to_overlay(x,y,w,h,0,get_window_overlay_number(desktopWin));
i := i + 1;
END;
draw_widgets_to_window(desktopWin);
END;
ELSIF eventArgs[2] <| 16 THEN ELSIF eventArgs[2] <| 16 THEN
start_dragging_window(PTROF(browserWindow)); start_dragging_window(PTROF(browserWindow));
END; END;

View File

@ -34,9 +34,42 @@ MODULE Desktop;
END; END;
END; END;
PROCEDURE HandleDesktopIconClick(buttonId: INT;); PROCEDURE Eep(ms: INT;); (* the furry version of sleep :3 *)
VAR deadline: INT;
BEGIN BEGIN
IF launch_fxf_from_disk("fetcher.fxf", get_boot_disk_id(), 0FFFFFFFFH, buttonId, 0, 0, 0) = 0FFFFFFFFH THEN deadline := ms + PortIn(80000706H);
WHILE PortIn(80000706H) <| deadline DO
save_state_and_yield_task();
END;
END;
PROCEDURE DrawWireframeBox(overlay, x, y, w, h, color: INT;);
BEGIN
draw_filled_rectangle_to_overlay(x,y,w,1,color,overlay);
draw_filled_rectangle_to_overlay(x,y,1,h,color,overlay);
draw_filled_rectangle_to_overlay(x+w-1,y,1,h,color,overlay);
draw_filled_rectangle_to_overlay(x,y+h-1,w,1,color,overlay);
END;
PROCEDURE HandleDesktopIconClick(buttonId: INT;);
VAR i, x, y, w, h: INT;
icon: POINTER TO Fox32OSButtonWidget;
BEGIN
(* Draw the expanding box animation *)
i := 0;
icon := PTROF(desktopIcons[buttonId]);
WHILE i < 16 DO
x := RSH(icon^.x *| (16 - i) + 64 *| i,4);
y := RSH(icon^.y *| (16 - i) + 64 *| i,4);
w := RSH(32 *| (16 - i) + 384 *| i,4);
h := RSH(32 *| (16 - i) + 192 *| i,4);
DrawWireframeBox(get_window_overlay_number(PTROF(desktopWindow)),x,y,w,h,20F0F0F0H);
Eep(5);
draw_filled_rectangle_to_overlay(x,y,w,h,0,get_window_overlay_number(PTROF(desktopWindow)));
i := i + 1;
END;
draw_widgets_to_window(PTROF(desktopWindow));
IF launch_fxf_from_disk("fetcher.fxf", get_boot_disk_id(), 0FFFFFFFFH, buttonId, icon^.x, icon^.y, PTROF(desktopWindow)) = 0FFFFFFFFH THEN
new_messagebox("Failed to start new", "instance of fetcher.fxf", 0, 64, 64, 200); new_messagebox("Failed to start new", "instance of fetcher.fxf", 0, 64, 64, 200);
END; END;
END; END;
@ -74,7 +107,7 @@ MODULE Desktop;
desktopIcon := PTROF(desktopIcons[2]); desktopIcon := PTROF(desktopIcons[2]);
desktopIcon^.type := WIDGET_TYPE_BUTTON; desktopIcon^.type := WIDGET_TYPE_BUTTON;
desktopIcon^.next := PTROF(desktopIcons[3]); desktopIcon^.next := PTROF(desktopIcons[3]);
desktopIcon^.id := 1; desktopIcon^.id := 2;
desktopIcon^.text := "Disk 2"; desktopIcon^.text := "Disk 2";
desktopIcon^.fgColor := 0FF000000H; desktopIcon^.fgColor := 0FF000000H;
desktopIcon^.bgColor := 0FFFFFFFFH; desktopIcon^.bgColor := 0FFFFFFFFH;
@ -87,7 +120,7 @@ MODULE Desktop;
desktopIcon := PTROF(desktopIcons[3]); desktopIcon := PTROF(desktopIcons[3]);
desktopIcon^.type := WIDGET_TYPE_BUTTON; desktopIcon^.type := WIDGET_TYPE_BUTTON;
desktopIcon^.next := PTROF(desktopIcons[4]); desktopIcon^.next := PTROF(desktopIcons[4]);
desktopIcon^.id := 1; desktopIcon^.id := 3;
desktopIcon^.text := "Disk 3"; desktopIcon^.text := "Disk 3";
desktopIcon^.fgColor := 0FF000000H; desktopIcon^.fgColor := 0FF000000H;
desktopIcon^.bgColor := 0FFFFFFFFH; desktopIcon^.bgColor := 0FFFFFFFFH;
@ -100,7 +133,7 @@ MODULE Desktop;
desktopIcon := PTROF(desktopIcons[4]); desktopIcon := PTROF(desktopIcons[4]);
desktopIcon^.type := WIDGET_TYPE_BUTTON; desktopIcon^.type := WIDGET_TYPE_BUTTON;
desktopIcon^.next := 0; desktopIcon^.next := 0;
desktopIcon^.id := 1; desktopIcon^.id := 4;
desktopIcon^.text := "Disk 4"; desktopIcon^.text := "Disk 4";
desktopIcon^.fgColor := 0FF000000H; desktopIcon^.fgColor := 0FF000000H;
desktopIcon^.bgColor := 0FFFFFFFFH; desktopIcon^.bgColor := 0FFFFFFFFH;

View File

@ -3,6 +3,9 @@ MODULE Fetcher;
EXTERN terminalStreamPtr: POINTER TO CHAR; EXTERN terminalStreamPtr: POINTER TO CHAR;
EXTERN arg0Ptr: POINTER TO CHAR; EXTERN arg0Ptr: POINTER TO CHAR;
EXTERN arg1Ptr: POINTER TO CHAR;
EXTERN arg2Ptr: POINTER TO CHAR;
EXTERN arg3Ptr: POINTER TO CHAR;
PROCEDURE Main(); PROCEDURE Main();
BEGIN BEGIN
@ -11,10 +14,10 @@ MODULE Fetcher;
DesktopMain(); DesktopMain();
ELSIF arg0Ptr <|= 5 THEN ELSIF arg0Ptr <|= 5 THEN
(* launched from an existing instance of fetcher *) (* launched from an existing instance of fetcher *)
BrowserMain(arg0Ptr); BrowserMain(arg0Ptr,arg1Ptr,arg2Ptr,arg3Ptr);
ELSE ELSE
(* probably launched from the terminal *) (* probably launched from the terminal *)
BrowserMain(string_to_int(arg0Ptr, 10)); BrowserMain(string_to_int(arg0Ptr, 10),0,0,0);
END; END;
END; END;
END. END.

View File

@ -7,6 +7,8 @@ MODULE OS;
EXTERN PROCEDURE brk: INT; EXTERN PROCEDURE brk: INT;
EXTERN PROCEDURE PortIn: INT;
EXTERN EVENT_TYPE_MOUSE_CLICK, EXTERN EVENT_TYPE_MOUSE_CLICK,
EVENT_TYPE_MOUSE_RELEASE, EVENT_TYPE_MOUSE_RELEASE,
EVENT_TYPE_BUTTON_CLICK, EVENT_TYPE_BUTTON_CLICK,

View File

@ -1,5 +1,8 @@
pop [terminalStreamPtr] pop [terminalStreamPtr]
pop [arg0Ptr] pop [arg0Ptr]
pop [arg1Ptr]
pop [arg2Ptr]
pop [arg3Ptr]
call Main call Main
call end_current_task call end_current_task
@ -30,9 +33,19 @@ brk:
brk brk
ret ret
PortIn:
push r1
in r1, r0
mov r0, r1
pop r1
ret
eventArgs: data.fill 0, 32 eventArgs: data.fill 0, 32
terminalStreamPtr: data.32 0 terminalStreamPtr: data.32 0
arg0Ptr: data.32 0 arg0Ptr: data.32 0
arg1Ptr: data.32 0
arg2Ptr: data.32 0
arg3Ptr: data.32 0
#include "../../../fox32rom/fox32rom.def" #include "../../../fox32rom/fox32rom.def"
#include "../../fox32os.def" #include "../../fox32os.def"

View File

@ -244,22 +244,31 @@ start_dragging_window:
push r1 push r1
push r2 push r2
push r4 push r4
push r5
mov r2, r0 mov r2, r0
mov r4, r0 mov r4, r0
add r4, 16 mov r5, r0
add r4, 20
add r5, 22
movz.16 r4, [r4] movz.16 r4, [r4]
div r4, 2 movz.16 r5, [r5]
call get_mouse_position
sub r0, r4
sub r1, r5
mov r4, r0
mov r5, r1
start_dragging_window_loop: start_dragging_window_loop:
call get_mouse_position call get_mouse_position
sub r0, r4 sub r0, r4
sub r1, 8 sub r1, r5
call move_window call move_window
call get_mouse_button call get_mouse_button
bts r0, 2 bts r0, 2
ifnz jmp start_dragging_window_loop ifnz jmp start_dragging_window_loop
pop r5
pop r4 pop r4
pop r2 pop r2
pop r1 pop r1