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>2022-07-02 22:49:21 +0300
committerJulian Eisel <julian@blender.org>2022-07-03 02:55:38 +0300
commitc355be6faeacef6a65afbce97f9776d2a2c7f54c (patch)
treee68bff81fa87b208ed433ade2b8fce7c522ed59a /source/blender/editors/include/UI_grid_view.hh
parent4ffee9a48d1bc01442e554d44a1f55dfc459a221 (diff)
UI: Add AbstractView base class for views, unify reconstruction in there
No user visible changes expected. There's plenty of duplicated code in the grid and the tree view, and I expect this to become more. This starts the process of unifying these parts, which should also make it easier to add new views. Complexity in the view classes is reduced, and some type shenanigans for C compatibility and general view management can be removed, since there is now a common base type. For the start this ports some of the view reconstruction, where the view and its items are compared to the version of itself in the previous redraw, so that state (highlighted, active, renaming, collapsed, ...) can be preserved. Notifier listening is also ported.
Diffstat (limited to 'source/blender/editors/include/UI_grid_view.hh')
-rw-r--r--source/blender/editors/include/UI_grid_view.hh20
1 files changed, 3 insertions, 17 deletions
diff --git a/source/blender/editors/include/UI_grid_view.hh b/source/blender/editors/include/UI_grid_view.hh
index 6f553f4fad1..cabc49e411c 100644
--- a/source/blender/editors/include/UI_grid_view.hh
+++ b/source/blender/editors/include/UI_grid_view.hh
@@ -13,6 +13,7 @@
#include "BLI_map.hh"
#include "BLI_vector.hh"
+#include "UI_abstract_view.hh"
#include "UI_resources.h"
struct bContext;
@@ -111,7 +112,7 @@ struct GridViewStyle {
int tile_height = 0;
};
-class AbstractGridView {
+class AbstractGridView : public AbstractView {
friend class AbstractGridViewItem;
friend class GridViewBuilder;
friend class GridViewLayoutBuilder;
@@ -122,7 +123,6 @@ class AbstractGridView {
* #update_from_old(). */
Map<StringRef, AbstractGridViewItem *> item_map_;
GridViewStyle style_;
- bool is_reconstructed_ = false;
public:
AbstractGridView();
@@ -131,9 +131,6 @@ class AbstractGridView {
using ItemIterFn = FunctionRef<void(AbstractGridViewItem &)>;
void foreach_item(ItemIterFn iter_fn) const;
- /** Listen to a notifier, returning true if a redraw is needed. */
- virtual bool listen(const wmNotifier &) const;
-
/**
* Convenience wrapper constructing the item by forwarding given arguments to the constructor of
* the type (\a ItemT).
@@ -154,19 +151,8 @@ class AbstractGridView {
protected:
virtual void build_items() = 0;
- /**
- * Check if the view is fully (re-)constructed. That means, both #build_items() and
- * #update_from_old() have finished.
- */
- bool is_reconstructed() const;
-
private:
- /**
- * Match the grid-view against an earlier version of itself (if any) and copy the old UI state
- * (e.g. active, selected, renaming, etc.) to the new one. See
- * #AbstractGridViewItem.update_from_old().
- */
- void update_from_old(uiBlock &new_block);
+ void update_children_from_old(const AbstractView &old_view) override;
AbstractGridViewItem *find_matching_item(const AbstractGridViewItem &item_to_match,
const AbstractGridView &view_to_search_in) const;
/**