UI: Tree View: Click select operator
Part of !138979 With that, it is now possible to configure specific key for selection in tree view. Pull Request: https://projects.blender.org/blender/blender/pulls/140033
This commit is contained in:
committed by
Pratik Borhade
parent
0571b66566
commit
a7b4137f3e
@@ -1042,6 +1042,7 @@ def km_user_interface(_params):
|
||||
("ui.view_scroll", {"type": 'WHEELUPMOUSE', "value": 'ANY'}, None),
|
||||
("ui.view_scroll", {"type": 'WHEELDOWNMOUSE', "value": 'ANY'}, None),
|
||||
("ui.view_scroll", {"type": 'TRACKPADPAN', "value": 'ANY'}, None),
|
||||
("ui.view_item_select", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
|
||||
])
|
||||
|
||||
return keymap
|
||||
|
||||
@@ -420,6 +420,7 @@ def km_user_interface(params):
|
||||
("anim.driver_button_remove", {"type": 'D', "value": 'PRESS', "alt": True}, None),
|
||||
("anim.keyingset_button_add", {"type": 'K', "value": 'PRESS'}, None),
|
||||
("anim.keyingset_button_remove", {"type": 'K', "value": 'PRESS', "alt": True}, None),
|
||||
("ui.view_item_select", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
|
||||
])
|
||||
|
||||
return keymap
|
||||
|
||||
@@ -61,7 +61,6 @@ class AbstractGridViewItem : public AbstractViewItem {
|
||||
virtual std::unique_ptr<GridViewItemDropTarget> create_drop_target();
|
||||
|
||||
private:
|
||||
static void grid_tile_click_fn(bContext *, void *but_arg1, void *);
|
||||
void add_grid_tile_button(uiBlock &block);
|
||||
};
|
||||
|
||||
|
||||
@@ -324,7 +324,6 @@ class AbstractTreeViewItem : public AbstractViewItem, public TreeViewItemContain
|
||||
void ensure_parents_uncollapsed();
|
||||
|
||||
private:
|
||||
static void tree_row_click_fn(bContext *, void *, void *);
|
||||
static void collapse_chevron_click_fn(bContext *, void *but_arg1, void *);
|
||||
|
||||
/**
|
||||
@@ -379,8 +378,6 @@ class BasicTreeViewItem : public AbstractTreeViewItem {
|
||||
IsActiveFn is_active_fn_;
|
||||
|
||||
private:
|
||||
static void tree_row_click_fn(bContext *C, void *arg1, void *arg2);
|
||||
|
||||
std::optional<bool> should_be_active() const override;
|
||||
void on_activate(bContext &C) override;
|
||||
};
|
||||
|
||||
@@ -2791,6 +2791,30 @@ static void UI_OT_view_item_rename(wmOperatorType *ot)
|
||||
|
||||
ot->flag = OPTYPE_INTERNAL;
|
||||
}
|
||||
|
||||
static wmOperatorStatus ui_view_item_select_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
const wmWindow &win = *CTX_wm_window(C);
|
||||
const ARegion ®ion = *CTX_wm_region(C);
|
||||
|
||||
if (AbstractViewItem *active_item = UI_region_views_find_item_at(region, win.eventstate->xy)) {
|
||||
active_item->activate(*C);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static void UI_OT_view_item_select(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Select View Item";
|
||||
ot->idname = "UI_OT_view_item_select";
|
||||
ot->description = "Activate selected view item";
|
||||
|
||||
ot->exec = ui_view_item_select_exec;
|
||||
ot->poll = ui_view_focused_poll;
|
||||
|
||||
ot->flag = OPTYPE_INTERNAL;
|
||||
}
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -2894,6 +2918,7 @@ void ED_operatortypes_ui()
|
||||
WM_operatortype_append(UI_OT_view_drop);
|
||||
WM_operatortype_append(UI_OT_view_scroll);
|
||||
WM_operatortype_append(UI_OT_view_item_rename);
|
||||
WM_operatortype_append(UI_OT_view_item_select);
|
||||
|
||||
WM_operatortype_append(UI_OT_override_type_set_button);
|
||||
WM_operatortype_append(UI_OT_override_remove_button);
|
||||
|
||||
@@ -137,15 +137,6 @@ bool AbstractGridViewItem::matches(const AbstractViewItem &other) const
|
||||
return identifier_ == other_grid_item.identifier_;
|
||||
}
|
||||
|
||||
void AbstractGridViewItem::grid_tile_click_fn(bContext *C, void *but_arg1, void * /*arg2*/)
|
||||
{
|
||||
uiButViewItem *view_item_but = (uiButViewItem *)but_arg1;
|
||||
AbstractGridViewItem &grid_item = reinterpret_cast<AbstractGridViewItem &>(
|
||||
*view_item_but->view_item);
|
||||
|
||||
grid_item.activate(*C);
|
||||
}
|
||||
|
||||
void AbstractGridViewItem::add_grid_tile_button(uiBlock &block)
|
||||
{
|
||||
const GridViewStyle &style = this->get_view().get_style();
|
||||
@@ -163,7 +154,6 @@ void AbstractGridViewItem::add_grid_tile_button(uiBlock &block)
|
||||
"");
|
||||
|
||||
view_item_but_->view_item = this;
|
||||
UI_but_func_set(view_item_but_, grid_tile_click_fn, view_item_but_, nullptr);
|
||||
}
|
||||
|
||||
std::optional<std::string> AbstractGridViewItem::debug_name() const
|
||||
|
||||
@@ -448,14 +448,6 @@ std::optional<DropLocation> TreeViewItemDropTarget::choose_drop_location(
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AbstractTreeViewItem::tree_row_click_fn(bContext *C, void *but_arg1, void * /*arg2*/)
|
||||
{
|
||||
uiButViewItem *item_but = (uiButViewItem *)but_arg1;
|
||||
AbstractTreeViewItem &tree_item = reinterpret_cast<AbstractTreeViewItem &>(*item_but->view_item);
|
||||
|
||||
tree_item.activate(*C);
|
||||
}
|
||||
|
||||
void AbstractTreeViewItem::add_treerow_button(uiBlock &block)
|
||||
{
|
||||
/* For some reason a width > (UI_UNIT_X * 2) make the layout system use all available width. */
|
||||
@@ -474,7 +466,6 @@ void AbstractTreeViewItem::add_treerow_button(uiBlock &block)
|
||||
|
||||
view_item_but_->view_item = this;
|
||||
view_item_but_->draw_height = unpadded_item_height();
|
||||
UI_but_func_set(view_item_but_, tree_row_click_fn, view_item_but_, nullptr);
|
||||
}
|
||||
|
||||
int AbstractTreeViewItem::indent_width() const
|
||||
|
||||
Reference in New Issue
Block a user