UI: Asset Shelf (Experimental Feature) #104831
|
@ -85,8 +85,9 @@ class AbstractView {
|
|||
virtual bool listen(const wmNotifier &) const;
|
||||
|
||||
/**
|
||||
* Enable filtering (typically triggered on Ctrl+F).
|
||||
* \return True when filtering was begun successfully.
|
||||
* Enable filtering. Typically used to enable a filter text button. Triggered on Ctrl+F by
|
||||
* default.
|
||||
* \return True when filtering was enabled successfully.
|
||||
*/
|
||||
virtual bool begin_filtering(const bContext &C) const;
|
||||
|
||||
|
|
|
@ -3269,6 +3269,11 @@ void UI_interface_tag_script_reload(void);
|
|||
/* Support click-drag motion which presses the button and closes a popover (like a menu). */
|
||||
#define USE_UI_POPOVER_ONCE
|
||||
|
||||
/**
|
||||
* Call the #ui::AbstractView::begin_filtering() function of the view to enable filtering.
|
||||
* Typically used to enable a filter text button. Triggered on Ctrl+F by default.
|
||||
* \return True when filtering was enabled successfully.
|
||||
*/
|
||||
bool UI_view_begin_filtering(const struct bContext *C, const uiViewHandle *view_handle);
|
||||
|
||||
bool UI_view_item_is_interactive(const uiViewItemHandle *item_handle);
|
||||
|
|
|
@ -2346,42 +2346,27 @@ static void UI_OT_list_start_filter(wmOperatorType *ot)
|
|||
/** \name UI View Start Filter Operator
|
||||
* \{ */
|
||||
|
||||
static int ui_view_start_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
static bool ui_view_focused_poll(bContext *C)
|
||||
{
|
||||
|
||||
ARegion *region;
|
||||
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "region_type");
|
||||
if (RNA_property_is_set(op->ptr, prop)) {
|
||||
region = BKE_area_find_region_type(CTX_wm_area(C), RNA_property_enum_get(op->ptr, prop));
|
||||
}
|
||||
else {
|
||||
region = CTX_wm_region(C);
|
||||
}
|
||||
|
||||
const ARegion *region = CTX_wm_region(C);
|
||||
if (!region) {
|
||||
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
|
||||
return false;
|
||||
}
|
||||
const wmWindow *win = CTX_wm_window(C);
|
||||
const uiViewHandle *view = UI_region_view_find_at(region, win->eventstate->xy, 0);
|
||||
|
||||
/* Hovered view gets priority. */
|
||||
return view != nullptr;
|
||||
}
|
||||
|
||||
static int ui_view_start_filter_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
|
||||
{
|
||||
const ARegion *region = CTX_wm_region(C);
|
||||
const uiViewHandle *hovered_view = UI_region_view_find_at(region, event->xy, 0);
|
||||
if (hovered_view && UI_view_begin_filtering(C, hovered_view)) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
bool filtering_started = false;
|
||||
UI_region_views_foreach(region, [C, &filtering_started](const uiViewHandle &view) {
|
||||
if (UI_view_begin_filtering(C, &view)) {
|
||||
filtering_started = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
if (!filtering_started) {
|
||||
if (!UI_view_begin_filtering(C, hovered_view)) {
|
||||
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -2392,18 +2377,9 @@ static void UI_OT_view_start_filter(wmOperatorType *ot)
|
|||
ot->description = "Start entering filter text for the data-set in focus";
|
||||
|
||||
ot->invoke = ui_view_start_filter_invoke;
|
||||
ot->poll = ED_operator_areaactive;
|
||||
ot->poll = ui_view_focused_poll;
|
||||
|
||||
ot->flag = OPTYPE_INTERNAL;
|
||||
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_enum(ot->srna,
|
||||
"region_type",
|
||||
rna_enum_region_type_items,
|
||||
0,
|
||||
"Region Type",
|
||||
"Override the region to look for the search button in");
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
Loading…
Reference in New Issue