Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilém Duha <vilda.novak@gmail.com>2021-04-30 13:50:38 +0300
committerVilém Duha <vilda.novak@gmail.com>2021-04-30 13:50:38 +0300
commit6dac52a35f3387720da6ca6fd04aa8160819c24e (patch)
treec93cc0e1e817352a718ae2bf0267b2952c16d084
parentf1d959b003e28ee2226b26651dfd6b0fff13d2e1 (diff)
BlenderKit: minor ui fixes and cleanup
-rw-r--r--blenderkit/ui.py23
-rw-r--r--blenderkit/ui_panels.py28
2 files changed, 25 insertions, 26 deletions
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index 6351bdc7..ba5855f7 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -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)
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 09231e6f..8d880fdd 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -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