// File: /workspace/github_c_makefile_star2_O2/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 0x93144
movq %rdi, %rbx
movb $0x1, 0xcb(%rdi)
movq (%rdi), %rax
callq *0x88(%rax)
testb %al, %al
je 0x93144
movq 0x190(%rbx), %rdi
callq 0x56a50
movq %rax, %r12
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq %rax, %r13
callq 0x59120
movq %rax, %r14
movq %rdx, %r15
movq %r13, %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
divsd 0x5061d(%rip), %xmm0    # 0xe3510
movq 0x5d0(%rbx), %rax
testq %rax, %rax
je 0x92f0d
movq 0xb0(%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x92f5a
leaq 0x140(%rbx), %r13
leaq 0xf0(%rbx), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movsd %xmm0, 0x18(%rsp)
callq 0x591e0
movq %r12, 0x20(%rsp)
movl %eax, %r12d
addl $0x6, %r12d
movq %r13, %rdi
movq %rbp, %rsi
callq 0x59d90
movsd 0x18(%rsp), %xmm0
addl $0x4, %eax
movl %r12d, 0x10(%rsp)
movq 0x20(%rsp), %r12
movl %eax, 0x14(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x57480
movq %rax, %r13
movq %rax, %rcx
shrq $0x20, %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)
addl 0xac(%r12), %edx
movq %r14, %rcx
shrq $0x20, %rcx
addl $0x2, %ecx
cmpl %ecx, %edx
jge 0x92fad
movq 0xcef53(%rip), %rdx     # 0x161ef8
addl %eax, %ecx
addl (%rdx), %ecx
movl %ecx, 0xc(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x160(%rax)
testb %al, %al
je 0x9300c
movl 0xa8(%r12), %eax
movl 0xb0(%r12), %ecx
movl %ecx, %edx
subl %ebp, %edx
addl %eax, %edx
leal -0x2(%r15), %esi
cmpl %esi, %edx
jle 0x92fea
movl %ecx, %edx
subl %r15d, %edx
leal (%rdx,%rax), %ebp
addl $0x2, %ebp
movl %ebp, 0x8(%rsp)
addl %r13d, %ebp
movl %ecx, %edx
subl %ebp, %edx
addl %eax, %edx
leal 0x2(%r14), %esi
cmpl %esi, %edx
jge 0x9304a
addl %r13d, %r14d
subl %r14d, %ecx
addl %ecx, %eax
addl $-0x2, %eax
movl %eax, 0x8(%rsp)
jmp 0x9304a
movl 0xa8(%r12), %eax
addl %eax, %r13d
addl $-0x2, %r15d
movl %r15d, %ecx
subl %r13d, %ecx
addl %ebp, %r13d
cmpl %r15d, %r13d
cmovlel %ebp, %ecx
leal (%rax,%rcx), %edx
addl $0x2, %r14d
cmpl %r15d, %r13d
jg 0x9303b
cmpl %r14d, %edx
jge 0x9304a
movl %r14d, %esi
subl %eax, %esi
cmpl %r14d, %edx
cmovll %esi, %ecx
movl %ecx, 0x8(%rsp)
movl $0x6d8, %edi            # imm = 0x6D8
callq 0x56700
movq %rax, %r14
leaq 0x8(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rax, %rdi
callq 0x5a380
movq %r14, 0x5b8(%rbx)
addq $0x648, %r14            # imm = 0x648
movq 0xce2da(%rip), %rsi     # 0x161358
movq %r14, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x933c6
movl $0x668, %edi            # imm = 0x668
addq 0x5b8(%rbx), %rdi
movq 0xcebaa(%rip), %rsi     # 0x161c48
xorl %edx, %edx
movq %rbx, %rcx
callq 0x93462
movq 0x5b8(%rbx), %rdi
movq (%rdi), %rax
movq 0xce447(%rip), %rsi     # 0x161500
callq *0x138(%rax)
movq 0x5d0(%rbx), %rsi
testq %rsi, %rsi
je 0x930d8
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 0x93135
pushq $0x68
popq %rdi
callq 0x56700
movq %rax, %r14
movq %rax, %rdi
callq 0x56c00
movq %r14, 0x5c0(%rbx)
addq $0x48, %r14
movq 0xce7f2(%rip), %rsi     # 0x161908
movq %r14, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x933c6
movq 0x5c0(%rbx), %rdi
movl 0x5c8(%rbx), %esi
callq 0x56100
addq $0x1f8, %rbx            # imm = 0x1F8
movq %rbx, %rdi
callq 0x70196
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
pushq $0x68
popq %rsi
jmp 0x93165
movq %rax, %rbx
movl $0x6d8, %esi            # imm = 0x6D8
movq %r14, %rdi
callq 0x564c0
movq %rbx, %rdi
callq 0x58260
nop