//virtual S32 LLFlatListView::notify(const LLSD& info) { if(info.has("action")) { std::string str_action = info["action"]; if(str_action == "select_first") { setFocus(true); selectFirstItem(); return 1; } else if(str_action == "select_last") { setFocus(true); selectLastItem(); return 1; } } else if (info.has("rearrange")) { rearrangeItems(); notifyParentItemsRectChanged(); return 1; } return 0; }
void DeckViewScene::setDeck(const DeckList &_deck) { if (deck) delete deck; deck = new DeckList(_deck); rebuildTree(); applySideboardPlan(deck->getCurrentSideboardPlan()); rearrangeItems(); }
void LLFlatListView::sort() { if (!mItemComparator) { llwarns << "No comparator specified for sorting FlatListView items." << llendl; return; } mItemPairs.sort(ComparatorAdaptor(*mItemComparator)); rearrangeItems(); }
void LLFlatListView::reshape(S32 width, S32 height, BOOL called_from_parent /* = TRUE */) { S32 delta = height - getRect().getHeight(); LLScrollContainer::reshape(width, height, called_from_parent); setItemsNoScrollWidth(width); rearrangeItems(); if(delta!= 0 && mKeepSelectionVisibleOnReshape) { ensureSelectedVisible(); } }
bool LLFlatListView::removeItemPair(item_pair_t* item_pair, bool rearrange) { llassert(item_pair); bool deleted = false; bool selection_changed = false; for (pairs_iterator_t it = mItemPairs.begin(); it != mItemPairs.end(); ++it) { item_pair_t* _item_pair = *it; if (_item_pair == item_pair) { mItemPairs.erase(it); deleted = true; break; } } if (!deleted) return false; for (pairs_iterator_t it = mSelectedItemPairs.begin(); it != mSelectedItemPairs.end(); ++it) { item_pair_t* selected_item_pair = *it; if (selected_item_pair == item_pair) { it = mSelectedItemPairs.erase(it); selection_changed = true; break; } } mItemsPanel->removeChild(item_pair->first); item_pair->first->die(); delete item_pair; if (rearrange) { rearrangeItems(); notifyParentItemsRectChanged(); } if (selection_changed && mCommitOnSelectionChange) { onCommit(); } return true; }
bool LLFlatListView::insertItemAfter(LLPanel* after_item, LLPanel* item_to_add, const LLSD& value /*= LLUUID::null*/) { if (!after_item) return false; if (!item_to_add) return false; if (value.isUndefined()) return false; if (mItemPairs.empty()) return false; //force uniqueness of items, easiest check but unreliable if (item_to_add->getParent() == mItemsPanel) return false; item_pair_t* after_pair = getItemPair(after_item); if (!after_pair) return false; item_pair_t* new_pair = new item_pair_t(item_to_add, value); if (after_pair == mItemPairs.back()) { mItemPairs.push_back(new_pair); mItemsPanel->addChild(item_to_add); } else { pairs_iterator_t it = mItemPairs.begin(); for (; it != mItemPairs.end(); ++it) { if (*it == after_pair) { // insert new elements before the element at position of passed iterator. mItemPairs.insert(++it, new_pair); mItemsPanel->addChild(item_to_add); break; } } } //_4 is for MASK item_to_add->setMouseDownCallback(boost::bind(&LLFlatListView::onItemMouseClick, this, new_pair, _4)); item_to_add->setRightMouseDownCallback(boost::bind(&LLFlatListView::onItemRightMouseClick, this, new_pair, _4)); rearrangeItems(); notifyParentItemsRectChanged(); return true; }
bool LLFlatListView::addItem(LLPanel * item, const LLSD& value /*= LLUUID::null*/, EAddPosition pos /*= ADD_BOTTOM*/,bool rearrange /*= true*/) { if (!item) return false; if (value.isUndefined()) return false; //force uniqueness of items, easiest check but unreliable if (item->getParent() == mItemsPanel) return false; item_pair_t* new_pair = new item_pair_t(item, value); switch (pos) { case ADD_TOP: mItemPairs.push_front(new_pair); //in LLView::draw() children are iterated in backorder mItemsPanel->addChildInBack(item); break; case ADD_BOTTOM: mItemPairs.push_back(new_pair); mItemsPanel->addChild(item); break; default: break; } //_4 is for MASK item->setMouseDownCallback(boost::bind(&LLFlatListView::onItemMouseClick, this, new_pair, _4)); item->setRightMouseDownCallback(boost::bind(&LLFlatListView::onItemRightMouseClick, this, new_pair, _4)); // Children don't accept the focus item->setTabStop(false); if (rearrange) { rearrangeItems(); notifyParentItemsRectChanged(); } return true; }
void DeckViewScene::resetSideboardPlan() { rebuildTree(); rearrangeItems(); }
void DeckViewScene::updateContents() { rearrangeItems(); emit sideboardPlanChanged(); }
void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items) { LLSD action; action.with("detach", LLSD()); // Clear detached_items list detached_items.clear(); // Go through items and detach valid items, remove them from items panel // and add to detached_items. for (pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); iter != iter_end; ++iter) { LLPanel* pItem = (*iter)->first; if (1 == pItem->notify(action)) { selectItemPair((*iter), false); mItemsPanel->removeChild(pItem); detached_items.push_back(pItem); } } if (!detached_items.empty()) { // Some items were detached, clean ourself from unusable memory if (detached_items.size() == mItemPairs.size()) { // This way will be faster if all items were disconnected for (pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); iter != iter_end; ++iter) { (*iter)->first = NULL; delete *iter; } mItemPairs.clear(); // Also set items panel height to zero. // Reshape it to allow reshaping of non-item children. LLRect rc = mItemsPanel->getRect(); rc.mBottom = rc.mTop; mItemsPanel->reshape(rc.getWidth(), rc.getHeight()); mItemsPanel->setRect(rc); setNoItemsCommentVisible(true); } else { for (std::vector<LLPanel*>::const_iterator detached_iter = detached_items.begin(), detached_iter_end = detached_items.end(); detached_iter != detached_iter_end; ++detached_iter) { LLPanel* pDetachedItem = *detached_iter; for (pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); iter != iter_end; ++iter) { item_pair_t* item_pair = *iter; if (item_pair->first == pDetachedItem) { mItemPairs.erase(iter); item_pair->first = NULL; delete item_pair; break; } } } rearrangeItems(); } notifyParentItemsRectChanged(); } }
void LLFlatListView::reshape(S32 width, S32 height, BOOL called_from_parent /* = TRUE */) { LLScrollContainer::reshape(width, height, called_from_parent); setItemsNoScrollWidth(width); rearrangeItems(); }