// File: /workspace/github_c_makefile_star2_O3/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 0x96caa
movq %rdi, %rbx
movb $0x1, 0xcb(%rdi)
movq (%rdi), %rax
callq *0x88(%rax)
testb %al, %al
je 0x96caa
movq 0x190(%rbx), %rdi
callq 0x559e0
movq %rax, 0x20(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq %rax, %r13
callq 0x57e90
movq %rax, %r14
movq %rdx, %r15
movq %r13, %rdi
callq 0x58930
cwtl
cvtsi2sd %eax, %xmm6
divsd 0x5ccb3(%rip), %xmm6    # 0xf36b8
movq 0x5d0(%rbx), %rax
testq %rax, %rax
je 0x96a26
movq 0xb0(%rax), %r13
movq %r13, 0x10(%rsp)
movq %r13, %rax
shrq $0x20, %rax
jmp 0x96a69
leaq 0x140(%rbx), %rbp
leaq 0xf0(%rbx), %r12
movq %rbp, %rdi
movq %r12, %rsi
movsd %xmm6, 0x18(%rsp)
callq 0x57f50
movl %eax, %r13d
addl $0x6, %r13d
movq %rbp, %rdi
movq %r12, %rsi
callq 0x58a50
movsd 0x18(%rsp), %xmm6
addl $0x4, %eax
movl %r13d, 0x10(%rsp)
movl %eax, 0x14(%rsp)
cvtsi2sd %r13d, %xmm0
mulsd %xmm6, %xmm0
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
cmpltsd %xmm1, %xmm2
movsd 0x5c909(%rip), %xmm3    # 0xf3390
movapd %xmm2, %xmm4
andpd %xmm3, %xmm4
movsd 0x5c901(%rip), %xmm5    # 0xf3398
andnpd %xmm5, %xmm2
orpd %xmm4, %xmm2
addsd %xmm0, %xmm2
cvttsd2si %xmm2, %r12
xorps %xmm0, %xmm0
cvtsi2sd %eax, %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), %ebp
movl 0xac(%rbx), %eax
movl %eax, %edx
subl %ecx, %edx
incl %edx
movl %ebp, 0x8(%rsp)
movl %edx, 0xc(%rsp)
movq 0x20(%rsp), %r13
addl 0xac(%r13), %edx
movq %r14, %rcx
shrq $0x20, %rcx
addl $0x2, %ecx
cmpl %ecx, %edx
jge 0x96b14
movq 0xd53ec(%rip), %rdx     # 0x16bef8
addl %eax, %ecx
addl (%rdx), %ecx
movl %ecx, 0xc(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x160(%rax)
testb %al, %al
je 0x96b71
movl 0xa8(%r13), %eax
movl 0xb0(%r13), %ecx
movl %ecx, %edx
subl %ebp, %edx
addl %eax, %edx
leal -0x2(%r15), %esi
cmpl %esi, %edx
jle 0x96b4f
movl %ecx, %edx
subl %r15d, %edx
leal (%rdx,%rax), %ebp
addl $0x2, %ebp
movl %ebp, 0x8(%rsp)
addl %r12d, %ebp
movl %ecx, %edx
subl %ebp, %edx
addl %eax, %edx
leal 0x2(%r14), %esi
cmpl %esi, %edx
jge 0x96bae
addl %r12d, %r14d
subl %r14d, %ecx
addl %ecx, %eax
addl $-0x2, %eax
movl %eax, 0x8(%rsp)
jmp 0x96bae
movl 0xa8(%r13), %eax
addl %eax, %r12d
addl $-0x2, %r15d
movl %r15d, %ecx
subl %r12d, %ecx
addl %ebp, %r12d
cmpl %r15d, %r12d
cmovlel %ebp, %ecx
leal (%rax,%rcx), %edx
addl $0x2, %r14d
cmpl %r15d, %r12d
jg 0x96b9f
cmpl %r14d, %edx
jge 0x96bae
movl %r14d, %esi
subl %eax, %esi
cmpl %r14d, %edx
cmovll %esi, %ecx
movl %ecx, 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 0xd4776(%rip), %rsi     # 0x16b358
movq %r14, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x96f3a
movl $0x668, %edi            # imm = 0x668
addq 0x5b8(%rbx), %rdi
movq 0xd5046(%rip), %rsi     # 0x16bc48
xorl %edx, %edx
movq %rbx, %rcx
callq 0x96ffa
movq 0x5b8(%rbx), %rdi
movq (%rdi), %rax
movq 0xd48e3(%rip), %rsi     # 0x16b500
callq *0x138(%rax)
movq 0x5d0(%rbx), %rsi
testq %rsi, %rsi
je 0x96c3c
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 0x96c9b
movl $0x68, %edi
callq 0x556b0
movq %rax, %r14
movq %rax, %rdi
callq 0x55b80
movq %r14, 0x5c0(%rbx)
addq $0x48, %r14
movq 0xd4c8c(%rip), %rsi     # 0x16b908
movq %r14, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x96f3a
movq 0x5c0(%rbx), %rdi
movl 0x5c8(%rbx), %esi
callq 0x55100
addq $0x1f8, %rbx            # imm = 0x1F8
movq %rbx, %rdi
callq 0x701aa
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 0x96ccd
movq %rax, %rbx
movl $0x6d8, %esi            # imm = 0x6D8
movq %r14, %rdi
callq 0x55480
movq %rbx, %rdi
callq 0x57090
nop