// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/gui/widgets/basic/slider.cpp
// Function: smooth::GUI::Slider::Paint(int)
S::Int S::GUI::Slider::Paint(Int message)
{
	if (!IsRegistered())	return Error();
	if (!IsVisible())	return Success();

	Surface	*surface  = GetDrawSurface();
	Point	 realPos  = GetRealPosition();
	Size	 realSize = GetRealSize();
	Int	 realGripSize = Math::Round(gripSize * surface->GetSurfaceDPI() / 96.0);
	Rect	 sliderRect;

	switch (message)
	{
		case SP_PAINT:
			surface->StartPaint(Rect(realPos, realSize));

			surface->Box(Rect(realPos, realSize), GetBackgroundColor(), Rect::Filled);

			if (subtype == OR_HORZ)	surface->Bar(realPos + Point((realGripSize - 1) / 2, (realSize.cy - 2) / 2), realPos + Point(realSize.cx - (realGripSize - 1) / 2, (realSize.cy - 2) / 2), OR_HORZ);
			else			surface->Bar(realPos + Point((realSize.cy - 2) / 2, (realGripSize - 1) / 2), realPos + Point((realSize.cy - 2) / 2, realSize.cy - (realGripSize - 1) / 2), OR_VERT);

			if (subtype == OR_HORZ)	sliderRect = Rect(realPos + Point((Int) (((Float) (realSize.cx - realGripSize)) / ((Float) (endValue - startValue)) * ((Float) (*variable - startValue))), 0), Size(gripSize - 1, 16) * surface->GetSurfaceDPI() / 96.0 + Size(1, 1));
			else			sliderRect = Rect(realPos + Point(0, (realSize.cy - realGripSize - 1) - (Int) (((Float) (realSize.cy - realGripSize - 1)) / ((Float) (endValue - startValue)) * ((Float) (*variable - startValue)))), Size(16, gripSize - 1) * surface->GetSurfaceDPI() / 96.0 + Size(2, 2));

			if (!dragging)	surface->Box(sliderRect, Setup::BackgroundColor, Rect::Filled);
			else		surface->Box(sliderRect, Setup::LightGrayColor, Rect::Filled);

			surface->Frame(sliderRect, FRAME_UP);

			surface->EndPaint();

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %ebp
movq %rdi, %r15
movq (%rdi), %rax
callq *0x88(%rax)
testb %al, %al
je 0x7b631
movq (%r15), %rax
movq %r15, %rdi
callq *0x90(%rax)
xorl %ebx, %ebx
testb %al, %al
je 0x7b634
movq (%r15), %rax
movq %r15, %rdi
callq *0x40(%rax)
movq %rax, %r13
movq (%r15), %rax
movq %r15, %rdi
callq *0x48(%rax)
movq %rax, 0x38(%rsp)
movq (%r15), %rax
movq %r15, %rdi
callq *0x50(%rax)
movq %rax, %r12
movl 0x5c8(%r15), %r14d
movq %r13, %rdi
callq 0x59c60
cwtl
imull %r14d, %eax
cvtsi2sd %eax, %xmm0
divsd 0x68014(%rip), %xmm0    # 0xe3510
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %cl
xorpd %xmm1, %xmm1
movapd %xmm1, 0x10(%rsp)
testl %ebp, %ebp
jne 0x7b634
movq %r12, %rdx
movq 0x38(%rsp), %r14
movq %r14, %r12
shrq $0x20, %r12
movq %rdx, %rsi
movb %cl, %al
leaq 0x6843a(%rip), %rcx     # 0xe3970
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x50(%rsp)
shrq $0x20, %rsi
leaq 0x40(%rsp), %rbp
movl %r14d, (%rbp)
movl %r12d, 0x4(%rbp)
movq %r13, %rdi
movq %r13, 0x30(%rsp)
movq %rdx, 0x60(%rsp)
leal (%rdx,%r14), %ebx
movl %ebx, 0x8(%rbp)
movq %rsi, 0x28(%rsp)
leal (%rsi,%r12), %r13d
movl %r13d, 0xc(%rbp)
movq %rbp, %rsi
callq 0x56160
movl %r14d, (%rbp)
movq %r12, (%rsp)
movl %r12d, 0x4(%rbp)
movq %rbx, 0x58(%rsp)
movl %ebx, 0x8(%rbp)
movl %r13d, 0xc(%rbp)
movq (%r15), %rax
movq %r15, %rdi
callq *0x140(%rax)
movq 0xe69fe(%rip), %rcx     # 0x161fa8
movl (%rcx), %ecx
leaq 0x8(%rsp), %r8
andq $0x0, (%r8)
leaq 0x40(%rsp), %rsi
movq 0x30(%rsp), %rdi
movq %rax, %rdx
callq 0x58b80
cmpw $0x1, 0x1a0(%r15)
jne 0x7b645
movq 0x50(%rsp), %r14
leal -0x1(%r14), %eax
pushq $0x2
popq %rsi
cltd
idivl %esi
movl %eax, %ecx
movq 0x28(%rsp), %r12
leal -0x2(%r12), %eax
cltd
idivl %esi
movq 0x38(%rsp), %rbp
leal (%rcx,%rbp), %edx
addl (%rsp), %eax
shlq $0x20, %rax
orq %rax, %rdx
leaq 0x40(%rsp), %rsi
movq %rdx, (%rsi)
movq 0x58(%rsp), %rdi
subl %ecx, %edi
orq %rax, %rdi
leaq 0x8(%rsp), %rdx
movq %rdi, (%rdx)
pushq $0x1
popq %rcx
movq 0x30(%rsp), %r13
movq %r13, %rdi
callq 0x5a330
movq %r12, %rcx
jmp 0x7b6a5
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%rsp), %rax
addl $-0x2, %eax
pushq $0x2
popq %rcx
cltd
idivl %ecx
movl %eax, %edi
movq 0x50(%rsp), %r12
leal -0x1(%r12), %eax
cltd
idivl %ecx
movq 0x38(%rsp), %rbp
addl %ebp, %edi
movq (%rsp), %rdx
addl %eax, %edx
shlq $0x20, %rdx
orq %rdi, %rdx
leaq 0x40(%rsp), %rsi
movq %rdx, (%rsi)
subl %eax, %r13d
shlq $0x20, %r13
orq %rdi, %r13
leaq 0x8(%rsp), %rdx
movq %r13, (%rdx)
movq 0x30(%rsp), %r13
movq %r13, %rdi
callq 0x5a330
movq %r12, %r14
movq 0x28(%rsp), %rcx
cmpw $0x1, 0x1a0(%r15)
movq 0x60(%rsp), %rax
movl $0x0, %ebx
jne 0x7b754
subl %r14d, %eax
cvtsi2sd %eax, %xmm0
movl 0x5dc(%r15), %eax
movl 0x5d8(%r15), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movq 0x5d0(%r15), %rax
movl (%rax), %eax
subl %ecx, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %r14d
addl %ebp, %r14d
movl 0x5c8(%r15), %eax
decl %eax
leaq 0x8(%rsp), %rbp
movl %eax, (%rbp)
movl $0x10, 0x4(%rbp)
movq %r13, %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
movq %rbp, %rdi
callq 0x57480
leaq 0x40(%rsp), %rdi
movq %rax, (%rdi)
movsd 0x67ddb(%rip), %xmm0    # 0xe3510
callq 0x59050
leal (%rax,%r14), %ecx
incl %ecx
shrq $0x20, %rax
movq (%rsp), %rdx
addl %edx, %eax
incl %eax
movl %r14d, %ebp
jmp 0x7b7ed
notl %r14d
addl %ecx, %r14d
cvtsi2sd %r14d, %xmm0
movl 0x5dc(%r15), %eax
movl 0x5d8(%r15), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm1
movq 0x5d0(%r15), %rax
movl (%rax), %eax
subl %ecx, %eax
cvtsi2sd %eax, %xmm2
divsd %xmm1, %xmm0
mulsd %xmm0, %xmm2
cvttsd2si %xmm2, %eax
subl %eax, %r14d
addl (%rsp), %r14d
movl 0x5c8(%r15), %eax
decl %eax
leaq 0x8(%rsp), %r12
movl $0x10, (%r12)
movl %eax, 0x4(%r12)
movq %r13, %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
movq %r12, %rdi
callq 0x57480
leaq 0x40(%rsp), %rdi
movq %rax, (%rdi)
movsd 0x67d3b(%rip), %xmm0    # 0xe3510
callq 0x59050
leal (%rax,%rbp), %ecx
addl $0x2, %ecx
shrq $0x20, %rax
addl %r14d, %eax
addl $0x2, %eax
movl %r14d, %edx
movl %ebp, 0x10(%rsp)
movl %edx, 0x14(%rsp)
movl %ecx, 0x18(%rsp)
movl %eax, 0x1c(%rsp)
movq 0xe67a4(%rip), %rax     # 0x161fa8
movl (%rax), %ecx
cmpb $0x0, 0x5c4(%r15)
je 0x7b822
leaq 0x40(%rsp), %r8
andq $0x0, (%r8)
movq 0xe5f88(%rip), %rdx     # 0x1617a8
jmp 0x7b832
leaq 0x40(%rsp), %r8
andq $0x0, (%r8)
movq 0xe5c9e(%rip), %rdx     # 0x1614d0
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
callq 0x58b80
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x58ad0
movq %r13, %rdi
callq 0x59a80
jmp 0x7b634
nop