// File: /workspace/github_c_makefile_star2_O2/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 0x88254
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq 0x190(%rdi), %rdi
callq 0x56a50
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq %r14, 0x8(%rsp)
testq %r14, %r14
je 0x88246
movq %rax, %r12
movq 0x688(%rbx), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
callq 0x59120
movq %rax, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq %r12, %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
divsd 0x5b493(%rip), %xmm0    # 0xe3510
movsd %xmm0, 0x20(%rsp)
movq 0x690(%rbx), %rdi
callq 0x5a250
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, %r14
movq %rax, %r13
shrq $0x20, %r13
movzwl 0x1a0(%rbx), %eax
xorl %ecx, %ecx
cmpw $0x1, %ax
movq %r14, %r15
cmovneq %rcx, %r15
cmpw $0x2, %ax
cmovneq %rcx, %r13
movq %rbp, 0x18(%rsp)
addq %rbp, %r15
addq %r12, %r13
movq %r13, %rax
shlq $0x20, %rax
movl %r15d, %ecx
orq %rax, %rcx
movq %rcx, (%rsp)
movq 0x690(%rbx), %rax
movl 0xb0(%rax), %ebp
movl 0xb4(%rax), %eax
movl %eax, 0x14(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x160(%rax)
testb %al, %al
je 0x88255
movq 0x8(%rsp), %rax
movl 0xb0(%rax), %ecx
addl 0xa8(%rax), %ecx
subl %r15d, %ecx
cvtsi2sd %ebp, %xmm0
movsd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x5b822(%rip), %rdx     # 0xe3970
addsd (%rdx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
movslq %ecx, %rcx
subq %rax, %rcx
movslq 0x30(%rsp), %rdx
cmpq %rdx, %rcx
movq 0x28(%rsp), %rsi
movapd %xmm2, %xmm1
jge 0x8818d
movq 0x18(%rsp), %rcx
subl %eax, %ecx
xorl %eax, %eax
cmpw $0x2, 0x1a0(%rbx)
cmovnel %eax, %r14d
addl %ecx, %r14d
movl %r14d, (%rsp)
movq 0x8(%rsp), %rax
movslq 0xac(%rax), %rax
movslq %r13d, %rcx
addq %rax, %rcx
cvtsi2sdl 0x14(%rsp), %xmm0
mulsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
leaq 0x5b7b3(%rip), %rdx     # 0xe3970
addsd (%rdx,%rax,8), %xmm1
cvttsd2si %xmm1, %rax
addq %rax, %rcx
sarq $0x20, %rsi
cmpq %rsi, %rcx
jl 0x881f0
subl %eax, %r12d
xorl %eax, %eax
cmpw $0x1, 0x1a0(%rbx)
jne 0x881e8
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 0xd9847(%rip), %rsi     # 0x161a68
xorl %edx, %edx
movq %rbx, %rcx
callq 0x88918
addq %rbx, %r14
movq %r14, %rdi
callq 0x70196
movq 0x690(%rbx), %rsi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x30(%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rax
movslq 0xa8(%rax), %rax
movslq %r15d, %rcx
addq %rax, %rcx
cvtsi2sd %ebp, %xmm0
movsd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x5b6e7(%rip), %rdx     # 0xe3970
addsd (%rdx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
addq %rax, %rcx
movq 0x28(%rsp), %rsi
movslq %esi, %rdx
cmpq %rdx, %rcx
movapd %xmm2, %xmm1
jge 0x88171
jmp 0x8818d