// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/classes/gui/window/window.cpp
// Function: smooth::GUI::Window::CalculateOffsets()
S::Void S::GUI::Window::CalculateOffsets()
{
	Widget	*lastTopWidget	= NIL;
	Int	 positions	= 0;

	innerOffset = Rect(Point(frameWidth, frameWidth), Size(0, 0));

	for (Int i = 0; i < GetNOfObjects(); i++)
	{
		Widget	*widget = GetNthObject(i);

		positions |= widget->GetOrientation();

		if (widget->GetOrientation() == OR_TOP)
		{
			lastTopWidget = widget;

			widget->SetMetrics(Point(innerOffset.left, innerOffset.top), Size(GetWidth() - innerOffset.left - innerOffset.right, widget->GetHeight()));

			innerOffset.top += widget->GetHeight();

			if (widget->subtype == WO_SEPARATOR) innerOffset.top += 3;
		}
		else if (widget->GetOrientation() == OR_BOTTOM)
		{
			widget->SetMetrics(Point(innerOffset.left, GetHeight() - innerOffset.bottom - widget->GetHeight()), Size(GetWidth() - innerOffset.left - innerOffset.right, widget->GetHeight()));

			innerOffset.bottom += widget->GetHeight();
		}
	}

	if (positions & OR_TOP)	   innerOffset.top    += 3;
	if (positions & OR_BOTTOM) innerOffset.bottom += 5;

	if (lastTopWidget != NIL)  innerOffset.top    += (lastTopWidget->subtype == WO_NOSEPARATOR ? 3 : 0);

	for (Int i = 0; i < GetNOfObjects(); i++)
	{
		Widget	*widget = GetNthObject(i);

		if (widget->GetOrientation() == OR_LEFT)
		{
			widget->SetMetrics(Point(innerOffset.left, innerOffset.top), Size(widget->GetWidth(), GetHeight() - innerOffset.top - innerOffset.bottom));

			innerOffset.left += widget->GetWidth();
		}
		else if (widget->GetOrientation() == OR_RIGHT)
		{
			widget->SetMetrics(Point(GetWidth() - innerOffset.right - widget->GetWidth(), innerOffset.top), Size(widget->GetWidth(), GetHeight() - innerOffset.top - innerOffset.bottom));

			innerOffset.right += widget->GetWidth();
		}
	}

	if (positions & OR_LEFT)  innerOffset.left  += 3;
	if (positions & OR_RIGHT) innerOffset.right += 3;

	for (Int i = 0; i < GetNOfObjects(); i++)
	{
		Widget	*widget = GetNthObject(i);

		if (widget->GetOrientation() == OR_CENTER)
		{
			widget->SetMetrics(Point(innerOffset.left, innerOffset.top), Size(GetWidth() - innerOffset.left - innerOffset.right, GetHeight() - innerOffset.top - innerOffset.bottom));
			widget->SetOrientation(OR_CENTER);
		}
	}
}

// Assembly:
movdqu 0x5e8(%rdi), %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
movdqu %xmm0, 0x5d8(%rdi)
cmpl $0x0, 0x40(%rdi)
jle 0x97f6c
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x5d8(%rdi), %rax
movq %rax, 0x20(%rsp)
leaq 0x5e0(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x38(%rdi), %r14
movq $0x0, 0x10(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x5b074
movq (%rax), %r15
movq (%r15), %rax
movq %r15, %rdi
callq *0x128(%rax)
movl %eax, %r13d
movq (%r15), %rax
movq %r15, %rdi
callq *0x128(%rax)
cmpl $0x4, %eax
jne 0x97cef
movq 0x5d8(%rbx), %rax
movq %rax, 0x8(%rsp)
movl 0xb0(%rbx), %ecx
addl 0x5e0(%rbx), %eax
subl %eax, %ecx
movl 0xb4(%r15), %eax
movl %ecx, (%rsp)
movl %eax, 0x4(%rsp)
movq (%r15), %rax
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
callq *0x150(%rax)
movl 0x5dc(%rbx), %eax
addl 0xb4(%r15), %eax
movl %eax, 0x5dc(%rbx)
cmpw $0x1, 0x1a0(%r15)
jne 0x97ce8
addl $0x3, %eax
movl %eax, 0x5dc(%rbx)
movq %r15, 0x10(%rsp)
jmp 0x97d5b
movq (%r15), %rax
movq %r15, %rdi
callq *0x128(%rax)
cmpl $0x8, %eax
jne 0x97d5b
movl 0x5d8(%rbx), %eax
movl 0xb4(%rbx), %ecx
movl 0xb4(%r15), %edx
movl 0x5e4(%rbx), %esi
addl %edx, %esi
subl %esi, %ecx
movl %eax, 0x8(%rsp)
movl %ecx, 0xc(%rsp)
movl 0xb0(%rbx), %ecx
addl 0x5e0(%rbx), %eax
subl %eax, %ecx
movl %ecx, (%rsp)
movl %edx, 0x4(%rsp)
movq (%r15), %rax
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
callq *0x150(%rax)
movl 0xb4(%r15), %eax
addl %eax, 0x5e4(%rbx)
orl %r13d, %r12d
incl %ebp
movl 0x40(%rbx), %eax
cmpl %eax, %ebp
jl 0x97c58
testb $0x4, %r12b
je 0x97d78
addl $0x3, 0x5dc(%rbx)
testb $0x8, %r12b
movq 0x10(%rsp), %rdx
je 0x97d8a
addl $0x5, 0x5e4(%rbx)
testq %rdx, %rdx
je 0x97da5
xorl %ecx, %ecx
cmpw $0x2, 0x1a0(%rdx)
sete %cl
leal (%rcx,%rcx,2), %ecx
addl %ecx, 0x5dc(%rbx)
testl %eax, %eax
jle 0x97ea7
xorl %ebp, %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x5b074
movq (%rax), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
cmpl $0x10, %eax
jne 0x97e21
movl 0x5d8(%rbx), %eax
movl 0x5dc(%rbx), %ecx
movl %eax, 0x8(%rsp)
movl %ecx, 0xc(%rsp)
leaq 0xb0(%r13), %r15
movl 0xb0(%r13), %eax
movl 0xb4(%rbx), %edx
addl 0x5e4(%rbx), %ecx
subl %ecx, %edx
movl %eax, (%rsp)
movl %edx, 0x4(%rsp)
movq (%r13), %rax
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
callq *0x150(%rax)
movq 0x20(%rsp), %rax
jmp 0x97e8e
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
cmpl $0x20, %eax
jne 0x97e93
movl 0xb0(%rbx), %eax
leaq 0xb0(%r13), %r15
movl 0xb0(%r13), %ecx
movl 0x5e0(%rbx), %edx
addl %ecx, %edx
subl %edx, %eax
movl 0x5dc(%rbx), %edx
movl %eax, 0x8(%rsp)
movl %edx, 0xc(%rsp)
movl 0xb4(%rbx), %eax
addl 0x5e4(%rbx), %edx
subl %edx, %eax
movl %ecx, (%rsp)
movl %eax, 0x4(%rsp)
movq (%r13), %rax
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
callq *0x150(%rax)
movq 0x18(%rsp), %rax
movl (%r15), %ecx
addl %ecx, (%rax)
incl %ebp
movl 0x40(%rbx), %eax
cmpl %eax, %ebp
jl 0x97daf
testl %eax, %eax
setg %al
jmp 0x97ea9
xorl %eax, %eax
testb $0x10, %r12b
je 0x97eb7
movq 0x20(%rsp), %rcx
addl $0x3, (%rcx)
testb $0x20, %r12b
je 0x97ec5
movq 0x18(%rsp), %rcx
addl $0x3, (%rcx)
testb %al, %al
je 0x97f5e
xorl %ebp, %ebp
leaq 0x8(%rsp), %r15
movq %rsp, %r12
movq %r14, %rdi
movl %ebp, %esi
callq 0x5b074
movq (%rax), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
cmpl $0x40, %eax
jne 0x97f53
movq 0x5d8(%rbx), %rax
movq %rax, %xmm0
movl %eax, 0x8(%rsp)
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
movd %xmm1, 0xc(%rsp)
movq 0xb0(%rbx), %xmm1
movq 0x5e0(%rbx), %xmm2
paddd %xmm0, %xmm2
psubd %xmm2, %xmm1
movq %xmm1, (%rsp)
movq (%r13), %rax
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *0x150(%rax)
movq (%r13), %rax
movq %r13, %rdi
movl $0x40, %esi
callq *0x120(%rax)
incl %ebp
cmpl 0x40(%rbx), %ebp
jl 0x97ed7
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop