aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llscrollingpanellist.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llui/llscrollingpanellist.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llui/llscrollingpanellist.cpp')
-rw-r--r--linden/indra/llui/llscrollingpanellist.cpp169
1 files changed, 169 insertions, 0 deletions
diff --git a/linden/indra/llui/llscrollingpanellist.cpp b/linden/indra/llui/llscrollingpanellist.cpp
new file mode 100644
index 0000000..209785e
--- /dev/null
+++ b/linden/indra/llui/llscrollingpanellist.cpp
@@ -0,0 +1,169 @@
1/**
2 * @file llscrollingpanellist.cpp
3 * @brief
4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "linden_common.h"
29#include "llstl.h"
30
31#include "llscrollingpanellist.h"
32
33/////////////////////////////////////////////////////////////////////
34// LLScrollingPanelList
35
36// This could probably be integrated with LLScrollContainer -SJB
37
38void LLScrollingPanelList::clearPanels()
39{
40 deleteAllChildren();
41 mPanelList.clear();
42 reshape( 1, 1, FALSE );
43}
44
45void LLScrollingPanelList::addPanel( LLScrollingPanel* panel )
46{
47 addChildAtEnd( panel );
48 mPanelList.push_front( panel );
49
50 const S32 GAP_BETWEEN_PANELS = 6;
51
52 // Resize this view
53 S32 total_height = 0;
54 S32 max_width = 0;
55 S32 cur_gap = 0;
56 for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
57 iter != mPanelList.end(); ++iter)
58 {
59 LLScrollingPanel *childp = *iter;
60 total_height += childp->getRect().getHeight() + cur_gap;
61 max_width = llmax( max_width, childp->getRect().getWidth() );
62 cur_gap = GAP_BETWEEN_PANELS;
63 }
64 reshape( max_width, total_height, FALSE );
65
66 // Reposition each of the child views
67 S32 cur_y = total_height;
68 for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
69 iter != mPanelList.end(); ++iter)
70 {
71 LLScrollingPanel *childp = *iter;
72 cur_y -= childp->getRect().getHeight();
73 childp->translate( -childp->getRect().mLeft, cur_y - childp->getRect().mBottom);
74 cur_y -= GAP_BETWEEN_PANELS;
75 }
76}
77
78void LLScrollingPanelList::updatePanels(BOOL allow_modify)
79{
80 for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
81 iter != mPanelList.end(); ++iter)
82 {
83 LLScrollingPanel *childp = *iter;
84 childp->updatePanel(allow_modify);
85 }
86}
87
88void LLScrollingPanelList::updatePanelVisiblilty()
89{
90 // Determine visibility of children.
91 S32 BORDER_WIDTH = 2; // HACK
92
93 LLRect parent_local_rect = getParent()->getRect();
94 parent_local_rect.stretch( -BORDER_WIDTH );
95
96 LLRect parent_screen_rect;
97 getParent()->localPointToScreen(
98 BORDER_WIDTH, 0,
99 &parent_screen_rect.mLeft, &parent_screen_rect.mBottom );
100 getParent()->localPointToScreen(
101 parent_local_rect.getWidth() - BORDER_WIDTH, parent_local_rect.getHeight() - BORDER_WIDTH,
102 &parent_screen_rect.mRight, &parent_screen_rect.mTop );
103
104 for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
105 iter != mPanelList.end(); ++iter)
106 {
107 LLScrollingPanel *childp = *iter;
108 const LLRect& local_rect = childp->getRect();
109 LLRect screen_rect;
110 childp->localPointToScreen(
111 0, 0,
112 &screen_rect.mLeft, &screen_rect.mBottom );
113 childp->localPointToScreen(
114 local_rect.getWidth(), local_rect.getHeight(),
115 &screen_rect.mRight, &screen_rect.mTop );
116
117 BOOL intersects =
118 ( (screen_rect.mRight > parent_screen_rect.mLeft) && (screen_rect.mLeft < parent_screen_rect.mRight) ) &&
119 ( (screen_rect.mTop > parent_screen_rect.mBottom) && (screen_rect.mBottom < parent_screen_rect.mTop) );
120
121 childp->setVisible( intersects );
122 }
123}
124
125void LLScrollingPanelList::setValue(const LLSD& value)
126{
127
128}
129
130EWidgetType LLScrollingPanelList::getWidgetType() const
131{
132 return WIDGET_TYPE_SCROLLING_PANEL_LIST;
133}
134
135LLString LLScrollingPanelList::getWidgetTag() const
136{
137 return LL_SCROLLING_PANEL_LIST_TAG;
138}
139
140void LLScrollingPanelList::draw()
141{
142 if( getVisible() )
143 {
144 updatePanelVisiblilty();
145 }
146 LLUICtrl::draw();
147}
148
149
150// static
151LLView* LLScrollingPanelList::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
152{
153 LLString name("scrolling_panel_list");
154 node->getAttributeString("name", name);
155
156 LLRect rect;
157 createRect(node, rect, parent, LLRect());
158
159 LLScrollingPanelList* scrolling_panel_list = new LLScrollingPanelList(name, rect);
160 scrolling_panel_list->initFromXML(node, parent);
161 return scrolling_panel_list;
162}
163
164// virtual
165LLXMLNodePtr LLScrollingPanelList::getXML(bool save_children) const
166{
167 LLXMLNodePtr node = LLUICtrl::getXML();
168 return node;
169}