Supports RNA properties initializing settings for operators.
When activating the file browser to change a property, there was no way to control the settings which the file browser would use.
Resolve this by adding PropertyRNA.operator_invoke which operators may call when editing properties.
Currently file browsing is the most obvious use-case but it could be used for other kinds of properties in the future (so the property could control how the eye-dropper is used for e.g.).
This introduces user visible changes:
- Browsing font paths in the user preferences enables the font filter.
- Browsing the render output path shows +/- buttons (to increment/decrement the file name).
Now "check_existing" is available for all file browser operators, defaulting to ON for FILE_SAFE, allowing any call to the browse operator to optionally check for output.
Exposing this to the Python API (via bpy.props is a remaining TODO).
Notes:
- This is an alternative to both D13937 & D15968.
- The naming operator_invoke could be changed to be less generic (as it's a fairly spesific action).
- There are some unused arguments to the PropertyRNA.operator_invoke(..), these will be needed when Python supports defining the callback.
Possible Solutions
Add File Browser Specific RNA Properties
The property it's self could store settings such as.
- Is the path input or output (which could control "check_existing").
- The filter flag (to filter on images, fonts, textures etc).
The main down side of this is we would end up adding properties which are spesific to the file browser into RNA, adding API duplication for something that is only used in a few places.
Add File Browser Specific Property API
We could UILayout.prop_filepath(..) however it has some draw-backs.
- The prop_filepath may end up having to take many file-paramaters (duplicating the filter options for e.g. for different file types).
- Something which is logically part of the property is being stored in UI layout (meaning automatic layouts won't have useful file browser settings).
Add an Operator Invoke Callback (this patch)
This allows the property to set any operator settings that seem useful, as shown in this patch "check_existing" and "filter_font" happen to be useful for render output and font selection.
It has the advantage of not duplicating operator settings into the RNAProperty or the UILayout methods.
A down side of this is that the operator needs to be checked by the properties invoke function, which is a trade-off made to avoid duplicating those settings into other parts of the API.