]> sigrok.org Git - pulseview.git/blobdiff - pv/view/rowitemowner.h
RowItem: Replaced fixed signal heights with extents
[pulseview.git] / pv / view / rowitemowner.h
index d961d6b9eeb9098ef0f4f271ada681fabe8c6baf..4b25a580da685bf6bd8de62ff3d3167db72612bc 100644 (file)
@@ -24,6 +24,8 @@
 #include <memory>
 #include <vector>
 
+#include "rowitemiterator.h"
+
 namespace pv {
 
 class SigSession;
@@ -35,6 +37,11 @@ class View;
 
 class RowItemOwner
 {
+public:
+       typedef std::vector< std::shared_ptr<RowItem> > item_list;
+       typedef RowItemIterator<RowItemOwner, RowItem> iterator;
+       typedef RowItemIterator<const RowItemOwner, RowItem> const_iterator;
+
 public:
        /**
         * Returns the session of the onwer.
@@ -61,10 +68,61 @@ public:
        /**
         * Returns a list of row items owned by this object.
         */
-       virtual std::vector< std::shared_ptr<RowItem> > child_items() const = 0;
+       virtual item_list& child_items();
+
+       /**
+        * Returns a list of row items owned by this object.
+        */
+       virtual const item_list& child_items() const;
+
+       /**
+        * Clears the list of child items.
+        */
+       void clear_child_items();
+
+       /**
+        * Adds a child item to this object.
+        */
+       void add_child_item(std::shared_ptr<RowItem> item);
+
+       /**
+        * Removes a child item from this object.
+        */
+       void remove_child_item(std::shared_ptr<RowItem> item);
+
+       /**
+        * Returns a depth-first iterator at the beginning of the child RowItem
+        * tree.
+        */
+       iterator begin();
+
+       /**
+        * Returns a depth-first iterator at the end of the child RowItem tree.
+        */
+       iterator end();
+
+       /**
+        * Returns a constant depth-first iterator at the beginning of the
+        * child RowItem tree.
+        */
+       const_iterator begin() const;
+
+       /**
+        * Returns a constant depth-first iterator at the end of the child
+        * RowItem tree.
+        */
+       const_iterator end() const;
+
+       /**
+        * Computes the vertical extents of the contents of this row item owner.
+        * @return A pair containing the minimum and maximum y-values.
+        */
+       std::pair<int, int> v_extents() const;
 
-protected:
        virtual void update_viewport() = 0;
+
+private:
+       item_list _items;
 };
 
 } // view