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>2020-02-07 01:11:48 +0300
committerVilém Duha <vilda.novak@gmail.com>2020-02-07 01:11:48 +0300
commit538e48dd9121f8ca98cdeb2c8d4dd81bb70ece39 (patch)
tree9cda1f2b60fbc698b303fc6795a16a10a10ba708
parent8b659917baecbea5471a05369aa754ae544a814b (diff)
BlenderKit: fix occasional crash during reordering.
It was caused with order of unregistration, now UI panels go first. also separated advanced search panel
-rw-r--r--blenderkit/__init__.py6
-rw-r--r--blenderkit/search.py2
-rw-r--r--blenderkit/ui.py27
-rw-r--r--blenderkit/ui_panels.py64
-rw-r--r--blenderkit/utils.py2
5 files changed, 86 insertions, 15 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index bf0ec328..82361f6e 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -400,7 +400,7 @@ class BlenderKitCommonSearchProps(object):
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",
- default=False)
+ default=False, update=search.search_update)
search_advanced: BoolProperty(name="Advanced Search Options", description="use advanced search properties",
default=False, update=search.search_update)
@@ -1651,8 +1651,9 @@ def register():
def unregister():
bpy.app.timers.unregister(check_timers_timer)
-
+ ui_panels.unregister_ui_panels()
ui.unregister_ui()
+
icons.unregister_icons()
search.unregister_search()
asset_inspector.unregister_asset_inspector()
@@ -1660,7 +1661,6 @@ def unregister():
upload.unregister_upload()
ratings.unregister_ratings()
autothumb.unregister_thumbnailer()
- ui_panels.unregister_ui_panels()
bg_blender.unregister()
overrides.unregister_overrides()
bkit_oauth.unregister()
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 6eeafcd1..426f2923 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -132,7 +132,7 @@ last_clipboard = ''
@bpy.app.handlers.persistent
-def timer_update(): # TODO might get moved to handle all blenderkit stuff.
+def timer_update():
# this makes a first search after opening blender. showing latest assets.
global first_time
preferences = bpy.context.preferences.addons['blenderkit'].preferences
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index 2101e54b..e51d17ea 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -602,6 +602,9 @@ def draw_tooltip_old(x, y, text='', author='', img=None):
def draw_callback_2d(self, context):
+ if not utils.guard_from_crash():
+ return;
+
a = context.area
w = context.window
try:
@@ -769,6 +772,7 @@ def draw_callback_2d_search(self, context):
ui_props.thumb_size,
img,
1)
+
if search_results_orig['count'] - ui_props.scrolloffset > (ui_props.wcount * ui_props.hcount) + 1:
if ui_props.active_index == -1:
ui_bgl.draw_rect(ui_props.bar_x + ui_props.bar_width - 25,
@@ -782,6 +786,7 @@ def draw_callback_2d_search(self, context):
for b in range(0, h_draw):
w_draw = min(ui_props.wcount, len(search_results) - b * ui_props.wcount - ui_props.scrolloffset)
+
y = ui_props.bar_y - (b + 1) * (row_height)
for a in range(0, w_draw):
x = ui_props.bar_x + a * (
@@ -896,7 +901,6 @@ def draw_callback_2d_search(self, context):
ui_props.mouse_y - linelength, 2, white)
-
def draw_callback_3d(self, context):
''' Draw snapped bbox while dragging and in the future other blenderkit related stuff. '''
if not utils.guard_from_crash():
@@ -1110,8 +1114,15 @@ def mouse_in_area(mx, my, x, y, w, h):
def mouse_in_asset_bar(mx, my):
+ s = bpy.context.scene
+
ui_props = bpy.context.scene.blenderkitUI
+ w_draw1 = min(ui_props.wcount + 1, len(search_results) - b * ui_props.wcount - ui_props.scrolloffset)
+ end = ui_props.bar_x + (w_draw1) * (
+ ui_props.margin + ui_props.thumb_size) + ui_props.margin + ui_props.drawoffset + 25
+ ui_bgl.draw_rect(end, ui_props.bar_y, 50, 50, highlight)
+
if ui_props.bar_y - ui_props.bar_height < my < ui_props.bar_y \
and mx > ui_props.bar_x and mx < ui_props.bar_x + ui_props.bar_width:
return True
@@ -1575,8 +1586,8 @@ class AssetBarOperator(bpy.types.Operator):
else:
# first, test if object can have material applied.
- #TODO add other types here if droppable.
- if object is None or object.is_library_indirect and object.type =='MESH' :
+ # TODO add other types here if droppable.
+ if object is None or object.is_library_indirect and object.type == 'MESH':
target_object = object.name
# create final mesh to extract correct material slot
depsgraph = bpy.context.evaluated_depsgraph_get()
@@ -1725,8 +1736,6 @@ class AssetBarOperator(bpy.types.Operator):
self.area = context.area
self.scene = bpy.context.scene
-
-
self.has_quad_views = len(bpy.context.area.spaces[0].region_quadviews) > 0
for r in self.area.regions:
@@ -1779,7 +1788,7 @@ class UndoWithContext(bpy.types.Operator):
# def modal(self, context, event):
# return {'RUNNING_MODAL'}
- message = StringProperty('Undo Message', default = 'BlenderKit operation')
+ message = StringProperty('Undo Message', default='BlenderKit operation')
def execute(self, context):
C_dict = bpy.context.copy()
@@ -1788,7 +1797,7 @@ class UndoWithContext(bpy.types.Operator):
w, a, r = get_largest_3dview()
override = {'window': w, 'screen': w.screen, 'area': a, 'region': r}
C_dict.update(override)
- bpy.ops.ed.undo_push(C_dict, 'INVOKE_REGION_WIN', message = self.message)
+ bpy.ops.ed.undo_push(C_dict, 'INVOKE_REGION_WIN', message=self.message)
return {'FINISHED'}
@@ -1823,7 +1832,8 @@ classess = (
# store keymap items here to access after registration
addon_keymapitems = []
-#@persistent
+
+# @persistent
def pre_load(context):
ui_props = bpy.context.scene.blenderkitUI
ui_props.assetbar_on = False
@@ -1832,7 +1842,6 @@ def pre_load(context):
preferences.login_attempt = False
-
def register_ui():
global handler_2d, handler_3d
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 3dabbe68..e9727d0e 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -672,6 +672,67 @@ def draw_login_buttons(layout):
icon='URL')
+class VIEW3D_PT_blenderkit_advanced_model_search(Panel):
+ bl_category = "BlenderKit"
+ bl_idname = "VIEW3D_PT_blenderkit_advanced_model_search"
+ # bl_parent_id = "VIEW3D_PT_blenderkit_unified"
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'UI'
+ bl_label = "Advanced search options"
+
+ @classmethod
+ def poll(cls, context):
+ return True
+
+ def draw(self, context):
+ s = context.scene
+
+ props = s.blenderkit_models
+ layout = self.layout
+ layout.separator()
+
+ # layout.label(text = "common searches keywords:")
+ # layout.prop(props, "search_global_keywords", text = "")
+ # layout.prop(props, "search_modifier_keywords")
+ # if props.search_engine == 'OTHER':
+ # layout.prop(props, "search_engine_keyword")
+
+ # AGE
+ layout.prop(props, "search_condition", text='Condition') # , text ='condition of object new/old e.t.c.')
+
+ # DESIGN YEAR
+ layout.prop(props, "search_design_year", text='designed in ( min - max )')
+ if props.search_design_year:
+ row = layout.row(align=True)
+ row.prop(props, "search_design_year_min", text='min')
+ row.prop(props, "search_design_year_max", text='max')
+
+ # POLYCOUNT
+ layout.prop(props, "search_polycount", text='Poly count in ( min - max )')
+ if props.search_polycount:
+ row = layout.row(align=True)
+ row.prop(props, "search_polycount_min", text='min')
+ row.prop(props, "search_polycount_max", text='max')
+
+ # TEXTURE RESOLUTION
+ layout.prop(props, "search_texture_resolution", text='texture resolution ( min - max )')
+ if props.search_texture_resolution:
+ row = layout.row(align=True)
+ row.prop(props, "search_texture_resolution_min", text='min')
+ row.prop(props, "search_texture_resolution_max", text='max')
+
+ # FILE SIZE
+ layout.prop(props, "search_file_size", text='File size ( min - max )')
+ if props.search_file_size:
+ row = layout.row(align=True)
+ row.prop(props, "search_file_size_min", text='min')
+ row.prop(props, "search_file_size_max", text='max')
+
+ # layout.prop(props, "search_procedural", expand=True)
+ # ADULT
+ # layout.prop(props, "search_adult") # , text ='condition of object new/old e.t.c.')
+
+
class VIEW3D_PT_blenderkit_unified(Panel):
bl_category = "BlenderKit"
bl_idname = "VIEW3D_PT_blenderkit_unified"
@@ -1085,6 +1146,7 @@ classess = (
VIEW3D_PT_blenderkit_profile,
VIEW3D_PT_blenderkit_login,
VIEW3D_PT_blenderkit_unified,
+ # VIEW3D_PT_blenderkit_advanced_model_search,
VIEW3D_PT_blenderkit_model_properties,
VIEW3D_PT_blenderkit_downloads,
OBJECT_MT_blenderkit_asset_menu,
@@ -1099,7 +1161,7 @@ def register_ui_panels():
def unregister_ui_panels():
+ bpy.types.VIEW3D_MT_editor_menus.remove(header_search_draw)
for c in classess:
print('unregister', c)
bpy.utils.unregister_class(c)
- bpy.types.VIEW3D_MT_editor_menus.remove(header_search_draw)
diff --git a/blenderkit/utils.py b/blenderkit/utils.py
index 706600ee..fe80e1a0 100644
--- a/blenderkit/utils.py
+++ b/blenderkit/utils.py
@@ -554,7 +554,7 @@ def profile_is_validator():
def guard_from_crash():
'''Blender tends to crash when trying to run some functions with the addon going through unregistration process.'''
- if bpy.context.preferences.addons['blenderkit'] is None:
+ if bpy.context.preferences.addons.get('blenderkit') is None:
return False;
if bpy.context.preferences.addons['blenderkit'].preferences is None:
return False;