Add outline around active brush colour selector

This commit is contained in:
Ben Bridle 2022-09-21 12:07:04 +12:00
parent 4535c81881
commit d3f13ef67f
2 changed files with 58 additions and 42 deletions

View File

@ -12,6 +12,34 @@
r/SCREEN.Y! r/SCREEN.X! RETURN ( -- )
@draw_capsule_outline ( colour width* height* )
( Store original coordinates and move right by 1 )
r/SCREEN.X? INCkr* r/SCREEN.X! ( c w* h* | x* )
r/SCREEN.Y? ( c w* h* | x* y* )
STH* STH* DUPk DUP ( c c c c | x* y* h* w* )
( Draw top line )
STHkr* #0002 SUB* ( c c c c width-2* | x* y* h* w* )
;draw_horizontal_line CALL ( c c c | x* y* h* w* )
( Draw bottom line )
OVRr* r/SCREEN.Y? ADDr*
LITr* 0001 SUBr* r/SCREEN.Y!
STHkr* #0002 SUB* ( c c c width-2* | x* y* h* w* )
;draw_horizontal_line CALL ( c c | x* y* h* w* )
( Draw left line )
STHr* STHr* OVRr* ( c c w* h* | x* y* x* )
r/SCREEN.X! INCkr* r/SCREEN.Y! ( c c w* h* | x* y* )
SWP* STH* STHk* ( c c h* | x* y* w* h* )
#0002 SUB* ( c height-2* | x* y* w* h* )
;draw_vertical_line CALL ( c | x* y* w* h* )
( Draw right line )
SWPr* r/SCREEN.X? ADDr*
LITr* 0001 SUBr* r/SCREEN.X! ( c | x* y* h* w* )
STHr* #0002 SUB* ( c height-2* | x* y* )
;draw_vertical_line CALL ( | x* y* )
( Clean up and return )
r/SCREEN.Y! r/SCREEN.X! RETURN ( -- )
@draw_capsule_smooth ( colour width* height* )
r/SCREEN.X? r/SCREEN.Y? SWPkr* ( c w* h* | sx* sy* sy* sx* )
INCr* r/SCREEN.X! INCr* r/SCREEN.Y! ( c w* h* | sx* sy* )

View File

@ -209,67 +209,55 @@
@tool_screen__B NORETURN ;canvas_screen GOTO
@tool_screen__change__tool ( delta -- )
/V.ACTIVE_TOOL TOOL_COUNT? ,change__variable JMP
@tool_screen__change__colour ( delta -- )
/V.BRUSH1.COLOUR #04 ,change__variable JMP
@tool_screen__change__shape ( delta -- )
/V.BRUSH1.SHAPE #08 ,change__variable JMP
@tool_screen__change__pattern ( delta -- )
/V.BRUSH1.PATTERN #08 ,change__variable JMP
@tool_screen__change__tool ( delta -- )
/V.ACTIVE_TOOL TOOL_COUNT? ,change__variable JMP
@tool_screen__change__colour ( delta -- )
/V.BRUSH1.COLOUR #04 ,change__variable JMP
@tool_screen__change__shape ( delta -- )
/V.BRUSH1.SHAPE #08 ,change__variable JMP
@tool_screen__change__pattern ( delta -- )
/V.BRUSH1.PATTERN #08 ( ... jump elided ... )
@change__variable ( delta var_addr count -- )
STH LDZk ROT ADD STHr ;clamp CALL SWP STZ RETURN
@tool_screen__draw__colours ( active? )
#0013 CENTER_LEFT! #0005 CENTER_DOWN!
( Choose the colour of the selected colour, whether control is active or not )
COL_2 COL_3 CHOOSE ,&active_col STR
#0400 ( total i )
STH #0400 ( total i | active? )
&loop
DUP /V.BRUSH1.COLOUR? EQU ( is_chosen? )
COL_1 [ LIT &active_col $1 ] CHOOSE
#0015 #0008 ;draw_capsule CALL
DUP /V.BRUSH1.COLOUR? EQU ( total i selected? | active? )
STHkr COL_2 COL_3 CHOOSE ( total i selected? col | active? )
COL_1 SWP CHOOSE ( total i col | active? )
#0015 #0008 ;draw_capsule CALL ( total i | active? )
STHkr NOT ,&skip JCN
COL_1 #0015 #0008 ;draw_capsule_outline CALL
&skip
#0017 MOVE_RIGHT
INC NEQk ,&loop JCN
POP*
POP* POPr
RETURN
@tool_screen__draw__shapes ( active? )
#0010 CENTER_LEFT! #0013 CENTER_DOWN!
( Choose the colour of the selected colour, whether control is active or not )
COL_12 COL_13 CHOOSE ,&active_col STR
;brush_shape /SCREEN.ADDR!
#05 /SCREEN.AUTO!
#0800 ( total i )
&loop
DUP /V.BRUSH1.SHAPE? EQU ( is_chosen? )
COL_10 [ LIT &active_col $1 ] CHOOSE /SCREEN.SPRITE!
#0003 MOVE_RIGHT
INC NEQk ,&loop JCN
#00 /SCREEN.AUTO!
POP*
RETURN
/V.BRUSH1.SHAPE #0013 ;draw_sprite_row JMP*
@tool_screen__draw__patterns ( active? )
#0010 CENTER_LEFT! #0021 CENTER_DOWN!
( Choose the colour of the selected colour, whether control is active or not )
COL_12 COL_13 CHOOSE ,&active_col STR
;brush_pattern /SCREEN.ADDR!
#05 /SCREEN.AUTO!
#0800 ( total i )
/V.BRUSH1.PATTERN #0021 ( ... jump elided ... )
@draw_sprite_row ( active? variable down* )
CENTER_DOWN! #0010 CENTER_LEFT!
#05 /SCREEN.AUTO! ,&variable STR #0800 ( active? total i )
&loop
DUP /V.BRUSH1.PATTERN? EQU ( is_chosen? )
COL_10 [ LIT &active_col $1 ] CHOOSE /SCREEN.SPRITE!
#0003 MOVE_RIGHT
INC NEQk ,&loop JCN
#00 /SCREEN.AUTO!
POP*
DUP [ LIT &variable $1 ] LDZ EQU ( active? total i selected? )
OVR* POP ( active? total i selected? active? )
COL_12 COL_13 CHOOSE COL_10 SWP CHOOSE ( active? total i colour )
/SCREEN.SPRITE! #0003 MOVE_RIGHT ( active? total i )
INC NEQk ,&loop JCN ( active? total i+1 )
POP* POP #00 /SCREEN.AUTO!
RETURN
@tool_screen__draw__tools ( active? )
( TODO: Have the icon that the mouse is currently hovering over be
rendered in the chosen-but-not-active colour. Figure out how to do this