How to auto scale widget when you click some button to let some widget popup?

I want to let my layout change when I clicked the button.
There is a horizontal box in the bottom of my layout and the right hand side is the sidebar menu.
And then, I hope the horizontal box will scale when I chick the button to expand the sidebar menu. How can I do, must use animation?
First pics:
image

The result I wanted:
image
image

Just dropping a link, answered here:

If you want this done with a button, call the script that’s shown on button click, either instead or in addition to.