diff --git a/scripts/modules/bpy/utils/images.py b/scripts/modules/bpy/utils/images.py deleted file mode 100644 index b4bd02b395c..00000000000 --- a/scripts/modules/bpy/utils/images.py +++ /dev/null @@ -1,49 +0,0 @@ -# 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 diff --git a/source/blender/editors/include/UI_interface_c.hh b/source/blender/editors/include/UI_interface_c.hh index 6dedc600d5b..a8e1c5c7a50 100644 --- a/source/blender/editors/include/UI_interface_c.hh +++ b/source/blender/editors/include/UI_interface_c.hh @@ -2465,9 +2465,6 @@ 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. */ diff --git a/source/blender/editors/interface/interface_templates.cc b/source/blender/editors/interface/interface_templates.cc index 0b3ee5afd1f..1f543d7b0b8 100644 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@ -78,9 +78,6 @@ #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" @@ -100,7 +97,7 @@ #include "UI_string_search.hh" #include "interface_intern.hh" -#include "BPY_extern.h" +using blender::Vector; /* we may want to make this optional, disable for now. */ // #define USE_OP_RESET_BUT @@ -3368,28 +3365,6 @@ 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 * \{ */ diff --git a/source/blender/makesrna/intern/rna_ui_api.cc b/source/blender/makesrna/intern/rna_ui_api.cc index 59084715c9f..83032a1fc56 100644 --- a/source/blender/makesrna/intern/rna_ui_api.cc +++ b/source/blender/makesrna/intern/rna_ui_api.cc @@ -1911,21 +1911,6 @@ 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); diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index 3a00f2767f2..db70947b683 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -133,8 +133,6 @@ 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); diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index 3da41f71895..fd9770b96b9 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -68,7 +68,6 @@ set(SRC bpy_rna_ui.cc bpy_traceback.cc bpy_utils_previews.cc - bpy_utils_images.cc bpy_utils_units.cc stubs.cc @@ -111,7 +110,6 @@ 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 diff --git a/source/blender/python/intern/bpy.cc b/source/blender/python/intern/bpy.cc index 0ee5a3f36e6..93cf175b5aa 100644 --- a/source/blender/python/intern/bpy.cc +++ b/source/blender/python/intern/bpy.cc @@ -43,7 +43,6 @@ #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,7 +704,6 @@ 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); diff --git a/source/blender/python/intern/bpy_utils_images.cc b/source/blender/python/intern/bpy_utils_images.cc deleted file mode 100644 index 6d92bb4d132..00000000000 --- a/source/blender/python/intern/bpy_utils_images.cc +++ /dev/null @@ -1,173 +0,0 @@ -/* 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 -#include - -#include - -#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(__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; -} diff --git a/source/blender/python/intern/bpy_utils_images.h b/source/blender/python/intern/bpy_utils_images.h deleted file mode 100644 index 6e27babe26a..00000000000 --- a/source/blender/python/intern/bpy_utils_images.h +++ /dev/null @@ -1,19 +0,0 @@ -/* 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 diff --git a/source/blender/tornavis/patches/MB_0014.h b/source/blender/tornavis/patches/MB_0014.h deleted file mode 100644 index ddf2a41c228..00000000000 --- a/source/blender/tornavis/patches/MB_0014.h +++ /dev/null @@ -1 +0,0 @@ -/* Empty File */ diff --git a/source/blender/tornavis/patches/MB_0015.h b/source/blender/tornavis/patches/MB_0015.h deleted file mode 100644 index ddf2a41c228..00000000000 --- a/source/blender/tornavis/patches/MB_0015.h +++ /dev/null @@ -1 +0,0 @@ -/* Empty File */