diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llui/llviewquery.cpp | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/linden/indra/llui/llviewquery.cpp b/linden/indra/llui/llviewquery.cpp index f86f855..40c2d61 100644 --- a/linden/indra/llui/llviewquery.cpp +++ b/linden/indra/llui/llviewquery.cpp | |||
@@ -12,12 +12,12 @@ | |||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | 12 | * ("GPL"), unless you have obtained a separate licensing agreement |
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | 13 | * ("Other License"), formally executed by you and Linden Lab. Terms of |
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | 14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or |
15 | * online at http://secondlife.com/developers/opensource/gplv2 | 15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 |
16 | * | 16 | * |
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlife.com/developers/opensource/flossexception | 20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception |
21 | * | 21 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 22 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 23 | * that you have read and understood your obligations described above, |
@@ -37,9 +37,14 @@ | |||
37 | 37 | ||
38 | void LLQuerySorter::operator() (LLView * parent, viewList_t &children) const {} | 38 | void LLQuerySorter::operator() (LLView * parent, viewList_t &children) const {} |
39 | 39 | ||
40 | filterResult_t LLNoLeavesFilter::operator() (const LLView* const view, const viewList_t & children) const | 40 | filterResult_t LLLeavesFilter::operator() (const LLView* const view, const viewList_t & children) const |
41 | { | 41 | { |
42 | return filterResult_t(!(view->getChildList()->size() == 0), TRUE); | 42 | return filterResult_t(children.empty(), TRUE); |
43 | } | ||
44 | |||
45 | filterResult_t LLRootsFilter::operator() (const LLView* const view, const viewList_t & children) const | ||
46 | { | ||
47 | return filterResult_t(TRUE, FALSE); | ||
43 | } | 48 | } |
44 | 49 | ||
45 | filterResult_t LLVisibleFilter::operator() (const LLView* const view, const viewList_t & children) const | 50 | filterResult_t LLVisibleFilter::operator() (const LLView* const view, const viewList_t & children) const |
@@ -56,6 +61,16 @@ filterResult_t LLTabStopFilter::operator() (const LLView* const view, const view | |||
56 | view->canFocusChildren()); | 61 | view->canFocusChildren()); |
57 | } | 62 | } |
58 | 63 | ||
64 | filterResult_t LLCtrlFilter::operator() (const LLView* const view, const viewList_t & children) const | ||
65 | { | ||
66 | return filterResult_t(view->isCtrl(),TRUE); | ||
67 | } | ||
68 | |||
69 | filterResult_t LLWidgetTypeFilter::operator() (const LLView* const view, const viewList_t & children) const | ||
70 | { | ||
71 | return filterResult_t(view->getWidgetType() == mType, TRUE); | ||
72 | } | ||
73 | |||
59 | // LLViewQuery | 74 | // LLViewQuery |
60 | 75 | ||
61 | LLViewQuery::LLViewQuery(): mPreFilters(), mPostFilters(), mSorterp() | 76 | LLViewQuery::LLViewQuery(): mPreFilters(), mPostFilters(), mSorterp() |
@@ -73,45 +88,53 @@ const LLViewQuery::filterList_t & LLViewQuery::getPostFilters() const { return m | |||
73 | void LLViewQuery::setSorter(const LLQuerySorter* sorterp) { mSorterp = sorterp; } | 88 | void LLViewQuery::setSorter(const LLQuerySorter* sorterp) { mSorterp = sorterp; } |
74 | const LLQuerySorter* LLViewQuery::getSorter() const { return mSorterp; } | 89 | const LLQuerySorter* LLViewQuery::getSorter() const { return mSorterp; } |
75 | 90 | ||
76 | viewList_t LLViewQuery::run(LLView * view) const | 91 | viewList_t LLViewQuery::run(LLView* view) const |
77 | { | 92 | { |
78 | viewList_t result; | 93 | viewList_t result; |
79 | 94 | ||
80 | filterResult_t pre = runFilters(view, viewList_t(), mPreFilters); | 95 | // prefilter gets immediate children of view |
96 | filterResult_t pre = runFilters(view, *view->getChildList(), mPreFilters); | ||
81 | if(!pre.first && !pre.second) | 97 | if(!pre.first && !pre.second) |
82 | { | 98 | { |
83 | // skip post filters completely if we're not including ourselves or the children | 99 | // not including ourselves or the children |
100 | // nothing more to do | ||
84 | return result; | 101 | return result; |
85 | } | 102 | } |
103 | |||
104 | viewList_t filtered_children; | ||
105 | filterResult_t post(TRUE, TRUE); | ||
86 | if(pre.second) | 106 | if(pre.second) |
87 | { | 107 | { |
88 | // run filters on children | 108 | // run filters on children |
89 | viewList_t filtered_children; | ||
90 | filterChildren(view, filtered_children); | 109 | filterChildren(view, filtered_children); |
91 | filterResult_t post = runFilters(view, filtered_children, mPostFilters); | 110 | // only run post filters if this element passed pre filters |
92 | if(pre.first && post.first) | 111 | // so if you failed to pass the pre filter, you can't filter out children in post |
93 | { | 112 | if (pre.first) |
94 | result.push_back(view); | ||
95 | } | ||
96 | if(post.second) | ||
97 | { | 113 | { |
98 | result.insert(result.end(), filtered_children.begin(), filtered_children.end()); | 114 | post = runFilters(view, filtered_children, mPostFilters); |
99 | } | 115 | } |
100 | } | 116 | } |
101 | else | 117 | |
118 | if(pre.first && post.first) | ||
102 | { | 119 | { |
103 | if(pre.first) | 120 | result.push_back(view); |
104 | { | 121 | } |
105 | result.push_back(view); | 122 | |
106 | } | 123 | if(pre.second && post.second) |
124 | { | ||
125 | result.insert(result.end(), filtered_children.begin(), filtered_children.end()); | ||
107 | } | 126 | } |
127 | |||
108 | return result; | 128 | return result; |
109 | } | 129 | } |
110 | 130 | ||
111 | void LLViewQuery::filterChildren(LLView * view, viewList_t & filtered_children) const | 131 | void LLViewQuery::filterChildren(LLView * view, viewList_t & filtered_children) const |
112 | { | 132 | { |
113 | LLView::child_list_t views(*(view->getChildList())); | 133 | LLView::child_list_t views(*(view->getChildList())); |
114 | (*mSorterp)(view, views); // sort the children per the sorter | 134 | if (mSorterp) |
135 | { | ||
136 | (*mSorterp)(view, views); // sort the children per the sorter | ||
137 | } | ||
115 | for(LLView::child_list_iter_t iter = views.begin(); | 138 | for(LLView::child_list_iter_t iter = views.begin(); |
116 | iter != views.end(); | 139 | iter != views.end(); |
117 | iter++) | 140 | iter++) |