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-07 15:59:43 +0300
committerJulian Eisel <julian@blender.org>2021-10-07 16:30:59 +0300
commitc0a5b13b5ed3d1477afdbae48653acf87c6a0d08 (patch)
tree151f46d224e05acbef29318d269d7e7e940da270 /source/blender/editors/interface/interface_handlers.c
parent13a28d9e6f12dcba3f97deb20efb0b0761e93db4 (diff)
Asset Browser: Rework layout & behavior of catalog tree-view
This reworks how tree rows are constructed in the layout and how they behave in return. * To open or collapse a row, the triangle/chevron icon has to be clicked now. The previous behavior of allowing to do it on the entire row, but only if the item was active already, was just too unusual and felt weird. * Reduce margin between chevron icon and the row label. * Indent child items without chevron some more, otherwise they feel like a row on the same level as their parent, just without chevron. * Fix renaming button taking entire row width. Respect indentation now. * Fix double-clicking to rename toggling collapsed state on each click. Some hacks/special-handling was needed so tree-rows always highlight while the mouse is hovering them, even if the mouse is actually hovering another button inside the row.
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r--source/blender/editors/interface/interface_handlers.c55
1 files changed, 50 insertions, 5 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index f73420b3668..8fdc055a13b 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4830,14 +4830,23 @@ static int ui_do_but_TREEROW(bContext *C,
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);
+ if (data->state == BUTTON_STATE_HIGHLIGHT) {
+ if (event->type == LEFTMOUSE) {
+ if (event->val == KM_CLICK) {
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ return WM_UI_HANDLER_BREAK;
+ }
+ else if (event->val == KM_DBL_CLICK) {
+ data->cancel = true;
- UI_tree_view_item_begin_rename(tree_row_but->tree_item);
- return WM_UI_HANDLER_BREAK;
+ UI_tree_view_item_begin_rename(tree_row_but->tree_item);
+ ED_region_tag_redraw(CTX_wm_region(C));
+ return WM_UI_HANDLER_BREAK;
+ }
+ }
}
- return ui_do_but_TOG(C, but, data, event);
+ return WM_UI_HANDLER_CONTINUE;
}
static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
@@ -9683,6 +9692,38 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *regi
return retval;
}
+static int ui_handle_tree_hover(const wmEvent *event, const ARegion *region)
+{
+ bool has_treerows = false;
+ LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
+ /* Avoid unnecessary work: Tree-rows are assumed to be inside tree-views. */
+ if (BLI_listbase_is_empty(&block->views)) {
+ continue;
+ }
+
+ LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
+ if (but->type == UI_BTYPE_TREEROW) {
+ but->flag &= ~UI_ACTIVE;
+ has_treerows = true;
+ }
+ }
+ }
+
+ if (!has_treerows) {
+ /* Avoid unnecessary lookup. */
+ return WM_UI_HANDLER_CONTINUE;
+ }
+
+ /* Always highlight the hovered tree-row, even if the mouse hovers another button inside of it.
+ */
+ uiBut *hovered_row_but = ui_tree_row_find_mouse_over(region, event->x, event->y);
+ if (hovered_row_but) {
+ hovered_row_but->flag |= UI_ACTIVE;
+ }
+
+ return WM_UI_HANDLER_CONTINUE;
+}
+
static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, uiBut *but)
{
uiHandleButtonData *data = but->active;
@@ -11286,6 +11327,10 @@ static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(use
ui_blocks_set_tooltips(region, true);
}
+ /* Always do this, to reliably update tree-row highlighting, even if the mouse hovers a button
+ * inside the row (it's an overlapping layout). */
+ ui_handle_tree_hover(event, region);
+
/* delayed apply callbacks */
ui_apply_but_funcs_after(C);