Compare commits
171 Commits
main
...
mb-0013-bl
Author | SHA1 | Date |
---|---|---|
Jaume Bellet | 58877fd199 | |
Jaume Bellet | 6470fbf6b6 | |
Jaume Bellet | 913e155c7b | |
Jaume Bellet | 99261bcd1a | |
Jaume Bellet | 183ad17df5 | |
Jaume Bellet | f0c51c2927 | |
Jaume Bellet | 222bbd5870 | |
Jaume Bellet | 0a09b279cf | |
Jaume Bellet | 316ec095f9 | |
Jaume Bellet | 41634ec713 | |
Jaume Bellet | 1beab72f70 | |
Jaume Bellet | 5010e61a15 | |
Jaume Bellet | 0651f8fe2f | |
Jaume Bellet | 197d935395 | |
Jaume Bellet | 3c281ddf78 | |
Jaume Bellet | 0223f93c2d | |
Jaume Bellet | fc14101e67 | |
Jaume Bellet | 8d178ec03d | |
Jaume Bellet | d82734d3a1 | |
Jaume Bellet | 7fcb34fa1d | |
Jaume Bellet | 76d136b561 | |
Jaume Bellet | 2138265035 | |
Jaume Bellet | 280850ddf1 | |
Jaume Bellet | e2e0d25e55 | |
Jaume Bellet | 5ca0cb05b7 | |
Jaume Bellet | 352759ebaf | |
Jaume Bellet | 391f2b37bd | |
Jaume Bellet | 59d84807d2 | |
Jaume Bellet | a782515ff1 | |
Jaume Bellet | f1f212085a | |
Jaume Bellet | c5443dad4e | |
Jaume Bellet | c529b6b7c4 | |
Jaume Bellet | 7eb9a490e5 | |
Jaume Bellet | 750c5f2723 | |
Jaume Bellet | ea58d624cd | |
Jaume Bellet | a5d0f13b1f | |
Jaume Bellet | 4d4d9280d4 | |
Jaume Bellet | c2bb4c5c18 | |
Jaume Bellet | 5bf1925aec | |
Jaume Bellet | c50ec6c401 | |
Jaume Bellet | dbaf864dde | |
Jaume Bellet | d9bb3a88c8 | |
Jaume Bellet | 6e6cfbe2c9 | |
Jaume Bellet | 74db93745b | |
Jaume Bellet | 8d5a39a26d | |
Jaume Bellet | 2d46aed94b | |
Jaume Bellet | afff173475 | |
Jaume Bellet | 63e9375ec8 | |
Jaume Bellet | cde3c2f0c4 | |
Jaume Bellet | bc81accaf0 | |
Jaume Bellet | 5ff326c5f4 | |
Jaume Bellet | 22a9bb1cd3 | |
Jaume Bellet | 8d31fe702c | |
Jaume Bellet | 563ad93b39 | |
Jaume Bellet | 963db09985 | |
Jaume Bellet | 6d7fd0cb9b | |
Jaume Bellet | 668b7f7d88 | |
Jaume Bellet | dbd0a965d1 | |
Jaume Bellet | 5d18b0cf1a | |
Jaume Bellet | d00901e305 | |
Jaume Bellet | cd95bdf19f | |
Jaume Bellet | 28d81fcb0a | |
Jaume Bellet | e5b1b06e87 | |
Jaume Bellet | fac3c2b05f | |
Jaume Bellet | ddcab1e21a | |
Jaume Bellet | db2382af5f | |
Jaume Bellet | 236564a441 | |
Jaume Bellet | c410d149da | |
Jaume Bellet | 8c28254ea4 | |
Jaume Bellet | 542ac1b43c | |
Jaume Bellet | 0c4b16c3cd | |
Jaume Bellet | d31a0c060a | |
Jaume Bellet | e1dba50d08 | |
Jaume Bellet | aa234d9e15 | |
Jaume Bellet | 0b15841ad6 | |
Jaume Bellet | 18faafda39 | |
Jaume Bellet | 4217cb75a5 | |
Jaume Bellet | a3e63eb3fb | |
Jaume Bellet | f842025279 | |
Jaume Bellet | c7d83eae9a | |
Jaume Bellet | 4800eb3934 | |
Jaume Bellet | e5d5b31f3c | |
Jaume Bellet | d98ded7b7c | |
Jaume Bellet | 7d02cebca1 | |
Jaume Bellet | 9b548ae368 | |
Jaume Bellet | d1b5309057 | |
Jaume Bellet | 900417d60b | |
Jaume Bellet | c3d76d17a7 | |
Jaume Bellet | 2285de9e8d | |
Jaume Bellet | 217992d312 | |
Jaume Bellet | c5cfd962f0 | |
Jaume Bellet | 52fad90ee9 | |
Jaume Bellet | 9ec91804a2 | |
Jaume Bellet | d54c76f122 | |
Jaume Bellet | 22da6ed3ce | |
Jaume Bellet | 02b1ce4aeb | |
Jaume Bellet | a8cf22cb96 | |
Jaume Bellet | 06908cda20 | |
Jaume Bellet | 3817881c4f | |
Jaume Bellet | c11e478be9 | |
Jaume Bellet | 41388f8dc8 | |
Jaume Bellet | e084874db7 | |
Jaume Bellet | 33914c92cc | |
Jaume Bellet | 4ae40c1e3a | |
Jaume Bellet | 3b5da577f7 | |
Jaume Bellet | b7e97dc8bb | |
Jaume Bellet | fe4b73b603 | |
Jaume Bellet | da2aaaa63d | |
Jaume Bellet | e7ce2a8b75 | |
Jaume Bellet | 20c8b6ac79 | |
Jaume Bellet | 0eaeaec449 | |
Jaume Bellet | 5738c4116c | |
Jaume Bellet | 76c900aecc | |
Jaume Bellet | 1f4b02a4d1 | |
Jaume Bellet | bc37e5c2b5 | |
Jaume Bellet | 62ef498db4 | |
Jaume Bellet | 894945ac73 | |
Jaume Bellet | 53f625bf2f | |
Jaume Bellet | d130c0eeb5 | |
Jaume Bellet | 7f73f363b3 | |
Jaume Bellet | 3f8b87b49b | |
Jaume Bellet | 9f440d1904 | |
Jaume Bellet | 4fd2cc482f | |
Jaume Bellet | b1ed1c5048 | |
Jaume Bellet | 50bc821d26 | |
Jaume Bellet | 18793361af | |
Jaume Bellet | 6c74c139dc | |
Jaume Bellet | eb44324cad | |
Jaume Bellet | 1cdc8ad52d | |
Jaume Bellet | aea389f4a2 | |
Jaume Bellet | fef6af1266 | |
Jaume Bellet | 5978db8006 | |
Jaume Bellet | 57d65bfa06 | |
Jaume Bellet | fd6dac3248 | |
Jaume Bellet | 8ab9eb2bf4 | |
Jaume Bellet | 9414fe8f70 | |
Jaume Bellet | 01fedda773 | |
Jaume Bellet | 179dd5ca89 | |
Jaume Bellet | a2cc93e23f | |
Jaume Bellet | a19b4eb1ca | |
Jaume Bellet | 46252130aa | |
Jaume Bellet | 2add8e01d5 | |
Jaume Bellet | 5e515d954c | |
Jaume Bellet | ed86f7be23 | |
Jaume Bellet | cca4693bdd | |
Jaume Bellet | 08b36c66b1 | |
Jaume Bellet | 8a475e7ae6 | |
Jaume Bellet | d568f25ef0 | |
Jaume Bellet | 6b5734c635 | |
Jaume Bellet | c712982580 | |
Jaume Bellet | ee8bff63f9 | |
Jaume Bellet | c2ddfdf09c | |
Jaume Bellet | 8aacc84821 | |
Jaume Bellet | d34bc451c7 | |
Jaume Bellet | 7eeb9693a9 | |
Jaume Bellet | 7f71b9ac5b | |
Jaume Bellet | 14a8265648 | |
Jaume Bellet | b5acb41f73 | |
Jaume Bellet | 0fdf1c88e9 | |
Jaume Bellet | 997eeac87c | |
Jaume Bellet | 3ea0ab9d87 | |
Jaume Bellet | 6d6bd017f3 | |
Jaume Bellet | d7cbb13067 | |
Jaume Bellet | 680120c380 | |
Jaume Bellet | 131c94004d | |
Jaume Bellet | f5c10fca1a | |
Jaume Bellet | dc0b6d0162 | |
Jaume Bellet | a11f0637b6 | |
Jaume Bellet | 82fdcfa589 | |
Jaume Bellet | 788d99b940 | |
Jaume Bellet | 260514cd54 |
|
@ -0,0 +1 @@
|
|||
Binary data like icons or images related to mechanical blender
|
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
|
@ -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.
|
||||
|
|
|
@ -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
|
|
@ -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):
|
||||
|
|
|
@ -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'])
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
* \{ */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -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}")
|
|
@ -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
|
|
@ -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");
|
||||
}
|
||||
|
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
/* Empty file */
|
|
@ -0,0 +1 @@
|
|||
/* Empty File */
|
|
@ -0,0 +1 @@
|
|||
/* Empty File */
|
|
@ -0,0 +1 @@
|
|||
/* Empty File */
|
|
@ -0,0 +1 @@
|
|||
/* Empty file */
|
|
@ -0,0 +1 @@
|
|||
/* Empty File */
|
|
@ -0,0 +1 @@
|
|||
/* Empty 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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -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` */
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue