diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llui/lltabcontainer.h | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/llui/lltabcontainer.h')
-rw-r--r-- | linden/indra/llui/lltabcontainer.h | 263 |
1 files changed, 111 insertions, 152 deletions
diff --git a/linden/indra/llui/lltabcontainer.h b/linden/indra/llui/lltabcontainer.h index e2770ee..07554b4 100644 --- a/linden/indra/llui/lltabcontainer.h +++ b/linden/indra/llui/lltabcontainer.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /** | 1 | /** |
2 | * @file lltabcontainer.h | 2 | * @file lltabcontainer.h |
3 | * @brief LLTabContainerCommon base class | 3 | * @brief LLTabContainer class |
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
@@ -29,19 +29,16 @@ | |||
29 | * $/LicenseInfo$ | 29 | * $/LicenseInfo$ |
30 | */ | 30 | */ |
31 | 31 | ||
32 | // Fear my script-fu! | ||
33 | |||
34 | #ifndef LL_TABCONTAINER_H | 32 | #ifndef LL_TABCONTAINER_H |
35 | #define LL_TABCONTAINER_H | 33 | #define LL_TABCONTAINER_H |
36 | 34 | ||
37 | #include "llpanel.h" | 35 | #include "llpanel.h" |
36 | #include "lltextbox.h" | ||
38 | #include "llframetimer.h" | 37 | #include "llframetimer.h" |
39 | 38 | ||
40 | class LLButton; | 39 | extern const S32 TABCNTR_HEADER_HEIGHT; |
41 | class LLTextBox; | ||
42 | |||
43 | 40 | ||
44 | class LLTabContainerCommon : public LLPanel | 41 | class LLTabContainer : public LLPanel |
45 | { | 42 | { |
46 | public: | 43 | public: |
47 | enum TabPosition | 44 | enum TabPosition |
@@ -58,81 +55,82 @@ public: | |||
58 | RIGHT_OF_CURRENT | 55 | RIGHT_OF_CURRENT |
59 | } eInsertionPoint; | 56 | } eInsertionPoint; |
60 | 57 | ||
61 | LLTabContainerCommon( const LLString& name, | 58 | LLTabContainer( const LLString& name, const LLRect& rect, TabPosition pos, |
62 | const LLRect& rect, | 59 | BOOL bordered, BOOL is_vertical); |
63 | TabPosition pos, | ||
64 | void(*close_callback)(void*), void* callback_userdata, | ||
65 | BOOL bordered = TRUE); | ||
66 | |||
67 | LLTabContainerCommon( const LLString& name, | ||
68 | const LLString& rect_control, | ||
69 | TabPosition pos, | ||
70 | void(*close_callback)(void*), void* callback_userdata, | ||
71 | BOOL bordered = TRUE); | ||
72 | 60 | ||
73 | virtual ~LLTabContainerCommon(); | 61 | /*virtual*/ ~LLTabContainer(); |
74 | 62 | ||
75 | virtual void initButtons() = 0; | 63 | // from LLView |
76 | 64 | /*virtual*/ void setValue(const LLSD& value); | |
77 | virtual void setValue(const LLSD& value) { selectTab((S32) value.asInteger()); } | 65 | /*virtual*/ EWidgetType getWidgetType() const; |
78 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_TAB_CONTAINER; } | 66 | /*virtual*/ LLString getWidgetTag() const; |
79 | virtual LLString getWidgetTag() const { return LL_TAB_CONTAINER_COMMON_TAG; } | 67 | /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent); |
80 | 68 | /*virtual*/ void draw(); | |
81 | virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const; | 69 | /*virtual*/ BOOL handleMouseDown( S32 x, S32 y, MASK mask ); |
82 | 70 | /*virtual*/ BOOL handleHover( S32 x, S32 y, MASK mask ); | |
83 | static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); | 71 | /*virtual*/ BOOL handleMouseUp( S32 x, S32 y, MASK mask ); |
84 | 72 | /*virtual*/ BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect ); | |
85 | virtual void addTabPanel(LLPanel* child, | 73 | /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); |
86 | const LLString& label, | 74 | /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, |
87 | BOOL select = FALSE, | 75 | EDragAndDropType type, void* cargo_data, |
88 | void (*on_tab_clicked)(void*, bool) = NULL, | 76 | EAcceptance* accept, LLString& tooltip); |
89 | void* userdata = NULL, | 77 | /*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const; |
90 | S32 indent = 0, | 78 | |
91 | BOOL placeholder = FALSE, | 79 | void addTabPanel(LLPanel* child, |
92 | eInsertionPoint insertion_point = END) = 0; | 80 | const LLString& label, |
93 | virtual void addPlaceholder(LLPanel* child, const LLString& label); | 81 | BOOL select = FALSE, |
94 | virtual void lockTabs(S32 num_tabs = 0); | 82 | void (*on_tab_clicked)(void*, bool) = NULL, |
95 | virtual void unlockTabs(); | 83 | void* userdata = NULL, |
96 | S32 getNumLockedTabs() { return mLockedTabCount; } | 84 | S32 indent = 0, |
97 | 85 | BOOL placeholder = FALSE, | |
98 | virtual void enableTabButton(S32 which, BOOL enable); | 86 | eInsertionPoint insertion_point = END); |
99 | 87 | void addPlaceholder(LLPanel* child, const LLString& label); | |
100 | virtual void removeTabPanel( LLPanel* child ); | 88 | void removeTabPanel( LLPanel* child ); |
101 | virtual void deleteAllTabs(); | 89 | void lockTabs(S32 num_tabs = 0); |
102 | virtual LLPanel* getCurrentPanel(); | 90 | void unlockTabs(); |
103 | virtual S32 getCurrentPanelIndex(); | 91 | S32 getNumLockedTabs() { return mLockedTabCount; } |
104 | virtual S32 getTabCount(); | 92 | void enableTabButton(S32 which, BOOL enable); |
105 | virtual S32 getPanelIndexByTitle(const LLString& title); | 93 | void deleteAllTabs(); |
106 | virtual LLPanel* getPanelByIndex(S32 index); | 94 | LLPanel* getCurrentPanel(); |
107 | virtual LLPanel* getPanelByName(const LLString& name); | 95 | S32 getCurrentPanelIndex(); |
108 | virtual S32 getIndexForPanel(LLPanel* panel); | 96 | S32 getTabCount(); |
109 | 97 | LLPanel* getPanelByIndex(S32 index); | |
110 | virtual void setCurrentTabName(const LLString& name); | 98 | S32 getIndexForPanel(LLPanel* panel); |
111 | 99 | S32 getPanelIndexByTitle(const LLString& title); | |
112 | 100 | LLPanel* getPanelByName(const LLString& name); | |
113 | virtual void selectFirstTab(); | 101 | void setCurrentTabName(const LLString& name); |
114 | virtual void selectLastTab(); | 102 | |
115 | virtual BOOL selectTabPanel( LLPanel* child ); | 103 | void selectFirstTab(); |
116 | virtual BOOL selectTab(S32 which) = 0; | 104 | void selectLastTab(); |
117 | virtual BOOL selectTabByName(const LLString& title); | 105 | void selectNextTab(); |
118 | virtual void selectNextTab(); | 106 | void selectPrevTab(); |
119 | virtual void selectPrevTab(); | 107 | BOOL selectTabPanel( LLPanel* child ); |
108 | BOOL selectTab(S32 which); | ||
109 | BOOL selectTabByName(const LLString& title); | ||
120 | 110 | ||
121 | BOOL getTabPanelFlashing(LLPanel* child); | 111 | BOOL getTabPanelFlashing(LLPanel* child); |
122 | void setTabPanelFlashing(LLPanel* child, BOOL state); | 112 | void setTabPanelFlashing(LLPanel* child, BOOL state); |
123 | virtual void setTabImage(LLPanel* child, std::string img_name, const LLColor4& color = LLColor4::white); | 113 | void setTabImage(LLPanel* child, std::string img_name, const LLColor4& color = LLColor4::white); |
124 | void setTitle( const LLString& title ); | 114 | void setTitle( const LLString& title ); |
125 | const LLString getPanelTitle(S32 index); | 115 | const LLString getPanelTitle(S32 index); |
126 | 116 | ||
127 | void setDragAndDropDelayTimer() { mDragAndDropDelayTimer.start(); } | 117 | void setTopBorderHeight(S32 height); |
128 | 118 | S32 getTopBorderHeight() const; | |
129 | virtual void setTopBorderHeight(S32 height); | ||
130 | 119 | ||
131 | virtual void setTabChangeCallback(LLPanel* tab, void (*on_tab_clicked)(void*,bool)); | 120 | void setTabChangeCallback(LLPanel* tab, void (*on_tab_clicked)(void*,bool)); |
132 | virtual void setTabUserData(LLPanel* tab, void* userdata); | 121 | void setTabUserData(LLPanel* tab, void* userdata); |
133 | 122 | ||
134 | virtual void reshape(S32 width, S32 height, BOOL called_from_parent); | 123 | void setRightTabBtnOffset( S32 offset ); |
124 | void setPanelTitle(S32 index, const LLString& title); | ||
135 | 125 | ||
126 | TabPosition getTabPosition() const { return mTabPosition; } | ||
127 | void setMinTabWidth(S32 width) { mMinTabWidth = width; } | ||
128 | void setMaxTabWidth(S32 width) { mMaxTabWidth = width; } | ||
129 | S32 getMinTabWidth() const { return mMinTabWidth; } | ||
130 | S32 getMaxTabWidth() const { return mMaxTabWidth; } | ||
131 | |||
132 | void startDragAndDropDelayTimer() { mDragAndDropDelayTimer.start(); } | ||
133 | |||
136 | static void onCloseBtn(void* userdata); | 134 | static void onCloseBtn(void* userdata); |
137 | static void onTabBtn(void* userdata); | 135 | static void onTabBtn(void* userdata); |
138 | static void onNextBtn(void* userdata); | 136 | static void onNextBtn(void* userdata); |
@@ -142,17 +140,17 @@ public: | |||
142 | static void onJumpFirstBtn( void* userdata ); | 140 | static void onJumpFirstBtn( void* userdata ); |
143 | static void onJumpLastBtn( void* userdata ); | 141 | static void onJumpLastBtn( void* userdata ); |
144 | 142 | ||
145 | virtual void setRightTabBtnOffset( S32 offset ) { } | 143 | static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); |
146 | virtual void setPanelTitle(S32 index, const LLString& title) { } | ||
147 | 144 | ||
148 | virtual TabPosition getTabPosition() { return mTabPosition; } | 145 | protected: |
146 | /*virtual*/ LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const; | ||
149 | 147 | ||
150 | 148 | ||
151 | protected: | 149 | private: |
152 | // Structure used to map tab buttons to and from tab panels | 150 | // Structure used to map tab buttons to and from tab panels |
153 | struct LLTabTuple | 151 | struct LLTabTuple |
154 | { | 152 | { |
155 | LLTabTuple( LLTabContainerCommon* c, LLPanel* p, LLButton* b, | 153 | LLTabTuple( LLTabContainer* c, LLPanel* p, LLButton* b, |
156 | void (*cb)(void*,bool), void* userdata, LLTextBox* placeholder = NULL ) | 154 | void (*cb)(void*,bool), void* userdata, LLTextBox* placeholder = NULL ) |
157 | : | 155 | : |
158 | mTabContainer(c), | 156 | mTabContainer(c), |
@@ -165,7 +163,7 @@ protected: | |||
165 | mPadding(0) | 163 | mPadding(0) |
166 | {} | 164 | {} |
167 | 165 | ||
168 | LLTabContainerCommon* mTabContainer; | 166 | LLTabContainer* mTabContainer; |
169 | LLPanel* mTabPanel; | 167 | LLPanel* mTabPanel; |
170 | LLButton* mButton; | 168 | LLButton* mButton; |
171 | void (*mOnChangeCallback)(void*, bool); | 169 | void (*mOnChangeCallback)(void*, bool); |
@@ -175,8 +173,35 @@ protected: | |||
175 | S32 mPadding; | 173 | S32 mPadding; |
176 | }; | 174 | }; |
177 | 175 | ||
176 | void initButtons(); | ||
177 | |||
178 | LLTabTuple* getTab(S32 index) { return mTabList[index]; } | ||
179 | LLTabTuple* getTabByPanel(LLPanel* child); | ||
180 | void insertTuple(LLTabTuple * tuple, eInsertionPoint insertion_point); | ||
181 | |||
182 | S32 getScrollPos() const { return mScrollPos; } | ||
183 | void setScrollPos(S32 pos) { mScrollPos = pos; } | ||
184 | S32 getMaxScrollPos() const { return mMaxScrollPos; } | ||
185 | void setMaxScrollPos(S32 pos) { mMaxScrollPos = pos; } | ||
186 | S32 getScrollPosPixels() const { return mScrollPosPixels; } | ||
187 | void setScrollPosPixels(S32 pixels) { mScrollPosPixels = pixels; } | ||
188 | |||
189 | void setTabsHidden(BOOL hidden) { mTabsHidden = hidden; } | ||
190 | BOOL getTabsHidden() const { return mTabsHidden; } | ||
191 | |||
192 | void setCurrentPanelIndex(S32 index) { mCurrentTabIdx = index; } | ||
193 | |||
194 | void scrollPrev() { mScrollPos = llmax(0, mScrollPos-1); } // No wrap | ||
195 | void scrollNext() { mScrollPos = llmin(mScrollPos+1, mMaxScrollPos); } // No wrap | ||
196 | |||
197 | void updateMaxScrollPos(); | ||
198 | void commitHoveredButton(S32 x, S32 y); | ||
199 | |||
200 | // Variables | ||
201 | |||
178 | typedef std::vector<LLTabTuple*> tuple_list_t; | 202 | typedef std::vector<LLTabTuple*> tuple_list_t; |
179 | tuple_list_t mTabList; | 203 | tuple_list_t mTabList; |
204 | |||
180 | S32 mCurrentTabIdx; | 205 | S32 mCurrentTabIdx; |
181 | BOOL mTabsHidden; | 206 | BOOL mTabsHidden; |
182 | 207 | ||
@@ -186,8 +211,6 @@ protected: | |||
186 | S32 mScrollPosPixels; | 211 | S32 mScrollPosPixels; |
187 | S32 mMaxScrollPos; | 212 | S32 mMaxScrollPos; |
188 | 213 | ||
189 | LLFrameTimer mDragAndDropDelayTimer; | ||
190 | |||
191 | void (*mCloseCallback)(void*); | 214 | void (*mCloseCallback)(void*); |
192 | void* mCallbackUserdata; | 215 | void* mCallbackUserdata; |
193 | 216 | ||
@@ -196,87 +219,23 @@ protected: | |||
196 | S32 mTopBorderHeight; | 219 | S32 mTopBorderHeight; |
197 | TabPosition mTabPosition; | 220 | TabPosition mTabPosition; |
198 | S32 mLockedTabCount; | 221 | S32 mLockedTabCount; |
222 | S32 mMinTabWidth; | ||
223 | LLButton* mPrevArrowBtn; | ||
224 | LLButton* mNextArrowBtn; | ||
199 | 225 | ||
200 | protected: | 226 | BOOL mIsVertical; |
201 | void scrollPrev(); | ||
202 | void scrollNext(); | ||
203 | |||
204 | virtual void updateMaxScrollPos() = 0; | ||
205 | virtual void commitHoveredButton(S32 x, S32 y) = 0; | ||
206 | LLTabTuple* getTabByPanel(LLPanel* child); | ||
207 | void insertTuple(LLTabTuple * tuple, eInsertionPoint insertion_point); | ||
208 | }; | ||
209 | |||
210 | class LLTabContainer : public LLTabContainerCommon | ||
211 | { | ||
212 | public: | ||
213 | LLTabContainer( const LLString& name, const LLRect& rect, TabPosition pos, | ||
214 | void(*close_callback)(void*), void* callback_userdata, | ||
215 | const LLString& title=LLString::null, BOOL bordered = TRUE ); | ||
216 | |||
217 | LLTabContainer( const LLString& name, const LLString& rect_control, TabPosition pos, | ||
218 | void(*close_callback)(void*), void* callback_userdata, | ||
219 | const LLString& title=LLString::null, BOOL bordered = TRUE ); | ||
220 | |||
221 | ~LLTabContainer(); | ||
222 | |||
223 | /*virtual*/ void initButtons(); | ||
224 | |||
225 | /*virtual*/ void draw(); | ||
226 | |||
227 | /*virtual*/ void addTabPanel(LLPanel* child, | ||
228 | const LLString& label, | ||
229 | BOOL select = FALSE, | ||
230 | void (*on_tab_clicked)(void*, bool) = NULL, | ||
231 | void* userdata = NULL, | ||
232 | S32 indent = 0, | ||
233 | BOOL placeholder = FALSE, | ||
234 | eInsertionPoint insertion_point = END); | ||
235 | |||
236 | /*virtual*/ BOOL selectTab(S32 which); | ||
237 | /*virtual*/ void removeTabPanel( LLPanel* child ); | ||
238 | |||
239 | /*virtual*/ void setPanelTitle(S32 index, const LLString& title); | ||
240 | /*virtual*/ void setTabImage(LLPanel* child, std::string img_name, const LLColor4& color = LLColor4::white); | ||
241 | /*virtual*/ void setRightTabBtnOffset( S32 offset ); | ||
242 | |||
243 | /*virtual*/ void setMinTabWidth(S32 width); | ||
244 | /*virtual*/ void setMaxTabWidth(S32 width); | ||
245 | |||
246 | /*virtual*/ S32 getMinTabWidth() const; | ||
247 | /*virtual*/ S32 getMaxTabWidth() const; | ||
248 | |||
249 | /*virtual*/ BOOL handleMouseDown( S32 x, S32 y, MASK mask ); | ||
250 | /*virtual*/ BOOL handleHover( S32 x, S32 y, MASK mask ); | ||
251 | /*virtual*/ BOOL handleMouseUp( S32 x, S32 y, MASK mask ); | ||
252 | /*virtual*/ BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect ); | ||
253 | /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); | ||
254 | /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | ||
255 | EDragAndDropType type, void* cargo_data, | ||
256 | EAcceptance* accept, LLString& tooltip); | ||
257 | |||
258 | virtual LLXMLNodePtr getXML(bool save_children = true) const; | ||
259 | |||
260 | 227 | ||
261 | protected: | 228 | // Horizontal specific |
262 | 229 | LLButton* mJumpPrevArrowBtn; | |
263 | LLButton* mLeftArrowBtn; | 230 | LLButton* mJumpNextArrowBtn; |
264 | LLButton* mJumpLeftArrowBtn; | ||
265 | LLButton* mRightArrowBtn; | ||
266 | LLButton* mJumpRightArrowBtn; | ||
267 | 231 | ||
268 | S32 mRightTabBtnOffset; // Extra room to the right of the tab buttons. | 232 | S32 mRightTabBtnOffset; // Extra room to the right of the tab buttons. |
269 | 233 | ||
270 | protected: | ||
271 | virtual void updateMaxScrollPos(); | ||
272 | virtual void commitHoveredButton(S32 x, S32 y); | ||
273 | |||
274 | S32 mMinTabWidth; | ||
275 | S32 mMaxTabWidth; | 234 | S32 mMaxTabWidth; |
276 | S32 mTotalTabWidth; | 235 | S32 mTotalTabWidth; |
236 | |||
237 | LLFrameTimer mDragAndDropDelayTimer; | ||
277 | }; | 238 | }; |
278 | 239 | ||
279 | const S32 TABCNTR_CLOSE_BTN_SIZE = 16; | ||
280 | const S32 TABCNTR_HEADER_HEIGHT = LLPANEL_BORDER_WIDTH + TABCNTR_CLOSE_BTN_SIZE; | ||
281 | 240 | ||
282 | #endif // LL_TABCONTAINER_H | 241 | #endif // LL_TABCONTAINER_H |