X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Frowitemowner.cpp;h=8970f45a73727207fae763043efbb6df66467c21;hp=3ef2782eb3ec62db7c2c1b46bd1a33b5e41edb38;hb=bc01bb31fb03f69c8ceef57676b3399d7a08dcd9;hpb=18f7104f875a71bceeb152398b682737528a4ad7 diff --git a/pv/view/rowitemowner.cpp b/pv/view/rowitemowner.cpp index 3ef2782e..8970f45a 100644 --- a/pv/view/rowitemowner.cpp +++ b/pv/view/rowitemowner.cpp @@ -18,4 +18,103 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "rowitemowner.h" +#include + +#include "rowitem.hpp" +#include "rowitemowner.hpp" + +using std::max; +using std::make_pair; +using std::min; +using std::pair; +using std::shared_ptr; +using std::vector; + +namespace pv { +namespace view { + +vector< shared_ptr >& RowItemOwner::child_items() +{ + return items_; +} + +const vector< shared_ptr >& RowItemOwner::child_items() const +{ + return items_; +} + +void RowItemOwner::clear_child_items() +{ + for (auto &i : items_) { + assert(i->owner() == this); + i->set_owner(nullptr); + } + items_.clear(); +} + +void RowItemOwner::add_child_item(std::shared_ptr item) +{ + assert(!item->owner()); + item->set_owner(this); + items_.push_back(item); + + extents_changed(true, true); +} + +void RowItemOwner::remove_child_item(std::shared_ptr 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); + + extents_changed(true, true); +} + +RowItemOwner::iterator RowItemOwner::begin() +{ + return iterator(this, items_.begin()); +} + +RowItemOwner::iterator RowItemOwner::end() +{ + return iterator(this); +} + +RowItemOwner::const_iterator RowItemOwner::begin() const +{ + return const_iterator(this, items_.cbegin()); +} + +RowItemOwner::const_iterator RowItemOwner::end() const +{ + return const_iterator(this); +} + +pair RowItemOwner::v_extents() const +{ + pair extents(INT_MAX, INT_MIN); + + for (const shared_ptr r : child_items()) { + assert(r); + if (!r->enabled()) + continue; + + const int child_offset = r->layout_v_offset(); + const pair child_extents = r->v_extents(); + extents.first = min(child_extents.first + child_offset, + extents.first); + extents.second = max(child_extents.second + child_offset, + extents.second); + } + + return extents; +} + +void RowItemOwner::restack_items() +{ +} + +} // view +} // pv