BlenderKit: enable new asset bar
This commit is contained in:
parent
7c099b03e4
commit
68ab11bdb0
|
@ -61,6 +61,7 @@ if "bpy" in locals():
|
|||
upload_bg = reload(upload_bg)
|
||||
utils = reload(utils)
|
||||
|
||||
bl_ui_label = reload(bl_ui_widget)
|
||||
bl_ui_label = reload(bl_ui_label)
|
||||
bl_ui_button = reload(bl_ui_button)
|
||||
# bl_ui_checkbox = reload(bl_ui_checkbox)
|
||||
|
@ -98,13 +99,14 @@ else:
|
|||
from blenderkit import upload_bg
|
||||
from blenderkit import utils
|
||||
|
||||
from blenderkit.bl_ui_widgets import bl_ui_widget
|
||||
from blenderkit.bl_ui_widgets import bl_ui_label
|
||||
from blenderkit.bl_ui_widgets import bl_ui_button
|
||||
# from blenderkit.bl_ui_widgets import bl_ui_checkbox
|
||||
# from blenderkit.bl_ui_widgets import bl_ui_slider
|
||||
# from blenderkit.bl_ui_widgets import bl_ui_up_down
|
||||
from blenderkit.bl_ui_widgets import bl_ui_drag_panel
|
||||
from blenderkit.bl_ui_widgets import bl_ui_draw_op
|
||||
from blenderkit.bl_ui_widgets import bl_ui_drag_panel
|
||||
# from blenderkit.bl_ui_widgets import bl_ui_textbox
|
||||
|
||||
import os
|
||||
|
@ -268,6 +270,10 @@ def switch_search_results(self, context):
|
|||
if not (context.sculpt_object or context.image_paint_object):
|
||||
ui.add_report(
|
||||
'Switch to paint or sculpt mode to search in BlenderKit brushes.')
|
||||
# if wm['search results'] == None:
|
||||
# wm['search results'] = []
|
||||
# if wm['search results orig'] == None:
|
||||
# wm['search results orig'] = {'count': 0, 'results': []}
|
||||
|
||||
search.load_previews()
|
||||
if wm['search results'] == None and props.down_up == 'SEARCH':
|
||||
|
|
|
@ -247,10 +247,16 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator):
|
|||
w.visible = True
|
||||
|
||||
def check_new_search_results(self, context):
|
||||
sr = bpy.context.window_manager.get('search results',[])
|
||||
sr = bpy.context.window_manager.get('search results')
|
||||
if not hasattr(self, 'search_results_count'):
|
||||
if not sr:
|
||||
self.search_results_count = 0
|
||||
return True
|
||||
|
||||
self.search_results_count = len(sr)
|
||||
if len(sr)!= self.search_results_count:
|
||||
print(sr, len(sr), self.search_results_count)
|
||||
|
||||
if sr is not None and len(sr)!= self.search_results_count:
|
||||
self.search_results_count = len(sr)
|
||||
return True
|
||||
return False
|
||||
|
@ -373,7 +379,6 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator):
|
|||
new_button.set_mouse_enter(self.enter_button)
|
||||
new_button.set_mouse_exit(self.exit_button)
|
||||
new_button.text_input = self.handle_key_input
|
||||
self.asset_buttons.append(new_button)
|
||||
# add validation icon to button
|
||||
icon_size = 24
|
||||
validation_icon = BL_UI_Button(asset_x + self.button_size - icon_size - self.margin,
|
||||
|
@ -403,15 +408,17 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator):
|
|||
self.panel.bg_color = (0.0, 0.0, 0.0, 0.5)
|
||||
|
||||
sr = bpy.context.window_manager.get('search results', [])
|
||||
for a in range(0, self.wcount):
|
||||
for b in range(0, self.hcount):
|
||||
if sr is not None:
|
||||
for a in range(0, self.wcount):
|
||||
for b in range(0, self.hcount):
|
||||
|
||||
asset_x = self.assetbar_margin + a * (self.button_size)
|
||||
asset_y = self.assetbar_margin + b * (self.button_size)
|
||||
button_idx = a + b * self.wcount
|
||||
asset_idx = a + b * self.wcount + self.scroll_offset
|
||||
if asset_idx < len(sr):
|
||||
new_button = self.asset_button_init(asset_x, asset_y, button_idx)
|
||||
asset_x = self.assetbar_margin + a * (self.button_size)
|
||||
asset_y = self.assetbar_margin + b * (self.button_size)
|
||||
button_idx = a + b * self.wcount
|
||||
asset_idx = a + b * self.wcount + self.scroll_offset
|
||||
if asset_idx < len(sr):
|
||||
new_button = self.asset_button_init(asset_x, asset_y, button_idx)
|
||||
self.asset_buttons.append(new_button)
|
||||
|
||||
other_button_size = 30
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ class BL_UI_OT_draw_operator(Operator):
|
|||
result = False
|
||||
for widget in self.widgets:
|
||||
if widget.handle_event(event):
|
||||
print(type(widget))
|
||||
result = True
|
||||
return result
|
||||
|
||||
|
|
|
@ -88,6 +88,8 @@ class BL_UI_Widget:
|
|||
self.batch_panel = batch_for_shader(self.shader, 'TRIS', {"pos" : vertices}, indices=indices)
|
||||
|
||||
def handle_event(self, event):
|
||||
if not self._is_visible:
|
||||
return False
|
||||
x = event.mouse_region_x
|
||||
y = event.mouse_region_y
|
||||
|
||||
|
@ -100,6 +102,7 @@ class BL_UI_Widget:
|
|||
self.mouse_up(x, y)
|
||||
|
||||
elif (event.type == 'RIGHTMOUSE'):
|
||||
|
||||
if (event.value == 'PRESS'):
|
||||
self._mouse_down_right = True
|
||||
return self.mouse_down_right(x, y)
|
||||
|
@ -109,7 +112,6 @@ class BL_UI_Widget:
|
|||
|
||||
elif (event.type == 'MOUSEMOVE'):
|
||||
self.mouse_move(x, y)
|
||||
|
||||
inrect = self.is_in_rect(x, y)
|
||||
|
||||
# we enter the rect
|
||||
|
@ -125,6 +127,7 @@ class BL_UI_Widget:
|
|||
return False
|
||||
|
||||
elif event.value == 'PRESS' and (event.ascii != '' or event.type in self.get_input_keys()):
|
||||
|
||||
return self.text_input(event)
|
||||
|
||||
return False
|
||||
|
@ -143,6 +146,10 @@ class BL_UI_Widget:
|
|||
(self.x_screen <= x <= (self.x_screen + self.width)) and
|
||||
(widget_y >= y >= (widget_y - self.height))
|
||||
):
|
||||
print('is in rect!?')
|
||||
print('area height', area_height)
|
||||
print ('x sceen ',self.x_screen,'x ', x, 'width', self.width)
|
||||
print ('widghet y', widget_y,'y', y, 'height',self.height)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
|
|
@ -1704,7 +1704,6 @@ class AssetDragOperator(bpy.types.Operator):
|
|||
|
||||
if not object:
|
||||
return
|
||||
print('insta', object.is_from_instancer)
|
||||
if object.is_library_indirect:
|
||||
ui_panels.ui_message(title='This object is linked from outer file',
|
||||
message="Please select the model,"
|
||||
|
@ -1904,7 +1903,7 @@ class RunAssetBarWithContext(bpy.types.Operator):
|
|||
C_dict = utils.get_fake_context(context)
|
||||
if C_dict.get('window'): # no 3d view, no asset bar.
|
||||
preferences = bpy.context.preferences.addons['blenderkit'].preferences
|
||||
if preferences.experimental_features:
|
||||
if preferences.experimental_features or 1:
|
||||
bpy.ops.view3d.blenderkit_asset_bar_widget(C_dict, 'INVOKE_REGION_WIN', keep_running=self.keep_running,
|
||||
do_search=self.do_search)
|
||||
|
||||
|
|
|
@ -334,17 +334,13 @@ def draw_assetbar_show_hide(layout, props):
|
|||
ttip = 'Click to Show Asset Bar'
|
||||
|
||||
preferences = bpy.context.preferences.addons['blenderkit'].preferences
|
||||
if preferences.experimental_features:
|
||||
if preferences.experimental_features or 1:
|
||||
op = layout.operator('view3d.blenderkit_asset_bar_widget', text='', icon=icon)
|
||||
op.keep_running = False
|
||||
op.do_search = False
|
||||
op.tooltip = ttip
|
||||
else:
|
||||
op = layout.operator('view3d.blenderkit_asset_bar', text='', icon=icon)
|
||||
op.keep_running = False
|
||||
op.do_search = False
|
||||
|
||||
op.tooltip = ttip
|
||||
op.keep_running = False
|
||||
op.do_search = False
|
||||
op.tooltip = ttip
|
||||
|
||||
|
||||
def draw_panel_model_search(self, context):
|
||||
|
@ -2236,14 +2232,14 @@ def draw_panel_categories(self, context):
|
|||
ctext = '%s (%i)' % (c['name'], c['assetCount'])
|
||||
|
||||
preferences = bpy.context.preferences.addons['blenderkit'].preferences
|
||||
if preferences.experimental_features:
|
||||
if preferences.experimental_features or 1:
|
||||
op = row.operator('view3d.blenderkit_asset_bar_widget', text=ctext)
|
||||
else:
|
||||
op = row.operator('view3d.blenderkit_asset_bar', text=ctext)
|
||||
op.do_search = True
|
||||
op.keep_running = True
|
||||
op.tooltip = f"Browse {c['name']} category"
|
||||
op.category = c['slug']
|
||||
op.do_search = True
|
||||
op.keep_running = True
|
||||
op.tooltip = f"Browse {c['name']} category"
|
||||
op.category = c['slug']
|
||||
if len(c['children']) > 0 and c['assetCount'] > 15 or (
|
||||
utils.profile_is_validator() and user_preferences.categories_fix):
|
||||
# row = row.split()
|
||||
|
|
Loading…
Reference in New Issue