Commit Graph

3904 Commits

Author SHA1 Message Date
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
56bfd3235c fix [#33616] Documentation not matching the behaviour of bmesh.utils
incorrect api docs
2012-12-19 11:18:08 +00:00
0a1f8ada34 Minor fix 2012-12-19 09:50:31 +00:00
7e56e5ac94 Adding "build_options" to bpy.app, a frozenset containing strings matching optional feature's build defines (like 'FFMPEG', 'MOD_BOOLEAN', 'INTERNATIONAL', etc.) for all enabled elements.
Note I tried to select all interesting defines, but this might be extended if needed...
2012-12-18 18:02:20 +00:00
734b4f60c1 missed adding show_grease_pencil to node space in recent commit 2012-12-17 09:17:21 +00:00
ab2c273b12 Added GPL header to sconscripts!
Also changed shebang to '#!/usr/bin/env python', this is more portable across unixes...
2012-12-17 08:01:43 +00:00
c92dd5fa40 bpy/rna api: add support for classmethods.
So RNA can expose functions from the type, eg:
  bpy.types.Objects.some_function()
2012-12-17 06:58:19 +00:00
dc7a138830 correct bad comment 2012-12-16 10:28:52 +00:00
950fb66c38 replace TypeError with Value error for matrix operations where the type is right but it can't succeed because of a property of the instance (normally the wrong col/row size). 2012-12-16 04:10:57 +00:00
1886ae38b4 add Matrix.normalized(), handy for transforming normals. 2012-12-16 04:05:16 +00:00
21a9fa9089 move bpath module from BLI to BKE, it was making many bad level calls into BKE. 2012-12-15 15:31:50 +00:00
d5c2a1f8f4 remove context argument from EDBM_update_generic() 2012-12-12 15:22:54 +00:00
3e8b56b321 add destructive argument to bmesh.update_edit_mesh() 2012-12-12 06:57:41 +00:00
adf7bfa8bb ifdef out dynstr so mathutils can be compiled as an external module again. 2012-12-08 01:16:59 +00:00
a864259d50 bump python requirement to 3.3 2012-12-06 02:42:42 +00:00
5b9f30980a update parse_syntax_error() from python3.3 - this is an internal python function that isn't exposed to the api. 2012-12-04 20:09:07 +00:00
d0667c70dd fix for python button evaluation not restoring the __main__ module. 2012-12-04 19:58:13 +00:00
60cd5ee412 fix for typo when overwriting pythons stdout/stderr, also print errors if they happen here now. 2012-12-04 11:21:33 +00:00
4302cde8ff re-apply a workaround for [#31555] Username with special chars in Windows 7
this time keep the stderr/stdout so there FD's are not closed (causing [#32720]).

This workaround is ugly but saves us from using a patched python.
2012-12-03 10:01:09 +00:00
61da29996a fix own mistake with recent commit to skip calculating tessface. If you were already in editmode the tessfaces wouldn't get recalculated.
also minor edits to bmesh rst.
2012-12-03 02:26:13 +00:00
f7f4148b40 change uiButGetStrInfo() to use a trailing NULL arg rather then passing the number of args as an arg. 2012-12-02 04:51:15 +00:00
07ccd3ee3f fix [#33029] Applying modifier leaks memory
Thanks for Sergey for finding the bug & patching, This fix works a bit differently.
Theres no need to allocate the customdata in the first place - since its written into. So add a flag for vert/edge/face/loop creation functions so they can skip customdata creation.
2012-11-29 16:26:39 +00:00
149b607141 py/bmesh api: add radial prev/next attributes to the loop 2012-11-29 05:54:35 +00:00
858149d7c7 bmesh py api: add bmesh.update_edit_mode(), there was no way to redraw the 3d view or re-calculate face tessellation from python.
add py template for editing meshes in editmode.

also remove double call to CTX_wm_region which does a string lookup.
2012-11-29 05:02:06 +00:00
ede703ab85 some minor edits
- script stub printed resource warning with py3.3 (not closing a file).
- bmesh customdata layer access had bad docstring.
- float/double conversion warnings in sequencer code (use doubles since result is double)
- remove unused var
2012-11-29 03:55:07 +00:00
c86045d7a2 bmesh py api: use generic checking macros to see if an object if from the same bmesh.
- was such a common operation so this saves having exceptions set inline all over the place.
2012-11-29 03:25:37 +00:00
078487e98e bmesh py api: add BMeshFaceSeq.active attribute- bm.faces.active 2012-11-29 02:44:06 +00:00
96136d3d88 bmesh operator py api:
- fix for incorrect bmesh operator type-check for mapping slots.
- fix for python causing an assert when invalid args are given.
- fix memory leak with some exceptions.
2012-11-28 15:07:57 +00:00
c5a8bd498d use radians for 'spin' bmesh operator (since the rest of the py api uses radians). also rename BMO_OP_SLOT_SUBTYPE_MAP_FLOAT -> BMO_OP_SLOT_SUBTYPE_MAP_FLT for consistency. 2012-11-28 00:47:33 +00:00
21db9ac0f4 replace and exception macro's for static functions and fix some bad assumptions. 2012-11-27 15:26:10 +00:00
c9d84ab5ed split py->slot & slot->py into their own functions & fixed some mistakes with conversion. 2012-11-27 14:25:38 +00:00
492af7cc6b move bmesh operator calling into its own file. 2012-11-27 13:54:34 +00:00
2d5b8172e9 add empty files (will move bmesh operator calling here) 2012-11-27 13:45:28 +00:00
a9855c227e py/bmesh api - add support for single item buffers (odd feature but used quite a bit with bmesh operators).
also add utility functions BMO_slot_buffer_from_single(), BMO_slot_buffer_get_single()
2012-11-27 09:21:57 +00:00