// File: /workspace/github_c_makefile_star2_O1/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 0x829c1
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 0x82668
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 0x20(%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 0x829c1
movq 0x6f0(%rbx), %rdi
movq (%rdi), %rax
movl $0x5, %esi
callq *0x78(%rax)
jmp 0x829c1
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
callq 0x57e90
movq %rdx, %r15
movq %r12, %rdi
callq 0x58930
cwtl
cvtsi2sd %eax, %xmm0
divsd 0x71e61(%rip), %xmm0    # 0xf44f0
movsd %xmm0, 0x18(%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
movl $0x5, %eax
cmovgel %ecx, %eax
cmpl %eax, %ebp
cmovll %ebp, %eax
shll $0x4, %eax
orl $0x4, %eax
movl %r12d, (%rsp)
movl %eax, 0x4(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x48(%rax)
movq %rax, %r12
movq (%rbx), %rax
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq *0x50(%rax)
andq %r13, %rax
addq %r12, %rax
movq %rax, 0x10(%rsp)
movslq 0xac(%r14), %rax
movslq 0x14(%rsp), %rcx
addq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x72044(%rip), %r12     # 0xf4790
addsd (%r12,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
addq %rcx, %rax
sarq $0x20, %r15
cmpq %r15, %rax
jl 0x827ad
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
mulsd %xmm0, %xmm1
xorl %ecx, %ecx
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
seta %cl
addsd (%r12,%rcx,8), %xmm1
cvttsd2si %xmm1, %rcx
shlq $0x20, %rcx
movl %eax, %edx
subq %rcx, %rax
andq %r13, %rax
orq %rax, %rdx
movq %rdx, 0x10(%rsp)
movl $0x718, %edi            # imm = 0x718
callq 0x556b0
movq %rax, %r15
leaq 0x20(%rsp), %rsi
movq $0x0, (%rsi)
movq %rsp, %rdx
movq %rax, %rdi
callq 0x56bb0
movq 0x8(%rsp), %r13
movq %r15, 0x6d0(%r13)
movl $0x688, %esi            # imm = 0x688
addq %rsi, %r15
addq %r13, %rsi
movq %r15, %rdi
callq 0x834d4
movl $0x6d8, %edi            # imm = 0x6D8
callq 0x556b0
movq %rax, %r15
leaq 0x10(%rsp), %rsi
movq %rsp, %rdx
movq %rax, %rdi
callq 0x59000
movq %r15, 0x6c8(%r13)
addq $0x518, %r15            # imm = 0x518
movq 0xea68e(%rip), %r12     # 0x16ceb0
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x83416
leaq 0x278(%r14), %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x831dc
addq $0x298, %r14            # imm = 0x298
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x83584
movq 0x6d0(%r13), %r15
movl $0xa, 0x30(%r15)
leaq 0x20(%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 0x20(%rsp), %rdi
callq 0x59200
movq %r13, %rdi
callq 0x55f90
testq %rax, %rax
je 0x828b5
movl 0x8(%rax), %eax
movl %eax, 0x6e0(%r13)
movq (%r13), %rax
movq %r13, %rdi
callq *0x178(%rax)
testl %eax, %eax
jle 0x8299c
xorl %ebp, %ebp
leaq 0x20(%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 (%rsp), %r13d
movl 0x4(%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 0x8295c
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 0x82977
movq (%r15), %rax
movq %r15, %rdi
callq *0xa8(%rax)
movq (%r15), %rcx
movq %r15, %rdi
movq %rax, %rsi
callq *0xb0(%rcx)
movq 0x8(%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 0x828d1
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 0x829ee
movq %rax, %rbx
movl $0x6d8, %esi            # imm = 0x6D8
jmp 0x829e4
movq %rax, %rbx
movl $0x718, %esi            # imm = 0x718
movq %r15, %rdi
callq 0x55480
jmp 0x829fb
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x57090
nop