// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movl 0x5e8(%rdi), %eax
movl %eax, 0x5d8(%rdi)
movl %eax, 0x5dc(%rdi)
movl %eax, 0x5e0(%rdi)
movl %eax, 0x5e4(%rdi)
cmpl $0x0, 0x40(%rdi)
jle 0x984a4
leaq 0x38(%rbx), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %ebp, %ebp
movq 0x18(%rsp), %rdi
movl %ebp, %esi
callq 0x5b0a4
movq (%rax), %r14
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
movl %eax, %r12d
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x4, %eax
jne 0x9841f
movl 0x5d8(%rbx), %eax
movl 0x5dc(%rbx), %ecx
movl %eax, 0x10(%rsp)
movl %ecx, 0x14(%rsp)
movl 0xb0(%rbx), %ecx
addl 0x5e0(%rbx), %eax
subl %eax, %ecx
movl 0xb4(%r14), %eax
movl %ecx, 0x8(%rsp)
movl %eax, 0xc(%rsp)
movq (%r14), %rax
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq *0x150(%rax)
movl 0x5dc(%rbx), %eax
addl 0xb4(%r14), %eax
movl %eax, 0x5dc(%rbx)
cmpw $0x1, 0x1a0(%r14)
jne 0x98491
addl $0x3, %eax
movl %eax, 0x5dc(%rbx)
jmp 0x98491
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x8, %eax
jne 0x9848e
movl 0x5d8(%rbx), %eax
movl 0xb4(%rbx), %ecx
movl 0xb4(%r14), %edx
movl 0x5e4(%rbx), %esi
addl %edx, %esi
subl %esi, %ecx
movl %eax, 0x10(%rsp)
movl %ecx, 0x14(%rsp)
movl 0xb0(%rbx), %ecx
addl 0x5e0(%rbx), %eax
subl %eax, %ecx
movl %ecx, 0x8(%rsp)
movl %edx, 0xc(%rsp)
movq (%r14), %rax
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq *0x150(%rax)
movl 0xb4(%r14), %eax
addl %eax, 0x5e4(%rbx)
movq %r13, %r14
orl %r12d, %r15d
incl %ebp
movq %r14, %r13
cmpl 0x40(%rbx), %ebp
jl 0x98380
jmp 0x984aa
xorl %r15d, %r15d
xorl %r14d, %r14d
testb $0x4, %r15b
je 0x984b7
addl $0x3, 0x5dc(%rbx)
testb $0x8, %r15b
je 0x984c4
addl $0x5, 0x5e4(%rbx)
testq %r14, %r14
je 0x984e0
xorl %eax, %eax
cmpw $0x2, 0x1a0(%r14)
sete %al
leal (%rax,%rax,2), %eax
addl %eax, 0x5dc(%rbx)
leaq 0x5d8(%rbx), %rax
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x40(%rbx)
jle 0x985fe
leaq 0x38(%rbx), %r14
leaq 0x5e0(%rbx), %rax
movq %rax, 0x20(%rsp)
xorl %ebp, %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x5b0a4
movq (%rax), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
cmpl $0x10, %eax
jne 0x9857d
movl 0x5d8(%rbx), %eax
movl 0x5dc(%rbx), %ecx
movl %eax, 0x10(%rsp)
movl %ecx, 0x14(%rsp)
leaq 0xb0(%r13), %r12
movl 0xb0(%r13), %eax
movl 0xb4(%rbx), %edx
addl 0x5e4(%rbx), %ecx
subl %ecx, %edx
movl %eax, 0x8(%rsp)
movl %edx, 0xc(%rsp)
movq (%r13), %rax
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq *0x150(%rax)
movq 0x18(%rsp), %rax
jmp 0x985ed
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
cmpl $0x20, %eax
jne 0x985f3
movl 0xb0(%rbx), %eax
leaq 0xb0(%r13), %r12
movl 0xb0(%r13), %ecx
movl 0x5e0(%rbx), %edx
addl %ecx, %edx
subl %edx, %eax
movl 0x5dc(%rbx), %edx
movl %eax, 0x10(%rsp)
movl %edx, 0x14(%rsp)
movl 0xb4(%rbx), %eax
addl 0x5e4(%rbx), %edx
subl %edx, %eax
movl %ecx, 0x8(%rsp)
movl %eax, 0xc(%rsp)
movq (%r13), %rax
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq *0x150(%rax)
movq 0x20(%rsp), %rax
movl (%r12), %ecx
addl %ecx, (%rax)
incl %ebp
cmpl 0x40(%rbx), %ebp
jl 0x98508
testb $0x10, %r15b
je 0x9860c
movq 0x18(%rsp), %rax
addl $0x3, (%rax)
testb $0x20, %r15b
je 0x98619
addl $0x3, 0x5e0(%rbx)
cmpl $0x0, 0x40(%rbx)
jle 0x986ba
leaq 0x38(%rbx), %r14
xorl %ebp, %ebp
leaq 0x10(%rsp), %r15
leaq 0x8(%rsp), %r12
movq %r14, %rdi
movl %ebp, %esi
callq 0x5b0a4
movq (%rax), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
cmpl $0x40, %eax
jne 0x986af
movl 0x5d8(%rbx), %eax
movl 0x5dc(%rbx), %ecx
movl %eax, 0x10(%rsp)
movl %ecx, 0x14(%rsp)
addl 0x5e0(%rbx), %eax
movl 0xb0(%rbx), %edx
subl %eax, %edx
movl 0xb4(%rbx), %eax
addl 0x5e4(%rbx), %ecx
subl %ecx, %eax
movl %edx, 0x8(%rsp)
movl %eax, 0xc(%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 0x98633
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop