Compare commits

...

171 Commits

Author SHA1 Message Date
Jaume Bellet 58877fd199 Merge branch 'bf-blender' into mb-0013-blender-top-bar 2024-04-04 19:38:21 +02:00
Jaume Bellet 6470fbf6b6 Merge branch 'mb-0013-blender-top-bar-base' into mb-0013-blender-top-bar 2024-03-12 07:29:22 +01:00
Jaume Bellet 913e155c7b Merge branch 'mb-0015-image-ui' into mb-0013-blender-top-bar-base 2024-03-12 07:28:33 +01:00
Jaume Bellet 99261bcd1a Merge branch 'mb-0014-bpy-images' into mb-0015-image-ui 2024-03-12 07:27:36 +01:00
Jaume Bellet 183ad17df5 Merge branch 'bf-blender' into mb-0014-bpy-images 2024-03-12 07:27:04 +01:00
Jaume Bellet f0c51c2927 Merge branch 'bf-blender' into mb-0015-image-ui
Conflicts:
 	source/blender/editors/interface/interface_templates.cc

due to f4e670af2c and fdc367f842
2024-03-12 07:17:19 +01:00
Jaume Bellet 222bbd5870 Merge branch 'mb-0013-blender-top-bar-base' into mb-0013-blender-top-bar 2024-02-26 00:16:25 +01:00
Jaume Bellet 0a09b279cf removed mb-0012 stuff 2024-02-26 00:15:53 +01:00
Jaume Bellet 316ec095f9 removed mb-0009 changes, will be merged next 2024-02-25 23:58:16 +01:00
Jaume Bellet 41634ec713 removed mb-0015 changes, will be merged next 2024-02-25 23:57:12 +01:00
Jaume Bellet 1beab72f70 removed mb-0010 changes, will be merged next 2024-02-25 23:55:27 +01:00
Jaume Bellet 5010e61a15 Merge branch 'mb-0012-custom-splash' into mb-0013-blender-top-bar-base 2024-02-25 23:51:46 +01:00
Jaume Bellet 0651f8fe2f Merge branch 'mb-0009-addon-menu-references' into mb-0013-blender-top-bar-base 2024-02-25 23:51:18 +01:00
Jaume Bellet 197d935395 Merge branch 'mb-0015-image-ui' into mb-0013-blender-top-bar-base 2024-02-25 23:50:32 +01:00
Jaume Bellet 3c281ddf78 restoring original README.md file 2024-02-25 23:46:11 +01:00
Jaume Bellet 0223f93c2d Merge branch 'mb-0014-bpy-images' into mb-0015-image-ui 2024-02-25 23:44:26 +01:00
Jaume Bellet fc14101e67 removing mb-0014 changes, will be merged next 2024-02-25 23:43:54 +01:00
Jaume Bellet 8d178ec03d restoring original md file 2024-02-25 23:42:21 +01:00
Jaume Bellet d82734d3a1 removing patches.py 2024-02-25 23:40:10 +01:00
Jaume Bellet 7fcb34fa1d Merge branch 'bf-blender' into mb-0014-bpy-images 2024-02-25 23:39:46 +01:00
Jaume Bellet 76d136b561 removing stored patch and patches.py 2024-02-25 23:39:07 +01:00
Jaume Bellet 2138265035 removing patches.py and stored patches 2024-02-25 23:36:45 +01:00
Jaume Bellet 280850ddf1 remving patches.py 2024-02-25 23:35:05 +01:00
Jaume Bellet e2e0d25e55 removing patches.py file 2024-02-25 23:32:53 +01:00
Jaume Bellet 5ca0cb05b7 Merge branch 'bf-blender' into mb-0009-addon-menu-references 2024-02-25 23:32:30 +01:00
Jaume Bellet 352759ebaf Merge branch 'mb-0008-mblender-core' into mb-0010-url-presets 2024-02-25 23:16:12 +01:00
Jaume Bellet 391f2b37bd removing all stuff related to mb-0008, will be merged on next commit 2024-02-25 23:16:03 +01:00
Jaume Bellet 59d84807d2 deleting patches.py file 2024-02-25 23:14:12 +01:00
Jaume Bellet a782515ff1 deleting patches.py 2024-02-25 23:13:21 +01:00
Jaume Bellet f1f212085a resets changes on README.md This info is availiable on project 2024-02-25 23:06:24 +01:00
Jaume Bellet c5443dad4e deleting stored patch 2024-02-25 22:59:48 +01:00
Jaume Bellet c529b6b7c4 Merge branch 'bf-blender' into mb-0008-mblender-core 2024-02-25 22:52:51 +01:00
Jaume Bellet 7eb9a490e5 Merge branch 'bf-blender' into mb-0015-image-ui
Conflicts:
	source/blender/editors/interface/interface_templates.cc
2024-02-23 23:33:02 +01:00
Jaume Bellet 750c5f2723 Cleanup on bf-blender was removing an include, that is needed here 2024-02-23 23:29:26 +01:00
Jaume Bellet ea58d624cd Merge branch 'bf-blender' into mb-0012-custom-splash 2024-02-23 23:29:15 +01:00
Jaume Bellet a5d0f13b1f Merge branch 'bf-blender' into mb-0013-blender-top-bar
Conflicts:
	source/blender/editors/interface/interface_templates.cc
	source/blender/makesrna/intern/rna_ui_api.cc
	source/blender/windowmanager/intern/wm_splash_screen.cc
	source/creator/creator_args.cc
2024-02-23 23:28:16 +01:00
Jaume Bellet 4d4d9280d4 Merge branch 'bf-blender' into mb-0010-url-presets
Conflicts:
	source/creator/creator_args.cc
2024-02-23 23:19:12 +01:00
Jaume Bellet c2bb4c5c18 Merge branch 'bf-blender' into mb-0008-mblender-core
Conflicts:
	source/creator/creator_args.cc
2024-02-18 12:53:18 +01:00
Jaume Bellet 5bf1925aec Merge branch 'bf-blender' into mb-0015-image-ui 2024-02-11 23:01:44 +01:00
Jaume Bellet c50ec6c401 Merge branch 'bf-blender' into mb-0009-addon-menu-references
Conflicts:
	source/blender/makesrna/intern/rna_ui_api.cc
2024-02-11 23:00:11 +01:00
Jaume Bellet dbaf864dde Merge branch 'bf-blender' into mb-0012-custom-splash
conflict with 2ccada61cb

 Conflicts:
	source/blender/windowmanager/intern/wm_splash_screen.cc
2024-02-11 21:32:37 +01:00
Jaume Bellet d9bb3a88c8 update parent references 2024-01-28 23:24:40 +01:00
Jaume Bellet 6e6cfbe2c9 added patches.py file 2024-01-28 23:10:52 +01:00
Jaume Bellet 74db93745b Merge branch 'bf-blender' into mb-0009-addon-menu-references 2024-01-28 23:08:35 +01:00
Jaume Bellet 8d5a39a26d IMB_imbuf.h is converted to IMB_imbuf.hh 2024-01-28 22:43:45 +01:00
Jaume Bellet 2d46aed94b 0618de49ad
Cleanup: Replace MIN/MAX macros with C++ functions

Use `std::min` and `std::max` instead. Though keep MIN2 and MAX2
just for C code that hasn't been moved to C++ yet.

Pull Request: #117384
2024-01-28 22:19:56 +01:00
Jaume Bellet afff173475 Merge branch 'bf-blender' into mb-0013-blender-top-bar
Conflicts:
	source/blender/editors/interface/interface_templates.cc
2024-01-28 22:19:24 +01:00
Jaume Bellet 63e9375ec8 0618de49ad
Cleanup: Replace MIN/MAX macros with C++ functions

Use `std::min` and `std::max` instead. Though keep MIN2 and MAX2
just for C code that hasn't been moved to C++ yet.

Pull Request: #117384
2024-01-28 19:27:15 +01:00
Jaume Bellet cde3c2f0c4 Merge branch 'bf-blender' into mb-0012-custom-splash 2024-01-28 19:23:28 +01:00
Jaume Bellet bc81accaf0 Merge branch 'bf-blender' into mb-0008-mblender-core
Conflicts:
	README.md
2024-01-20 00:44:09 +01:00
Jaume Bellet 5ff326c5f4 IMB_imbuf.h > IMB_imbuf.hh 2024-01-20 00:39:26 +01:00
Jaume Bellet 22a9bb1cd3 patches file 2024-01-20 00:05:36 +01:00
Jaume Bellet 8d31fe702c Merge branch 'bf-blender' into mb-0014-bpy-images
Conflicts:
	README.md
2024-01-20 00:02:50 +01:00
Jaume Bellet 563ad93b39 IMB_imbuf.h -> IMB_imbuf.hh, missing files on previous commit 2024-01-19 23:42:22 +01:00
Jaume Bellet 963db09985 Merge branch 'bf-blender' into mb-0015-image-ui
Conflicts:
	README.md
	source/blender/editors/interface/interface_templates.cc

Also

IMB_imbuf.h > IMB_imbuf.hh
2024-01-19 23:37:31 +01:00
Jaume Bellet 6d7fd0cb9b Merge branch 'bf-blender' into mb-0015-image-ui 2024-01-09 21:51:32 +01:00
Jaume Bellet 668b7f7d88 Merge branch 'bf-blender' into mb-0009-addon-menu-references 2023-12-10 13:53:32 +01:00
Jaume Bellet dbd0a965d1 moving id file 2023-12-04 23:41:11 +01:00
Jaume Bellet 5d18b0cf1a Merge branch 'bf-blender' into mb-0008-mblender-core 2023-12-03 22:23:02 +01:00
Jaume Bellet d00901e305 place file in correct place 2023-12-03 20:51:38 +01:00
Jaume Bellet cd95bdf19f replacing mechanical blender with tornavis 2023-12-03 20:09:54 +01:00
Jaume Bellet 28d81fcb0a move file in correct file 2023-12-03 19:51:20 +01:00
Jaume Bellet e5b1b06e87 mb-0012 was not applied 2023-12-03 19:48:53 +01:00
Jaume Bellet fac3c2b05f replace mblender logo with tornavis logo 2023-12-03 19:39:08 +01:00
Jaume Bellet ddcab1e21a reaply patches 2023-12-03 18:28:08 +01:00
Jaume Bellet db2382af5f Merge branch 'bf-blender' into mb-0013-blender-top-bar 2023-12-03 18:18:35 +01:00
Jaume Bellet 236564a441 Merge branch 'bf-blender' into mb-0012-custom-splash 2023-12-03 18:16:59 +01:00
Jaume Bellet c410d149da reaply patches 2023-12-03 18:13:01 +01:00
Jaume Bellet 8c28254ea4 rename mblender folder 2023-12-03 18:11:50 +01:00
Jaume Bellet 542ac1b43c Merge branch 'bf-blender' into mb-0015-image-ui 2023-12-03 18:11:11 +01:00
Jaume Bellet 0c4b16c3cd rename id folder 2023-12-03 18:10:33 +01:00
Jaume Bellet d31a0c060a Merge branch 'bf-blender' into mb-0014-bpy-images 2023-12-03 18:09:59 +01:00
Jaume Bellet e1dba50d08 moving ID file 2023-12-03 18:08:53 +01:00
Jaume Bellet aa234d9e15 mv from mblender to tornavis, folder 2023-12-03 18:08:33 +01:00
Jaume Bellet 0b15841ad6 moving mblender to tornavis folder 2023-12-03 18:07:29 +01:00
Jaume Bellet 18faafda39 rename id folder 2023-12-03 18:04:16 +01:00
Jaume Bellet 4217cb75a5 Merge branch 'bf-blender' into mb-0009-addon-menu-references 2023-12-03 18:03:32 +01:00
Jaume Bellet a3e63eb3fb rename id folder 2023-12-03 17:40:52 +01:00
Jaume Bellet f842025279 updated presets 2023-12-03 16:10:40 +01:00
Jaume Bellet c7d83eae9a reaply mb-0008 2023-12-03 16:06:40 +01:00
Jaume Bellet 4800eb3934 rename mblender to tornavis, python path 2023-12-03 15:32:52 +01:00
Jaume Bellet e5d5b31f3c rename from mblender to tornavis folder 2023-12-03 13:18:07 +01:00
Jaume Bellet d98ded7b7c removed mblender folder 2023-12-03 13:15:36 +01:00
Jaume Bellet 7d02cebca1 apply mb-0008-mblender-core 2023-12-03 12:40:35 +01:00
Jaume Bellet 9b548ae368 Merge branch 'bf-blender' into mb-0010-url-presets 2023-12-03 12:34:33 +01:00
Jaume Bellet d1b5309057 unaply mb-0008-mblender-core 2023-12-03 12:34:27 +01:00
Jaume Bellet 900417d60b missing folder to be renamed 2023-12-02 17:57:19 +01:00
Jaume Bellet c3d76d17a7 rebranding from mblender to tornavis 2023-12-02 17:56:11 +01:00
Jaume Bellet 2285de9e8d fixes building 2023-12-02 16:05:37 +01:00
Jaume Bellet 217992d312 modified README.md 2023-11-28 06:50:38 +01:00
Jaume Bellet c5cfd962f0 python interface to get mb patches 2023-11-27 19:36:45 +01:00
Jaume Bellet 52fad90ee9 fixed readme.md 2023-11-25 16:49:15 +01:00
Jaume Bellet 9ec91804a2 Merge branch 'bf-blender' into mb-0008-mblender-core 2023-11-25 13:55:05 +01:00
Jaume Bellet d54c76f122 readme 2023-11-22 23:35:38 +01:00
Jaume Bellet 22da6ed3ce added binary info 2023-11-21 20:23:33 +01:00
Jaume Bellet 02b1ce4aeb removed .gitattibutes 2023-11-21 19:41:23 +01:00
Jaume Bellet a8cf22cb96 ignore data files 2023-11-21 18:56:29 +01:00
Jaume Bellet 06908cda20 reaply patches 2023-11-21 18:40:43 +01:00
Jaume Bellet 3817881c4f added patches.py 2023-11-21 18:16:16 +01:00
Jaume Bellet c11e478be9 install blender datafiles 2023-11-21 18:14:01 +01:00
Jaume Bellet 41388f8dc8 added mblender-logo 2023-11-21 00:12:54 +01:00
Jaume Bellet e084874db7 added mb-0014 and mb-0015 2023-11-20 23:02:08 +01:00
Jaume Bellet 33914c92cc Merge branch 'bf-blender' into mb-0013-blender-top-bar 2023-11-20 22:58:10 +01:00
Jaume Bellet 4ae40c1e3a remove deps.. 2023-11-20 22:52:39 +01:00
Jaume Bellet 3b5da577f7 added patch dependencies 2023-11-20 22:50:13 +01:00
Jaume Bellet b7e97dc8bb Merge branch 'bf-blender' into mb-0012-custom-splash 2023-11-20 22:46:30 +01:00
Jaume Bellet fe4b73b603 files moved to utils 2023-11-20 19:14:10 +01:00
Jaume Bellet da2aaaa63d Merge branch 'bf-blender' into mb-0008-mblender-core 2023-11-19 22:53:23 +01:00
Jaume Bellet e7ce2a8b75 removing file 2023-11-19 20:05:27 +01:00
Jaume Bellet 20c8b6ac79 mb-0008 was not applied on previous commit 2023-11-19 20:02:26 +01:00
Jaume Bellet 0eaeaec449 fix mb-0008 name 2023-11-19 20:00:56 +01:00
Jaume Bellet 5738c4116c reapply 2023-11-19 19:53:16 +01:00
Jaume Bellet 76c900aecc Merge branch 'bf-blender' into mb-0013-blender-top-bar 2023-11-19 19:52:04 +01:00
Jaume Bellet 1f4b02a4d1 unapply 2023-11-19 19:51:57 +01:00
Jaume Bellet bc37e5c2b5 removed extensions 2023-11-19 19:45:04 +01:00
Jaume Bellet 62ef498db4 added ID file 2023-11-19 19:42:54 +01:00
Jaume Bellet 894945ac73 replaced apply.cmd with new version on py 2023-11-19 19:41:36 +01:00
Jaume Bellet 53f625bf2f added ID file 2023-11-19 19:35:52 +01:00
Jaume Bellet d130c0eeb5 update MB-0014 2023-11-19 19:34:55 +01:00
Jaume Bellet 7f73f363b3 Rename file to MB_0014.h, build failed. 2023-11-19 19:27:54 +01:00
Jaume Bellet 3f8b87b49b apply new version of mb-0014 2023-11-19 17:27:02 +01:00
Jaume Bellet 9f440d1904 fixes was not unapplying patches 2023-11-19 17:25:38 +01:00
Jaume Bellet 4fd2cc482f end of lines, and traling spaces 2023-11-19 17:20:42 +01:00
Jaume Bellet b1ed1c5048 apply mb-0014 2023-11-19 16:57:43 +01:00
Jaume Bellet 50bc821d26 added interface to get imbuf 2023-11-19 16:24:28 +01:00
Jaume Bellet 18793361af ok 2023-11-19 16:11:52 +01:00
Jaume Bellet 6c74c139dc replace endings 2023-11-19 16:06:04 +01:00
Jaume Bellet eb44324cad applied mb-0014 2023-11-19 11:08:58 +01:00
Jaume Bellet 1cdc8ad52d added python scripts to apply, unapply 2023-11-19 11:08:06 +01:00
Jaume Bellet aea389f4a2 added MB-ID file 2023-11-19 01:03:33 +01:00
Jaume Bellet fef6af1266 Custom info about branch on README.md 2023-11-19 00:57:53 +01:00
Jaume Bellet 5978db8006 allows loading and unload images from python 2023-11-18 17:06:22 +01:00
Jaume Bellet 57d65bfa06 Merge branch 'bf-blender' into mb-0008-mblender-core
Solves conflict in source/creator/creator.cc
2023-11-12 20:45:44 +01:00
Jaume Bellet fd6dac3248 updated script, due to changes on MB-0012 2023-11-09 07:15:43 +01:00
Jaume Bellet 8ab9eb2bf4 updated patches 2023-11-09 06:55:50 +01:00
Jaume Bellet 9414fe8f70 fixes memory issue 2023-11-08 07:51:58 +01:00
Jaume Bellet 01fedda773 removing spaces, and correct EOLs 2023-11-07 00:20:24 +01:00
Jaume Bellet 179dd5ca89 working 2023-11-07 00:18:10 +01:00
Jaume Bellet a2cc93e23f added MB-0010 2023-11-07 00:16:11 +01:00
Jaume Bellet a19b4eb1ca added mb-0012 2023-11-06 22:59:59 +01:00
Jaume Bellet 46252130aa apply mb-0008 and mb-0009 2023-11-06 19:05:29 +01:00
Jaume Bellet 2add8e01d5 added missing definitions 2023-11-06 18:40:12 +01:00
Jaume Bellet 5e515d954c Merge branch 'bf-blender' into mb-0008-mblender-core 2023-11-06 18:16:59 +01:00
Jaume Bellet ed86f7be23 added ID file 2023-11-06 06:21:19 +01:00
Jaume Bellet cca4693bdd works 2023-11-05 23:34:07 +01:00
Jaume Bellet 08b36c66b1 removed trailing spaces 2023-11-03 22:25:44 +01:00
Jaume Bellet 8a475e7ae6 defined checks until MB_0020 2023-11-03 22:24:33 +01:00
Jaume Bellet d568f25ef0 utilities 2023-11-03 07:31:01 +01:00
Jaume Bellet 6b5734c635 add ID file 2023-11-03 07:25:58 +01:00
Jaume Bellet c712982580 reaply mb-0008 2023-11-02 23:21:10 +01:00
Jaume Bellet ee8bff63f9 removing mb-0008 2023-11-02 23:19:12 +01:00
Jaume Bellet c2ddfdf09c added py file 2023-11-02 23:12:30 +01:00
Jaume Bellet 8aacc84821 presets file 2023-11-02 22:46:52 +01:00
Jaume Bellet d34bc451c7 applying MB-0008 2023-11-02 22:45:11 +01:00
Jaume Bellet 7eeb9693a9 missing code on previous commit 2023-11-02 22:34:20 +01:00
Jaume Bellet 7f71b9ac5b removing trailing spaces 2023-11-02 22:06:34 +01:00
Jaume Bellet 14a8265648 Merge branch 'bf-blender' into mb-0008-mblender-core 2023-11-02 21:54:56 +01:00
Jaume Bellet b5acb41f73 allow to execute py scripts located on scripts/mblender folder 2023-11-02 21:54:32 +01:00
Jaume Bellet 0fdf1c88e9 added file ID 2023-10-31 06:59:45 +01:00
Jaume Bellet 997eeac87c minor fixes 2023-10-31 06:56:53 +01:00
Jaume Bellet 3ea0ab9d87 get D10753-addon-menu-references.diff be applied and build 2023-10-30 08:57:26 +01:00
Jaume Bellet 6d6bd017f3 remove bad folder 2023-10-27 07:55:11 +02:00
Jaume Bellet d7cbb13067 remove bad located file 2023-10-26 22:38:40 +02:00
Jaume Bellet 680120c380 Merge branch 'bf-blender' into mb-0008-mblender-core 2023-10-26 19:24:48 +02:00
Jaume Bellet 131c94004d added MB_ID file, was removed during a merge? 2023-10-26 08:09:06 +02:00
Jaume Bellet f5c10fca1a Merge branch 'main' into mb-0008-mblender-core 2023-10-26 08:07:32 +02:00
Jaume Bellet dc0b6d0162 Merge branch 'main' into mb-0008-mblender-core 2023-10-26 07:51:53 +02:00
Jaume Bellet a11f0637b6 added a file pattern check 2023-10-26 07:44:34 +02:00
Jaume Bellet 82fdcfa589 added MB-ID file 2023-10-25 19:49:05 +02:00
Jaume Bellet 788d99b940 Creating diff file 2023-10-25 07:12:56 +02:00
Jaume Bellet 260514cd54 implements mblender-info command line option.
implmements patch discovery
2023-10-24 18:46:48 +02:00
38 changed files with 1053 additions and 7 deletions

View File

@ -0,0 +1 @@
Binary data like icons or images related to mechanical blender

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -70,7 +70,7 @@ _preferences = _bpy.context.preferences
_is_factory_startup = _bpy.app.factory_startup
# Directories added to the start of `sys.path` for all of Blender's "scripts" directories.
_script_module_dirs = "startup", "modules"
_script_module_dirs = "startup", "modules","tornavis"
# Base scripts, this points to the directory containing: "modules" & "startup" (see `_script_module_dirs`).
# In Blender's code-base this is `./scripts`.
@ -312,6 +312,10 @@ def load_scripts(*, reload_scripts=False, refresh_scripts=False, extensions=True
for mod in modules_from_path(path, loaded_modules):
test_register(mod)
if path_subdir == "tornavis":
for mod in modules_from_path(path, loaded_modules):
test_register(mod)
if reload_scripts:
# Update key-maps for key-map items referencing operators defined in "startup".
# Without this, key-map items wont be set properly, see: #113309.

View File

@ -0,0 +1,49 @@
# SPDX-FileCopyrightText: 2015-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
"""
This module contains utility functions to handle custom images.
"""
__all__ = (
"load",
"release"
"list",
)
from _bpy import _utils_images
list = []
def load(name, path):
r = _utils_images.load(name, path)
if r != None:
data = {'id' : r , 'name' : name, 'path' : path}
list.append(data)
return data;
else:
return None;
load.__doc__ = _utils_images.load.__doc__;
def release(image_id):
r = _utils_images.release(image_id)
if r == True:
for data in list:
if data.get('id') == image_id:
list.remove(data)
return r;
release.__doc__ = _utils_images.release.__doc__
import atexit
def exit_clear():
while len(list):
release(list[0].get('id'))
atexit.register(exit_clear)
del atexit, exit_clear

View File

@ -987,6 +987,11 @@ class AddonPreferences(StructRNA, metaclass=RNAMeta):
__slots__ = ()
class ReferencedDrawFunc:
def __init__(self, func):
self.func = func
self.used = False
class _GenericUI:
__slots__ = ()
@ -1007,6 +1012,13 @@ class _GenericUI:
else:
owner_names = None
if (hasattr(cls, "reference_debug") and cls.reference_debug):
print ("---")
# Reset drawn flag, to be able shown error if not used
for label in cls.referenced_post:
for ref in cls.referenced_post[label]:
ref.used = False
for func in draw_ls._draw_funcs:
# Begin 'owner_id' filter.
@ -1030,11 +1042,38 @@ class _GenericUI:
self.layout.operator_context = operator_context_default
for label in cls.referenced_post:
for ref in cls.referenced_post[label]:
if ref.used == False:
print("ERR: ", label, " referenced not drawn in", self.__class__.__name__)
draw_funcs = draw_ls._draw_funcs = [cls.draw]
cls.draw = draw_ls
cls.referenced_pre = {}
cls.referenced_post = {}
return draw_funcs
def draw_referenced_pre(cls, label):
if (hasattr(cls, "reference_debug") and cls.reference_debug):
print (label)
cls._dyn_ui_initialize()
if label in cls.referenced_pre:
for ref in cls.referenced_pre[label]:
#need to get the context
ref.used = True
ref.func(cls, None)
def draw_referenced_post(cls, label):
cls._dyn_ui_initialize()
if label in cls.referenced_post:
for ref in cls.referenced_post[label]:
#need to get the context
ref.used = True
ref.func(cls, None)
@staticmethod
def _dyn_owner_apply(draw_func):
from _bpy import _bl_owner_id_get
@ -1052,24 +1091,36 @@ class _GenericUI:
return len(draw_funcs) > 1
@classmethod
def append(cls, draw_func):
def append(cls, draw_func, label_referenced = None):
"""
Append a draw function to this menu,
takes the same arguments as the menus draw function
"""
draw_funcs = cls._dyn_ui_initialize()
cls._dyn_owner_apply(draw_func)
draw_funcs.append(draw_func)
if label_referenced != None:
if not (label_referenced in cls.referenced_post):
cls.referenced_post[label_referenced] = []
cls.referenced_post[label_referenced].append(ReferencedDrawFunc(draw_func))
else:
draw_funcs.append(draw_func)
@classmethod
def prepend(cls, draw_func):
def prepend(cls, draw_func, label_referenced = None):
"""
Prepend a draw function to this menu, takes the same arguments as
the menus draw function
"""
draw_funcs = cls._dyn_ui_initialize()
cls._dyn_owner_apply(draw_func)
draw_funcs.insert(0, draw_func)
if label_referenced != None:
if not (label_referenced in cls.referenced_pre):
cls.referenced_pre[label_referenced] = []
cls.referenced_pre[label_referenced].append(ReferencedDrawFunc(draw_func))
else:
draw_funcs.insert(0, draw_func)
@classmethod
def remove(cls, draw_func):

View File

@ -0,0 +1,47 @@
import bpy
import bpy.utils.images
import os
img = None
class WM_MT_splash_about_mblender(bpy.types.Menu):
bl_label = "About Tornavis"
def draw(self, context):
layout = self.layout
layout.operator_context = 'EXEC_DEFAULT'
split = layout.split(factor=0.6)
split.template_image_ui(image_value = img['id'], scale= 1)
layout.row().label(text="Tornavis - A project for giving CAD development to Blender")
row = layout.row()
row.emboss = 'PULLDOWN_MENU'
col = row.column()
col.operator("wm.url_open", text="Patreon", icon='FUND').url = "https://www.patreon.com/tornavis"
col.operator("wm.url_open", text="Credits", icon='URL').url = "https://tornavis.org/#credits"
col.operator("wm.url_open", text="License", icon='URL').url = "https://tornavis.org/#license"
col.operator("wm.url_open_preset", text="Tornavis Website", icon='URL').type = 'TORNAVIS'
def draw_mblender_about_menu(self, context):
self.layout.operator("wm.splash_custom", text=WM_MT_splash_about_mblender.bl_label).menutype='WM_MT_splash_about_mblender'
def draw_blender_doc_menu(self, context):
self.layout.operator("wm.url_open_preset", text="Tornavis Project's documentation", icon='URL').type = 'TORNAVIS_DOC'
def register():
global img
bpy.types.TOPBAR_MT_blender.append(draw_mblender_about_menu, label_referenced = "About Blender")
bpy.types.TOPBAR_MT_help.append(draw_blender_doc_menu, label_referenced = "Manual")
bpy.utils.register_class(WM_MT_splash_about_mblender)
path = os.path.join(bpy.utils.system_resource('DATAFILES', path="tornavis"), 'tornavis_logo.png')
img = bpy.utils.images.load('tornavis-logo', path)
def unregister():
global img
bpy.utils.unregister_class(AboutMBlenderOperator)
bpy.utils.unregister_class(WM_MT_splash_about_mblender)
bpy.utils.images.release(img['id'])

View File

@ -0,0 +1,17 @@
import bpy
def register ():
# bpy.ops.wm.url_open_preset(type="TORNAVIS")
bpy.types.WM_OT_url_open_preset.preset_items.append(
(('TORNAVIS', "Tornavis.org", "Tornavis project official web-site"),
"https://www.tornavis.org")
)
bpy.types.WM_OT_url_open_preset.preset_items.append(
(('TORNAVIS_DOC', "Tornavis Doc", "Tornavis project documentation"),
"https://www.tornavis.org/#documentation")
)
def unregister():
pass

View File

@ -160,6 +160,7 @@ add_subdirectory(functions)
add_subdirectory(makesdna)
add_subdirectory(makesrna)
add_subdirectory(compositor)
add_subdirectory(tornavis)
if(WITH_BLENDER_THUMBNAILER)
add_subdirectory(blendthumb)

View File

@ -2189,6 +2189,9 @@ void UI_menutype_draw(bContext *C, MenuType *mt, uiLayout *layout);
*/
void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout);
void *uiLayoutGetParentObject(uiLayout *layout);
struct ExtensionRNA *uiLayoutGetParentRnaExt(uiLayout *layout);
/* Only for convenience. */
void uiLayoutSetContextFromBut(uiLayout *layout, uiBut *but);
@ -2455,6 +2458,9 @@ void uiTemplatePreview(uiLayout *layout,
MTex *slot,
const char *preview_id);
void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname, bool expand);
void uiTemplateImageUI(uiLayout *layout, int image_id, float image_scale);
/**
* \param icon_scale: Scale of the icon, 1x == button height.
*/

View File

@ -167,6 +167,10 @@ struct uiLayout {
eUIEmbossType emboss;
/** for fixed width or height to avoid UI size changes */
float units[2];
ExtensionRNA *parent_rna_ext;
void *parent_object;
};
struct uiLayoutItemFlow {
@ -5990,6 +5994,20 @@ bContextStore *uiLayoutGetContextStore(uiLayout *layout)
return layout->context;
}
void *uiLayoutGetParentObject(uiLayout * layout)
{
return layout->parent_object;
}
ExtensionRNA *uiLayoutGetParentRnaExt(uiLayout *layout)
{
// rna ext is set on menu draw, layout maybe a sublayout
while (layout && layout->parent_rna_ext == NULL) {
layout = layout->parent;
}
return layout ? layout->parent_rna_ext : NULL;
}
void uiLayoutContextCopy(uiLayout *layout, const bContextStore *context)
{
uiBlock *block = layout->root->block;
@ -6084,6 +6102,9 @@ void UI_menutype_draw(bContext *C, MenuType *mt, uiLayout *layout)
menu.layout = layout;
menu.type = mt;
layout->parent_rna_ext = &mt->rna_ext;
layout->parent_object = (void*) &menu;
if (G.debug & G_DEBUG_WM) {
printf("%s: opening menu \"%s\"\n", __func__, mt->idname);
}
@ -6106,6 +6127,10 @@ void UI_menutype_draw(bContext *C, MenuType *mt, uiLayout *layout)
if (layout->context) {
CTX_store_set(C, nullptr);
}
layout->parent_rna_ext = NULL;
layout->parent_object = NULL;
}
static bool ui_layout_has_panel_label(const uiLayout *layout, const PanelType *pt)

View File

@ -78,6 +78,9 @@
#include "ED_render.hh"
#include "ED_screen.hh"
#include "ED_undo.hh"
#include "ED_datafiles.h"
#include "IMB_imbuf.hh"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
@ -97,6 +100,8 @@
#include "UI_string_search.hh"
#include "interface_intern.hh"
#include "BPY_extern.h"
using blender::StringRef;
using blender::Vector;
@ -3349,6 +3354,28 @@ void uiTemplatePreview(uiLayout *layout,
/** \} */
void uiTemplateImageUI(uiLayout* layout, int image_id,float image_scale) {
ImBuf *ibuf = IMB_dupImBuf((ImBuf *) BPY_utils_images_get(image_id));
if (ibuf) {
int width = ibuf->x * image_scale;
int height = (width * ibuf->y) / ibuf->x;
IMB_premultiply_alpha(ibuf);
IMB_scaleImBuf(ibuf, width, height);
bTheme *btheme = UI_GetTheme();
uchar *color = btheme->tui.wcol_menu_back.text_sel;
//color = btheme->tui.wcol_box.inner;
uiBlock *block = uiLayoutAbsoluteBlock(layout);
uiBut *but = uiDefButImage(block, ibuf, 0, U.widget_unit, width, height, color);
}
}
/* -------------------------------------------------------------------- */
/** \name ColorRamp Template
* \{ */

View File

@ -990,7 +990,7 @@ static StructRNA *rna_Menu_register(Main *bmain,
const char *error_prefix = "Registering menu class:";
MenuType *mt, dummy_mt = {nullptr};
Menu dummy_menu = {nullptr};
bool have_function[2];
bool have_function[4];
size_t over_alloc = 0; /* Warning, if this becomes a mess, we better do another allocation. */
size_t description_size = 0;
char _menu_descr[RNA_DYN_DESCR_MAX];
@ -2200,6 +2200,19 @@ static void rna_def_menu(BlenderRNA *brna)
parm = RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
/* draw referenced */
func = RNA_def_function(srna, "draw_referenced_pre", nullptr);
RNA_def_function_ui_description(func, "Draw UI elements into the menu UI layout before reference");
RNA_def_function_flag(func, FUNC_REGISTER);
parm = RNA_def_string(func, "label", nullptr, 0, "", "draw reference menu label");
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
func = RNA_def_function(srna, "draw_referenced_post", nullptr);
RNA_def_function_ui_description(func, "Draw UI elements into the menu UI layout after reference");
RNA_def_function_flag(func, FUNC_REGISTER);
parm = RNA_def_string(func, "label", nullptr, 0, "", "draw reference menu label");
RNA_def_parameter_flags(parm,PropertyFlag(0), PARM_REQUIRED);
RNA_define_verify_sdna(false); /* not in sdna */
prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);

View File

@ -11,6 +11,7 @@
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLT_translation.hh"
#include "RNA_define.hh"
@ -327,6 +328,63 @@ static void rna_uiItemPointerR(uiLayout *layout,
layout, ptr, prop, searchptr, searchprop, name, icon, results_are_suggestions);
}
static void rna_call_draw_referenced(uiLayout *layout, const char *name, FunctionRNA *func)
{
if (*name == '\0') {
return;
}
char *label = (char*) MEM_callocN(255, __func__); // Error defined as not dinamic []
BLI_strncpy(label, name, 255);
// Remove ... added in some menus, like Open...
size_t label_len = BLI_strnlen(name, 255);
if (label_len > 4) {
char *end = label + label_len;
if (*(end - 1) == '.' && *(end - 2) == '.' && *(end - 3) == '.') {
*(end - 3) = '\0';
}
}
ExtensionRNA *ext_rna = uiLayoutGetParentRnaExt(layout);
if (ext_rna) {
PointerRNA ptr = RNA_pointer_create(NULL, ext_rna->srna, uiLayoutGetParentObject(layout));
ParameterList list;
RNA_parameter_list_create(&list, &ptr, func);
// Do not know how the get the context, is lost on python RNA call.
// RNA_parameter_set_lookup(&list, "context", &C);
// rna_ext->call((bContext *)C, &ptr, func, &list);
RNA_parameter_set_lookup(&list, "label", &label);
ext_rna->call(NULL, &ptr, func, &list);
RNA_parameter_list_free(&list);
}
MEM_freeN(label);
}
static void rna_call_draw_referenced_pre(uiLayout *layout, const char *name)
{
extern FunctionRNA rna_Menu_draw_referenced_pre_func;
FunctionRNA *func;
func = &rna_Menu_draw_referenced_pre_func; /* RNA_struct_find_function(&ptr,
"draw_referenced_pre") */
rna_call_draw_referenced(layout, name, func);
}
static void rna_call_draw_referenced_post(uiLayout *layout, const char *name)
{
extern FunctionRNA rna_Menu_draw_referenced_post_func;
FunctionRNA *func;
func = &rna_Menu_draw_referenced_post_func; /* RNA_struct_find_function(&ptr, "draw_referenced_post") */
rna_call_draw_referenced(layout, name, func);
}
static PointerRNA rna_uiItemO(uiLayout *layout,
const char *opname,
const char *name,
@ -338,6 +396,11 @@ static PointerRNA rna_uiItemO(uiLayout *layout,
int icon_value)
{
wmOperatorType *ot;
char original_name[255] = {0};
if (name) {
BLI_strncpy(original_name, name, 255);
}
ot = WM_operatortype_find(opname, false); /* print error next */
if (!ot || !ot->srna) {
@ -345,6 +408,13 @@ static PointerRNA rna_uiItemO(uiLayout *layout,
return PointerRNA_NULL;
}
if (name && *name != '\0') {
BLI_strncpy(original_name, name, 255);
}
else {
BLI_strncpy(original_name, ot->name, 255);
}
/* Get translated name (label). */
name = rna_translate_ui_text(name, text_ctxt, ot->srna, nullptr, translate);
@ -359,10 +429,15 @@ static PointerRNA rna_uiItemO(uiLayout *layout,
flag |= UI_ITEM_O_DEPRESS;
}
rna_call_draw_referenced_pre(layout, original_name);
PointerRNA opptr;
uiItemFullO_ptr(
layout, ot, name, icon, nullptr, uiLayoutGetOperatorContext(layout), flag, &opptr);
return opptr;
rna_call_draw_referenced_post(layout, original_name);
return opptr;
}
static PointerRNA rna_uiItemOMenuHold(uiLayout *layout,
@ -406,8 +481,17 @@ static void rna_uiItemsEnumO(uiLayout *layout,
const char *propname,
const bool icon_only)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
/** Calling only once per operator **/
rna_call_draw_referenced_pre(layout, ot->name);
eUI_Item_Flag flag = icon_only ? UI_ITEM_R_ICON_ONLY : UI_ITEM_NONE;
uiItemsFullEnumO(layout, opname, propname, nullptr, uiLayoutGetOperatorContext(layout), flag);
rna_call_draw_referenced_post(layout, ot->name);
}
static PointerRNA rna_uiItemMenuEnumO(uiLayout *layout,
@ -421,6 +505,12 @@ static PointerRNA rna_uiItemMenuEnumO(uiLayout *layout,
{
wmOperatorType *ot = WM_operatortype_find(opname, false); /* print error next */
char original_name[255] = {0};
if (name) {
BLI_strncpy(original_name, name, 255);
}
if (!ot || !ot->srna) {
RNA_warning("%s '%s'", ot ? "operator missing srna" : "unknown operator", opname);
return PointerRNA_NULL;
@ -429,8 +519,13 @@ static PointerRNA rna_uiItemMenuEnumO(uiLayout *layout,
/* Get translated name (label). */
name = rna_translate_ui_text(name, text_ctxt, ot->srna, nullptr, translate);
rna_call_draw_referenced_pre(layout, original_name);
PointerRNA opptr;
uiItemMenuEnumFullO_ptr(layout, C, ot, propname, name, icon, &opptr);
rna_call_draw_referenced_post(layout, original_name);
return opptr;
}
@ -466,12 +561,33 @@ static void rna_uiItemM(uiLayout *layout,
icon = icon_value;
}
MenuType *mt = WM_menutype_find(menuname, false);
if (mt == NULL) {
RNA_warning("not found %s", menuname);
return;
}
rna_call_draw_referenced_pre(layout, mt->label);
uiItemM(layout, menuname, name, icon);
rna_call_draw_referenced_post(layout, mt->label);
}
static void rna_uiItemM_contents(uiLayout *layout, const char *menuname)
{
MenuType *mt = WM_menutype_find(menuname, false);
if (mt == NULL) {
RNA_warning("not found %s", menuname);
return;
}
rna_call_draw_referenced_pre(layout, mt->label);
uiItemMContents(layout, menuname);
rna_call_draw_referenced_post(layout, mt->label);
}
static void rna_uiItemPopoverPanel(uiLayout *layout,
@ -1795,6 +1911,21 @@ void RNA_api_ui_layout(StructRNA *srna)
1.0f,
100.0f);
func = RNA_def_function(srna, "template_image_ui", "uiTemplateImageUI");
RNA_def_function_ui_description(func, "A image on UI");
parm = RNA_def_int(func, "image_value", 0, 0, INT_MAX, "image to display", "", 0, INT_MAX);
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
RNA_def_float(func,
"scale",
1.0f,
1.0f,
100.0f,
"Scale",
"Scale the icon size (by the button size)",
1.0f,
100.0f);
func = RNA_def_function(srna, "template_icon_view", "uiTemplateIconView");
RNA_def_function_ui_description(func, "Enum. Large widget showing Icon previews");
api_ui_item_rna_common(func);

View File

@ -133,6 +133,8 @@ bool BPY_string_is_keyword(const char *str);
void BPY_callback_screen_free(struct ARegionType *art);
void BPY_callback_wm_free(struct wmWindowManager *wm);
void* BPY_utils_images_get(int image_id);
/* I18n for addons */
#ifdef WITH_INTERNATIONAL
const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid);

View File

@ -15,6 +15,7 @@ set(INC
../../windowmanager
../../../../intern/mantaflow/extern
../../../../intern/opencolorio
../../tornavis
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
@ -39,6 +40,7 @@ set(SRC
bpy_app_timers.cc
bpy_app_translations.cc
bpy_app_usd.cc
bpy_app_tornavis.cc
bpy_capi_utils.cc
bpy_cli_command.cc
bpy_driver.cc
@ -69,6 +71,7 @@ set(SRC
bpy_rna_ui.cc
bpy_traceback.cc
bpy_utils_previews.cc
bpy_utils_images.cc
bpy_utils_units.cc
stubs.cc
@ -87,6 +90,7 @@ set(SRC
bpy_app_timers.h
bpy_app_translations.h
bpy_app_usd.h
bpy_app_tornavis.h
bpy_capi_utils.h
bpy_cli_command.h
bpy_driver.h
@ -112,6 +116,7 @@ set(SRC
bpy_rna_ui.h
bpy_traceback.h
bpy_utils_previews.h
bpy_utils_images.h
bpy_utils_units.h
../BPY_extern.h
../BPY_extern_clog.h
@ -130,6 +135,7 @@ set(LIB
PRIVATE bf::intern::guardedalloc
PRIVATE bf::animrig
bf_python_gpu
tornavis
${PYTHON_LINKFLAGS}
${PYTHON_LIBRARIES}

View File

@ -44,6 +44,7 @@
#include "bpy_rna_gizmo.h"
#include "bpy_rna_types_capi.h"
#include "bpy_utils_previews.h"
#include "bpy_utils_images.h"
#include "bpy_utils_units.h"
#include "../generic/py_capi_utils.h"
@ -705,6 +706,7 @@ void BPy_init_modules(bContext *C)
PyModule_AddObject(mod, "app", BPY_app_struct());
PyModule_AddObject(mod, "_utils_units", BPY_utils_units());
PyModule_AddObject(mod, "_utils_previews", BPY_utils_previews_module());
PyModule_AddObject(mod, "_utils_images", BPY_utils_images_module());
PyModule_AddObject(mod, "msgbus", BPY_msgbus_module());
PointerRNA ctx_ptr = RNA_pointer_create(nullptr, &RNA_Context, C);

View File

@ -23,6 +23,7 @@
#include "bpy_app_openvdb.h"
#include "bpy_app_sdl.h"
#include "bpy_app_usd.h"
#include "bpy_app_tornavis.h"
#include "bpy_app_translations.h"
@ -116,6 +117,7 @@ static PyStructSequence_Field app_info_fields[] = {
{"build_options", "A set containing most important enabled optional build features"},
{"handlers", "Application handler callbacks"},
{"translations", "Application and addons internationalization API"},
{"tornavis", "Tornavis options"},
/* Modules (not struct sequence). */
{"icons", "Manage custom icons"},
@ -202,6 +204,7 @@ static PyObject *make_app_info()
SetObjItem(BPY_app_build_options_struct());
SetObjItem(BPY_app_handlers_struct());
SetObjItem(BPY_app_translations_struct());
SetObjItem(BPY_app_tornavis_struct());
/* modules */
SetObjItem(BPY_app_icons_module());

View File

@ -0,0 +1,71 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup pythonintern
*/
#include <Python.h>
#include "BLI_utildefines.h"
#include "bpy_app_tornavis.h"
#include "MB_tornavis.h"
static PyTypeObject BlenderAppTornavisType;
static PyStructSequence_Field app_tornavis_info_fields[] = {
{"patches", nullptr},
{nullptr},
};
static PyStructSequence_Desc app_tornavis_info_desc = {
"bpy.app.tornavis", /* name */
"This module contains options about tornavis project", /* doc */
app_tornavis_info_fields, /* fields */
ARRAY_SIZE(app_tornavis_info_fields) - 1,
};
static PyObject *make_tornavis_info()
{
PyObject *tornavis_info;
PyObject *list;
int pos=0;
char *patch = nullptr;
tornavis_info = PyStructSequence_New(&BlenderAppTornavisType);
if (tornavis_info == nullptr) {
return nullptr;
}
list = PyList_New(0);
PyStructSequence_SET_ITEM(tornavis_info, pos++, list);
for (int i =0 ; (patch = MB_patch_get(i)); i++) {
PyList_Append(list, PyUnicode_FromString(patch));
}
return tornavis_info;
}
PyObject *BPY_app_tornavis_struct()
{
PyObject *ret;
PyStructSequence_InitType(&BlenderAppTornavisType, &app_tornavis_info_desc);
ret = make_tornavis_info();
/* prevent user from creating new instances */
BlenderAppTornavisType.tp_init = nullptr;
BlenderAppTornavisType.tp_new = nullptr;
/* Without this we can't do `set(sys.modules)` #29635. */
BlenderAppTornavisType.tp_hash = (hashfunc)_Py_HashPointer;
return ret;
}

View File

@ -0,0 +1,19 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup pythonintern
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
PyObject *BPY_app_tornavis_struct(void);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,173 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup pythonintern
*
* This file defines a singleton py object accessed via 'bpy.utils.images',
*/
#include <Python.h>
#include <structmember.h>
#include <string.h>
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "RNA_access.hh"
#include "RNA_prototypes.h"
#include "RNA_types.hh"
#include "BPY_extern.h"
#include "bpy_rna.h"
#include "bpy_utils_images.h"
#include "../generic/py_capi_utils.h"
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.hh"
#include "../generic/python_utildefines.h"
struct bpy_image_data{
bpy_image_data *prev;
bpy_image_data *next;
int id;
ImBuf *ibuf;
std::string name;
std::string path;
};
int bpy_images_last_id = 0;
ListBase bpy_images_list;
bpy_image_data* BPY_utils_images_get_data(int image_id) {
return (bpy_image_data *)BLI_listbase_bytes_find(
&bpy_images_list, &image_id, sizeof(int), sizeof(bpy_image_data *) * 2);
}
void* BPY_utils_images_get(int image_id)
{
bpy_image_data *el = BPY_utils_images_get_data(image_id);
return (el != nullptr) ? el->ibuf : nullptr;
}
PyDoc_STRVAR(bpy_utils_images_load_doc,
".. method:: load(name, filepath)\n"
"\n"
" Generate a new preview from given file path.\n"
"\n"
" :arg name: The name identifying the image.\n"
" :type name: string\n"
" :arg filepath: The file path to the image.\n"
" :type filepath: string or bytes\n"
" :return: image id.\n"
" :rtype: long`\n");
static PyObject *bpy_utils_images_load(PyObject * /*self*/, PyObject *args)
{
char *name = NULL;
PyC_UnicodeAsBytesAndSize_Data filepath_data = {nullptr};
if (!PyArg_ParseTuple(args,
"s" /* `name` */
"O&" /* `filepath` */
":load",
&name,
PyC_ParseUnicodeAsBytesAndSize,
&filepath_data,
0))
{
return nullptr;
}
if (!filepath_data.value || !name) {
Py_RETURN_NONE;
}
ImBuf *ibuf = IMB_loadiffname(filepath_data.value, 0, nullptr);
if (ibuf) {
bpy_image_data *data = MEM_new<bpy_image_data>(__func__);
data->id = ++bpy_images_last_id;
data->ibuf = ibuf;
data->name = name;
data->path = filepath_data.value;
BLI_addtail(&bpy_images_list, data);
return PyLong_FromLong(data->id);
}
else {
Py_RETURN_NONE;
}
}
PyDoc_STRVAR(bpy_utils_images_release_doc,
".. method:: release(image_id)\n"
"\n"
" Release (free) a previously added image.\n"
"\n"
"\n"
" :arg image_id: The id identifying the image.\n"
" :type name: long\n"
" :return: true if release.\n"
" :rtype: bool`\n");
static PyObject *bpy_utils_images_release(PyObject * /*self*/, PyObject *args)
{
int image_id = -1;
if (!PyArg_ParseTuple(args, "i:release", &image_id)) {
return nullptr;
}
bpy_image_data *el = BPY_utils_images_get_data(image_id);
if (el != nullptr) {
BLI_remlink(&bpy_images_list, el);
IMB_freeImBuf(el->ibuf);
MEM_freeN(el);
Py_RETURN_TRUE;
}
else {
Py_RETURN_FALSE;
}
}
static PyMethodDef bpy_utils_images_methods[] = {
/* Can't use METH_KEYWORDS alone, see http://bugs.python.org/issue11587 */
{"load", (PyCFunction)bpy_utils_images_load, METH_VARARGS, bpy_utils_images_load_doc},
{"release",(PyCFunction)bpy_utils_images_release,METH_VARARGS, bpy_utils_images_release_doc},
{nullptr, nullptr, 0, nullptr},
};
PyDoc_STRVAR(
bpy_utils_images_doc,
"This object contains basic static methods to handle cached (non-ID) previews in Blender\n"
"(low-level API, not exposed to final users).");
static PyModuleDef bpy_utils_images_module = {
/*m_base*/ PyModuleDef_HEAD_INIT,
/*m_name*/ "bpy._utils_images",
/*m_doc*/ bpy_utils_images_doc,
/*m_size*/ 0,
/*m_methods*/ bpy_utils_images_methods,
/*m_slots*/ nullptr,
/*m_traverse*/ nullptr,
/*m_clear*/ nullptr,
/*m_free*/ nullptr,
};
PyObject *BPY_utils_images_module()
{
PyObject *submodule;
submodule = PyModule_Create(&bpy_utils_images_module);
return submodule;
}

View File

@ -0,0 +1,19 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup pythonintern
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
PyObject *BPY_utils_images_module(void);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,45 @@
#
#
#
set(INC
.
../blenlib
)
set(LIB
PRIVATE bf::blenlib
)
if(WITH_BOOST)
list(APPEND INC_SYS
${BOOST_INCLUDE_DIR}
)
else()
message (FATAL_ERROR "tornavis requires WITH_BOOST")
endif()
# Auto fill source files, so patches will not touch that file
file(GLOB sources "MB_*")
foreach(source ${sources})
get_filename_component(name ${source} NAME)
list(APPEND SRC "${name}")
endforeach()
# Generate a Definition for each found patch
file(GLOB patches "patches/*")
foreach(patch ${patches})
get_filename_component(def ${patch} NAME_WE)
get_filename_component(name ${patch} NAME)
if (${name} MATCHES "^MB_[0-9][0-9][0-9][0-9]\.h$" )
add_definitions(-D${def})
list(APPEND SRC "patches/${name}")
else()
message (FATAL_ERROR "invalid patch file ${name}")
endif ()
endforeach()
blender_add_lib(tornavis "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -0,0 +1,149 @@
#ifndef MB_BLENDER_PATCHES_H
#define MB_BLENDER_PATCHES_H
#ifdef MB_0001
#include "patches/MB_0001.h"
#define MB_0001_APPLIED 1
#else
#define MB_0001_APPLIED 0
#endif
#ifdef MB_0002
#include "patches/MB_0002.h"
#define MB_0002_APPLIED 1
#else
#define MB_0002_APPLIED 0
#endif
#ifdef MB_0003
#include "patches/MB_0003.h"
#define MB_0003_APPLIED 1
#else
# define MB_0003_APPLIED 0
#endif
#ifdef MB_0004
#include "patches/MB_0004.h"
#define MB_0004_APPLIED 1
#else
# define MB_0004_APPLIED 0
#endif
#ifdef MB_0005
#include "patches/MB_0005.h"
#define MB_0005_APPLIED 1
#else
# define MB_0005_APPLIED 0
#endif
#ifdef MB_0006
#include "patches/MB_0006.h"
#define MB_0006_APPLIED 1
#else
#define MB_0006_APPLIED 0
#endif
#ifdef MB_0007
#include "patches/MB_0007.h"
#define MB_0007_APPLIED 1
#else
#define MB_0007_APPLIED 0
#endif
#ifdef MB_0008
#include "patches/MB_0008.h"
#define MB_0008_APPLIED 1
#else
#define MB_0008_APPLIED 0
#endif
#ifdef MB_0009
#include "patches/MB_0009.h"
#define MB_0009_APPLIED 1
#else
#define MB_0009_APPLIED 0
#endif
#ifdef MB_0010
#include "patches/MB_0010.h"
#define MB_0010_APPLIED 1
#else
#define MB_0010_APPLIED 0
#endif
#ifdef MB_0011
#include "patches/MB_0011.h"
#define MB_0011_APPLIED 1
#else
#define MB_0011_APPLIED 0
#endif
#ifdef MB_0012
#include "patches/MB_0012.h"
#define MB_0012_APPLIED 1
#else
#define MB_0012_APPLIED 0
#endif
#ifdef MB_0013
#include "patches/MB_0013.h"
#define MB_0013_APPLIED 1
#else
#define MB_0013_APPLIED 0
#endif
#ifdef MB_0014
#include "patches/MB_0014.h"
#define MB_0014_APPLIED 1
#else
#define MB_0014_APPLIED 0
#endif
#ifdef MB_0015
#include "patches/MB_0015.h"
#define MB_0015_APPLIED 1
#else
#define MB_0015_APPLIED 0
#endif
#ifdef MB_0016
#include "patches/MB_0016.h"
#define MB_0016_APPLIED 1
#else
#define MB_0016_APPLIED 0
#endif
#ifdef MB_0017
#include "patches/MB_0017.h"
#define MB_0017_APPLIED 1
#else
#define MB_0017_APPLIED 0
#endif
#ifdef MB_0018
#include "patches/MB_0018.h"
#define MB_0018_APPLIED 1
#else
#define MB_0018_APPLIED 0
#endif
#ifdef MB_0019
#include "patches/MB_0019.h"
#define MB_0019_APPLIED 1
#else
#define MB_0019_APPLIED 0
#endif
#ifdef MB_0020
#include "patches/MB_0020.h"
#define MB_0020_APPLIED 1
#else
#define MB_0020_APPLIED 0
#endif
#ifndef MB_0021
#define MAX_MB_PATCHES 21
#endif
#endif // !MB_BLENDER_PATCHES_H

View File

@ -0,0 +1,68 @@
/**
*
*/
#include "MB_patches.h"
#include <boost/preprocessor/if.hpp>
#include <BLI_assert.h>
#include <stdio.h>
#include <string.h>
char patches[MAX_MB_PATCHES][8] = {0};
void MB_patches_discover()
{
int i = 0;
BOOST_PP_IF(MB_0001_APPLIED, strcpy(patches[i++], "MB_0001"), );
BOOST_PP_IF(MB_0002_APPLIED, strcpy(patches[i++], "MB_0002"), );
BOOST_PP_IF(MB_0003_APPLIED, strcpy(patches[i++], "MB_0003"), );
BOOST_PP_IF(MB_0004_APPLIED, strcpy(patches[i++], "MB_0004"), );
BOOST_PP_IF(MB_0005_APPLIED, strcpy(patches[i++], "MB_0005"), );
BOOST_PP_IF(MB_0006_APPLIED, strcpy(patches[i++], "MB_0006"), );
BOOST_PP_IF(MB_0007_APPLIED, strcpy(patches[i++], "MB_0007"), );
BOOST_PP_IF(MB_0008_APPLIED, strcpy(patches[i++], "MB_0008"), );
BOOST_PP_IF(MB_0009_APPLIED, strcpy(patches[i++], "MB_0009"), );
BOOST_PP_IF(MB_0010_APPLIED, strcpy(patches[i++], "MB_0010"), );
BOOST_PP_IF(MB_0011_APPLIED, strcpy(patches[i++], "MB_0011"), );
BOOST_PP_IF(MB_0012_APPLIED, strcpy(patches[i++], "MB_0012"), );
BOOST_PP_IF(MB_0013_APPLIED, strcpy(patches[i++], "MB_0013"), );
BOOST_PP_IF(MB_0014_APPLIED, strcpy(patches[i++], "MB_0014"), );
BOOST_PP_IF(MB_0015_APPLIED, strcpy(patches[i++], "MB_0015"), );
BOOST_PP_IF(MB_0016_APPLIED, strcpy(patches[i++], "MB_0016"), );
BOOST_PP_IF(MB_0017_APPLIED, strcpy(patches[i++], "MB_0017"), );
BOOST_PP_IF(MB_0018_APPLIED, strcpy(patches[i++], "MB_0018"), );
BOOST_PP_IF(MB_0019_APPLIED, strcpy(patches[i++], "MB_0019"), );
BOOST_PP_IF(MB_0020_APPLIED, strcpy(patches[i++], "MB_0020"), );
// Not necessary becuase initialitzed to {0}
strcpy(patches[i++], "\0");
return;
}
void MB_init(void) {
MB_patches_discover();
}
char* MB_patch_get(int pos) {
BLI_assert(pos < MAX_MB_PATCHES);
return *patches[pos] == '\0' ? nullptr : patches[pos];
}
void MB_print_info()
{
printf("%s", "Tornavis Info\n");
printf("%s", "---------------------\n");
for (int i = 0; i < MAX_MB_PATCHES; i++) {
if (*patches[i] == '\0') {
break;
}
printf("Applied Patch %s\n", patches[i]);
}
printf("%s", "---------------------\n");
}

View File

@ -0,0 +1,13 @@
/**
*
*/
#ifndef MB_BLENDER_H
#define MB_BLENDER_H
void MB_init(void);
void MB_patches_discover(void);
char* MB_patch_get(int pos);
void MB_print_info(void);
#endif

View File

@ -0,0 +1 @@
/* Empty file */

View File

@ -0,0 +1 @@
/* Empty File */

View File

@ -0,0 +1 @@
/* Empty File */

View File

@ -0,0 +1 @@
/* Empty File */

View File

@ -0,0 +1 @@
/* Empty file */

View File

@ -0,0 +1 @@
/* Empty File */

View File

@ -0,0 +1 @@
/* Empty File */

View File

@ -4043,6 +4043,7 @@ void wm_operatortypes_register()
WM_operatortype_append(WM_OT_operator_defaults);
WM_operatortype_append(WM_OT_splash);
WM_operatortype_append(WM_OT_splash_about);
WM_operatortype_append(WM_OT_splash_custom);
WM_operatortype_append(WM_OT_search_menu);
WM_operatortype_append(WM_OT_search_operator);
WM_operatortype_append(WM_OT_search_single_menu);

View File

@ -17,6 +17,8 @@
#include <algorithm>
#include <cstring>
#include "CLG_log.h"
#include "DNA_ID.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
@ -45,6 +47,9 @@
#include "WM_api.hh"
#include "WM_types.hh"
#include "RNA_define.hh"
#include "RNA_access.hh"
#include "wm.hh"
/* -------------------------------------------------------------------- */
@ -370,4 +375,67 @@ void WM_OT_splash_about(wmOperatorType *ot)
ot->poll = WM_operator_winactive;
}
static uiBlock *wm_block_create_custom_splash(bContext *C, ARegion *region, void *arg) {
char *menutype_str = (char*) arg;
const uiStyle *style = UI_style_get_dpi();
const int text_points_max = std::max(style->widget.points, style->widgetlabel.points);
const int dialog_width = text_points_max * 42 * UI_SCALE_FAC;
uiBlock *block = UI_block_begin(C, region, "about", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_LOOP | UI_BLOCK_NO_WIN_CLIP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
uiLayout *layout = UI_block_layout(
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, dialog_width, 0, 0, style);
uiLayout *col = uiLayoutColumn(layout, true);
MenuType *mt = WM_menutype_find(menutype_str, true);
if (mt) {
UI_menutype_draw(C, mt, col);
} else {
CLOG_ERROR(WM_LOG_OPERATORS, "cannot find WM menutype '%s'", menutype_str);
}
UI_block_bounds_set_centered(block, 22 * UI_SCALE_FAC);
return block;
}
static int wm_about_custom_exec(bContext *C, wmOperator *op)
{
char *menutype_str = MEM_cnew_array<char>(100, __func__);
*menutype_str = '\0';
if (RNA_struct_property_is_set(op->ptr, "menutype")) {
RNA_string_get(op->ptr, "menutype", menutype_str);
}
UI_popup_block_invoke(C, wm_block_create_custom_splash, menutype_str, MEM_freeN);
return OPERATOR_FINISHED;
}
static int wm_about_custom_invoke(bContext *C, wmOperator *op , const wmEvent * /*event*/) {
return op->type->exec(C, op);
}
void WM_OT_splash_custom(wmOperatorType *ot)
{
PropertyRNA *prop;
prop = RNA_def_string(ot->srna, "menutype", "MT_", 100, "", "MenuType class name");
ot->name = "Custom Splash";
ot->idname = "WM_OT_splash_custom";
ot->description = "Open a splash window with some custom information";
ot->exec = wm_about_custom_exec;
ot->invoke = wm_about_custom_invoke;
ot->poll = WM_operator_winactive;
}
/** \} */

View File

@ -98,6 +98,7 @@ void wm_autosave_delete();
void WM_OT_splash(wmOperatorType *ot);
void WM_OT_splash_about(wmOperatorType *ot);
void WM_OT_splash_custom(wmOperatorType *ot);
/* `wm_stereo.cc` */

View File

@ -12,6 +12,7 @@ set(INC
../blender/makesrna
../blender/render
../blender/windowmanager
../blender/tornavis
)
set(LIB
@ -21,6 +22,7 @@ set(LIB
PRIVATE bf::intern::clog
PRIVATE bf::intern::guardedalloc
bf_windowmanager
tornavis
)
if(HAVE_FEENABLEEXCEPT)
@ -507,6 +509,13 @@ install(
DESTINATION ${TARGETDIR_VER}/datafiles
)
#tornavis
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/tornavis
DESTINATION ${TARGETDIR_VER}/datafiles
)
# localization
if(WITH_INTERNATIONAL)
set(_locale_dir "${CMAKE_SOURCE_DIR}/locale")

View File

@ -55,6 +55,8 @@
#include "BKE_vfont.hh"
#include "BKE_volume.hh"
#include "MB_tornavis.h"
#ifndef WITH_PYTHON_MODULE
# include "BLI_args.h"
#endif
@ -467,6 +469,8 @@ int main(int argc,
/* After parsing number of threads argument. */
BLI_task_scheduler_init();
MB_init();
#ifndef WITH_PYTHON_MODULE
/* The settings pass includes:
* - Background-mode assignment (#Global.background), checked by other subsystems

View File

@ -49,6 +49,8 @@
# include "GPU_context.hh"
# include "MB_tornavis.h"
# ifdef WITH_PYTHON
# include "BPY_extern_python.h"
# include "BPY_extern_run.h"
@ -1546,6 +1548,16 @@ static int arg_handle_start_with_console(int /*argc*/, const char ** /*argv*/, v
return 0;
}
static const char arg_handle_tornavis_info_doc[] =
"\n\t"
"Shows Tornavis project info on loading.";
static int arg_handle_tornavis_info(int /*argc*/, const char ** /*argv*/, void * /*data*/)
{
MB_print_info();
return 0;
}
static const char arg_handle_register_extension_doc[] =
"\n\t"
"Register blend-file extension for current user, then exit (Windows only).";
@ -2601,6 +2613,8 @@ void main_args_setup(bContext *C, bArgs *ba, bool all)
BLI_args_add(ba, nullptr, "--open-last", CB(arg_handle_load_last_file), C);
BLI_args_add(ba, nullptr, "--tornavis-info", CB(arg_handle_tornavis_info), nullptr);
# undef CB
# undef CB_EX
# undef CB_ALL