more work on GUI module.
This commit is contained in:
@@ -105,6 +105,8 @@ WID_Widget_Handler:
|
|||||||
breq WID_Widget_Handler_getMinHeight
|
breq WID_Widget_Handler_getMinHeight
|
||||||
cpi r16, WID_SIGNAL_LAYOUT
|
cpi r16, WID_SIGNAL_LAYOUT
|
||||||
breq WID_Widget_Handler_layout
|
breq WID_Widget_Handler_layout
|
||||||
|
cpi r16, WID_SIGNAL_DRAW
|
||||||
|
breq WID_Widget_Handler_draw
|
||||||
; for now just forward signal to all children
|
; for now just forward signal to all children
|
||||||
WID_Widget_Handler_forward:
|
WID_Widget_Handler_forward:
|
||||||
rcall OBJ_ForwardSignalToChildren
|
rcall OBJ_ForwardSignalToChildren
|
||||||
@@ -115,11 +117,45 @@ WID_Widget_Handler_getMinHeight:
|
|||||||
rjmp widgetGetMinHeight
|
rjmp widgetGetMinHeight
|
||||||
WID_Widget_Handler_layout:
|
WID_Widget_Handler_layout:
|
||||||
rjmp widgetLayout
|
rjmp widgetLayout
|
||||||
|
WID_Widget_Handler_draw:
|
||||||
|
rjmp wDraw
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wDraw:
|
||||||
|
ldd r16, Y+OBJ_OFFS_OPTIONS
|
||||||
|
sbrs r16, WID_OPTIONS0_BIT_VISIBLE ; only draw visible widgets
|
||||||
|
rjmp wDraw_ret
|
||||||
|
cbr r16, (1<<WID_OPTIONS0_BIT_DIRTY)
|
||||||
|
std Y+OBJ_OFFS_OPTIONS, r16
|
||||||
|
|
||||||
|
; fill window background
|
||||||
|
ldd r2, Y+WID_OFFS_BG_COL_LO
|
||||||
|
ldd r3, Y+WID_OFFS_BG_COL_HI
|
||||||
|
ldd r4, Y+WID_OFFS_ABS_X_LO
|
||||||
|
ldd r5, Y+WID_OFFS_ABS_X_HI
|
||||||
|
ldd r6, Y+WID_OFFS_ABS_Y_LO
|
||||||
|
ldd r7, Y+WID_OFFS_ABS_Y_HI
|
||||||
|
ldd r8, Y+WID_OFFS_WIDTH_LO
|
||||||
|
ldd r9, Y+WID_OFFS_WIDTH_HI
|
||||||
|
ldd r10, Y+WID_OFFS_HEIGHT_LO
|
||||||
|
ldd r11, Y+WID_OFFS_HEIGHT_HI
|
||||||
|
bigcall ILI9341_FillRect
|
||||||
|
wDraw_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
widgetLayout:
|
widgetLayout:
|
||||||
|
rjmp wVLayout
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wVLayout:
|
||||||
rcall wSetChildrenWidthsFromMinWidths
|
rcall wSetChildrenWidthsFromMinWidths
|
||||||
rcall wSetChildrenHeightsFromMinHeights
|
rcall wSetChildrenHeightsFromMinHeights
|
||||||
|
|
||||||
@@ -128,7 +164,7 @@ widgetLayout:
|
|||||||
ldi r17, WID_OPTIONS1_BIT_STRETCH_Y
|
ldi r17, WID_OPTIONS1_BIT_STRETCH_Y
|
||||||
rcall widgetCountVisibleChildrenWithOptions1 ; (r18, r24, r25, X)
|
rcall widgetCountVisibleChildrenWithOptions1 ; (r18, r24, r25, X)
|
||||||
tst r18
|
tst r18
|
||||||
breq widgetLayout_Ydone ; no expandable children, nothing to distribute
|
breq wVLayout_Ydone ; no expandable children, nothing to distribute
|
||||||
; determine full height needed by all children
|
; determine full height needed by all children
|
||||||
push r18 ; number of visible expandable child widgets
|
push r18 ; number of visible expandable child widgets
|
||||||
clr r17 ; mask=0 -> count all visible children
|
clr r17 ; mask=0 -> count all visible children
|
||||||
@@ -142,30 +178,90 @@ widgetLayout:
|
|||||||
ldd r17, Y+WID_OFFS_BORDER_TOP ; subtract top border
|
ldd r17, Y+WID_OFFS_BORDER_TOP ; subtract top border
|
||||||
sub r20, r17
|
sub r20, r17
|
||||||
sbc r21, r16
|
sbc r21, r16
|
||||||
brcs widgetLayout_heightTooSmall ; jmp if too small
|
brcs wVLayout_heightTooSmall ; jmp if too small
|
||||||
ldd r17, Y+WID_OFFS_BORDER_BOT ; subtract bottom border
|
ldd r17, Y+WID_OFFS_BORDER_BOT ; subtract bottom border
|
||||||
sub r20, r17
|
sub r20, r17
|
||||||
sbc r21, r16
|
sbc r21, r16
|
||||||
brcs widgetLayout_heightTooSmall ; jmp if too small
|
brcs wVLayout_heightTooSmall ; jmp if too small
|
||||||
|
|
||||||
sub r20, r18 ; r21:r20 = HEIGHT-SUM_OF_VIS_CHILDREN_HEIGHTS
|
sub r20, r18 ; r21:r20 = HEIGHT-SUM_OF_VIS_CHILDREN_HEIGHTS
|
||||||
sbc r21, r19
|
sbc r21, r19
|
||||||
brcc widgetLayout_heightTooSmall
|
brcc wVLayout_heightTooSmall
|
||||||
breq widgetLayout_yDone ; nothing to distribute
|
breq wVLayout_yDone ; nothing to distribute
|
||||||
bigcall Utils_Divu16_16_16 ; r17:r16 = r21:r20 / r23:r22
|
bigcall Utils_Divu16_16_16 ; r17:r16 = r21:r20 / r23:r22
|
||||||
; add additional pixel to heights of expandable child widgets
|
; add additional pixel to heights of expandable child widgets
|
||||||
rcall wAddToHeightsOfExpandableVisibleChildren
|
rcall wAddToHeightsOfExpandableVisibleChildren
|
||||||
|
|
||||||
widgetLayout_yDone:
|
wVLayout_yDone:
|
||||||
rcall wSetRelYFromHeightInVisibleChildren
|
rcall wSetRelYFromHeightInVisibleChildren
|
||||||
rcall wAlignChildrenHorizontally
|
rcall wAlignChildrenHorizontally
|
||||||
widgetLayout_heightTooSmall:
|
; rcall wSetAbsoluteCoords call in GUI loop after calling layout on all widgets
|
||||||
|
wVLayout_heightTooSmall:
|
||||||
; TODO: how to handle this case?
|
; TODO: how to handle this case?
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wSetAbsoluteCoords:
|
||||||
|
push yl
|
||||||
|
push yh
|
||||||
|
wSetAbsoluteCoords_loop:
|
||||||
|
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||||
|
andi r18, WID_OPTIONS0_BIT_VISIBLE
|
||||||
|
breq wSetAbsoluteCoords_nextSibling
|
||||||
|
push yl
|
||||||
|
push yh
|
||||||
|
bigcall Tree_GetParentObject
|
||||||
|
clr r18
|
||||||
|
clr r19
|
||||||
|
clr r20
|
||||||
|
clr r21
|
||||||
|
mov r17, xl
|
||||||
|
or r17, xh
|
||||||
|
breq wSetAbsoluteCoords_r1820set
|
||||||
|
mov yl, xl
|
||||||
|
mov yh, xh
|
||||||
|
ldd r18, Y+WID_OFFS_ABS_X_LO
|
||||||
|
ldd r19, Y+WID_OFFS_ABS_X_HI
|
||||||
|
ldd r20, Y+WID_OFFS_ABS_Y_LO
|
||||||
|
ldd r21, Y+WID_OFFS_ABS_Y_HI
|
||||||
|
wSetAbsoluteCoords_r1820set:
|
||||||
|
pop yh
|
||||||
|
pop yl
|
||||||
|
; handle X
|
||||||
|
ldd r16, Y+WID_OFFS_REL_X_LO
|
||||||
|
ldd r17, Y+WID_OFFS_REL_X_HI
|
||||||
|
add r16, r18
|
||||||
|
adc r17, r19
|
||||||
|
std Y+WID_OFFS_ABS_X_LO, r16
|
||||||
|
std Y+WID_OFFS_ABS_X_HI, r17
|
||||||
|
; handle Y
|
||||||
|
ldd r16, Y+WID_OFFS_REL_Y_LO
|
||||||
|
ldd r17, Y+WID_OFFS_REL_Y_HI
|
||||||
|
add r16, r20
|
||||||
|
adc r17, r21
|
||||||
|
std Y+WID_OFFS_ABS_Y_LO, r16
|
||||||
|
std Y+WID_OFFS_ABS_Y_HI, r17
|
||||||
|
bigcall Tree_GetObjectBelow
|
||||||
|
rjmp wSetAbsoluteCoords_loopEnd
|
||||||
|
wSetAbsoluteCoords_nextSibling:
|
||||||
|
bigcall Tree_GetNextSibling
|
||||||
|
wSetAbsoluteCoords_loopEnd:
|
||||||
|
mov r17, xl
|
||||||
|
or r17, xh
|
||||||
|
breq wSetAbsoluteCoords_end
|
||||||
|
mov yl, xl
|
||||||
|
mov yh, xh
|
||||||
|
rjmp wSetAbsoluteCoords_loop
|
||||||
|
wSetAbsoluteCoords_end:
|
||||||
|
pop yh
|
||||||
|
pop yl
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine wAlignChildrenHorizontally
|
; @routine wAlignChildrenHorizontally
|
||||||
;
|
;
|
||||||
@@ -230,6 +326,8 @@ wAlignChildrenHorizontally_loopEnd:
|
|||||||
|
|
||||||
wAlignHorizontally:
|
wAlignHorizontally:
|
||||||
ldd r16, Y+WID_OFFS_OPTIONS1
|
ldd r16, Y+WID_OFFS_OPTIONS1
|
||||||
|
sbrc r16, WID_OPTIONS1_BIT_STRETCH_X
|
||||||
|
rjmp wAlignHorizontally_stretch
|
||||||
andi r16, (WID_OPTIONS1_BIT_HALIGN0 | WID_OPTIONS1_BIT_HALIGN1)
|
andi r16, (WID_OPTIONS1_BIT_HALIGN0 | WID_OPTIONS1_BIT_HALIGN1)
|
||||||
cpi r16, (0<<WID_OPTIONS1_BIT_HALIGN1) | (0<<WID_OPTIONS1_BIT_HALIGN0)
|
cpi r16, (0<<WID_OPTIONS1_BIT_HALIGN1) | (0<<WID_OPTIONS1_BIT_HALIGN0)
|
||||||
breq wAlignHorizontally_left
|
breq wAlignHorizontally_left
|
||||||
@@ -252,6 +350,7 @@ wAlignHorizontally_right:
|
|||||||
ldd r17, Y+WID_OFFS_WIDTH_HI
|
ldd r17, Y+WID_OFFS_WIDTH_HI
|
||||||
sub r24, r16
|
sub r24, r16
|
||||||
sbc r25, r17
|
sbc r25, r17
|
||||||
|
wAlignHorizontally_stretch:
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user