Skip to content

Commit

Permalink
BlenderKit: show categories and filters in header search UI
Browse files Browse the repository at this point in the history
Use hand curor over asset bar
  • Loading branch information
vilemduha committed Jul 13, 2021
1 parent 4ecb089 commit 7e441a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 11 additions & 1 deletion blenderkit/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,7 @@ def modal(self, context, event):
self.area.tag_redraw()
s = context.scene


if ui_props.turn_off:
ui_props.turn_off = False
self.exit_modal()
Expand Down Expand Up @@ -1301,6 +1302,7 @@ def modal(self, context, event):
return {'PASS_THROUGH'}
if len(sr) - ui_props.scrolloffset < (ui_props.wcount * ui_props.hcount) + 10:
self.search_more()

if event.type == 'WHEELUPMOUSE' or event.type == 'WHEELDOWNMOUSE' or event.type == 'TRACKPADPAN':
# scrolling
mx = event.mouse_region_x
Expand Down Expand Up @@ -1354,7 +1356,7 @@ def modal(self, context, event):
sr = bpy.context.window_manager['search results']

if not ui_props.dragging:
bpy.context.window.cursor_set("DEFAULT")
bpy.context.window.cursor_set("HAND")

if sr != None and ui_props.wcount * ui_props.hcount > len(sr) and ui_props.scrolloffset > 0:
ui_props.scrolloffset = 0
Expand Down Expand Up @@ -1802,6 +1804,8 @@ def modal(self, context, event):
if event.type in {'RIGHTMOUSE', 'ESC'} or \
not mouse_in_region(context.region, self.mouse_x, self.mouse_y):
self.handlers_remove()
bpy.context.window.cursor_set("DEFAULT")

return {'CANCELLED'}

sprops = bpy.context.scene.blenderkit_models
Expand Down Expand Up @@ -1833,7 +1837,10 @@ def modal(self, context, event):
if event.type == 'LEFTMOUSE' and event.value == 'RELEASE':
self.mouse_release()# does the main job with assets
self.handlers_remove()
bpy.context.window.cursor_set("DEFAULT")

bpy.ops.object.run_assetbar_fix_context(keep_running = True, do_search = False)

return {'FINISHED'}
self.steps +=1

Expand Down Expand Up @@ -1877,6 +1884,9 @@ def invoke(self, context, event):
self._handle_3d = bpy.types.SpaceView3D.draw_handler_add(draw_callback_3d_dragging, args, 'WINDOW',
'POST_VIEW')
context.window_manager.modal_handler_add(self)

bpy.context.window.cursor_set("NONE")

return {'RUNNING_MODAL'}
else:
self.report({'WARNING'}, "View3D not found, cannot run operator")
Expand Down
5 changes: 5 additions & 0 deletions blenderkit/ui_panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2201,6 +2201,11 @@ def header_search_draw(self, context):
layout.prop(ui_props, "asset_type", expand=True, icon_only=True, text='', icon='URL')
layout.prop(props, "search_keywords", text="", icon='VIEWZOOM')
draw_assetbar_show_hide(layout, props)
layout.popover(panel="VIEW3D_PT_blenderkit_categories", text="", icon = 'OUTLINER')
if ui_props.asset_type=='MODEL':
layout.popover(panel="VIEW3D_PT_blenderkit_advanced_model_search", text="", icon = 'FILTER')
elif ui_props.asset_type=='MATERIAL':
layout.popover(panel="VIEW3D_PT_blenderkit_advanced_material_search", text="", icon = 'FILTER')


def ui_message(title, message):
Expand Down

0 comments on commit 7e441a7

Please sign in to comment.