Commit Graph

158 Commits

Author SHA1 Message Date
d268cad06a Fix T52090: clarify meaning of EnumProperty number when using ENUM_FLAG. 2017-07-17 18:31:19 +02:00
c822b1612f Docs: correct doc-strings 2017-06-26 07:36:29 +10:00
ed6d88f06a PyAPI: Fix warning about indent 2017-06-16 12:30:18 -04:00
a7b3047cef Datablock ID Properties
The absence of datablock properties "will certainly be resolved soon as the need for them is becoming obvious" said the [[http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.67/Python_Nodes|Python Nodes release notes]]. So this patch allows Python scripts to create ID Properties which reference datablocks.
This functionality is implemented for `PointerProperty` and now such properties can be created with Python.

In addition to the standard update callback, `PointerProperty` can have a `poll` callback (standard RNA) which is useful for search menus. For details see the test included in this patch.

Original author: @artfunkel

Alexander (Blend4Web Team)

Reviewers: brecht, artfunkel, mont29, campbellbarton

Reviewed By: mont29, campbellbarton

Subscribers: jta, sergey, campbellbarton, wisaac, poseidon4o, mont29, homyachetser, Evgeny_Rodygin, AlexKowel, yurikovelenov, fjuhec, sharlybg, cardboard, duarteframos, blueprintrandom, a.romanov, BYOB, disnel, aditiapratama, bliblubli, dfelinto, lukastoenne

Maniphest Tasks: T37754

Differential Revision: https://developer.blender.org/D113
2017-04-13 12:33:05 +03:00
411e7abe94 Cleanup: redundant casts 2017-04-05 01:08:19 +10:00
ab4c921e82 Clarified warning in EnumProperty
Blender doesn't necessarily crash when Python doesn't keep references to
the returned strings. As a result, someone that implements this incorrectly
could be lulled into a false sense of correctness by Blender not crashing.
2016-10-18 11:24:33 +02:00
ffe106a56a Docs: improve bpy.props.EnumProperty reference 2016-07-19 05:03:50 +10:00
4a64b36029 Cleanup: use bool 2016-04-12 11:26:06 +10:00
a1d7f67d81 cleanup: spelling / typos
no functional changes
2016-01-28 00:30:50 -05:00
676d790d29 Cleanup: use rna_enum_ prefix for RNA enums
Definitions could shadow local vars.
2015-11-23 17:40:09 +11:00
cff288cf3a Use PyC_ParseBool to parse bools
This could cause problems since they could be any int,
then passed directly to internal functions that assume bools.
2015-08-04 18:49:42 +10:00
339915a962 Optimize PySequence_Fast usage
Access arrays directly, avoiding type-check every time.
2015-07-29 10:49:35 +10:00
72565fbf30 Cleanup: style, spelling 2015-07-06 17:45:11 +10:00
a80c1e50bc Fix T44822: python enums' itemf callback did not handle 'NULL' context case.
Enum's itemf callback can be called without context in some cases (UI, doc generation...).
Python's enum properties did not handle this at all - it's kind of odd this did not cause
more trouble and wasn't notice earlier... Probably dynamic enums using context are not
much used in py code.

Note about nodes: those are heavy users of dynamic enum with context. Now,
we expect `NodeCategory.poll()` and `NodeItem.poll()` to always be called with
a valid context (since when there is no context available, we can assume `poll()`
is always True). `NodeCategory.items()`, however, must accept NULL context, so if
you use custom `items` callable for your custom node categories, you may need
to update it (as was done here for builtin `node_group_items()`).
2015-05-25 14:24:49 +02:00
a8da11c014 Add missing TEXTEDIT_UPDATE option 2015-05-08 08:58:29 +10:00
324751259e correcting typos in python api docs 2015-04-24 14:08:31 +01:00
fff8a519b8 Py Enum props definition: 'default' parameter cleanup/fix.
* There was no real default value for this parameter (neither "" nor None would work the same as
  not specifying that parameter). Now, 'None' is considered as default value, and you get
  exact same behavior with this value and if not specifying it. This is important at least for
  consistency, and potentially too in some esoteric cases (like generated code or so).
* Add a warning about the fact that 'default' parameter shall not be psecified when items
  are given a callback function.
2015-02-27 23:02:13 +01:00
3e034831de Refactor 'immediate search' feature
Currently, code just checks whether a text-edited button uses a given icon (VIEWZOOM) to decide to apply changes on each typed char.

This patch adds a propper button flag (UI_BUT_TEXTEDIT_UPDATE) and a dedicated RNA flag (PROP_TEXTEDIT_UPDATE) for that.
It's also now usable not only for text buttons, but also for example for num buttons when in 'text edit' mode, etc.

It also fixes an actual bug, which is for text properties, in 'immediate' mode, hitting escape would not restore org value, because `ui_apply_but_TEX()` would set its orgstr to NULL on first call (giving it to `but->rename_orig` instead of copying it).

Note no change in behavior is expected from user POV.
Update for addons using that 'VIEWZOOM' icon 'feature' will follow (if any).

Reviewers: campbellbarton

Reviewed By: campbellbarton

Projects: #user_interface, #bf_blender:_next

Differential Revision: https://developer.blender.org/D938
2014-12-25 12:55:29 +01:00
97e2d62c79 Fix T42581: Add 'icon_value' feature to UI Py/RNA's operator button and items of enums.
Rather straightforward, allows for 'DATA' icons (like mat or tex 'previews')
to be used as icon for operator button or items of an enum.

Patch by Simon Lušenc, with minor cleanup by self.
2014-11-16 15:55:55 +01:00
db5493ec7a Fix T42233: Python property ignores 'PROPORTIONAL' 2014-11-03 20:59:14 +01:00
6b2689c3f2 Fix T40191: Misleading TypeError message when registering CollectionProperty wtihout kwarg "type".
Turned up to be a cleanup of doc in that whole module...
2014-05-14 17:50:32 +02:00
e73d0f57a3 Code cleanup: use 'const' for arrays (python) 2014-04-27 00:25:15 +10:00
433b20b7ea PyAPI: correct warning with dynamic enums 2014-02-28 21:26:19 +11:00
a8a567d28e RNA: add flag to be used for changing numbers proportionally 2014-02-09 06:30:48 +11:00
06e0e3fb8a Py Docs: move bpy.props options and subtype flags into generic defines
added some missing flags into docs too.
2014-02-09 06:26:55 +11:00
299180f3c6 Fix T36955: API docs referred to sys.maxint which does not exist in Python 3. 2014-01-29 16:49:12 +01:00
a5c35fb27f Code cleanup: use booleans where appropriate 2014-01-28 04:00:04 +11:00
e9efde2a05 Fix T38297: missing StringProperty subtype 'PASSWORD' in API docs. 2014-01-20 22:01:11 +01:00
348cf17448 Code Cleanup: no need to pass empty strings as default values 2014-01-16 22:00:29 +11:00
6734936c13 RNA API: use bool's for enum itemf callbacks. 2014-01-04 18:10:01 +11:00
c701082a92 RNA: Add pixels property type 2013-12-13 04:40:30 +11:00
4dd7d4110a replace macro PYC_INTERPRETER_ACTIVE for PyC_IsInterpreterActive() function call,
(indirectly referenced Python define of ~30 lines, most were optimized out but still caused some code bloat).
2013-09-18 23:21:24 +00:00
742c1cb328 Related to #34558: clarify the description for the "default" parameter in bpy.props.EnumProperty. 2013-04-11 18:10:57 +00:00
2b2099cd51 Fix #34875: 0 digits of precision was not supported for FloatProperty, now
you can specify precision=0 for this, and use -1 for the default 2.
2013-04-08 18:55:08 +00:00
858ff6b696 Fix for [#34898] Typo in error message of mathutils.Vector
* Also fixed some more cases of "more then" -> "more than".
2013-04-07 15:09:06 +00:00
74e37ec0e6 Fix to EnumProperty doc (content of items tuples was rather fuzzy, ways how these "parameters" are interpreted are rather strange, current text should now reflect exactly code's behavior). 2013-03-25 14:46:34 +00:00
f9f7070336 add STREQ macro (commonly used macro like CLAMP, MAX2, STRINGIFY). Use for some areas of the python api, bmesh. 2013-03-10 06:18:03 +00:00
1a620ac9c3 bpy.props.RemoveProperty() py api docs were still incorrect. 2013-02-19 15:21:12 +00:00
6550fb8452 bpy.props.RemoveProperty() had incorrect docstring. 2013-02-19 02:48:14 +00:00
327b17b26f Fix #31338: python enum properties can now specify icons for items, in the following
order: (identifier, name, description, icon, unique number)

This also works without the icon still, for compatibility.
2013-01-23 21:55:11 +00:00
cef730d969 Python i18n API. Many thanks to Campbell and Brecht for the reviews and suggestions!
This commit adds:
* A new bpy.app.translations module giving some info about locales/translation stuff (current active locale, all locales currently known by blender, all translation contexts currently defined, etc.).

* The ability for addons to feature translations, using the (un)register functions of above module.

* Also cleans up "translate py string when storing into RNA prop" by removing "PROP_TRANSLATE" string's subtype, and adding a PROP_STRING_PY_TRANSLATE flag instead (this way it is no more exposed to python...).

Addon translations work with py dictionaries: each addon features a dict {lang: {(context, message): translation, ...}, ...}, which is registered when the addon is enabled (and unregistered when disabled). 

Then, when a key (context, message) is not found in regular mo catalog, a cache dict for current locale is built from all registered addon translations, and key is searched in it.

Note: currently addons writers have to do all the work by hand, will add something (probably extend "edit translation" addon) to automate messages extraction from addons soon(ish)! To get a look to expected behavior from addons, have a look at render_copy_settings/__init__.py and render_copy_settings/translations.py (rather stupid example currently, but...). Once we have a complete process, I'll also update relevant wiki pages.
2013-01-20 17:29:07 +00:00
a4d5ef8c7d fix for bpy.props string get-length callback, PyUnicode_GetLength() isn't a measure of the buffer size. 2013-01-11 04:09:54 +00:00
1c99e6aa0b pyapi internal api code: check for == -1 rather then < 0, for known error returns. 2013-01-10 15:22:19 +00:00
Lukas Toenne
127b5423d6 Another fix for bpy.props getters/setters: PyC_AsArray does a refcount decrement internally on errors, need to skip Py_DECREF in that case to avoid negative refcounts. 2013-01-10 14:36:08 +00:00
Lukas Toenne
273cf512dd Fix for bpy.props getter/setter callbacks. These were missing a valid GIL state when being called outside the UI context. 2013-01-10 12:32:09 +00:00
1bf5832dfb code cleanup: warnings and use stdbool for bpy* funcs. 2013-01-07 05:26:12 +00:00
8ee99cc39c add ability to use world gradient rendering when 'Only Render' option is enabled.
supports paper/blend/real.
2013-01-06 15:02:23 +00:00
Lukas Toenne
e8b415bdb4 This patch adds support in bpy.props for getter/setter callback functions. We already have update callbacks, but generic get/set functions can come in handy in some cases where the functionality is too complex to use a single value.
The current C callback functions are too simple allow a straightforward implementation, in particular they don't receive the PropertyRNA pointer itself as an argument, which means the callback cannot directly access the PropertyRNA's py_data pointers which store the python function objects. For this reason a second runtime variant of these callbacks has been added. It is only used for runtime callbacks and not in makesrna, but otherwise works the same way.
2013-01-05 14:56:37 +00:00
b88836a45b Add a warning to enum props' items parameter, to *never* use a generator as value for this param! It works in most cases, but in some it leads to an empty set of values for the enum (see [#33716]), and it's not an easy bug to track down! 2013-01-01 15:55:21 +00:00
f4dea6d829 when an invalid subtype is passed to a property, a list of valid subtypes is now included in the exception message.
from bug report [#33018], this avoids common mistakes.
2012-10-30 12:45:42 +00:00