// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/gui/widgets/multi/menu/popupmenu.cpp
// Function: smooth::GUI::PopupMenu::CalculateSize()
S::Void S::GUI::PopupMenu::CalculateSize()
{
	SetSize(Size(50, 5));

	Int	 nextYPos		= 3;
	Int	 maxShortcutTextSize	= 0;

	for (Int i = 0; i < Length(); i++)
	{
		PopupMenuEntry	*entry = (PopupMenuEntry *) GetNthEntry(i);

		if (entry->GetObjectType() != PopupMenuEntry::classID) continue;

		maxShortcutTextSize = Math::Max(maxShortcutTextSize, entry->GetShortcutTextSize());
	}

	for (Int i = 0; i < Length(); i++)
	{
		PopupMenuEntry	*entry = (PopupMenuEntry *) GetNthEntry(i);

		if (entry->GetObjectType() != PopupMenuEntry::classID) continue;

		SetWidth(Math::Max(GetWidth(), 6 + entry->GetMinimumSize().cx - (entry->GetShortcutTextSize() > 0 ? entry->GetShortcutTextSize() - maxShortcutTextSize : 0)));
		SetHeight(GetHeight() + 5 + (entry->GetText() != NIL ? 11 : 0));

		entry->SetPosition(Point(3, nextYPos));

		nextYPos += entry->GetHeight() + 1;
	}

	for (Int i = 0; i < Length(); i++)
	{
		PopupMenuEntry	*entry = (PopupMenuEntry *) GetNthEntry(i);

		if (entry->GetObjectType() != PopupMenuEntry::classID) continue;

		entry->SetWidth(GetWidth() - 6);
		entry->SetShortcutOffset(maxShortcutTextSize + 21);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movabsq $0x500000032, %rax      # imm = 0x500000032
leaq 0x8(%rsp), %rdx
movq %rax, (%rdx)
leaq 0xa8(%rdi), %rsi
movq (%rdi), %rax
callq *0x150(%rax)
movq 0xd86f4(%rip), %rax     # 0x161688
xorl %r15d, %r15d
movswl (%rax), %ebp
xorl %r12d, %r12d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
cmpl %eax, %r15d
jge 0x88fe3
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
callq *0x180(%rax)
movq %rax, %r14
leaq 0x20(%rax), %rdi
movl %ebp, %esi
callq 0x5a150
testb %al, %al
jne 0x88fde
movq %r14, %rdi
callq 0x5a130
cmpl %eax, %r12d
cmovlel %eax, %r12d
incl %r15d
jmp 0x88f9d
pushq $0x3
popq %r14
xorl %r15d, %r15d
movl %ebp, 0x4(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
cmpl %eax, %r15d
jge 0x890f8
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
callq *0x180(%rax)
movq %rax, %r13
leaq 0x20(%rax), %rdi
movl %ebp, %esi
callq 0x5a150
testb %al, %al
jne 0x890f0
movq %r14, 0x10(%rsp)
movl %r12d, %ebp
movl 0xb0(%rbx), %r12d
movq %r13, %rdi
callq 0x57c40
movq %rax, %r14
movq %r13, %rdi
callq 0x5a130
testl %eax, %eax
jle 0x8905c
movq %r13, %rdi
callq 0x5a130
movl %ebp, %ecx
subl %eax, %ecx
jmp 0x8905e
xorl %ecx, %ecx
addl $0x6, %r14d
addl %ecx, %r14d
cmpl %r14d, %r12d
jg 0x8906d
movl %r14d, %r12d
movq %rbx, %rdi
movl %r12d, %esi
callq 0x5a1f0
movl 0xb4(%rbx), %r14d
movq (%r13), %rax
movq %r13, %rdi
callq *0xa8(%rax)
movq %rax, %rdi
xorl %esi, %esi
callq 0x57d40
pushq $0xb
popq %rcx
testb %al, %al
jne 0x8909f
xorl %ecx, %ecx
leal (%r14,%rcx), %esi
addl $0x5, %esi
movq %rbx, %rdi
callq 0x58980
movl $0x3, 0x8(%rsp)
movq 0x10(%rsp), %r14
movl %r14d, 0xc(%rsp)
movq %r13, %rdx
addq $0xb0, %rdx
movq (%r13), %rax
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq *0x150(%rax)
movl 0xb4(%r13), %eax
addl %eax, %r14d
incl %r14d
movl %ebp, %r12d
movl 0x4(%rsp), %ebp
incl %r15d
jmp 0x88fee
addl $0x15, %r12d
xorl %r15d, %r15d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
cmpl %eax, %r15d
jge 0x89152
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
callq *0x180(%rax)
movq %rax, %r14
leaq 0x20(%rax), %rdi
movl %ebp, %esi
callq 0x5a150
testb %al, %al
jne 0x8914d
movl 0xb0(%rbx), %esi
addl $-0x6, %esi
movq %r14, %rdi
callq 0x5a1f0
movq %r14, %rdi
movl %r12d, %esi
callq 0x568e0
incl %r15d
jmp 0x890ff
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop