BlenderKit: fix quadview + drag cancelation when leaving active area.

This commit is contained in:
Vilém Duha 2019-08-12 15:54:47 +02:00
parent e7ae2e8582
commit 65812c69cc
1 changed files with 20 additions and 13 deletions

View File

@ -602,9 +602,9 @@ def draw_callback_2d(self, context):
# self.area might throw error just by itself.
a1 = self.area
go = True
if len(a.spaces[0].region_quadviews)>0:
# print(dir(bpy.context.region_data))
#print('quad', a.spaces[0].region_3d, a.spaces[0].region_quadviews[0])
if len(a.spaces[0].region_quadviews) > 0:
# print(dir(bpy.context.region_data))
# print('quad', a.spaces[0].region_3d, a.spaces[0].region_quadviews[0])
if a.spaces[0].region_3d != context.region_data:
go = False
except:
@ -980,7 +980,7 @@ def is_rating_possible():
return True, rated, b, ad
if ao is not None:
ad = None
#crawl parents to reach active asset. there could have been parenting so we need to find the first onw
# crawl parents to reach active asset. there could have been parenting so we need to find the first onw
ao_check = ao
while ad is None or (ad is None and ao_check.parent is not None):
ad = ao_check.get('asset_data')
@ -993,7 +993,6 @@ def is_rating_possible():
else:
break;
# check also materials
m = ao.active_material
if m is not None:
@ -1134,7 +1133,7 @@ def update_ui_size(area, region):
(ui.bar_width - 2 * ui.drawoffset) / (ui.thumb_size + ui.margin))
search_results = bpy.context.scene.get('search results')
if search_results != None and ui.wcount>0:
if search_results != None and ui.wcount > 0:
ui.hcount = min(user_preferences.max_assetbar_rows, math.ceil(len(search_results) / ui.wcount))
else:
ui.hcount = 1
@ -1194,20 +1193,20 @@ class AssetBarOperator(bpy.types.Operator):
areas = []
for w in context.window_manager.windows:
areas.extend(w.screen.areas)
if bpy.context.scene != self.scene:
self.exit_modal()
ui_props.assetbar_on = False
return {'CANCELLED'}
if self.area not in areas or self.area.type != 'VIEW_3D':
# print('search areas')
for w in context.window_manager.windows:
areas.extend(w.screen.areas)
if self.area not in areas or self.area.type != 'VIEW_3D' or self.has_quad_views != (
len(self.area.spaces[0].region_quadviews) > 0):
# print('search areas') bpy.context.area.spaces[0].region_quadviews
# stopping here model by now - because of:
# switching layouts or maximizing area now fails to assign new area throwing the bug
# internal error: modal gizmo-map handler has invalid area
self.exit_modal()
ui_props.assetbar_on = False
return {'CANCELLED'}
newarea = None
@ -1234,6 +1233,7 @@ class AssetBarOperator(bpy.types.Operator):
bg_blender.bg_update()
if context.region != self.region:
print(time.time(), 'pass trough because of region')
return {'PASS_THROUGH'}
# this was here to check if sculpt stroke is running, but obviously that didn't help,
@ -1349,10 +1349,16 @@ class AssetBarOperator(bpy.types.Operator):
ui_props.dragging = True
ui_props.drag_init = False
if not (ui_props.dragging and mouse_in_region(r, mx, my)) and not mouse_in_asset_bar(mx, my):
if not (ui_props.dragging and mouse_in_region(r, mx, my)) and not mouse_in_asset_bar(mx, my): #
ui_props.dragging = False
ui_props.has_hit = False
ui_props.active_index = -3
ui_props.draw_drag_image = False
ui_props.draw_snapped_bounds = False
ui_props.draw_tooltip = False
bpy.context.window.cursor_set("DEFAULT")
print('out of region')
return {'PASS_THROUGH'}
sr = bpy.context.scene['search results']
@ -1635,6 +1641,7 @@ class AssetBarOperator(bpy.types.Operator):
args = (self, context)
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:
if r.type == 'WINDOW':