forked from offtopia/ponydos
Add moving windows
This commit is contained in:
parent
7367a4cf34
commit
f4b0adc4da
3 changed files with 68 additions and 12 deletions
|
@ -8,9 +8,6 @@ bits 16
|
|||
|
||||
org 0x7c00
|
||||
|
||||
COLUMNS equ 80
|
||||
ROWS equ 25
|
||||
|
||||
X_SENSITIVITY equ 1
|
||||
Y_SENSITIVITY equ 2
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ FS_DIRENT_SIZE equ 32
|
|||
FS_DIRENT_NAME_SIZE equ 30
|
||||
FS_FILE_MAX_SIZE equ 128
|
||||
|
||||
COLUMNS equ 80
|
||||
ROWS equ 25
|
||||
|
||||
WM_PAINT equ 0
|
||||
WM_MOUSE equ 1
|
||||
WM_KEYBOARD equ 2
|
||||
|
|
74
shell.asm
74
shell.asm
|
@ -9,9 +9,15 @@ struc window
|
|||
.data resw 1
|
||||
.icon resb 1
|
||||
.mouse_released_inside resb 1
|
||||
.status resb 1
|
||||
.res_x resw 1
|
||||
.res_y resw 1
|
||||
.size:
|
||||
endstruc
|
||||
|
||||
WINDOW_MOVE equ 1
|
||||
WINDOW_RESIZE equ 2
|
||||
|
||||
cpu 8086
|
||||
bits 16
|
||||
|
||||
|
@ -134,11 +140,22 @@ paint:
|
|||
|
||||
; Draw a rectangle on-screen
|
||||
mov bx, [si + window.width]
|
||||
mov cx, bx
|
||||
mov dx, [si + window.height]
|
||||
mov di, [si + window.x]
|
||||
mov bp, [si + window.y]
|
||||
mov si, [si + window.data]
|
||||
|
||||
mov cx, bx
|
||||
add cx, di
|
||||
cmp cx, COLUMNS
|
||||
jle .no_clipping
|
||||
mov cx, COLUMNS
|
||||
sub cx, di
|
||||
jmp .clipping_done
|
||||
|
||||
.no_clipping:
|
||||
mov cx, bx
|
||||
.clipping_done:
|
||||
call PONYDOS_SEG:SYS_DRAW_RECT
|
||||
|
||||
ret
|
||||
|
@ -165,16 +182,22 @@ mouse:
|
|||
; X
|
||||
xor ch, ch
|
||||
|
||||
cmp cx, [si + window.x]
|
||||
jl .outside
|
||||
cmp bx, [si + window.y]
|
||||
jl .outside
|
||||
cmp byte [si + window.status], WINDOW_MOVE
|
||||
jne .not_move
|
||||
call move
|
||||
.not_move:
|
||||
cmp byte [si + window.status], WINDOW_RESIZE
|
||||
jne .not_resize
|
||||
;call window_resize
|
||||
.not_resize:
|
||||
|
||||
sub cx, [si + window.x]
|
||||
jc .outside
|
||||
cmp [si + window.width], cx
|
||||
jle .outside
|
||||
add cx, [si + window.x]
|
||||
sub bx, [si + window.y]
|
||||
jc .outside
|
||||
cmp [si + window.height], bx
|
||||
jle .outside
|
||||
add bx, [si + window.y]
|
||||
|
@ -194,6 +217,7 @@ mouse:
|
|||
jmp .inside
|
||||
.not_buttons_held:
|
||||
mov byte [si + window.mouse_released_inside], 1
|
||||
mov byte [si + window.status], 0
|
||||
|
||||
.inside:
|
||||
pop cx
|
||||
|
@ -213,6 +237,28 @@ mouse:
|
|||
call forward_event
|
||||
ret
|
||||
|
||||
; in:
|
||||
; ax = window ID
|
||||
; bx = Y coördinate
|
||||
; cx = X coördinate
|
||||
; si = pointer to window structure
|
||||
move:
|
||||
push dx
|
||||
mov [si + window.y], bx
|
||||
|
||||
mov [si + window.x], cx
|
||||
mov dx, [si + window.res_x]
|
||||
sub [si + window.x], dx
|
||||
jnc .not_underflow
|
||||
|
||||
mov word [si + window.x], 0
|
||||
|
||||
.not_underflow:
|
||||
pop dx
|
||||
|
||||
call request_redraw
|
||||
ret
|
||||
|
||||
; in:
|
||||
; ax = window ID
|
||||
; bx = Y coördinate
|
||||
|
@ -236,18 +282,28 @@ click:
|
|||
.file_window:
|
||||
call raise_window
|
||||
|
||||
; If clicked the window close button
|
||||
cmp bx, [si + window.y]
|
||||
jne .not_close
|
||||
jne .not_title_bar
|
||||
|
||||
; If clicked the window close button
|
||||
mov ax, [si + window.x]
|
||||
;cmp ax, cx
|
||||
;je .resize
|
||||
add ax, [si + window.width]
|
||||
dec ax
|
||||
cmp ax, cx
|
||||
jne .not_close
|
||||
je .close
|
||||
.move:
|
||||
mov byte [si + window.status], WINDOW_MOVE
|
||||
sub cx, [si + window.x]
|
||||
mov [si + window.res_x], cx
|
||||
jmp .end
|
||||
.close:
|
||||
call hide_file_window
|
||||
jmp .end
|
||||
.not_close:
|
||||
|
||||
|
||||
.not_title_bar:
|
||||
|
||||
; If clicked within the content area
|
||||
mov ax, bx
|
||||
|
|
Loading…
Reference in a new issue