[Bf-extensions-cvs] [c9646992] blender-v2.82-release: BlenderKit: several more UI fixes

Vilém Duha noreply at git.blender.org
Mon Jan 13 10:36:55 CET 2020


Commit: c96469928a3b0f6db6c31e183481f68b5d35c050
Author: Vilém Duha
Date:   Fri Jan 10 20:27:11 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rBAc96469928a3b0f6db6c31e183481f68b5d35c050

BlenderKit: several more UI fixes

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

M	blenderkit/search.py
M	blenderkit/ui_panels.py

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

diff --git a/blenderkit/search.py b/blenderkit/search.py
index 9923610f..b612cf41 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -327,15 +327,24 @@ def split_subs(text, threshold=40):
     # temporarily disable this, to be able to do this in drawing code
 
     text = text.rstrip()
+    text = text.replace('\r\n', '\n')
+
     lines = []
 
     while len(text) > threshold:
-        i = text.rfind(' ', 0, threshold)
-        i1 = text.rfind(',', 0, threshold)
-        i2 = text.rfind('.', 0, threshold)
-        i = max(i, i1, i2)
-        if i <= 0:
-            i = threshold
+        #first handle if there's an \n line ending
+        i_rn = text.find('\n')
+        print(i_rn)
+        if 1 < i_rn < threshold:
+            i = i_rn
+            text = text.replace('\n','',1)
+        else:
+            i = text.rfind(' ', 0, threshold)
+            i1 = text.rfind(',', 0, threshold)
+            i2 = text.rfind('.', 0, threshold)
+            i = max(i, i1, i2)
+            if i <= 0:
+                i = threshold
         lines.append(text[:i])
         text = text[i:]
     lines.append(text)
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 44bd4d2e..ed6c993b 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -768,16 +768,17 @@ class OBJECT_MT_blenderkit_asset_menu(bpy.types.Menu):
         op = layout.operator('view3d.blenderkit_search', text='Search Similar')
         op.keywords = asset_data['name'] + ' ' + asset_data['description'] + ' ' + ' '.join(asset_data['tags'])
 
-        if bpy.context.view_layer.objects.active is not None and ui_props.asset_type == 'MODEL':
-            aob = bpy.context.active_object
-            op = layout.operator('scene.blenderkit_download', text='Replace Active Models')
-            op.asset_type = ui_props.asset_type
-            op.asset_index = ui_props.active_index
-            op.model_location = aob.location
-            op.model_rotation = aob.rotation_euler
-            op.target_object = aob.name
-            op.material_target_slot = aob.active_material_index
-            op.replace = True
+        if asset_data['can_download']:
+            if bpy.context.view_layer.objects.active is not None and ui_props.asset_type == 'MODEL':
+                aob = bpy.context.active_object
+                op = layout.operator('scene.blenderkit_download', text='Replace Active Models')
+                op.asset_type = ui_props.asset_type
+                op.asset_index = ui_props.active_index
+                op.model_location = aob.location
+                op.model_rotation = aob.rotation_euler
+                op.target_object = aob.name
+                op.material_target_slot = aob.active_material_index
+                op.replace = True
 
         wm = bpy.context.window_manager
         profile = wm.get('bkit profile')
@@ -870,6 +871,7 @@ class UrlPopupDialog(bpy.types.Operator):
         layout = self.layout
         label_multiline(layout, text=self.message)
 
+        layout.active_default = True
         op = layout.operator("wm.url_open", text=self.link_text, icon='QUESTION')
         op.url = self.url



More information about the Bf-extensions-cvs mailing list