// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x128(%rbp)
cmpq $0x0, 0x6d0(%rax)
je 0xadc19
jmp 0xae2a6
movq -0x128(%rbp), %rax
movq 0x190(%rax), %rdi
callq 0x59bc0
movq -0x128(%rbp), %rdi
movq %rax, -0x10(%rbp)
movq (%rdi), %rax
callq *0x40(%rax)
movq %rax, -0x18(%rbp)
callq 0x5b700
movq -0x128(%rbp), %rcx
subq 0x6d8(%rcx), %rax
cmpq $0x64, %rax
jae 0xadce1
movq -0x128(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, -0x130(%rbp)
movq 0x6f0(%rax), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq %rax, %rcx
movq -0x128(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq 0x6f0(%rax), %rdi
movq (%rdi), %rax
callq *0x50(%rax)
movq %rax, -0x38(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x59ff0
movq -0x130(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x5c060
testb $0x1, %al
jne 0xadcc3
jmp 0xadcdc
movq -0x128(%rbp), %rax
movq 0x6f0(%rax), %rdi
movq (%rdi), %rax
movl $0x5, %esi
callq *0x78(%rax)
jmp 0xae2a6
callq 0x5c790
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5d470
movq -0x128(%rbp), %rdi
cwtl
cvtsi2sd %eax, %xmm0
movsd 0xd97b5(%rip), %xmm1    # 0x1874c0
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
callq 0x5a210
movq -0x128(%rbp), %rdi
movl %eax, -0x13c(%rbp)
movq (%rdi), %rax
callq *0x178(%rax)
movq -0x128(%rbp), %rdi
movl %eax, -0x140(%rbp)
movq (%rdi), %rax
callq *0x178(%rax)
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, %esi
movl $0x10, %edi
callq 0x5ce90
movl %eax, %esi
movl $0x5, %edi
callq 0x5aae0
movl -0x140(%rbp), %edi
movl %eax, %esi
callq 0x5ce90
movl -0x13c(%rbp), %esi
movl %eax, %edx
shll $0x4, %edx
addl $0x4, %edx
leaq -0x58(%rbp), %rdi
callq 0x59260
movq -0x128(%rbp), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq -0x128(%rbp), %rdi
movq %rax, -0x68(%rbp)
movq (%rdi), %rax
callq *0x50(%rax)
movq %rax, -0x78(%rbp)
movl -0x74(%rbp), %edx
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x5c2c0
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x5ca20
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5ddb0
addl -0x5c(%rbp), %eax
cltq
movq %rax, -0x138(%rbp)
cvtsi2sdl -0x54(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0x138(%rbp), %rax
addq %rcx, %rax
movslq -0x3c(%rbp), %rcx
cmpq %rcx, %rax
jl 0xade56
movq -0x128(%rbp), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq %rax, -0x88(%rbp)
cvtsi2sdl -0x54(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
callq 0x5a970
movl %eax, %edx
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x5c2c0
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x5cbd0
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x718, %edi            # imm = 0x718
callq 0x59820
movq %rax, -0x148(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x5b530
jmp 0xade75
movq -0x148(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x5b0f0
jmp 0xade8e
movq -0x128(%rbp), %rsi
movq -0x148(%rbp), %rax
movq %rax, 0x6d0(%rsi)
movq 0x6d0(%rsi), %rdi
addq $0x688, %rdi            # imm = 0x688
addq $0x688, %rsi            # imm = 0x688
callq 0xaf6e0
movl $0x6d8, %edi            # imm = 0x6D8
callq 0x59820
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x150(%rbp)
leaq -0x60(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x5dce0
jmp 0xadee3
movq -0x128(%rbp), %rcx
movq -0x150(%rbp), %rax
movq %rax, 0x6c8(%rcx)
movq 0x6c8(%rcx), %rdi
addq $0x518, %rdi            # imm = 0x518
movq 0x15af9b(%rip), %rax    # 0x208ea8
movq %rax, -0x168(%rbp)
movq %rax, -0xb8(%rbp)
movq $0x0, -0xb0(%rbp)
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
callq 0xaf550
movq -0x128(%rbp), %rcx
movq -0x168(%rbp), %rax
movq -0x10(%rbp), %rdi
addq $0x278, %rdi            # imm = 0x278
movq %rax, -0xc8(%rbp)
movq $0x0, -0xc0(%rbp)
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
callq 0xaf190
movq -0x128(%rbp), %rcx
movq -0x168(%rbp), %rax
movq -0x10(%rbp), %rdi
addq $0x298, %rdi            # imm = 0x298
movq %rax, -0xd8(%rbp)
movq $0x0, -0xd0(%rbp)
movq -0xd8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
callq 0xaf810
movq -0x128(%rbp), %rax
movq 0x6d0(%rax), %rdi
movl $0xa, %esi
callq 0x59730
movq -0x128(%rbp), %rax
movq 0x6d0(%rax), %rax
movq %rax, -0x160(%rbp)
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x158(%rbp)
xorl %esi, %esi
callq 0x5da90
movq -0x160(%rbp), %rdi
movq -0x158(%rbp), %rsi
movl $0x8000, %edx           # imm = 0x8000
movl $0x10, %ecx
callq 0x5b670
jmp 0xae016
leaq -0xf0(%rbp), %rdi
callq 0x5df00
movq -0x128(%rbp), %rdi
callq 0x5a280
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0xf8(%rbp)
je 0xae0d3
movq -0xf8(%rbp), %rdi
callq 0x5d050
movl %eax, %ecx
movq -0x128(%rbp), %rax
movl %ecx, 0x6e0(%rax)
jmp 0xae0d3
movq -0x148(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
movl $0x718, %esi            # imm = 0x718
callq 0x595b0
jmp 0xae2af
movq -0x150(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
movl $0x6d8, %esi            # imm = 0x6D8
callq 0x595b0
jmp 0xae2af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x5df00
jmp 0xae2af
movl $0x0, -0xfc(%rbp)
movq -0x128(%rbp), %rdi
movl -0xfc(%rbp), %eax
movl %eax, -0x16c(%rbp)
movq (%rdi), %rax
callq *0x178(%rax)
movl %eax, %ecx
movl -0x16c(%rbp), %eax
cmpl %ecx, %eax
jge 0xae277
movq -0x128(%rbp), %rdi
movl -0xfc(%rbp), %esi
movq (%rdi), %rax
callq *0x180(%rax)
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rdi
xorl %esi, %esi
callq 0x5ba80
movq -0x128(%rbp), %rax
movq 0x6d0(%rax), %rdi
movq -0x108(%rbp), %rsi
movq (%rdi), %rax
callq *0x30(%rax)
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
callq *0xf0(%rax)
movq -0x128(%rbp), %rdi
movl %eax, -0x170(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x174(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x178(%rbp)
movq (%rdi), %rax
callq *0x178(%rax)
movl -0x178(%rbp), %edi
movl -0x174(%rbp), %ecx
movl %eax, %r8d
movl -0x170(%rbp), %eax
shll $0x4, %r8d
movl $0x5, %edx
movl $0x16, %esi
cmpl %r8d, %edi
cmovll %esi, %edx
subl %edx, %ecx
cmpl %ecx, %eax
jl 0xae1e9
movq -0x108(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
callq *0xa8(%rax)
movq -0x180(%rbp), %rdi
movq %rax, %rsi
movq (%rdi), %rax
callq *0xb0(%rax)
jmp 0xae256
movq -0x108(%rbp), %rax
movq %rax, -0x190(%rbp)
leaq -0x120(%rbp), %rdi
movq %rdi, -0x188(%rbp)
xorl %esi, %esi
callq 0x5da90
movq -0x190(%rbp), %rdi
movq -0x188(%rbp), %rsi
movq (%rdi), %rax
movq 0xb0(%rax), %rax
callq *%rax
jmp 0xae228
leaq -0x120(%rbp), %rdi
callq 0x5df00
jmp 0xae256
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x5df00
jmp 0xae2af
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
callq *0x68(%rax)
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0xae0dd
movq -0x128(%rbp), %rax
movq 0x6c8(%rax), %rdi
movq 0x6d0(%rax), %rsi
movq (%rdi), %rax
callq *0x30(%rax)
movq -0x128(%rbp), %rdi
movq 0x6c8(%rdi), %rsi
movq (%rdi), %rax
callq *0x30(%rax)
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq -0xa0(%rbp), %rdi
callq 0x5b6b0
nopl (%rax,%rax)