diff --git a/avr/modules/lcd2/win/widget.asm b/avr/modules/lcd2/win/widget.asm index aee4957..d9d083b 100644 --- a/avr/modules/lcd2/win/widget.asm +++ b/avr/modules/lcd2/win/widget.asm @@ -105,6 +105,8 @@ WID_Widget_Handler: breq WID_Widget_Handler_getMinHeight cpi r16, WID_SIGNAL_LAYOUT breq WID_Widget_Handler_layout + cpi r16, WID_SIGNAL_DRAW + breq WID_Widget_Handler_draw ; for now just forward signal to all children WID_Widget_Handler_forward: rcall OBJ_ForwardSignalToChildren @@ -115,11 +117,45 @@ WID_Widget_Handler_getMinHeight: rjmp widgetGetMinHeight WID_Widget_Handler_layout: rjmp widgetLayout +WID_Widget_Handler_draw: + rjmp wDraw ; @end + +wDraw: + ldd r16, Y+OBJ_OFFS_OPTIONS + sbrs r16, WID_OPTIONS0_BIT_VISIBLE ; only draw visible widgets + rjmp wDraw_ret + cbr r16, (1< count all visible children @@ -142,30 +178,90 @@ widgetLayout: ldd r17, Y+WID_OFFS_BORDER_TOP ; subtract top border sub r20, r17 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 sub r20, r17 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 sbc r21, r19 - brcc widgetLayout_heightTooSmall - breq widgetLayout_yDone ; nothing to distribute + brcc wVLayout_heightTooSmall + breq wVLayout_yDone ; nothing to distribute bigcall Utils_Divu16_16_16 ; r17:r16 = r21:r20 / r23:r22 ; add additional pixel to heights of expandable child widgets rcall wAddToHeightsOfExpandableVisibleChildren -widgetLayout_yDone: +wVLayout_yDone: rcall wSetRelYFromHeightInVisibleChildren rcall wAlignChildrenHorizontally -widgetLayout_heightTooSmall: +; rcall wSetAbsoluteCoords call in GUI loop after calling layout on all widgets +wVLayout_heightTooSmall: ; TODO: how to handle this case? ret ; @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 ; @@ -230,6 +326,8 @@ wAlignChildrenHorizontally_loopEnd: wAlignHorizontally: 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) cpi r16, (0<