implement cache line for image editor

It works exactly the same as a cache line in movie clip editor.
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).

This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.

Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).

This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).

Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D342
Replace resize code of image scopes by use of new GRIP button.

This deduplicates/simplifies some code. Also cleanup up a bit scopes UI code!

Use new GRIP button for uiList grab-resize.

This allows us to greatly simplifies the code, and get rid of a few hacks in uiList event handling!

Note autosize mode of uiList is now trigered by any value of list_grip below a given threshold, rather than the fixed zero value...

Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D343
UI: Tweak last commit for UIList and image scopes' grip size.

Sorry, forgot the --hold arg to last arc land, wanted to check this before pushing... :/
Implement fame sliding from IE's cache line
Refactor to recent matcap built-ins to not use the built in system.
Those variables would get declared on fragment shader level and since we
use reserved opengl variables, some compilers would throw an error
(NVIDIA allows, some ATI compilers may break). Instead, use a separate
opengl built-in category especially for them. This works on NVIDIA, and
will wait for tests of this commit from ATI users.
Undoing masks in dyntopo leaked memory
Fix T39520, show diffuse not working in dyntopo.

Was marked as a todo in the code.

This does not yet take care of correct display for multi material
meshes, since it would need correct separation of faces during pbvh
creation. Instead we just take material of first face in node and assume
that the rest faces have the same. This will create some funky effects
if one attempts to sculpt in this way.

Note: This does not yet address T39517
Fix T39523: cycles cache BVH not working correct with deformation motion blur.
Fix T39525: cycles volume render difference between branched/non-branched path.
Fix T39517,

Issue here is that "show diffuse" option does not respect its intended
purpose which is to be used only for masking.

There are a couple of caveats here:

Dyntopo and multires -always- have mask data enabled, and thus as soon
as one goes to dyntopo mode or adds a multires modifier he would get the
default grey color instead.

Matcaps would break when nodes asked for a diffuse material color (this
was broken before too). Solved by adding global material state for when
matcaps are enabled. Also matcaps don't always played well with VBOs
off.

Added a few more missing updates for mask operators to notify
show_diffuse property as changed. This was also needed on rebuilding
dyntopo pbvh.

Also make zero mask color duller again after artist feedback.
Code cleanup: style
Code cleanup: use BKE_BIT_TEST_SET to set flags
WM: expose file loading operator property init functions
Add load_ui to WM_OT_read_homefile

Useful for implementing templates.

Patch D423 by Gaia Clary
Forgotten to add this on last commit. This would cause dyntopo to always
refresh all its nodes if show diffuse was on.
Freestyle: Fix for debug information about sweep line intersection detection.

Vertices of two edges were swapped by mistake.  Also fixed indentation and added
a couple of debug prints to make it easier to visualize the lines using Matlab.
Code cleanup: strict flags for bmesh_log
Fix T39245: Crash when dynamic topology is enabled

Redundant decrement was crashing for systems which didnt optimize it out.
Fix build for BSD (broken by own 35747ee3d547).

Reported by Shane Ambler, thanks!