Commit Graph

3937 Commits

Author SHA1 Message Date
ec97183876 add python api docstring for 'bpy.types.Operator.bl_property' 2013-02-05 05:09:19 +00:00
a8601a5702 fix [#34113] operator_menu_enum() - Tooltip not showing descriptions
Python wasn't able to set 'OperatorType.prop', which is used by uiButGetStrInfo().

add 'bl_property' to python operators which is assigned to OperatorType.prop when registering.

(api docs coming next)
2013-02-05 04:41:11 +00:00
4528405597 add BM_edge_is_contiguous(), check for python api. 2013-02-04 10:14:31 +00:00
6fca85780b style cleanup: also correct doc example for 'foreach_get/set' 2013-02-02 00:34:34 +00:00
2a71e4e4f0 make WITH_HEADLESS build again. 2013-02-01 08:24:18 +00:00
69585591d6 Correct fix for r54164, the testcase I was using worked but different edge slide examples didn't.
Edge slide needed to check for concave ngons too.

add BM_loop_is_convex() and expose to python too.
2013-01-29 03:25:47 +00:00
Lukas Toenne
c8d29c1af8 Fix for RNA FUNC_REGISTER/FUNC_REGISTER_OPTIONAL flags: The test in bpy validation of classes actually always passed for mandatory functions. This only worked since they all use fallback default implementations internally. 2013-01-28 12:17:49 +00:00
f44b7868c5 add mathutils function to intersect 2 circles. Converted to C from a python script by Alex Fraser. 2013-01-28 11:52:17 +00:00
f2a1a795cf Fix [#33997] Units Scale in Metric mode displays wrong face area.
Also now display nice "area" units (maybe using "length" units was a perf matter, but anyway, you can't have more than a few tens of values displayed at a time, after that they become unreadable). Easy to undo anyway if we really want to keep ugly "10m" as area display!
2013-01-25 21:21:38 +00:00
7803b51b42 Fixed for strict compiler flags 2013-01-24 13:43:37 +00:00
6146110270 Final memory fix for bpy.app.translations (not really a leak, but unfreed memory at end of program - I thought addons were unregistered at quit time...). 2013-01-24 11:38:17 +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
bb14b390e5 Fix own stupid memory leak in new py i18n code (forgot to free temp keys when searching messages in GHash cache!).
Thanks to PerfectionCat for finding this.
2013-01-23 07:59:07 +00:00
63edcf785e Fix for build with scons whithout i18n support.
This should not be needed, I really see no reason for this linking error, but I'd rather use this hack than wasting more time over this issue. When will we get rid of this "two build systems to maintain" time-wasting situation?
2013-01-22 14:55:34 +00:00
3406bafc59 comments for RNA_def_property_ui_range() and clamp some out-of-range values. 2013-01-22 11:23:05 +00:00
4c0ebedc66 On second thought, exposes bpy.app.translations also when built without i18n support, this will avoid the need for py scripts to test for its presence everywhere! 2013-01-21 15:10:22 +00:00
e0063bd74f Print warnings when invalid py dict/key/value is found in translations data (do not error here, this is not critical and can be ignored/skiped, and it would break translations for other addons as well). 2013-01-21 12:01:47 +00:00
57221e13ee Expose locale_explode in bpy.app.translations, will be handy in i18n manipulation scripts/addons. 2013-01-21 10:57:24 +00:00
3aa499f3f7 I18n fix: "" context is not the same as NULL context!
This bug did not appear earlier because the "" default context was actually never used, always NULL context was passed instead. But bpy.app.translations uses "" as default context in its keys (simplifies the hash/comp functions of internal py messages cache)...

So now, Blender prefers NULL (None in python) as default context value, but understands also "" as such.
2013-01-21 10:52:34 +00:00
d05f46c12d minor changes to _build_translations_cache(), remove unneeded NULL checks and use slightly different funcs for getting strings. 2013-01-21 02:40:36 +00:00
38cee985bb code cleanup: style & warnings. 2013-01-21 02:30:40 +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
b27854bd47 use booleans for bmesh api. 2013-01-14 16:42:43 +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
f9c87b86fc partial fix for [#32581] Mesh properties API does not allow for zeros in byte array
bmesh access allows zero bytes, support still needs adding via RNA.
2013-01-09 13:25:46 +00:00
e24443b79a style cleanup 2013-01-09 03:30:15 +00:00
c598a306c4 Add normal_flip() member to Python BMesh's Face. 2013-01-07 12:19:00 +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
927b2645d4 sequencer api args - rename start/end_frame to frame_start/end to match the rest of the RNA api. 2013-01-06 12:42:47 +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
3b3c0b97fd commit bpy_path files, missed these in recent commit. 2013-01-04 07:58:47 +00:00
1e762a29ee change bpy.app.build_options from frozen set to PyStructSequence_Field, mathes similar members of bpy.app and less error prone (typos won't fail silently). 2013-01-04 04:43:49 +00:00
9dbe85c17e expose common extensions for image/movie/audio types, since python scripts had to do this internally.
- bpy.path.extensions_image
- bpy.path.extensions_movie
- bpy.path.extensions_audio

eg:

  if os.path.splitext(filename)[1].lower() in bpy.path.extensions_image:
      ... we have an image ...
2013-01-04 03:47:37 +00:00
1a7638fa94 add id property clear function (matching the same python function for dicts/lists) 2013-01-02 23:10:14 +00:00
ea2224e28d changes needed for EDL import to work again.
- add sequence.update(data=False) function.
- made some sequence vars editable.
- correct some comments.

also rename rna function sequence.getStripElem() --> strip_elem_from_frame()
2013-01-02 16:15:45 +00:00
a94e4e0ef8 fix [#33726] keyframe_insert() and keyframe_delete() with index=-1 always fail
The bug was introduced in r53297, was calling pyrna_struct_anim_args_parse() twice for no reason, perhaps baddly applied patch?.
2013-01-02 06:09:53 +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
857df8065f style cleanup 2012-12-28 14:19:05 +00:00
7504cf34b4 This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!

This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!

To make all this work, other changes were also necessary:

* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.

* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.

* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.

* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
  Note: not sure whether we should add that one to all UILayout's prop funcs?

Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
71dbd39891 remove workaround for [#31555], forcing PYTHONIOENCODING was causing stdout to be lost on exit - no MEM_printmemlist_stats() 2012-12-28 00:54:22 +00:00
daa2a0d1c3 use keyword args for bmesh.update_edit_mesh(...) 2012-12-27 07:27:28 +00:00
789b2acd77 Add keying "options" parameter to keyframe_insert() bpy_rna function, so now you can enable 'INSERTKEY_NEEDED', 'INSERTKEY_VISUAL' and/or 'INSERTKEY_XYZ_TO_RGB' when you directly key some property from python script (previously those options were only available through keyingsets).
Thanks to Campbell for review!
2012-12-23 13:58:42 +00:00
b2c66e268f replace MIN/MAX 3,4 with inline functions 2012-12-21 05:07:26 +00:00
0e3d637ad0 Change region drawing callbacks to work much closer to how blender manages them internally.
- yes, this does break scripts, but the api is marked experimental.


ED_region_draw_cb_activate() adds a callback to a region type whereas the api made it look like the callback was being added to the region instance.
Use a class method on bpy.types.Space to manage region drawing, eg.

was:
  self._handle = context.region.callback_add(draw_callback_px, args, 'POST_PIXEL')

is now:
  self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL')
2012-12-20 13:29:58 +00:00
Lukas Toenne
35c2267aee Support for actual class methods in the RNA/bpy. Previously all functions with FUNC_NO_SELF were treated as static methods, which is not sufficient for getting actual type information if the function can not be generated in advance in makesrna. Now the FUNC_USE_SELF_TYPE flag can be set in addition to FUNC_NO_SELF (if FUNC_NO_SELF is not set, FUNC_USE_SELF_TYPE has no effect). Such functions will be interpreted as class methods and must take a StructRNA pointer argument. This pointer is the same as the type member in PointerRNA, but can be passed without an actual data/id instance. 2012-12-20 09:33:12 +00:00
3c9f502049 py api: be more strict with boolean assignment, only accept 0 or 1, True/False. Would allow any nonzero value. 2012-12-20 03:08:27 +00:00