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

	if (S::System::System::Clock() - popupMenuClosed < 100)
	{
		hotspot->Paint(SP_MOUSEUP);

		return;
	}

	Window	*window	     = container->GetContainerWindow();
	Surface	*surface     = GetDrawSurface();
	Float	 scaleFactor = surface->GetSurfaceDPI() / 96.0;

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

	Rect	 popupFrame  = Rect(realPos + Point(realSize.cx - 11 * scaleFactor, 0), Size(11 * scaleFactor, realSize.cy));

	if (onAction.GetNOfConnectedSlots() == 0 || window->IsMouseOn(popupFrame))
	{
		hotspot->Deactivate();

		Rect	 monitor   = System::Screen::GetActiveScreenWorkArea();

		popup->CalculateSize();

		Point	 popupPos  = realPos + Point(orientation == OR_LEFT ? -1 : realSize.cx + 1 - popup->GetWidth() * scaleFactor, realSize.cy + 1);
		Size	 popupSize = popup->GetSize();

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

		if (window->GetY() + popupPos.y + Math::Round(popupSize.cy * scaleFactor) >= monitor.bottom) popupPos.y = realPos.y - Math::Round(popupSize.cy * scaleFactor) - 1;

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

		Add(popup);

		container->SetFlags(container->GetFlags() | MB_POPUPOPEN);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, 0x5b8(%rax)
jne 0xbbf59
jmp 0xbc424
callq 0x5b700
movq -0x98(%rbp), %rcx
subq 0x5f0(%rcx), %rax
cmpq $0x64, %rax
jae 0xbbf90
movq -0x98(%rbp), %rax
movq 0x5f8(%rax), %rdi
movq (%rdi), %rax
movl $0x5, %esi
callq *0x78(%rax)
jmp 0xbc424
movq -0x98(%rbp), %rax
movq 0x190(%rax), %rdi
callq 0x59bc0
movq -0x98(%rbp), %rdi
movq %rax, -0x10(%rbp)
movq (%rdi), %rax
callq *0x40(%rax)
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5d470
movq -0x98(%rbp), %rdi
cwtl
cvtsi2sd %eax, %xmm0
movsd 0xcb4eb(%rip), %xmm1    # 0x1874c0
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movq (%rdi), %rax
callq *0x48(%rax)
movq -0x98(%rbp), %rdi
movq %rax, -0x28(%rbp)
movq (%rdi), %rax
callq *0x50(%rax)
movq %rax, -0x30(%rbp)
cvtsi2sdl -0x30(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
movsd 0xce78d(%rip), %xmm2    # 0x18a798
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %esi
leaq -0x50(%rbp), %rdi
xorl %edx, %edx
callq 0x5c2c0
leaq -0x28(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x5ca20
movq %rax, -0x48(%rbp)
movsd 0xcde8d(%rip), %xmm0    # 0x189ec8
mulsd -0x20(%rbp), %xmm0
cvttsd2si %xmm0, %esi
movl -0x2c(%rbp), %edx
leaq -0x58(%rbp), %rdi
callq 0x59260
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x59ff0
movq -0x98(%rbp), %rdi
addq $0x478, %rdi            # imm = 0x478
callq 0xbddc0
cmpl $0x0, %eax
je 0xbc08f
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5c060
testb $0x1, %al
jne 0xbc08f
jmp 0xbc424
movq -0x98(%rbp), %rax
movq 0x5f8(%rax), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
callq 0x5c790
movq %rax, %rcx
movq -0x98(%rbp), %rax
movq %rcx, -0x68(%rbp)
movq %rdx, -0x60(%rbp)
movq 0x5b8(%rax), %rdi
callq 0x5dbb0
movq -0x98(%rbp), %rax
movswl 0xd0(%rax), %eax
cmpl $0x10, %eax
jne 0xbc0eb
movsd 0xcb62f(%rip), %xmm0    # 0x187710
movsd %xmm0, -0xa0(%rbp)
jmp 0xbc148
movq -0x98(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
cvtsi2sd %ecx, %xmm0
movsd %xmm0, -0xa8(%rbp)
movq 0x5b8(%rax), %rdi
callq 0x5a210
movsd -0xa8(%rbp), %xmm1
cvtsi2sd %eax, %xmm0
movsd -0x20(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0xa0(%rbp), %xmm0
cvttsd2si %xmm0, %esi
movl -0x2c(%rbp), %edx
addl $0x1, %edx
leaq -0x78(%rbp), %rdi
callq 0x5c2c0
leaq -0x28(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x5ca20
movq %rax, %rcx
movq -0x98(%rbp), %rax
movq %rcx, -0x70(%rbp)
movq 0x5b8(%rax), %rdi
callq 0x5bf70
movq %rax, %rcx
movq -0x98(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x80(%rbp)
movswl 0xd0(%rax), %eax
cmpl $0x10, %eax
jne 0xbc2b7
movq -0x98(%rbp), %rdi
movq (%rdi), %rax
callq *0x160(%rax)
testb $0x1, %al
jne 0xbc22f
movq -0x10(%rbp), %rdi
callq 0x5dab0
addl -0x70(%rbp), %eax
cltq
movq %rax, -0xb0(%rbp)
cvtsi2sdl -0x80(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0xb0(%rbp), %rax
addq %rcx, %rax
movslq -0x60(%rbp), %rcx
cmpq %rcx, %rax
jl 0xbc22a
movl -0x28(%rbp), %eax
addl -0x30(%rbp), %eax
addl $0x1, %eax
cltq
movq %rax, -0xb8(%rbp)
cvtsi2sdl -0x80(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0xb8(%rbp), %rax
subq %rcx, %rax
movl %eax, -0x70(%rbp)
jmp 0xbc2b5
movq -0x10(%rbp), %rdi
callq 0x5dab0
movl %eax, -0xc4(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5a210
movl %eax, %ecx
movl -0xc4(%rbp), %eax
subl -0x70(%rbp), %ecx
addl %ecx, %eax
cltq
movq %rax, -0xc0(%rbp)
cvtsi2sdl -0x80(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0xc0(%rbp), %rax
subq %rcx, %rax
movslq -0x68(%rbp), %rcx
cmpq %rcx, %rax
jge 0xbc2b3
movl -0x28(%rbp), %eax
addl -0x30(%rbp), %eax
addl $0x1, %eax
cltq
movq %rax, -0xd0(%rbp)
cvtsi2sdl -0x80(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0xd0(%rbp), %rax
subq %rcx, %rax
movl %eax, -0x70(%rbp)
jmp 0xbc2b5
jmp 0xbc31e
movq -0x98(%rbp), %rdi
movq (%rdi), %rax
callq *0x160(%rax)
testb $0x1, %al
jne 0xbc2e7
movq -0x10(%rbp), %rdi
callq 0x5dab0
addl -0x70(%rbp), %eax
cmpl -0x68(%rbp), %eax
jge 0xbc2e5
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0xbc31c
movq -0x10(%rbp), %rdi
callq 0x5dab0
movl %eax, -0xd4(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5a210
movl %eax, %ecx
movl -0xd4(%rbp), %eax
subl -0x70(%rbp), %ecx
addl %ecx, %eax
cmpl -0x60(%rbp), %eax
jl 0xbc31a
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0xbc31c
jmp 0xbc31e
movq -0x10(%rbp), %rdi
callq 0x5ddb0
addl -0x6c(%rbp), %eax
cltq
movq %rax, -0xe0(%rbp)
cvtsi2sdl -0x7c(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0xe0(%rbp), %rax
addq %rcx, %rax
movslq -0x5c(%rbp), %rcx
cmpq %rcx, %rax
jl 0xbc386
movslq -0x24(%rbp), %rax
movq %rax, -0xe8(%rbp)
cvtsi2sdl -0x7c(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
callq 0x5a970
movq %rax, %rcx
movq -0xe8(%rbp), %rax
subq %rcx, %rax
subq $0x1, %rax
movl %eax, -0x6c(%rbp)
movq -0x98(%rbp), %rax
movq 0x5b8(%rax), %rdi
leaq -0x70(%rbp), %rsi
callq 0x5d8c0
movq -0x98(%rbp), %rcx
movq 0x5b8(%rcx), %rdi
addq $0x698, %rdi            # imm = 0x698
movq 0x14cabf(%rip), %rax    # 0x208e78
movq %rax, -0x90(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0xbda00
movq -0x98(%rbp), %rdi
movq 0x5b8(%rdi), %rsi
movq (%rdi), %rax
callq *0x30(%rax)
movq -0x98(%rbp), %rax
movq 0x190(%rax), %rcx
movq %rcx, -0xf0(%rbp)
movq 0x190(%rax), %rdi
callq 0x5a120
movq -0xf0(%rbp), %rdi
movl %eax, %esi
orl $0x2, %esi
callq 0x59730
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)