diff options
author | Julian Eisel <julian@blender.org> | 2022-07-19 19:00:56 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-07-19 19:04:03 +0300 |
commit | 16b145bc628d277228f5211a9dc076e516c443fb (patch) | |
tree | 9914de2f7519589b751a6107e9ccf05bab03dd8d /source/blender/editors/interface/views | |
parent | fb9dc810f17c463496381bbc9fba3b96c6437ce0 (diff) |
Cleanup: Improve API and documentation of interface_view.cc
File documentation was outdated and could use general improvement.
Function names didn't really reflect the level they are operating on.
Diffstat (limited to 'source/blender/editors/interface/views')
-rw-r--r-- | source/blender/editors/interface/views/interface_view.cc | 18 | ||||
-rw-r--r-- | source/blender/editors/interface/views/tree_view.cc | 2 |
2 files changed, 13 insertions, 7 deletions
diff --git a/source/blender/editors/interface/views/interface_view.cc b/source/blender/editors/interface/views/interface_view.cc index b35f6d2c969..c568a8cab74 100644 --- a/source/blender/editors/interface/views/interface_view.cc +++ b/source/blender/editors/interface/views/interface_view.cc @@ -3,10 +3,16 @@ /** \file * \ingroup edinterface * - * This part of the UI-View API is mostly needed to support persistent state of items within the - * view. Views are stored in #uiBlock's, and kept alive with it until after the next redraw. So we - * can compare the old view items with the new view items and keep state persistent for matching - * ones. + * Code to manage views as part of the regular screen hierarchy. E.g. managing ownership of views + * inside blocks (#uiBlock.views), looking up items in the region, passing WM notifiers to views, + * etc. + * + * Blocks and their contained views are reconstructed on every redraw. This file also contains + * functions related to this recreation of views inside blocks. For example to query state + * information before the view is done reconstructing (#AbstractView.is_reconstructed() returns + * false), it may be enough to query the previous version of the block/view/view-item. Since such + * queries rely on the details of the UI reconstruction process, they should remain internal to + * `interface/` code. */ #include <memory> @@ -86,7 +92,7 @@ void UI_block_views_listen(const uiBlock *block, const wmRegionListenerParams *l } } -uiViewItemHandle *UI_block_view_find_item_at(const ARegion *region, const int xy[2]) +uiViewItemHandle *UI_region_views_find_item_at(const ARegion *region, const int xy[2]) { uiButViewItem *item_but = (uiButViewItem *)ui_view_item_find_mouse_over(region, xy); if (!item_but) { @@ -96,7 +102,7 @@ uiViewItemHandle *UI_block_view_find_item_at(const ARegion *region, const int xy return item_but->view_item; } -uiViewItemHandle *UI_block_view_find_active_item(const ARegion *region) +uiViewItemHandle *UI_region_views_find_active_item(const ARegion *region) { uiButViewItem *item_but = (uiButViewItem *)ui_view_item_find_active(region); if (!item_but) { diff --git a/source/blender/editors/interface/views/tree_view.cc b/source/blender/editors/interface/views/tree_view.cc index c224226ba17..21078b711c7 100644 --- a/source/blender/editors/interface/views/tree_view.cc +++ b/source/blender/editors/interface/views/tree_view.cc @@ -168,7 +168,7 @@ void AbstractTreeViewItem::collapse_chevron_click_fn(struct bContext *C, const wmWindow *win = CTX_wm_window(C); const ARegion *region = CTX_wm_region(C); - uiViewItemHandle *hovered_item_handle = UI_block_view_find_item_at(region, win->eventstate->xy); + uiViewItemHandle *hovered_item_handle = UI_region_views_find_item_at(region, win->eventstate->xy); AbstractTreeViewItem *hovered_item = from_item_handle<AbstractTreeViewItem>(hovered_item_handle); BLI_assert(hovered_item != nullptr); |