Need help to understand the integral rules used solving the convolution of two functions I am teaching myself how convolution works, there's a question which looks like this - find the convolution of the following two functions $f$ and $g$.

I understand the problem intuitively that the resulting function should be essentially the product of $f$ sweeping over $g$, and since the functions are quite simple, I can find key points like when $x = 0, 1, 2, 3$ and interpolate the graph of the resulting function easily.
While reading through the "solution" of this problem in my textbook, for the intersection of $0 \le x \lt 1$, the author wrote this: for $0\leq x<1$,
$$\int_{-\infty}^{\infty} g(t)\cdot f(x-t)dt=\int_{0}^x 2t\cdot  dt=\frac{x^2}{2}\cdot 2.$$
which I'm having trouble to understand. How exactly did he replace the $\infty$ and $-\infty$ with $0$ and $x$, and how exactly did he turn the whole $g(t) \cdot f(x-t)$ into $2t$?
 A: Hint. Note that $f(x-t)=2$ when $0\leq x-t\leq 1$, i.e. $x-1\leq t\leq x$, otherwise it is zero. Hence 
$$\int_{-\infty}^{\infty} g(t)f(x-t)dt=\int_{x-1}^x g(t)2 dt.$$
Now if $x\in[0,1)$ then what is $g(t)$ for $t\in [x-1,0]$? And for $t\in [0,x]$?
A: I'm assuming
$$
f(x)=\begin{cases} 2 & x\in [0,1] \\ 0 & else \end{cases}
$$
And
$$
g(x)=\begin{cases} x & x\in [0,1] \\ 2-x & x\in [1,2)\\ 1 & x\in [2,3] \\0 & else \end{cases}
$$
Adding this together, we see
$$
\int_{-\infty}^{\infty} g(t)f(x-t)\textrm{d}t=2\int_{1-x}^x g(t)\textrm{d}t,
$$
since for these values of $t,$ $f(x-t)=2$ and for all other values of $t$, $f(x-t)$ is $0$.
Now, $g(t)=0$ for $t\leq 0$ so
 $$
2\int_{1-x}^x g(t)\textrm{d}t=2\int_0^x g(t)\textrm{d}t=2\int_0^x t\textrm{d}t,
$$
simply by plugging into the definition of $g$.
A: Observe that integrand $g(t)f(x-t)$ (where $x$ is fixed and $t$ is ranging over $\mathbb R$) takes value $0$ for every $t\notin[0,x]$. 
This justifies to replace $\int_{-\infty}^{\infty}\cdots$ by $\int_0^x\cdots$.
Further for any fixed $x\in[0,1)$ it is true that $g(t)f(x-t)=t2$ on interval $[0,x]$.
