]> sigrok.org Git - pulseview.git/blobdiff - pv/view/rowitemowner.cpp
RowItemOwner: Added list_row_item_owners
[pulseview.git] / pv / view / rowitemowner.cpp
index 0fa230ab4e3fb47a609c105cb1de0dc91ad4d277..ba2e1f4838ab44874b831b7ad06d9b79c12dd70c 100644 (file)
 
 #include <cassert>
 
-#include "rowitem.h"
-#include "rowitemowner.h"
+#include "rowitem.hpp"
+#include "rowitemowner.hpp"
 
 using std::max;
 using std::make_pair;
 using std::min;
 using std::pair;
+using std::set;
 using std::shared_ptr;
 using std::vector;
 
@@ -35,42 +36,46 @@ namespace view {
 
 vector< shared_ptr<RowItem> >& RowItemOwner::child_items()
 {
-       return _items;
+       return items_;
 }
 
 const vector< shared_ptr<RowItem> >& RowItemOwner::child_items() const
 {
-       return _items;
+       return items_;
 }
 
 void RowItemOwner::clear_child_items()
 {
-       for (auto &i : _items) {
+       for (auto &i : items_) {
                assert(i->owner() == this);
                i->set_owner(nullptr);
        }
-       _items.clear();
+       items_.clear();
 }
 
 void RowItemOwner::add_child_item(std::shared_ptr<RowItem> item)
 {
        assert(!item->owner());
        item->set_owner(this);
-       _items.push_back(item);
+       items_.push_back(item);
+
+       extents_changed(true, true);
 }
 
 void RowItemOwner::remove_child_item(std::shared_ptr<RowItem> item)
 {
        assert(item->owner() == this);
        item->set_owner(nullptr);
-       auto iter = std::find(_items.begin(), _items.end(), item);
-       assert(iter != _items.end());
-       _items.erase(iter);
+       auto iter = std::find(items_.begin(), items_.end(), item);
+       assert(iter != items_.end());
+       items_.erase(iter);
+
+       extents_changed(true, true);
 }
 
 RowItemOwner::iterator RowItemOwner::begin()
 {
-       return iterator(this, _items.begin());
+       return iterator(this, items_.begin());
 }
 
 RowItemOwner::iterator RowItemOwner::end()
@@ -80,7 +85,7 @@ RowItemOwner::iterator RowItemOwner::end()
 
 RowItemOwner::const_iterator RowItemOwner::begin() const
 {
-       return const_iterator(this, _items.cbegin());
+       return const_iterator(this, items_.cbegin());
 }
 
 RowItemOwner::const_iterator RowItemOwner::end() const
@@ -88,15 +93,24 @@ RowItemOwner::const_iterator RowItemOwner::end() const
        return const_iterator(this);
 }
 
+set< RowItemOwner* > RowItemOwner::list_row_item_owners()
+{
+       set< RowItemOwner* > owners;
+       for (const auto &r : *this)
+               owners.insert(r->owner());
+       return owners;
+}
+
 pair<int, int> RowItemOwner::v_extents() const
 {
-       pair<int, int> extents(0, 0);
+       pair<int, int> extents(INT_MAX, INT_MIN);
+
        for (const shared_ptr<RowItem> r : child_items()) {
                assert(r);
                if (!r->enabled())
                        continue;
 
-               const int child_offset = r->v_offset();
+               const int child_offset = r->layout_v_offset();
                const pair<int, int> child_extents = r->v_extents();
                extents.first = min(child_extents.first + child_offset,
                        extents.first);
@@ -107,5 +121,9 @@ pair<int, int> RowItemOwner::v_extents() const
        return extents;
 }
 
+void RowItemOwner::restack_items()
+{
+}
+
 } // view
 } // pv