[Bf-extensions-cvs] [7867fe8b] blender-v2.93-release: BlenderKit: UI fixes

Vilem Duha noreply at git.blender.org
Wed May 19 11:53:26 CEST 2021


Commit: 7867fe8bb34d6ddebcb0c29e143a506042571f69
Author: Vilem Duha
Date:   Wed May 19 11:51:45 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rBA7867fe8bb34d6ddebcb0c29e143a506042571f69

BlenderKit: UI fixes

Right clicking assetbar in a space where is no asset displayed did throw an error
several minor tooltip/layout fixes.

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

M	blenderkit/__init__.py
M	blenderkit/ratings.py
M	blenderkit/ui.py
M	blenderkit/ui_panels.py

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

diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index ca7cbeb2..e8043626 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -319,7 +319,7 @@ class BlenderKitUIProps(PropertyGroup):
         update=udate_down_up
     )
     asset_type: EnumProperty(
-        name="BlenderKit Active Asset Type",
+        name=" ",
         items=asset_type_callback,
         description="",
         default=None,
@@ -445,7 +445,7 @@ class BlenderKitCommonSearchProps(object):
                                  default=False)
     search_done: BoolProperty(name="Search Completed", description="at least one search did run (internal)",
                               default=False)
-    own_only: BoolProperty(name="My Assets", description="Search only for your assets",
+    own_only: BoolProperty(name="My Assets Only", description="Search only for your assets",
                            default=False, update=search.search_update)
     search_advanced: BoolProperty(name="Advanced Search Options", description="use advanced search properties",
                                   default=False, update=search.search_update)
diff --git a/blenderkit/ratings.py b/blenderkit/ratings.py
index dd4eeb3d..cde57893 100644
--- a/blenderkit/ratings.py
+++ b/blenderkit/ratings.py
@@ -180,7 +180,7 @@ def draw_ratings_menu(self, context, layout):
 
     profile_name = ''
     profile = bpy.context.window_manager.get('bkit profile')
-    if profile:
+    if profile and len(profile['user']['firstName'])>0:
         profile_name = ' ' + profile['user']['firstName']
 
     col = layout.column()
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index febf37b1..84deb24e 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -1419,7 +1419,7 @@ class AssetBarOperator(bpy.types.Operator):
             mx = event.mouse_x - r.x
             my = event.mouse_y - r.y
 
-            if event.value == 'PRESS' and mouse_in_asset_bar(mx, my):
+            if event.value == 'PRESS' and mouse_in_asset_bar(mx, my) and ui_props.active_index>-1:
                 # context.window.cursor_warp(event.mouse_x - 300, event.mouse_y - 10);
 
                 bpy.ops.wm.blenderkit_asset_popup('INVOKE_DEFAULT')
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index c04068ce..b92e985d 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -1362,6 +1362,11 @@ def numeric_to_str(s):
     return s
 
 
+def push_op_left(layout):
+    for a in range(0, 5):
+        layout.label(text='')
+
+
 def label_or_url(layout, text='', tooltip='', url='', icon_value=None, icon=None):
     '''automatically switch between different layout options for linking or tooltips'''
     layout.emboss = 'NONE'
@@ -1374,8 +1379,7 @@ def label_or_url(layout, text='', tooltip='', url='', icon_value=None, icon=None
             op = layout.operator('wm.blenderkit_url', text=text)
         op.url = url
         op.tooltip = tooltip
-        layout.label(text='')
-        layout.label(text='')
+        push_op_left(layout)
 
         return
     if tooltip != '':
@@ -1387,8 +1391,7 @@ def label_or_url(layout, text='', tooltip='', url='', icon_value=None, icon=None
             op = layout.operator('wm.blenderkit_tooltip', text=text)
         op.tooltip = tooltip
         # these are here to move the text to left, since operators can only center text by default
-        layout.label(text='')
-        layout.label(text='')
+        push_op_left(layout)
         return
     if icon:
         layout.label(text=text, icon=icon)
@@ -1416,14 +1419,14 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
     def draw_property(self, layout, left, right, icon=None, icon_value=None, url='', tooltip=''):
         right = str(right)
         row = layout.row()
-        split = row.split(factor=0.4)
+        split = row.split(factor=0.35)
         split.alignment = 'RIGHT'
         split.label(text=left)
         split = split.split()
         split.alignment = 'LEFT'
         # split for questionmark:
         if url != '':
-            split = split.split(factor=0.7)
+            split = split.split(factor=0.6)
         label_or_url(split, text=right, tooltip=tooltip, url=url, icon_value=icon_value, icon=icon)
         # additional questionmark icon where it's important?
         if url != '':
@@ -1442,12 +1445,14 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
             parameter = f"{parameter:,.1f}"
         self.draw_property(layout, pretext, parameter)
 
-    def draw_description(self, layout, width = 250):
+    def draw_description(self, layout, width=250):
         if len(self.asset_data['description']) > 0:
             box = layout.box()
-            box.scale_y = 0.8
+            box.scale_y = 0.4
             box.label(text='Description')
+            box.separator()
             utils.label_multiline(box, self.asset_data['description'], width=width)
+            box.separator()
 
     def draw_properties(self, layout, width=250):
 
@@ -1460,8 +1465,9 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
 
         box = layout.box()
 
-        box.scale_y = 0.8
+        box.scale_y = 0.4
         box.label(text='Properties')
+        box.separator()
         if self.asset_data.get('license') == 'cc_zero':
             t = 'CC Zero          '
             icon = pcoll['cc0']
@@ -1471,7 +1477,7 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
             icon = pcoll['royalty_free']
 
         self.draw_property(box,
-                           'License:', t,
+                           'License', t,
                            # icon_value=icon.icon_id,
                            url="https://www.blenderkit.com/docs/licenses/",
                            tooltip='All BlenderKit assets are available for commercial use. \n' \
@@ -1502,7 +1508,7 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
 
             }
             self.draw_property(box,
-                               'Verification:',
+                               'Verification',
                                self.asset_data['verificationStatus'],
                                icon_value=icon.icon_id,
                                url="https://www.blenderkit.com/docs/validation-status/",
@@ -1528,7 +1534,7 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
                     if f['fileType'].find('resolution') > -1:
                         resolutions += f['fileType'][11:] + ' '
                 resolutions = resolutions.replace('_', '.')
-                self.draw_property(box, 'Generated:', resolutions)
+                self.draw_property(box, 'Generated', resolutions)
 
         self.draw_asset_parameter(box, key='designer', pretext='Designer')
         self.draw_asset_parameter(box, key='manufacturer', pretext='Manufacturer')  # TODO make them clickable!
@@ -1548,15 +1554,15 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
             t = '%s×%s×%s m' % (utils.fmt_length(mparams['dimensionX']),
                                 utils.fmt_length(mparams['dimensionY']),
                                 utils.fmt_length(mparams['dimensionZ']))
-            self.draw_property(box, 'Size:', t)
+            self.draw_property(box, 'Size', t)
         if self.asset_data.get('filesSize'):
             fs = self.asset_data['filesSize']
             fsmb = fs // (1024 * 1024)
             fskb = fs % 1024
             if fsmb == 0:
-                self.draw_property(box, 'Original size:', f'{fskb}KB')
+                self.draw_property(box, 'Original size', f'{fskb} KB')
             else:
-                self.draw_property(box, 'Original size:', f'{fsmb}MB')
+                self.draw_property(box, 'Original size', f'{fsmb} MB')
         # Tags section
         # row = box.row()
         # letters_on_row = 0
@@ -1595,25 +1601,26 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
         plans_link = 'https://www.blenderkit.com/plans/pricing/'
         if self.asset_data['isPrivate']:
             t = 'Private'
-            self.draw_property(box, 'Access:', t, icon='LOCKED')
+            self.draw_property(box, 'Access', t, icon='LOCKED')
         elif self.asset_data['isFree']:
             t = 'Free plan'
             icon = pcoll['free']
-            self.draw_property(box, 'Access:', t,
+            self.draw_property(box, 'Access', t,
                                icon_value=icon.icon_id,
                                tooltip=plans_tooltip,
                                url=plans_link)
         else:
             t = 'Full plan'
             icon = pcoll['full']
-            self.draw_property(box, 'Access:', t,
+            self.draw_property(box, 'Access', t,
                                icon_value=icon.icon_id,
                                tooltip=plans_tooltip,
                                url=plans_link)
         if utils.profile_is_validator():
             date = self.asset_data['created'][:10]
             date = f"{date[8:10]}. {date[5:7]}. {date[:4]}"
-            self.draw_property(box, 'Created:', date)
+            self.draw_property(box, 'Created', date)
+        box.separator()
 
     def draw_author_area(self, context, layout, width=330):
         self.draw_author(context, layout, width=width)
@@ -1631,7 +1638,7 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
             author_box.label(text='Author')  # just one extra line to give spacing
             if hasattr(self, 'gimg'):
 
-                author_left = author_box.split(factor=0.25)
+                author_left = author_box.split(factor=image_split)
                 author_left.template_icon(icon_value=self.gimg.preview.icon_id, scale=7)
                 text_area = author_left.split()
                 text_width = int(text_width * (1 - image_split))
@@ -1673,13 +1680,13 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
             op.keywords = ''
             op.author_id = self.asset_data['author']['id']
 
-    def draw_thumbnail_box(self, layout, wi

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list