BlenderKit: make it clear when a filter is used

this required a new icon for filters and an update function.
This commit is contained in:
Vilem Duha 2021-07-23 15:09:17 +02:00
parent 0a34d11883
commit 7ebbe0f309
8 changed files with 40 additions and 9 deletions

View File

@ -459,8 +459,8 @@ class BlenderKitCommonSearchProps(object):
default=False)
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)
use_filters: BoolProperty(name="Filters are on", description="some filters are used",
default=False)
search_error: BoolProperty(name="Search Error", description="last search had an error", default=False)
report: StringProperty(
@ -574,6 +574,7 @@ class BlenderKitCommonSearchProps(object):
default=0, min=0, max=10, update=search.search_update)
def name_update(self, context):
''' checks for name change, because it decides if whole asset has to be re-uploaded. Name is stored in the blend file
and that's the reason.'''

View File

@ -605,7 +605,7 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator):
self.scroll_offset = min(self.scroll_offset, len(sr) - (self.wcount * self.hcount))
self.scroll_offset = max(self.scroll_offset, 0)
self.update_images()
if len(sr) - self.scroll_offset < (self.wcount * self.hcount) + 10:
if len(sr) - self.scroll_offset < (self.wcount * self.hcount) + 15:
self.search_more()
def search_by_author(self, asset_index):

View File

@ -31,6 +31,8 @@ icons_read = {
'dumbbell.png': 'dumbbell',
'cc0.png': 'cc0',
'royalty_free.png': 'royalty_free',
'filter.png': 'filter',
'filter_active.png': 'filter_active',
}
verification_icons = {

View File

@ -1083,7 +1083,7 @@ def build_query_common(query, props):
if props.quality_limit > 0:
query["quality_gte"] = props.quality_limit
query.update(query_common)
@ -1106,7 +1106,6 @@ def build_query_model():
# if props.free_only:
# query["is_free"] = True
# if props.search_advanced:
if props.search_condition != 'UNSPECIFIED':
query["condition"] = props.search_condition
@ -1387,7 +1386,7 @@ def search(category='', get_next=False, author_id=''):
# utils.p('searching')
props.is_searching = True
page_size = min(40, ui_props.wcount * user_preferences.max_assetbar_rows)
page_size = min(30, ui_props.wcount * user_preferences.max_assetbar_rows)
params = {
'scene_uuid': bpy.context.scene.get('uuid', None),
@ -1406,10 +1405,30 @@ def search(category='', get_next=False, author_id=''):
props.report = 'BlenderKit searching....'
def update_filters():
sprops = utils.get_search_props()
ui_props = bpy.context.scene.blenderkitUI
fcommon = sprops.own_only or \
sprops.search_texture_resolution or\
sprops.search_file_size or \
sprops.search_procedural != 'BOTH' or \
sprops.free_only or \
sprops.quality_limit>0
if ui_props.asset_type =='MODEL':
sprops.use_filters = fcommon or \
sprops.search_style != 'ANY' or \
sprops.search_condition != 'UNSPECIFIED' or \
sprops.search_design_year or \
sprops.search_polycount
elif ui_props.asset_type == 'MATERIAL':
sprops.use_filters = fcommon
def search_update(self, context):
utils.p('search updater')
# if self.search_keywords != '':
update_filters()
ui_props = bpy.context.scene.blenderkitUI
if ui_props.down_up != 'SEARCH':
ui_props.down_up = 'SEARCH'

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

View File

@ -1298,7 +1298,7 @@ class AssetBarOperator(bpy.types.Operator):
# If there aren't any results, we need no interaction(yet)
if sr is None:
return {'PASS_THROUGH'}
if len(sr) - ui_props.scrolloffset < (ui_props.wcount * user_preferences.max_assetbar_rows) + 10:
if len(sr) - ui_props.scrolloffset < (ui_props.wcount * user_preferences.max_assetbar_rows) + 15:
self.search_more()
if event.type == 'WHEELUPMOUSE' or event.type == 'WHEELDOWNMOUSE' or event.type == 'TRACKPADPAN':

View File

@ -2205,10 +2205,19 @@ def header_search_draw(self, context):
layout.prop(props, "search_keywords", text="", icon='VIEWZOOM')
draw_assetbar_show_hide(layout, props)
layout.popover(panel="VIEW3D_PT_blenderkit_categories", text="", icon = 'OUTLINER')
pcoll = icons.icon_collections["main"]
if props.use_filters:
icon_id = pcoll['filter_active'].icon_id
else:
icon_id = pcoll['filter'].icon_id
if ui_props.asset_type=='MODEL':
layout.popover(panel="VIEW3D_PT_blenderkit_advanced_model_search", text="", icon = 'FILTER')
layout.popover(panel="VIEW3D_PT_blenderkit_advanced_model_search", text="", icon_value = icon_id)
elif ui_props.asset_type=='MATERIAL':
layout.popover(panel="VIEW3D_PT_blenderkit_advanced_material_search", text="", icon = 'FILTER')
layout.popover(panel="VIEW3D_PT_blenderkit_advanced_material_search", text="", icon_value = icon_id)
def ui_message(title, message):