BlenderKit: minor ui fixes and cleanup
This commit is contained in:
parent
f1d959b003
commit
6dac52a35f
|
@ -289,8 +289,8 @@ def draw_tooltip(x, y, name='', author='', img=None, gravatar=None):
|
|||
x += 20
|
||||
y -= 20
|
||||
#first get image size scaled
|
||||
isizex = int(512 * scale * img.size[0] / max(img.size[0], img.size[1]))
|
||||
isizey = int(512 * scale * img.size[1] / max(img.size[0], img.size[1]))
|
||||
isizex = int(512 * scale * img.size[0] / min(img.size[0], img.size[1]))
|
||||
isizey = int(512 * scale * img.size[1] / min(img.size[0], img.size[1]))
|
||||
|
||||
ttipmargin = 5 * scale
|
||||
#then do recurrent re-scaling, to know where to fit the tooltip
|
||||
|
@ -299,13 +299,19 @@ def draw_tooltip(x, y, name='', author='', img=None, gravatar=None):
|
|||
scaledown = y / (estimated_height)
|
||||
scale *= scaledown
|
||||
|
||||
isizex = int(512 * scale * img.size[0] / max(img.size[0], img.size[1]))
|
||||
isizey = int(512 * scale * img.size[1] / max(img.size[0], img.size[1]))
|
||||
isizex = int(512 * scale * img.size[0] / min(img.size[0], img.size[1]))
|
||||
isizey = int(512 * scale * img.size[1] / min(img.size[0], img.size[1]))
|
||||
|
||||
ttipmargin = 5 * scale
|
||||
textmargin = 12 * scale
|
||||
|
||||
overlay_height = 90 * scale
|
||||
if gravatar is not None:
|
||||
overlay_height_base = 90
|
||||
else:
|
||||
overlay_height_base = 50
|
||||
|
||||
|
||||
overlay_height = overlay_height_base * scale
|
||||
name_height = int(20 * scale)
|
||||
|
||||
width = isizex + 2 * ttipmargin
|
||||
|
@ -343,7 +349,7 @@ def draw_tooltip(x, y, name='', author='', img=None, gravatar=None):
|
|||
|
||||
# draw gravatar
|
||||
author_x_text = x + isizex - textmargin
|
||||
gravatar_size = overlay_height * scale - 2 * textmargin
|
||||
gravatar_size = overlay_height - 2 * textmargin
|
||||
gravatar_y = y - isizey - ttipmargin + textmargin
|
||||
if gravatar is not None:
|
||||
author_x_text -= gravatar_size + textmargin
|
||||
|
@ -374,7 +380,10 @@ def draw_tooltip_with_author(asset_data, x, y):
|
|||
# author_s = ''
|
||||
# if not gimg:
|
||||
# author_s = 'Author: '
|
||||
draw_tooltip(x, y, name=asset_data['displayName'], author=f"by {a['firstName']} {a['lastName']}", img=img,
|
||||
aname = asset_data['displayName']
|
||||
if len(aname)>36:
|
||||
aname = f"{aname[:33]}..."
|
||||
draw_tooltip(x, y, name=aname, author=f"by {a['firstName']} {a['lastName']}", img=img,
|
||||
gravatar=gimg)
|
||||
|
||||
|
||||
|
|
|
@ -1319,7 +1319,7 @@ def draw_asset_context_menu(layout, context, asset_data, from_panel=False):
|
|||
op.state = 'deleted'
|
||||
|
||||
if utils.profile_is_validator():
|
||||
layout.label(text='Admin Tools:')
|
||||
layout.label(text='Dev Tools:')
|
||||
|
||||
op = layout.operator('object.blenderkit_print_asset_debug', text='Print asset debug')
|
||||
op.asset_id = asset_data['id']
|
||||
|
@ -1507,21 +1507,8 @@ class AssetPopupCard(bpy.types.Operator):
|
|||
return True
|
||||
|
||||
def draw_menu(self, context, layout):
|
||||
ui_props = context.scene.blenderkitUI
|
||||
|
||||
col_left = layout.column()
|
||||
# row_button = col_left.row()
|
||||
# row_button.scale_y = 3
|
||||
# op = row_button.operator('view3d.asset_drag_drop', text='Drag & Drop')
|
||||
# op.asset_search_index = ui_props.active_index
|
||||
draw_asset_context_menu(col_left, context, self.asset_data, from_panel=False)
|
||||
# layout = col_left
|
||||
# op = layout.operator('view3d.blenderkit_search', text='Search Similar')
|
||||
# # build search string from description and tags:
|
||||
# op.keywords = self.asset_data['name']
|
||||
# if self.asset_data.get('description'):
|
||||
# op.keywords += ' ' + self.asset_data.get('description') + ' '
|
||||
# op.keywords += ' '.join(self.asset_data.get('tags'))
|
||||
col = layout.column()
|
||||
draw_asset_context_menu(col, context, self.asset_data, from_panel=False)
|
||||
|
||||
def draw_property(self, layout, left, right, icon=None, icon_value=None, url=None, tooltip=''):
|
||||
right = str(right)
|
||||
|
@ -1675,7 +1662,10 @@ class AssetPopupCard(bpy.types.Operator):
|
|||
icon = pcoll['full']
|
||||
self.draw_property(box, 'Access:', t, icon_value=icon.icon_id)
|
||||
|
||||
def draw_author(self, layout, width=330):
|
||||
def draw_author_area(self, context, layout, width=330):
|
||||
self.draw_author(context, layout, width=330)
|
||||
|
||||
def draw_author(self, context, layout, width=330):
|
||||
image_split = 0.25
|
||||
text_width = width
|
||||
authors = bpy.context.window_manager['bkit authors']
|
||||
|
@ -1700,7 +1690,7 @@ class AssetPopupCard(bpy.types.Operator):
|
|||
col = row.column()
|
||||
|
||||
utils.label_multiline(col, text=a['tooltip'], width=text_width)
|
||||
#check if author didn't fill any data about himself and prompt him if that's the case
|
||||
# check if author didn't fill any data about himself and prompt him if that's the case
|
||||
if upload.user_is_owner(asset_data=self.asset_data) and a.get('aboutMe') is not None and len(
|
||||
a.get('aboutMe', '')) == 0:
|
||||
row = col.row()
|
||||
|
@ -1790,7 +1780,7 @@ class AssetPopupCard(bpy.types.Operator):
|
|||
self.draw_menu(context, col1)
|
||||
|
||||
# author
|
||||
self.draw_author(box)
|
||||
self.draw_author_area(context, box, width=330)
|
||||
|
||||
def draw(self, context):
|
||||
ui_props = context.scene.blenderkitUI
|
||||
|
|
Loading…
Reference in New Issue