Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-10-06 15:18:12 +0300
committerJulian Eisel <julian@blender.org>2021-10-06 15:25:26 +0300
commit539575b585a018eabda9137d724967692433165a (patch)
tree81cbc66ac926dcf2b02f3784c6e3a7aa66f94d66 /source/blender/editors/interface/interface_handlers.c
parent335f40ebfa28d36d0e4c3c562eb572554282a3ff (diff)
Assets: Support Renaming Catalogs in the UI
Catalogs can now be renamed by double clicking them in the Asset Browser. This is mostly done through the tree-view API, the asset specific code is very little. There is some polish left to be done here, e.g. the double click currently also collapses/uncollapses and activates the clicked item. And the rename button takes the full width of the row. But addressing these is better done as part of some other behavioral changes that are planned anyway.
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r--source/blender/editors/interface/interface_handlers.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 6ee563003ef..f73420b3668 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4822,6 +4822,24 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, cons
return WM_UI_HANDLER_CONTINUE;
}
+static int ui_do_but_TREEROW(bContext *C,
+ uiBut *but,
+ uiHandleButtonData *data,
+ const wmEvent *event)
+{
+ uiButTreeRow *tree_row_but = (uiButTreeRow *)but;
+ BLI_assert(tree_row_but->but.type == UI_BTYPE_TREEROW);
+
+ if ((event->type == LEFTMOUSE) && (event->val == KM_DBL_CLICK)) {
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+
+ UI_tree_view_item_begin_rename(tree_row_but->tree_item);
+ return WM_UI_HANDLER_BREAK;
+ }
+
+ return ui_do_but_TOG(C, but, data, event);
+}
+
static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
if (data->state == BUTTON_STATE_HIGHLIGHT) {
@@ -7989,10 +8007,12 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
case UI_BTYPE_CHECKBOX:
case UI_BTYPE_CHECKBOX_N:
case UI_BTYPE_ROW:
- case UI_BTYPE_TREEROW:
case UI_BTYPE_DATASETROW:
retval = ui_do_but_TOG(C, but, data, event);
break;
+ case UI_BTYPE_TREEROW:
+ retval = ui_do_but_TREEROW(C, but, data, event);
+ break;
case UI_BTYPE_SCROLL:
retval = ui_do_but_SCROLL(C, block, but, data, event);
break;