Commit: ef484c7a5963a691394f46bd9c77b814533a4033
Author: Bastien Montagne
Date:   Tue May 5 17:18:30 2015 +0200
Branches: asset-experiments
https://developer.blender.org/rBef484c7a5963a691394f46bd9c77b814533a4033

Expose preview/icon render sizes in bpy.app

===================================================================

M       source/blender/editors/include/UI_interface_icons.h
M       source/blender/editors/interface/interface_icons.c
M       source/blender/python/intern/bpy_app.c

===================================================================

diff --git a/source/blender/editors/include/UI_interface_icons.h 
b/source/blender/editors/include/UI_interface_icons.h
index e74246c..4085336 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -38,6 +38,8 @@ struct Scene;
 struct PreviewImage;
 struct PointerRNA;
 
+enum eIconSizes;
+
 typedef struct IconFile {
        struct IconFile *next, *prev;
        char filename[256]; /* FILE_MAXFILE size */
@@ -63,6 +65,7 @@ int UI_icon_get_height(int icon_id);
 
 void UI_id_icon_render(
         const struct bContext *C, struct Scene *scene, struct ID *id, const 
bool big, const bool use_job);
+int UI_preview_render_size(enum eIconSizes size);
 
 void UI_icon_draw(float x, float y, int icon_id);
 void UI_icon_draw_preview(float x, float y, int icon_id);
diff --git a/source/blender/editors/interface/interface_icons.c 
b/source/blender/editors/interface/interface_icons.c
index ee99eee..0398084 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -901,7 +901,7 @@ void UI_icons_init(int first_dyn_id)
 
 /* Render size for preview images and icons
  */
-static int preview_render_size(enum eIconSizes size)
+int UI_preview_render_size(enum eIconSizes size)
 {
        switch (size) {
                case ICON_SIZE_ICON:    return ICON_RENDER_DEFAULT_HEIGHT;
@@ -914,7 +914,7 @@ static int preview_render_size(enum eIconSizes size)
  */
 static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes 
size)
 {
-       unsigned int render_size = preview_render_size(size);
+       unsigned int render_size = UI_preview_render_size(size);
 
        if (!prv_img) {
                if (G.debug & G_DEBUG)
diff --git a/source/blender/python/intern/bpy_app.c 
b/source/blender/python/intern/bpy_app.c
index 04ab34e..5b90506 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -50,6 +50,10 @@
 #include "BKE_blender.h"
 #include "BKE_global.h"
 
+#include "DNA_ID.h"
+
+#include "UI_interface_icons.h"
+
 #include "../generic/py_capi_utils.h"
 #include "../generic/python_utildefines.h"
 
@@ -271,6 +275,14 @@ static PyObject *bpy_app_driver_dict_get(PyObject 
*UNUSED(self), void *UNUSED(cl
        return Py_INCREF_RET(bpy_pydriver_Dict);
 }
 
+PyDoc_STRVAR(bpy_app_preview_render_size_doc,
+"Reference size for icon/preview renders (read-only)"
+);
+static PyObject *bpy_app_preview_render_size_get(PyObject *UNUSED(self), void 
*closure)
+{
+       return 
PyLong_FromLong((long)UI_preview_render_size(GET_INT_FROM_POINTER(closure)));
+}
+
 static PyObject *bpy_app_autoexec_fail_message_get(PyObject *UNUSED(self), 
void *UNUSED(closure))
 {
        return PyC_UnicodeFromByte(G.autoexec_fail);
@@ -293,6 +305,9 @@ static PyGetSetDef bpy_app_getsets[] = {
        {(char *)"tempdir", bpy_app_tempdir_get, NULL, (char 
*)bpy_app_tempdir_doc, NULL},
        {(char *)"driver_namespace", bpy_app_driver_dict_get, NULL, (char 
*)bpy_app_driver_dict_doc, NULL},
 
+    {(char *)"render_icon_size", bpy_app_preview_render_size_get, NULL, (char 
*)bpy_app_preview_render_size_doc, (void *)ICON_SIZE_ICON},
+    {(char *)"render_preview_size", bpy_app_preview_render_size_get, NULL, 
(char *)bpy_app_preview_render_size_doc, (void *)ICON_SIZE_PREVIEW},
+
        /* security */
        {(char *)"autoexec_fail", bpy_app_global_flag_get, NULL, NULL, (void 
*)G_SCRIPT_AUTOEXEC_FAIL},
        {(char *)"autoexec_fail_quiet", bpy_app_global_flag_get, NULL, NULL, 
(void *)G_SCRIPT_AUTOEXEC_FAIL_QUIET},

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to