// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/gui/widgets/special/tooltip.cpp
// Function: smooth::GUI::Tooltip::Show()
S::Int S::GUI::Tooltip::Show()
{
	if (visible) return Success();

	visible = True;

	if (!IsRegistered()) return Success();

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

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

	Size	 tSize	     = (layer != NIL ? layer->GetSize() : Size(font.GetUnscaledTextSizeX(text) + 6, font.GetUnscaledTextSizeY(text) + 4));
	Size	 sSize	     = tSize * scaleFactor;
	Point	 tPos	     = Point(GetX(), GetY() - sSize.cy + 1);

	if (tPos.y + window->GetY() < monitor.top + 2) tPos.y = GetY() + monitor.top + 2 + Setup::HoverHeight;

	if (!IsRightToLeft())
	{
		if (tPos.x + window->GetX() + sSize.cx > monitor.right - 2) tPos.x = -window->GetX() + monitor.right - 2 - sSize.cx;
		if (tPos.x + window->GetX()	       < monitor.left  + 2) tPos.x = -window->GetX() + monitor.left + 2;
	}
	else
	{
		if (window->GetWidth() - tPos.x + window->GetX()	    > monitor.right - 2) tPos.x = -monitor.right + 2 + window->GetWidth() + window->GetX();
		if (window->GetWidth() - tPos.x - sSize.cx + window->GetX() < monitor.left  + 2) tPos.x = -(monitor.left + 2) + window->GetWidth() + window->GetX() - sSize.cx;
	}

	toolWindow = new ToolWindow(tPos, tSize);
	toolWindow->onPaint.Connect(&Tooltip::OnToolWindowPaint, this);
	toolWindow->onEvent.Connect(&Tooltip::OnToolWindowEvent, this);
	toolWindow->SetBackgroundColor(Setup::TooltipColor);

	if (layer != NIL) toolWindow->Add(layer);

	Add(toolWindow);

	if (timeOut != 0)
	{
		timer = new System::Timer();

		timer->onInterval.Connect(&Tooltip::OnTimer, this);
		timer->Start(timeOut);
	}

	onShow.Emit();

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpb $0x0, 0xcb(%rdi)
jne 0x973cd
movq %rdi, %rbx
movb $0x1, 0xcb(%rdi)
movq (%rdi), %rax
callq *0x88(%rax)
testb %al, %al
je 0x973cd
movq 0x190(%rbx), %rdi
callq 0x559e0
movq %rax, %r15
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq %rax, %r13
callq 0x57e90
movq %rax, %r14
movq %rdx, %rbp
movq %r13, %rdi
callq 0x58930
cwtl
cvtsi2sd %eax, %xmm6
divsd 0x5d3d9(%rip), %xmm6    # 0xf44f0
movq 0x5d0(%rbx), %rax
testq %rax, %rax
je 0x97131
movq 0xb0(%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x9717e
leaq 0x140(%rbx), %r13
movq %rbp, 0x20(%rsp)
leaq 0xf0(%rbx), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movsd %xmm6, 0x18(%rsp)
callq 0x57f50
movl %eax, %r12d
addl $0x6, %r12d
movq %r13, %rdi
movq %rbp, %rsi
movq 0x20(%rsp), %rbp
callq 0x58a50
movsd 0x18(%rsp), %xmm6
addl $0x4, %eax
movl %r12d, 0x10(%rsp)
movl %eax, 0x14(%rsp)
cvtsi2sdl 0x10(%rsp), %xmm0
mulsd %xmm6, %xmm0
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
cmpltsd %xmm1, %xmm2
movsd 0x5d1f3(%rip), %xmm3    # 0xf4390
movapd %xmm2, %xmm4
andpd %xmm3, %xmm4
movsd 0x5d1eb(%rip), %xmm5    # 0xf4398
andnpd %xmm5, %xmm2
orpd %xmm4, %xmm2
addsd %xmm0, %xmm2
cvttsd2si %xmm2, %r12
xorps %xmm0, %xmm0
cvtsi2sdl 0x14(%rsp), %xmm0
mulsd %xmm6, %xmm0
movapd %xmm0, %xmm2
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm5, %xmm2
orpd %xmm3, %xmm2
addsd %xmm0, %xmm2
cvttsd2si %xmm2, %rcx
movl 0xa8(%rbx), %edx
movl 0xac(%rbx), %eax
movl %eax, %esi
subl %ecx, %esi
incl %esi
movl %edx, 0x8(%rsp)
movl %esi, 0xc(%rsp)
addl 0xac(%r15), %esi
movq %r14, %rcx
shrq $0x20, %rcx
leal 0x2(%rcx), %edx
cmpl %edx, %esi
jge 0x9722d
movq 0xd5cd9(%rip), %rdx     # 0x16cef8
movl (%rdx), %edx
addl %eax, %ecx
leal (%rdx,%rcx), %eax
addl $0x2, %eax
movl %eax, 0xc(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x160(%rax)
testb %al, %al
je 0x97294
movl 0xb0(%r15), %eax
movl %eax, %edx
subl 0x8(%rsp), %edx
movl 0xa8(%r15), %ecx
addl %ecx, %edx
leal -0x2(%rbp), %esi
cmpl %esi, %edx
jle 0x97267
movl %eax, %edx
subl %ebp, %edx
addl %edx, %ecx
addl $0x2, %ecx
movl %ecx, 0x8(%rsp)
movl 0xa8(%r15), %ecx
movl 0x8(%rsp), %edx
addl %r12d, %edx
movl %eax, %esi
subl %edx, %esi
addl %ecx, %esi
leal 0x2(%r14), %edx
cmpl %edx, %esi
jge 0x972d1
addl %r12d, %r14d
subl %r14d, %eax
addl %ecx, %eax
addl $-0x2, %eax
movl %eax, 0x8(%rsp)
jmp 0x972d1
addl 0xa8(%r15), %r12d
movl 0x8(%rsp), %eax
addl %r12d, %eax
addl $-0x2, %ebp
cmpl %ebp, %eax
jle 0x972b0
subl %r12d, %ebp
movl %ebp, 0x8(%rsp)
movl 0xa8(%r15), %eax
movl 0x8(%rsp), %ecx
addl %eax, %ecx
leal 0x2(%r14), %edx
cmpl %edx, %ecx
jge 0x972d1
subl %eax, %r14d
addl $0x2, %r14d
movl %r14d, 0x8(%rsp)
movl $0x6d8, %edi            # imm = 0x6D8
callq 0x556b0
movq %rax, %r14
leaq 0x8(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rax, %rdi
callq 0x59000
movq %r14, 0x5b8(%rbx)
addq $0x648, %r14            # imm = 0x648
movq 0xd5053(%rip), %rsi     # 0x16c358
movq %r14, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x97666
movl $0x668, %edi            # imm = 0x668
addq 0x5b8(%rbx), %rdi
movq 0xd5923(%rip), %rsi     # 0x16cc48
xorl %edx, %edx
movq %rbx, %rcx
callq 0x97724
movq 0x5b8(%rbx), %rdi
movq (%rdi), %rax
movq 0xd51c0(%rip), %rsi     # 0x16c500
callq *0x138(%rax)
movq 0x5d0(%rbx), %rsi
testq %rsi, %rsi
je 0x9735f
movq 0x5b8(%rbx), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movq 0x5b8(%rbx), %rsi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x30(%rax)
cmpl $0x0, 0x5c8(%rbx)
je 0x973be
movl $0x68, %edi
callq 0x556b0
movq %rax, %r14
movq %rax, %rdi
callq 0x55b80
movq %r14, 0x5c0(%rbx)
addq $0x48, %r14
movq 0xd5569(%rip), %rsi     # 0x16c908
movq %r14, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x97666
movq 0x5c0(%rbx), %rdi
movl 0x5c8(%rbx), %esi
callq 0x55100
addq $0x1f8, %rbx            # imm = 0x1F8
movq %rbx, %rdi
callq 0x70488
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x68, %esi
jmp 0x973f0
movq %rax, %rbx
movl $0x6d8, %esi            # imm = 0x6D8
movq %r14, %rdi
callq 0x55480
movq %rbx, %rdi
callq 0x57090