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-18 17:51:57 +0300
committerJulian Eisel <julian@blender.org>2022-07-19 17:31:23 +0300
commit348ec37f52452614cb26baa8be40a161e1446b15 (patch)
tree0aac15385fab65929f8243702f974451aa5087b9 /source/blender/editors/include/UI_abstract_view.hh
parent2f834bfc14824c224f99ab7d9a9e561fa86aef6b (diff)
UI: Add AbstractViewItem base class
No user visible changes expected. Similar to rBc355be6faeac, but for view items now instead of the view. Not much of the item code is ported to use it yet, it's actually a bit tricky for the most part. But just introducing the base class already allows me to start unifying the view item buttons (`uiButTreeRow` and `uiButGridTile`). This would be a nice improvement.
Diffstat (limited to 'source/blender/editors/include/UI_abstract_view.hh')
-rw-r--r--source/blender/editors/include/UI_abstract_view.hh27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/editors/include/UI_abstract_view.hh b/source/blender/editors/include/UI_abstract_view.hh
index 82f81f1702b..fdb7069e7c4 100644
--- a/source/blender/editors/include/UI_abstract_view.hh
+++ b/source/blender/editors/include/UI_abstract_view.hh
@@ -15,12 +15,17 @@
#include <array>
#include <memory>
+#include "DNA_defs.h"
+
#include "BLI_span.hh"
struct wmNotifier;
+struct uiBlock;
namespace blender::ui {
+class AbstractViewItem;
+
class AbstractView {
bool is_reconstructed_ = false;
/**
@@ -66,4 +71,26 @@ class AbstractView {
bool is_reconstructed() const;
};
+class AbstractViewItem {
+ protected:
+ bool is_active_ = false;
+
+ public:
+ virtual ~AbstractViewItem() = default;
+
+ protected:
+ AbstractViewItem() = default;
+
+ /**
+ * Copy persistent state (e.g. active, selection, etc.) from a matching item of
+ * the last redraw to this item. If sub-classes introduce more advanced state they should
+ * override this and make it update their state accordingly.
+ *
+ * \note Always call the base class implementation when overriding this!
+ */
+ virtual void update_from_old(const AbstractViewItem &old);
+
+ void set_view(AbstractView &view);
+};
+
} // namespace blender::ui