diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llchatbar.cpp | 172 |
1 files changed, 21 insertions, 151 deletions
diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 5a2ae5f..292ff8f 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.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, |
@@ -93,51 +93,20 @@ private: | |||
93 | // Functions | 93 | // Functions |
94 | // | 94 | // |
95 | 95 | ||
96 | //inline constructor | 96 | LLChatBar::LLChatBar() |
97 | // for chat bars embedded in floaters, etc | 97 | : LLPanel("", LLRect(), BORDER_NO), |
98 | LLChatBar::LLChatBar(const std::string& name) | ||
99 | : LLPanel(name, LLRect(), BORDER_NO), | ||
100 | mInputEditor(NULL), | 98 | mInputEditor(NULL), |
101 | mGestureLabelTimer(), | 99 | mGestureLabelTimer(), |
102 | mLastSpecialChatChannel(0), | 100 | mLastSpecialChatChannel(0), |
103 | mIsBuilt(FALSE), | 101 | mIsBuilt(FALSE), |
104 | mDynamicLayout(FALSE), | ||
105 | mGestureCombo(NULL), | ||
106 | mObserver(NULL) | ||
107 | { | ||
108 | } | ||
109 | |||
110 | LLChatBar::LLChatBar(const std::string& name, const LLRect& rect) | ||
111 | : LLPanel(name, rect, BORDER_NO), | ||
112 | mInputEditor(NULL), | ||
113 | mGestureLabelTimer(), | ||
114 | mLastSpecialChatChannel(0), | ||
115 | mIsBuilt(FALSE), | ||
116 | mDynamicLayout(TRUE), | ||
117 | mGestureCombo(NULL), | 102 | mGestureCombo(NULL), |
118 | mObserver(NULL) | 103 | mObserver(NULL) |
119 | { | 104 | { |
120 | setIsChrome(TRUE); | 105 | setIsChrome(TRUE); |
121 | 106 | ||
122 | gUICtrlFactory->buildPanel(this,"panel_chat_bar.xml"); | 107 | #if !LL_RELEASE_FOR_DOWNLOAD |
123 | |||
124 | mIsFocusRoot = TRUE; | ||
125 | |||
126 | setRect(rect); // override xml rect | ||
127 | |||
128 | setBackgroundOpaque(TRUE); | ||
129 | setBackgroundVisible(TRUE); | ||
130 | |||
131 | // Start visible if we left the app while chatting. | ||
132 | setVisible( gSavedSettings.getBOOL("ChatVisible") ); | ||
133 | |||
134 | // Apply custom layout. | ||
135 | layout(); | ||
136 | |||
137 | #if !LL_RELEASE_FOR_DOWNLOAD | ||
138 | childDisplayNotFound(); | 108 | childDisplayNotFound(); |
139 | #endif | 109 | #endif |
140 | |||
141 | } | 110 | } |
142 | 111 | ||
143 | 112 | ||
@@ -151,25 +120,18 @@ LLChatBar::~LLChatBar() | |||
151 | BOOL LLChatBar::postBuild() | 120 | BOOL LLChatBar::postBuild() |
152 | { | 121 | { |
153 | childSetAction("History", toggleChatHistory, this); | 122 | childSetAction("History", toggleChatHistory, this); |
154 | childSetAction("Say", onClickSay, this); | 123 | childSetCommitCallback("Say", onClickSay, this); |
155 | childSetAction("Shout", onClickShout, this); | ||
156 | 124 | ||
157 | // attempt to bind to an existing combo box named gesture | 125 | // attempt to bind to an existing combo box named gesture |
158 | setGestureCombo(LLUICtrlFactory::getComboBoxByName(this, "Gesture")); | 126 | setGestureCombo(LLUICtrlFactory::getComboBoxByName(this, "Gesture")); |
159 | 127 | ||
160 | LLButton * sayp = static_cast<LLButton*>(getChildByName("Say", TRUE)); | ||
161 | if(sayp) | ||
162 | { | ||
163 | setDefaultBtn(sayp); | ||
164 | } | ||
165 | |||
166 | mInputEditor = LLUICtrlFactory::getLineEditorByName(this, "Chat Editor"); | 128 | mInputEditor = LLUICtrlFactory::getLineEditorByName(this, "Chat Editor"); |
167 | if (mInputEditor) | 129 | if (mInputEditor) |
168 | { | 130 | { |
169 | mInputEditor->setCallbackUserData(this); | 131 | mInputEditor->setCallbackUserData(this); |
170 | mInputEditor->setKeystrokeCallback(&onInputEditorKeystroke); | 132 | mInputEditor->setKeystrokeCallback(&onInputEditorKeystroke); |
171 | mInputEditor->setFocusLostCallback(&onInputEditorFocusLost); | 133 | mInputEditor->setFocusLostCallback(&onInputEditorFocusLost, this); |
172 | mInputEditor->setFocusReceivedCallback( &onInputEditorGainFocus ); | 134 | mInputEditor->setFocusReceivedCallback( &onInputEditorGainFocus, this ); |
173 | mInputEditor->setCommitOnFocusLost( FALSE ); | 135 | mInputEditor->setCommitOnFocusLost( FALSE ); |
174 | mInputEditor->setRevertOnEsc( FALSE ); | 136 | mInputEditor->setRevertOnEsc( FALSE ); |
175 | mInputEditor->setIgnoreTab(TRUE); | 137 | mInputEditor->setIgnoreTab(TRUE); |
@@ -189,16 +151,6 @@ BOOL LLChatBar::postBuild() | |||
189 | //----------------------------------------------------------------------- | 151 | //----------------------------------------------------------------------- |
190 | 152 | ||
191 | // virtual | 153 | // virtual |
192 | void LLChatBar::reshape(S32 width, S32 height, BOOL called_from_parent) | ||
193 | { | ||
194 | LLPanel::reshape(width, height, called_from_parent); | ||
195 | if (mIsBuilt) | ||
196 | { | ||
197 | layout(); | ||
198 | } | ||
199 | } | ||
200 | |||
201 | // virtual | ||
202 | BOOL LLChatBar::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) | 154 | BOOL LLChatBar::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) |
203 | { | 155 | { |
204 | BOOL handled = FALSE; | 156 | BOOL handled = FALSE; |
@@ -208,13 +160,6 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) | |||
208 | // ALT-RETURN is reserved for windowed/fullscreen toggle | 160 | // ALT-RETURN is reserved for windowed/fullscreen toggle |
209 | if( KEY_RETURN == key ) | 161 | if( KEY_RETURN == key ) |
210 | { | 162 | { |
211 | //if (childGetValue("Chat Editor").asString().empty()) | ||
212 | //{ | ||
213 | // // no text, just close chat bar | ||
214 | // stopChat(); | ||
215 | // return TRUE; | ||
216 | //} | ||
217 | |||
218 | if (mask == MASK_CONTROL) | 163 | if (mask == MASK_CONTROL) |
219 | { | 164 | { |
220 | // shout | 165 | // shout |
@@ -239,78 +184,8 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) | |||
239 | return handled; | 184 | return handled; |
240 | } | 185 | } |
241 | 186 | ||
242 | |||
243 | void LLChatBar::layout() | ||
244 | { | ||
245 | if (!mDynamicLayout) return; | ||
246 | |||
247 | S32 rect_width = mRect.getWidth(); | ||
248 | S32 count = 9; // number of elements in LLToolBar | ||
249 | S32 pad = 4; | ||
250 | |||
251 | LLRect gesture_rect; | ||
252 | S32 gesture_width = 0; | ||
253 | if (childGetRect("Gesture", gesture_rect)) | ||
254 | { | ||
255 | gesture_width = gesture_rect.getWidth(); | ||
256 | } | ||
257 | F32 segment_width = (F32)(rect_width - (pad + gesture_width)) / (F32)count; | ||
258 | |||
259 | S32 btn_width = lltrunc(segment_width-pad); | ||
260 | |||
261 | S32 x = 0; | ||
262 | S32 y = 1; | ||
263 | LLRect r; | ||
264 | |||
265 | x = llround(0 * segment_width); | ||
266 | r.setOriginAndSize(x, y, btn_width, BTN_HEIGHT); | ||
267 | childSetRect("History", r); | ||
268 | |||
269 | x = llround(1 * segment_width); | ||
270 | // Hack this one up so it looks nice. | ||
271 | if (mInputEditor) | ||
272 | { | ||
273 | r.setOriginAndSize(x, y+2, llfloor(6*segment_width-pad), 18); | ||
274 | mInputEditor->reshape(r.getWidth(), r.getHeight(), TRUE); | ||
275 | mInputEditor->setRect(r); | ||
276 | } | ||
277 | |||
278 | x = llround(7 * segment_width); | ||
279 | r.setOriginAndSize(x, y, btn_width, BTN_HEIGHT); | ||
280 | childSetRect("Say", r); | ||
281 | |||
282 | x = llround(8 * segment_width); | ||
283 | r.setOriginAndSize(x, y, btn_width, BTN_HEIGHT); | ||
284 | childSetRect("Shout", r); | ||
285 | |||
286 | x = rect_width - (pad + gesture_width); | ||
287 | r.setOriginAndSize(x, y, gesture_width, BTN_HEIGHT); | ||
288 | childSetRect("Gesture", r); | ||
289 | } | ||
290 | |||
291 | |||
292 | void LLChatBar::refresh() | 187 | void LLChatBar::refresh() |
293 | { | 188 | { |
294 | //BOOL chat_mode = gSavedSettings.getBOOL("ChatVisible"); | ||
295 | |||
296 | //// Grab focus when no one else has it, and we're in chat mode. | ||
297 | //if (!gFocusMgr.getKeyboardFocus() | ||
298 | // && chat_mode) | ||
299 | //{ | ||
300 | // childSetFocus("Chat Editor", TRUE); | ||
301 | //} | ||
302 | |||
303 | // Only show this view when user wants to be chatting | ||
304 | //setVisible(chat_mode); | ||
305 | |||
306 | // hide in mouselook, but keep previous visibility state | ||
307 | //BOOL mouselook = gAgent.cameraMouselook(); | ||
308 | // call superclass setVisible so that we don't overwrite the saved setting | ||
309 | if (mDynamicLayout) | ||
310 | { | ||
311 | LLPanel::setVisible(gSavedSettings.getBOOL("ChatVisible")); | ||
312 | } | ||
313 | |||
314 | // HACK: Leave the name of the gesture in place for a few seconds. | 189 | // HACK: Leave the name of the gesture in place for a few seconds. |
315 | const F32 SHOW_GESTURE_NAME_TIME = 2.f; | 190 | const F32 SHOW_GESTURE_NAME_TIME = 2.f; |
316 | if (mGestureLabelTimer.getStarted() && mGestureLabelTimer.getElapsedTimeF32() > SHOW_GESTURE_NAME_TIME) | 191 | if (mGestureLabelTimer.getStarted() && mGestureLabelTimer.getElapsedTimeF32() > SHOW_GESTURE_NAME_TIME) |
@@ -584,12 +459,7 @@ void LLChatBar::stopChat() | |||
584 | 459 | ||
585 | // hide chat bar so it doesn't grab focus back | 460 | // hide chat bar so it doesn't grab focus back |
586 | gChatBar->setVisible(FALSE); | 461 | gChatBar->setVisible(FALSE); |
587 | } | 462 | gSavedSettings.setBOOL("ChatVisible", FALSE); |
588 | |||
589 | void LLChatBar::setVisible(BOOL visible) | ||
590 | { | ||
591 | gSavedSettings.setBOOL("ChatVisible", visible); | ||
592 | LLPanel::setVisible(visible); | ||
593 | } | 463 | } |
594 | 464 | ||
595 | // static | 465 | // static |
@@ -663,30 +533,30 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) | |||
663 | } | 533 | } |
664 | 534 | ||
665 | // static | 535 | // static |
666 | void LLChatBar::onInputEditorFocusLost( LLUICtrl* caller, void* userdata) | 536 | void LLChatBar::onInputEditorFocusLost( LLFocusableElement* caller, void* userdata) |
667 | { | 537 | { |
668 | // stop typing animation | 538 | // stop typing animation |
669 | gAgent.stopTyping(); | 539 | gAgent.stopTyping(); |
670 | } | 540 | } |
671 | 541 | ||
672 | // static | 542 | // static |
673 | void LLChatBar::onInputEditorGainFocus( LLUICtrl* caller, void* userdata ) | 543 | void LLChatBar::onInputEditorGainFocus( LLFocusableElement* caller, void* userdata ) |
674 | { | 544 | { |
675 | LLFloaterChat::setHistoryCursorAndScrollToEnd(); | 545 | LLFloaterChat::setHistoryCursorAndScrollToEnd(); |
676 | } | 546 | } |
677 | 547 | ||
678 | // static | 548 | // static |
679 | void LLChatBar::onClickSay( void* userdata ) | 549 | void LLChatBar::onClickSay( LLUICtrl* ctrl, void* userdata ) |
680 | { | 550 | { |
681 | LLChatBar* self = (LLChatBar*) userdata; | 551 | LLChatBar* self = (LLChatBar*) userdata; |
682 | self->sendChat( CHAT_TYPE_NORMAL ); | 552 | if (ctrl->getValue().asString() == "shout") |
683 | } | 553 | { |
684 | 554 | self->sendChat( CHAT_TYPE_SHOUT ); | |
685 | // static | 555 | } |
686 | void LLChatBar::onClickShout( void* userdata ) | 556 | else |
687 | { | 557 | { |
688 | LLChatBar *self = (LLChatBar *)userdata; | 558 | self->sendChat( CHAT_TYPE_NORMAL ); |
689 | self->sendChat( CHAT_TYPE_SHOUT ); | 559 | } |
690 | } | 560 | } |
691 | 561 | ||
692 | void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate) | 562 | void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate) |
@@ -769,7 +639,7 @@ void LLChatBar::onCommitGesture(LLUICtrl* ctrl, void* data) | |||
769 | { | 639 | { |
770 | return; | 640 | return; |
771 | } | 641 | } |
772 | const std::string& trigger = gestures->getSimpleSelectedValue().asString(); | 642 | const std::string& trigger = gestures->getSelectedValue().asString(); |
773 | 643 | ||
774 | // pretend the user chatted the trigger string, to invoke | 644 | // pretend the user chatted the trigger string, to invoke |
775 | // substitution and logging. | 645 | // substitution and logging. |