gsoc 2013 branch soc-2013-ui_replay
merged trunk
Keeps the operator stack synchronised with the undo stack so that the redo panel displays the right operator after an undo.

N.B. This is an updated version of patch #35059 in the tracker, which had a nasty bug in it still.

This patch aims to introduce functionality that keeps the two undo stacks (object mode, and edit mode) synchronised with the operator stack in the window manager. This allows for the operator redo panel to be initialised to the last operator that was performed to arrive at the current state after undos and redos are performed. This is achieved by keeping pointers to the operators in the UndoElem structs and rebuilding the wmWindowManager's operator stack after each undo or redo.

The changes throughout the code aim to achieve that a) wmOperator structs are passed to the undo systems to be stored in the UndoElem structures (changes in undo_push_X functions), b) wmOperator structs that are referenced from UndoElem structs are only freed by the undo system, and that c) the operators that are repeated instead of redone (repeat last, repeat from history) are copied rather than moved to the back of the operator stack.

Operators that have a flag OPTYPE_UNDO are registered in the undo system and the undo system is responsible only for these operators. Other operators are freed after application. Even though all OPTYPE_UNDO operators are registered in the undo system, only OPTYPE_REGISTER operators are included when generating the window managers operator stack.

N.B. The following changes aren't very nice and I would like to point them out explicitly.
- The undo system, which is part of blender's core, is now more strongly connected to window managing subsystem than before
- The UndoElem structs (one for object mode undo, and one for edit mode undo) are not exposed, but mapped to a third UndoElem in wm.c. This was done to avoid bringing too much WM logic into blender.c. Better but more involved solutions exist.

Further changes should include doing away with the operator stack entirely and use the undo system as the backend data model for it.
Explicitly creating ListBase and assigning its fields before passing to WM_operator_build_stack.
Properly declaring variables at start of code blocks.
The operator redo panel now uses a two column layout. Labels on the left, widgets on the right. This increases readability and is part of an attempt to minimise scrolling.
Added shortcuts to buttons in regions of type RGN_TYPE_TOOLS. 

To do:
* take care of overlapping text
* add a preference to turn showing the shortcuts off
Shortcuts on buttons disappear if the buttons' labels and their shortcuts would overlap.
Stripping shortcut before adding it again. Without a shortcut appears twice on a button upon a mouse over.
Quick test to see how to implement default operator properties in a button's right click popup menu.

Some not so nice, rough corners:
* default properties are stored in a wmOperator in wmOperatorType and duplicated in default_properties.
* wmOperators in wmOperatorType aren't cleaned on exit yet.
* the widgets in the popup are not properly aligned.
* lots of properties are ignored upon executing an operator.
Extended uiLayout to make it possible to have taller buttons. Buttons in a row or a column layout can be from one to five times the normal height.
Some initial changes to the toolbar. Buttons can be double height, shortcuts show, many panels instead of a few (only object and edit mode).
Quick experiment to put mode switching buttons at the top of the toolbar.
Added shortcut parameter to "operator" function and aligning icon on the left is a shortcut is to be shown, but no label.
Added icons for object mode toolbar.

* duplicate
* duplicate linked
* add 
* delete
* ruler

I'm happy for someone to make proper icons for this.
Drawing little widgets on toolbar panels so that they can be opened in a popup. Handler is a stub for now. The plan is to execute an operator that displays the panel in a popup window.
Small bug fix. Was declaring UndoElem *uel not at the start of the function.
Toolbar popup panels work. There are still some bugs with laying out and drawing text.
Wasn't cleaning up after myself properly. This fixes memory leaks. 

There's still a memory leak that I have to look at more closely:

Error: Not freed memory blocks: 2
Data from SCR len: 336 0x10d8b54b8
Data from SCR len: 272 0x10d8b5648
The VIEW3D editor gets an extra, extensive toolbar. The idea is that this frees up space from the left sidebar for tool options and custom panels.

The extra menubar is meant to provide a place for many non-modal operators in a flatter hierarchy than the current header menu (less clicks, better visibility). The left sidebar is then meant to house custom panels and more activity based panels.

* fixed a bug in the undo/operator stack integration code whereby operators were freed in certain cases
* removed Select and Special menus from the header, and placed the underlying menus in the extra toolbar
* removed some of the sidebar panels, will work on replacing these with more activity based panels
* moved all grease pencil buttons and options into a single panel for the toolbar