Commit Graph

115 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
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
Brecht Van Lommel 47cd3cf225 BPY/RNA: determine callback functions that are allowed to write data by a flag
on the function instead of checking the name.
2012-11-03 14:31:38 +00:00
Jiri Hnidek 2821f822c5 * New string property subtype: PASSWORD
When this new subtypes is used, then string of property is hidden using
asterisks, e.g.: mysecretpassword -> ****************

This code was reviewed and modified by Brecht. Thanks very much:
 - https://codereview.appspot.com/6713044/

This new subtype of string property is intended mostly for Add-on developers
writing Add-on which communicates with some server (http, sql, ftp, verse,
etc.). When this server requires user authentication and user has to type
username and password, then current API didn't allow to type 'hidden' password,
e.g. when you want to demonstrate this script, then everybody can see this
security password. Some examples of Add-on which could use this new subtype:
 - On-line database of textures
 - Integration of render farm
 - Integration of Verse

Security Notes:
 - You can copy paste hiddent string of property from text input using (Ctrl-C, Ctrl-V),
but you can do this in other GUI toolkits too (this behavior it is widely used).
 - Text of string property is stored in plain text, but it is widely used in other
GUI toolkits (Qt, Gtk, etc.).

Simple examples:
 - https://dl.dropbox.com/u/369894/draw_op_passwd.py
 - https://dl.dropbox.com/u/369894/blender-password.png
2012-10-26 12:58:54 +00:00
Campbell Barton 32cf7fcdb1 code cleanup: spelling 2012-07-16 23:23:33 +00:00
Campbell Barton a9f6e54384 style cleanup: mostly whitespace in rna 2012-05-12 11:01:29 +00:00
Joshua Leung f1e3c31d4f Style Cleanup: Wrapping with parens for safety and whitespace edits 2012-05-05 05:46:45 +00:00
Campbell Barton e7f1033dcb style cleanup: for loop macros, also add a config file for uncrustify source formatter (able to get very close to our own style guide). 2012-04-15 07:24:14 +00:00
Campbell Barton e03ebf7a41 code cleanup: replace (val >> 16) with macro RNA_SUBTYPE_UNIT_VALUE(val) 2012-04-10 09:03:45 +00:00
Campbell Barton c4ce26c906 Address [#30842] Blenders Measurement Units set to Metric, makes some Precision Flaws.
use the same precision for location all over (2-5 was used), use define as 5.

also disallow boolean to have any subtype besides PROP_LAYER_MEMBER, some booleans had TRANSLATION / XYZ subtypes which don't make sense.
2012-04-10 08:33:30 +00:00
Campbell Barton 9a6a791ff0 fix [#30865] Crash when browsing last operators in outliner (or by Python API)
Operator descriptions can be NULL pointers,
fix this by making use of PROP_NEVER_NULL flag, when its not set, generated string funcs will test for NULL.
2012-04-09 04:39:47 +00:00
Campbell Barton 89a963fb7f style cleanup: comment blocks 2012-03-09 18:28:30 +00:00
Campbell Barton 9d49fa0e63 style cleanup - spelling corrections & update some incorrect comments. 2012-03-03 11:45:08 +00:00
Campbell Barton 2b7ca2304a unify include guard defines, __$FILENAME__
without the underscores these clogged up the namespace for autocompleation which was annoying.
2012-02-17 18:59:41 +00:00
Campbell Barton 22b5a3735f add flag FUNC_USE_MAIN for rna functions which don't need the context. (currently unused) 2011-11-17 18:41:37 +00:00
Campbell Barton d6c1009195 bytestring support for py/rna - this is so py can access data which
isn't meant to be accessed as unicode text.
2011-11-15 07:09:41 +00:00
Campbell Barton ce462fa1b7 - disable undo for user preferences (every click would do push an undo), was noticeable on large files.
- also netbeans project file generator now uses branch name for project.
2011-11-08 15:11:27 +00:00
Campbell Barton 4a04f72069 remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
Campbell Barton b001eeb10d Change struct alignment for structs which are intended to be aligned but aren't.
remove uiIconImage too since its unused.
2011-10-03 01:36:25 +00:00
Campbell Barton 943a026c60 py/rna string subtypes for strings which should be automatically translated:
layout.prop("blah", text="Translate Me!")
2011-09-21 13:53:35 +00:00
Lukas Toenne 8e0fe8bff7 Merged the particles-2010 branch with node improvements into trunk.
This branch adds mostly organizational improvements to the node system by renaming the node folders and files. A couple of internal features have been added too.
Detailed information can be found on the wiki page:

http://wiki.blender.org/index.php/User:Phonybone/Particles2010
2011-09-05 21:01:50 +00:00
Campbell Barton 2c8e1e633c comment unused lines. 2011-08-15 03:41:31 +00:00
Campbell Barton 9c8cc9fe60 rna option not to save certain properties for redoing later, currently only used by operator presets. 2011-06-07 10:54:57 +00:00
Campbell Barton 8cee328546 Support for update callbacks in python defined RNA properties as discussed last meeting.
This means script authors can perform actions using these callbacks rather then on drawing which puts blender in a readonly state.

Simple example:

import bpy
def up_func(self, context):
    print("test")

bpy.types.Scene.testprop = bpy.props.FloatProperty(update=up_func)
bpy.context.scene.testprop = 11

# prints -> test
2011-06-06 17:50:20 +00:00
Campbell Barton 155d589333 add the property as an argument to enum item functions, not used yet but needed for dynamic python enums. 2011-05-26 13:38:16 +00:00
Brecht Van Lommel 66f51ba5d1 RNA: make mechanism used by operators to keep python instance alive more generic, to be used by render engine later. 2011-05-18 11:21:10 +00:00
Brecht Van Lommel 178ba76b09 RNA: pass Main rather than Context to register/unregister callbacks. 2011-05-18 10:56:26 +00:00
Campbell Barton 70cd0803ab add new subtype PROP_COORDS, for generic coordinates that are not to be changed by units. 2011-04-08 13:32:56 +00:00
Brecht Van Lommel 128bed8480 RNA: use a different method to set DNA types for BlendData* collections, to
solve issues with c++ api.
2011-03-13 13:01:02 +00:00
Nathan Letwory a47ca06502 doxygen: blender/makesrna tagged. 2011-02-27 20:20:01 +00:00
Nathan Letwory 5b607701a7 doxygen: prevent GPL license block from being parsed as doxygen comment. 2011-02-23 10:52:22 +00:00
Campbell Barton 8ea0b4685c misc small changes:
- rename rna collection structs Main prefix to BlendData: eg, MainObjects --> BlendDataObjects
- printing python collection now prints its type (when available)
- renamed shadowed vars in bpy_rna.c.
- when making functions static I also made debugging/test functions static, reverse and add definitions to headers instead.
2011-02-14 03:15:55 +00:00
Campbell Barton daa09a4a60 Raise an exception when registering classes with ID names which are too long. (related to bug ), found while looking into bug [#25776]. 2011-01-24 03:38:34 +00:00
Campbell Barton 86bbab7de5 remove/comment unused defines. 2011-01-15 16:14:57 +00:00
Campbell Barton 9733e5f76f revert part of Tons commit r33884.
- rather then use unlink="None", just don't pass unlink as a keyword. This is more pythonic.
- added an RNA flag for properties which cant be unlinked by setting to None.
2010-12-30 12:22:28 +00:00
Campbell Barton d624d1cbdd pass along the context to extension functions, this was already being done in all cases except for the render engine.
this allows python to NULL its internal context while scripts are not running.
2010-12-07 04:12:15 +00:00
Campbell Barton b45c3363fd fix for some pedantic warnings. 2010-12-03 01:52:28 +00:00
Campbell Barton ee1d2adc16 partial fix for [#23532]
- Python calling operators didn't run WM_operator_properties_sanitize() so enum functions called from python were given a NULL context.
- PROP_ENUM_NO_CONTEXT and PROP_NEVER_NULL used the same value in the enum (possible conflict).
2010-11-23 12:05:35 +00:00
Campbell Barton dfb8c5974e rna support for passing dynamic sized arrays to rna functions
using this for object.vertex_groups.assign([index list ...], group, weight, mode)
2010-08-31 11:31:21 +00:00
Campbell Barton 4e3390437e - Properties from base classes are now registered too, this allows class mix-in's to define properties.
An example of how this is useful - an importer mixin could define the filepath properties and a generic invoke function which can run the subclasses exec for each selected file.

- Panels and Menus now skip the property check when registering.

- renamed _idproperties_ to _idprops_ in function names, function names were getting very long.
2010-08-19 10:16:30 +00:00
Nicholas Bishop 63791e03d6 * Partially revert r30763, where PROP_IMAGEPATH was added.
* Brush icon property back to not using image browser until a better solution is decided on.
2010-07-26 23:40:46 +00:00
Nicholas Bishop 8fb499c34f * Added a new RNA subtype, PROP_IMAGEPATH. It's the same as PROP_FILEPATH, but for images only.
* Changed UI code to display image browser for PROP_IMAGEPATH
* Set the icon_filepath RNA property for brushes to use PROP_IMAGEPATH
* Changed preview icon drawing to ignore unset icons
* Fixed const warnings in brush RNA
2010-07-26 18:37:47 +00:00
Campbell Barton 556b57febf get rid of some warnings,
removed NG_LoopBackNetworkDeviceInterface::GetNetworkVersion(), wasnt used anywhere.
2010-06-05 15:31:55 +00:00
Campbell Barton b9662fc637 patch from Dan Eicher
- pose markers new/remove
- font load/remove
- world load/remove
- particles new/remove

commented out node-tree for now since from what I can tell these have to be atteched to material/scene/texture (unlike other ID types)
2010-05-15 13:30:14 +00:00
Campbell Barton cd6332ca1e patch from Dan Eicher
rna add/remove functions for lattices, brushes and metaballs
2010-05-14 21:16:37 +00:00
Brecht Van Lommel 9a85013692 Merge various small changes from render branch:
* Division by zero fix for TNT SVD code.
* Sound fix, in case ffmpeg decode fails, don't use the samples.
* Fix for incorrect bounds of transformed objects in new raytracing code.
* Gave memory arena's a name used for allocations for easier memory
  usage debugging.
* Dupligroup no_draw option was using layers but not restrict view/render
  setting. (not a bugfix exactly but would do display list context switching
  while drawing for no reason).
* Fix objects instanced on hair particles not giving consistent results
  when the object is transformed.
* New math functions: madd_v4_v4fl, len_squared_v3v3, interp_v4_v4v4v4,
  mul_v4_m4v4, SH and form factor functions, box_minmax_bounds_m4.
* mul_m4_m4m4 and mul_m3_m3m3 now accept the same pointers for multiple
  arguments.
* endjob callback for WM jobs system.
* Geometry node uv/color layer now has search list/autocomplete.
* Various small buildsystem tweaks, not strictly needed yet in trunk.
2010-04-15 10:28:32 +00:00
Brecht Van Lommel 5bc2d53507 fix for parsing python args to rna functions, was using allocated size as argument count.
(commit 27670 by Campbell from render25 branch)
2010-03-23 15:04:06 +00:00
Brecht Van Lommel 33e0ea0e59 py/rna functions for adding and removing curve data.
(commit 27666 by Campbell from render25 branch)
2010-03-23 14:58:36 +00:00
Campbell Barton 391cc2d004 merge own commits into render branch into trunk since 27560
27562, 27570, 27571, 27574, 27576, 27577, 27579, 27590, 27591, 27594, 27595, 27596, 27599, 27605, 27611, 27612, 27613, 27614, 27623
2010-03-20 16:41:01 +00:00
Campbell Barton 081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00