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.
This commit is contained in:
2022-07-18 16:51:57 +02:00
parent 2f834bfc14
commit 348ec37f52
7 changed files with 60 additions and 27 deletions

View File

@@ -32,14 +32,12 @@ class AbstractGridView;
/** \name Grid-View Item Type
* \{ */
class AbstractGridViewItem {
class AbstractGridViewItem : public AbstractViewItem {
friend class AbstractGridView;
friend class GridViewLayoutBuilder;
const AbstractGridView *view_;
bool is_active_ = false;
protected:
/** Reference to a string that uniquely identifies this item in the view. */
StringRef identifier_{};
@@ -77,13 +75,6 @@ class AbstractGridViewItem {
*/
virtual std::optional<bool> should_be_active() const;
/**
* 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.
*/
virtual void update_from_old(const AbstractGridViewItem &old);
/**
* Activates this item, deactivates other items, and calls the
* #AbstractGridViewItem::on_activate() function.