// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/gui/widgets/multi/menu/micromenu.cpp
// Function: smooth::GUI::MicroMenu::OpenPopupMenu()
S::Void S::GUI::MicroMenu::OpenPopupMenu()
{
	if (popup == NIL) return;

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

	if (window == NIL) return;

	hotspot->Deactivate();

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

	popup->CalculateSize();

	Point	 realPos     = GetRealPosition();
	Size	 realSize    = GetRealSize();

	Point	 popupPos    = realPos + Point(subtype == OR_HORZ ? realSize.cx : 0, subtype == OR_VERT ? realSize.cy : 0);
	Size	 popupSize   = popup->GetSize();

	if (!IsRightToLeft()) { if (window->GetX() + popupPos.x			       + Math::Round(popupSize.cx * scaleFactor) >= monitor.right) popupPos.x = realPos.x - Math::Round(popupSize.cx * scaleFactor) + (subtype == OR_VERT ? realSize.cx : 0); }
	else		      { if (window->GetX() + (window->GetWidth() - popupPos.x) - Math::Round(popupSize.cx * scaleFactor) <  monitor.left)  popupPos.x = realPos.x - Math::Round(popupSize.cx * scaleFactor) + (subtype == OR_VERT ? realSize.cx : 0); }

	if (window->GetY() + popupPos.y + Math::Round(popupSize.cy * scaleFactor) >= monitor.bottom) popupPos.y = realPos.y - Math::Round(popupSize.cy * scaleFactor) + (subtype == OR_HORZ ? GetHeight() : 0);

	popup->SetPosition(popupPos);
	popup->internalRequestClose.Connect(&MicroMenu::ClosePopupMenu, this);

	onOpenPopupMenu.Emit();

	Add(popup);
}

// Assembly:
cmpq $0x0, 0x690(%rdi)
je 0x8b4cd
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x190(%rdi), %rdi
callq 0x559e0
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
testq %r14, %r14
je 0x8b4bf
movq %rax, %r12
movq 0x688(%rbx), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
callq 0x57e90
movq %rax, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq %r12, %rdi
callq 0x58930
cwtl
cvtsi2sd %eax, %xmm0
divsd 0x691e8(%rip), %xmm0    # 0xf44f0
movsd %xmm0, 0x10(%rsp)
movq 0x690(%rbx), %rdi
callq 0x58ee0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x48(%rax)
movq %rax, %rbp
movq %rax, %r12
shrq $0x20, %r12
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x50(%rax)
movq %rax, %r13
shrq $0x20, %rax
movzwl 0x1a0(%rbx), %ecx
xorl %edx, %edx
cmpw $0x1, %cx
movl %r13d, %esi
cmovnel %edx, %esi
movl %ebp, %edi
addl %esi, %edi
cmpw $0x2, %cx
cmovnel %edx, %eax
addl %r12d, %eax
shlq $0x20, %rax
orq %rax, %rdi
movq %rdi, (%rsp)
movq 0x690(%rbx), %rax
movl 0xb0(%rax), %r15d
movl 0xb4(%rax), %eax
movl %eax, 0xc(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x160(%rax)
testb %al, %al
je 0x8b4ce
movl 0xb0(%r14), %ecx
addl 0xa8(%r14), %ecx
subl (%rsp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd 0x10(%rsp), %xmm2
mulsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x693c4(%rip), %rdx     # 0xf4790
addsd (%rdx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
movslq %ecx, %rcx
subq %rax, %rcx
movslq 0x20(%rsp), %rdx
cmpq %rdx, %rcx
movq 0x18(%rsp), %rsi
movapd %xmm2, %xmm1
jge 0x8b406
subl %eax, %ebp
xorl %eax, %eax
cmpw $0x2, 0x1a0(%rbx)
cmovnel %eax, %r13d
addl %ebp, %r13d
movl %r13d, (%rsp)
movslq 0xac(%r14), %rax
movslq 0x4(%rsp), %rcx
addq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2sdl 0xc(%rsp), %xmm0
mulsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
leaq 0x6935a(%rip), %rdx     # 0xf4790
addsd (%rdx,%rax,8), %xmm1
cvttsd2si %xmm1, %rax
addq %rax, %rcx
sarq $0x20, %rsi
cmpq %rsi, %rcx
jl 0x8b469
subl %eax, %r12d
xorl %eax, %eax
cmpw $0x1, 0x1a0(%rbx)
jne 0x8b461
movl 0xb4(%rbx), %eax
addl %eax, %r12d
movl %r12d, 0x4(%rsp)
movq 0x690(%rbx), %rdi
leaq 0xb0(%rdi), %rdx
movq (%rdi), %rax
movq %rsp, %rsi
callq *0x150(%rax)
movl $0x698, %r14d           # imm = 0x698
movq 0x690(%rbx), %rdi
addq %r14, %rdi
movq 0xe15ce(%rip), %rsi     # 0x16ca68
xorl %edx, %edx
movq %rbx, %rcx
callq 0x8bbda
addq %rbx, %r14
movq %r14, %rdi
callq 0x70488
movq 0x690(%rbx), %rsi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x30(%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0xa8(%r14), %rax
movslq (%rsp), %rcx
addq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd 0x10(%rsp), %xmm2
mulsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x6928e(%rip), %rdx     # 0xf4790
addsd (%rdx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
addq %rax, %rcx
movq 0x18(%rsp), %rsi
movslq %esi, %rdx
cmpq %rdx, %rcx
movapd %xmm2, %xmm1
jge 0x8b3ef
jmp 0x8b406
nop