// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/classes/gui/widgets/multi/list/combobox.cpp
// Function: smooth::GUI::ComboBox::OpenListBox()
S::Void S::GUI::ComboBox::OpenListBox()
{
	if (listBox != NIL) return;

	Window	*window	     = container->GetContainerWindow();
	Surface	*surface     = GetDrawSurface();

	if (S::System::System::Clock() - listBoxClosed < 100)
	{
		if (window->IsMouseOn(Rect(buttonHotspot->GetRealPosition(), buttonHotspot->GetRealSize()))) buttonHotspot->Paint(SP_MOUSEUP);

		return;
	}

	Rect	 monitor     = System::Screen::GetActiveScreenWorkArea();
	Float	 scaleFactor = surface->GetSurfaceDPI() / 96.0;

	Size	 listBoxSize = Size(GetWidth(), 16 * Math::Min(Length(), Math::Max(5, Math::Min(16, Length() / 3))) + 4);
	Point	 listBoxPos  = Point(GetRealPosition() + Point(0, GetRealSize().cy));

	if (window->GetY() + listBoxPos.y + Math::Round(listBoxSize.cy * scaleFactor) >= monitor.bottom) listBoxPos = Point(GetRealPosition() - Point(0, Math::Round(listBoxSize.cy * scaleFactor)));

	listBox	   = new ListBox(Point(), listBoxSize);
	listBox->onSelectEntry.Connect(&onSelectEntry);

	toolWindow = new ToolWindow(listBoxPos, listBoxSize);
	toolWindow->onLoseFocus.Connect(&ComboBox::CloseListBox, this);

	window->onChangePosition.Connect(&ComboBox::CloseListBox, this);
	window->onChangeSize.Connect(&ComboBox::CloseListBox, this);

	listBox->SetFlags(LF_ALLOWRESELECT | LF_HIDEHEADER);
	listBox->AddTab(NIL, 32768);

	ListEntry	*selectedEntry = GetSelectedEntry();

	if (selectedEntry != NIL) prevSelectedEntry = selectedEntry->GetHandle();

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

		entry->SetRegisteredFlag(False);

		listBox->Add(entry);

		if (entry->GetUnscaledTextWidth() >= listBoxSize.cx - (listBoxSize.cy < 16 * Length() ? 22 : 5)) entry->SetTooltipText(entry->GetText());
		else												 entry->SetTooltipText(NIL);

		entry->Activate();
	}

	toolWindow->Add(listBox);

	Add(toolWindow);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpq $0x0, 0x6d0(%rdi)
jne 0x824de
movq %rdi, %rbx
movq 0x190(%rdi), %rdi
callq 0x559e0
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq %rax, %r12
callq 0x570e0
subq 0x6d8(%rbx), %rax
cmpq $0x63, %rax
ja 0x821a0
movq 0x6f0(%rbx), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq %rax, %r15
movq %rax, %r12
shrq $0x20, %r12
movq 0x6f0(%rbx), %rdi
movq (%rdi), %rax
callq *0x50(%rax)
leal (%rax,%r15), %ecx
shrq $0x20, %rax
leaq 0x18(%rsp), %rsi
movl %r15d, (%rsi)
movl %r12d, 0x4(%rsi)
movl %ecx, 0x8(%rsi)
addl %r12d, %eax
movl %eax, 0xc(%rsi)
movq %r14, %rdi
callq 0x578a0
testb %al, %al
je 0x824de
movq 0x6f0(%rbx), %rdi
movq (%rdi), %rax
movl $0x5, %esi
callq *0x78(%rax)
jmp 0x824de
callq 0x57e90
movq %rdx, %r15
movq %r12, %rdi
callq 0x58930
cwtl
cvtsi2sd %eax, %xmm0
divsd 0x714fb(%rip), %xmm0    # 0xf36b8
movsd %xmm0, 0x30(%rsp)
movl 0xb0(%rbx), %r12d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
movl %eax, %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
cltq
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
addl %ecx, %eax
cmpl $0x10, %eax
movl $0x10, %ecx
cmovll %eax, %ecx
cmpl $0x6, %ecx
movq %rbx, (%rsp)
movl $0x5, %r13d
cmovgel %ecx, %r13d
cmpl %r13d, %ebp
cmovll %ebp, %r13d
movabsq $-0x100000000, %rbp     # imm = 0xFFFFFFFF00000000
shll $0x4, %r13d
orl $0x4, %r13d
movl %r12d, 0x8(%rsp)
movl %r13d, 0xc(%rsp)
movq (%rsp), %rax
movq (%rax), %rax
movq (%rsp), %rdi
callq *0x48(%rax)
movq %rax, %r12
movq (%rsp), %rax
movq (%rax), %rax
movq (%rsp), %rdi
callq *0x50(%rax)
andq %rbp, %rax
addq %r12, %rax
movq %rax, 0x10(%rsp)
movslq 0xac(%r14), %rcx
sarq $0x20, %rax
addq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movq (%rsp), %r13
mulsd 0x30(%rsp), %xmm0
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
ucomisd %xmm0, %xmm1
seta %cl
leaq 0x71559(%rip), %rdx     # 0xf37f0
addsd (%rdx,%rcx,8), %xmm0
cvttsd2si %xmm0, %r12
addq %r12, %rax
sarq $0x20, %r15
cmpq %r15, %rax
jl 0x822cb
movq (%r13), %rax
movq %r13, %rdi
callq *0x48(%rax)
shlq $0x20, %r12
movl %eax, %ecx
subq %r12, %rax
andq %rbp, %rax
orq %rax, %rcx
movq %rcx, 0x10(%rsp)
movl $0x718, %edi            # imm = 0x718
callq 0x556b0
movq %rax, %r15
leaq 0x18(%rsp), %rsi
movq $0x0, (%rsi)
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
callq 0x56bb0
movq %r15, 0x6d0(%r13)
movl $0x688, %esi            # imm = 0x688
addq %rsi, %r15
addq %r13, %rsi
movq %r15, %rdi
callq 0x83012
movl $0x6d8, %edi            # imm = 0x6D8
callq 0x556b0
movq %rax, %r15
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
callq 0x59000
movq %r15, 0x6c8(%r13)
addq $0x518, %r15            # imm = 0x518
movq 0xe9b71(%rip), %r12     # 0x16beb0
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x82f52
leaq 0x278(%r14), %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x82d12
addq $0x298, %r14            # imm = 0x298
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x830c4
movq 0x6d0(%r13), %r15
movl $0xa, 0x30(%r15)
leaq 0x18(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x58e20
movq 0x6d8(%r15), %rdi
movq %r14, %rsi
movl $0x8000, %edx           # imm = 0x8000
movl $0x10, %ecx
callq 0x57690
leaq 0x18(%rsp), %rdi
callq 0x59200
movq %r13, %rdi
callq 0x55f90
testq %rax, %rax
je 0x823d2
movl 0x8(%rax), %eax
movl %eax, 0x6e0(%r13)
movq (%r13), %rax
movq %r13, %rdi
callq *0x178(%rax)
testl %eax, %eax
jle 0x824b9
xorl %ebp, %ebp
leaq 0x18(%rsp), %rbx
movq (%r13), %rax
movq %r13, %rdi
movl %ebp, %esi
callq *0x180(%rax)
movq %rax, %r15
movb $0x0, 0xca(%rax)
movq 0x6d0(%r13), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x30(%rax)
movq (%r15), %rax
movq %r15, %rdi
callq *0xf0(%rax)
movl %eax, %r12d
movq %r13, %rdi
movl 0x8(%rsp), %r13d
movl 0xc(%rsp), %r14d
movq (%rdi), %rax
callq *0x178(%rax)
shll $0x4, %eax
cmpl %eax, %r14d
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
movl $0xffffffea, %ecx       # imm = 0xFFFFFFEA
cmovll %ecx, %eax
addl %r13d, %eax
cmpl %eax, %r12d
jge 0x8247a
movq %rbx, %rdi
xorl %esi, %esi
callq 0x58e20
movq (%r15), %rax
movq %r15, %rdi
movq %rbx, %rsi
callq *0xb0(%rax)
movq %rbx, %rdi
callq 0x59200
jmp 0x82495
movq (%r15), %rax
movq %r15, %rdi
callq *0xa8(%rax)
movq (%r15), %rcx
movq %r15, %rdi
movq %rax, %rsi
callq *0xb0(%rcx)
movq (%rsp), %r13
movq (%r15), %rax
movq %r15, %rdi
callq *0x68(%rax)
incl %ebp
movq (%r13), %rax
movq %r13, %rdi
callq *0x178(%rax)
cmpl %eax, %ebp
jl 0x823ee
movq 0x6c8(%r13), %rdi
movq 0x6d0(%r13), %rsi
movq (%rdi), %rax
callq *0x30(%rax)
movq 0x6c8(%r13), %rsi
movq (%r13), %rax
movq %r13, %rdi
callq *0x30(%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8250b
movq %rax, %rbx
movl $0x6d8, %esi            # imm = 0x6D8
jmp 0x82501
movq %rax, %rbx
movl $0x718, %esi            # imm = 0x718
movq %r15, %rdi
callq 0x55480
jmp 0x82518
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x57090