3D Button

This commit is contained in:
Frater 2026-02-22 21:00:50 +01:00
commit 9992a05945
5 changed files with 1022 additions and 926 deletions

1
.gitignore vendored
View file

@ -8,3 +8,4 @@ build/
gfx/
roms/
tools/
doc/generated

View file

@ -123,9 +123,42 @@ on_click_hello:
main_test:
GFX RECTANGLE_FILL, 10,10,50,20, PATTERN_WHITE, 15, 0
; GFX RECTANGLE_FILL, 10,10,50,20, PATTERN_WHITE, 15, 0
; GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50, 100, 15
mov ax, 200
add ax, 4
mov bx, 50
; centrage vertical
mov cx, 15
sub cx, GUI_CHECKBOX_SIZE
shr cx, 1
add bx, cx ; bx = Y1 + (h/2)
mov cx, ax ; x
add cx, GUI_CHECKBOX_SIZE ; cx = X2
mov dx, bx
add dx, GUI_CHECKBOX_SIZE ; Y2
; Fond blanc + Bordure noire
GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_WHITE, 15, 0
GFX RECTANGLE, ax, bx, cx, dx, 0
; Dessin du X (Diagonales)
add ax, 2 ; x1
add bx, 2 ; y1
sub cx, 2 ; x2
sub dx, 2 ; y2
; Optimisation : Utilisation de LINE au lieu de PUTPIXEL en boucle
; Diagonale 1 : (ax, bx) -> (cx, dx)
GFX LINE, ax, bx, cx, dx, 0
; Diagonale 2 : (ax, dx) -> (cx, bx)
GFX LINE, ax, dx, cx, bx, 0
ret
%define .oldval word [bp-2]
@ -160,9 +193,6 @@ main_loop:
GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50+16*2, 100, 15
GUI OBJ_SET_TEXT, ax, cs, str_option3
DEBUG 3
ISADBG ISA_LEFT, 3
; Créer Slider (Drag)
GUI OBJ_CREATE, OBJ_TYPE_SLIDER, 10, 100, 150, 12
GUI OBJ_SET_MODE, ax, SLIDER_HORIZONTAL
@ -177,10 +207,7 @@ main_loop:
mov .oldval, 0x1256
mov .value, 0xFADE
DEBUG 4
ISADBG ISA_LEFT, 4
.loop:
.loop:
call gui_process_all
GUI OBJ_GET_VAL, .my_slider
mov .value, ax
@ -189,12 +216,12 @@ main_loop:
je .loop
; debug
mov .oldval, ax
GFX RECTANGLE_FILL,0,148,50,166, PATTERN_WHITE
GFX GOTOXY, 8, 150
;mov .oldval, ax
;GFX RECTANGLE_FILL,0,148,50,166, PATTERN_WHITE
;GFX GOTOXY, 8, 150
mov ax, .value
call print_word_hex
;mov ax, .value
;call print_word_hex
; end debug
; change palette...

File diff suppressed because it is too large Load diff

View file

@ -23,6 +23,13 @@
; --- Configuration ---
%define GUI_MAX_WIDGETS 32 ; Nombre max de widgets simultanés
; commenter cette ligne fait passer le GUI en B/W uniquement si EGA ou VGA
; %define COLOR_GUI 1
%if GFX_DRIVERS == 'CGA'
%undef COLOR_GUI
%endif
; Dimensions
%define GUI_CHECKBOX_SIZE 10 ; 10x10 pixels

View file

@ -24,6 +24,15 @@
; https://github.com/buserror/libmui
;
%macro RECT_3D 6
; %1 = x1, %2 = y1, %3 = x2, %4 = y2, %5 = c1, %6 = c2
GFX LINE, %1, %2, %3, %2, %5 ; haut
GFX LINE, %1, %2, %1, %4, %5 ; gauche
GFX LINE, %1, %4, %3, %4, %6 ; bas
GFX LINE, %3, %2, %3, %4, %6 ; droite
%endmacro
; Dessine le widget pointé par SI
gui_draw_single_widget:
pusha
@ -293,23 +302,31 @@ draw_button:
.draw_default_style:
; Bordure extérieure épaisse (2px)
;GFX RECTANGLE, ax, bx, cx, dx, 0
inc ax
inc bx
dec cx
dec dx
;inc ax
;inc bx
;dec cx
;dec dx
;GFX RECTANGLE, ax, bx, cx, dx, 0
%ifndef COLOR_GUI
; Bordure intérieure fine (après un gap de 1px blanc)
add ax, 2
add bx, 2
sub cx, 2
sub dx, 2
add ax, 1
add bx, 1
sub cx, 1
sub dx, 1
GFX RECTANGLE, ax, bx, cx, dx, 0
%else
RECT_3D ax, bx, cx, dx, 8, 7
%endif
jmp .done
.paint_hover:
%ifndef COLOR_GUI
GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_WHITE_LIGHT, 15, 0
GFX RECTANGLE, ax, bx, cx, dx, 0
%else
GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_WHITE, 7, 0
RECT_3D ax, bx, cx, dx, 7,8
%endif
jmp .done
.paint_pressed:
@ -337,26 +354,47 @@ draw_round_button:
je .paint_hover
.paint_normal:
%ifndef COLOR_GUI
GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_WHITE, 15, 0
mov di, 0 ; Couleur Noire
call draw_round_borders
GFX TXT_MODE, GFX_TXT_BLACK_TRANSPARENT
%else
GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_WHITE, 7, 0
RECT_3D ax, bx, cx, dx, 15,8
%endif
jmp .draw_text_now
.paint_hover:
%ifndef COLOR_GUI
GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_WHITE, 15, 0
GFX RECTANGLE_ROUND, ax, bx, cx, dx, 0
; GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_WHITE_LIGHT
mov di, 0 ; Couleur Noire
call draw_round_borders
GFX TXT_MODE, GFX_TXT_BLACK_TRANSPARENT
%else
GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_WHITE, 7, 0
RECT_3D ax, bx, cx, dx, 15,8
add ax, 2
add bx, 2
sub cx, 2
sub dx, 2
RECT_3D ax, bx, cx, dx, 15,8
%endif
jmp .draw_text_now
.paint_pressed:
%ifndef COLOR_GUI
GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_BLACK, 15, 0
mov di, 1 ; Bordure Blanche sur fond noir
call draw_round_borders
GFX TXT_MODE, GFX_TXT_WHITE_TRANSPARENT
%else
GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_WHITE, 7, 0
RECT_3D ax, bx, cx, dx, 8, 15
%endif
jmp .draw_text_now
.draw_text_now:
@ -412,24 +450,31 @@ draw_checkbox:
cmp word [gs:si + widget.thumb_pos], 0
je .draw_label
; Dessin du X (Diagonales)
add ax, 2
add bx, 2
sub cx, 2
sub dx, 2
push ax
push bx
push cx
push dx
; Dessin du X (Diagonales)
add ax, 2 ; x1
add bx, 2 ; y1
sub cx, 2 ; x2
sub dx, 2 ; y2
; Optimisation : Utilisation de LINE au lieu de PUTPIXEL en boucle
; Diagonale 1 : (ax, bx) -> (cx, dx)
GFX LINE, ax, bx, cx, dx, 0
; Diagonale 2 : (ax, dx) -> (cx, bx)
GFX LINE, ax, dx, cx, bx, 0
pop dx
pop cx
pop bx
pop ax
.draw_label:
; Dessin du texte à droite (BoxX2 + 6)
add cx, 6
add cx, (GUI_CHECKBOX_SIZE/2) + 1
; Y = Centré par rapport au widget
mov bx, [gs:si + widget.y]