Show file size for HDRi files.
This commit is contained in:
parent
7cf858855e
commit
3ce89ad5f4
@ -72,6 +72,7 @@ def register():
|
|||||||
|
|
||||||
reload_mod('blendfile')
|
reload_mod('blendfile')
|
||||||
reload_mod('home_project')
|
reload_mod('home_project')
|
||||||
|
reload_mod('utils')
|
||||||
|
|
||||||
blender = reload_mod('blender')
|
blender = reload_mod('blender')
|
||||||
async_loop = reload_mod('async_loop')
|
async_loop = reload_mod('async_loop')
|
||||||
|
@ -592,7 +592,8 @@ async def download_texture_thumbnail(texture_node, desired_size: str,
|
|||||||
# Load the File that belongs to this texture node's picture.
|
# Load the File that belongs to this texture node's picture.
|
||||||
loop.call_soon_threadsafe(thumbnail_loading, texture_node, texture_node)
|
loop.call_soon_threadsafe(thumbnail_loading, texture_node, texture_node)
|
||||||
file_desc = await pillar_call(pillarsdk.File.find, pic_uuid, params={
|
file_desc = await pillar_call(pillarsdk.File.find, pic_uuid, params={
|
||||||
'projection': {'filename': 1, 'variations': 1, 'width': 1, 'height': 1},
|
'projection': {'filename': 1, 'variations': 1, 'width': 1, 'height': 1,
|
||||||
|
'length': 1},
|
||||||
})
|
})
|
||||||
|
|
||||||
if file_desc is None:
|
if file_desc is None:
|
||||||
|
@ -26,7 +26,7 @@ import bgl
|
|||||||
import blf
|
import blf
|
||||||
|
|
||||||
import pillarsdk
|
import pillarsdk
|
||||||
from . import async_loop, pillar, cache, blender
|
from . import async_loop, pillar, cache, blender, utils
|
||||||
|
|
||||||
REQUIRED_ROLES_FOR_TEXTURE_BROWSER = {'subscriber', 'demo'}
|
REQUIRED_ROLES_FOR_TEXTURE_BROWSER = {'subscriber', 'demo'}
|
||||||
MOUSE_SCROLL_PIXELS_PER_TICK = 50
|
MOUSE_SCROLL_PIXELS_PER_TICK = 50
|
||||||
@ -511,10 +511,14 @@ class BlenderCloudBrowser(pillar.PillarOperatorMixin,
|
|||||||
self.update_menu_item(node, file_desc, thumb_path)
|
self.update_menu_item(node, file_desc, thumb_path)
|
||||||
|
|
||||||
def hdri_thumbnail_loading(node, texture_node):
|
def hdri_thumbnail_loading(node, texture_node):
|
||||||
self.add_menu_item(node, None, 'SPINNER', node.resolution)
|
self.add_menu_item(node, None, 'SPINNER',
|
||||||
|
'Resolution: %s' % node.resolution)
|
||||||
|
|
||||||
def hdri_thumbnail_loaded(node, file_desc, thumb_path):
|
def hdri_thumbnail_loaded(node, file_desc, thumb_path):
|
||||||
self.update_menu_item(node, file_desc, thumb_path)
|
filesize = utils.sizeof_fmt(file_desc.length)
|
||||||
|
|
||||||
|
self.update_menu_item(node, file_desc, thumb_path,
|
||||||
|
'Resolution: %s (%s)' % (node.resolution, filesize))
|
||||||
|
|
||||||
project_uuid = self.current_path.project_uuid
|
project_uuid = self.current_path.project_uuid
|
||||||
node_uuid = self.current_path.node_uuid
|
node_uuid = self.current_path.node_uuid
|
||||||
|
31
blender_cloud/utils.py
Normal file
31
blender_cloud/utils.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
# ##### END GPL LICENSE BLOCK #####
|
||||||
|
|
||||||
|
|
||||||
|
def sizeof_fmt(num: int, suffix='B') -> str:
|
||||||
|
"""Returns a human-readable size.
|
||||||
|
|
||||||
|
Source: http://stackoverflow.com/a/1094933/875379
|
||||||
|
"""
|
||||||
|
|
||||||
|
for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
|
||||||
|
if abs(num) < 1024:
|
||||||
|
return '%.1f %s%s' % (num, unit, suffix)
|
||||||
|
num /= 1024
|
||||||
|
|
||||||
|
return '%.1f Yi%s' % (num, suffix)
|
Reference in New Issue
Block a user