aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui')
-rw-r--r--linden/indra/llui/CMakeLists.txt15
-rw-r--r--linden/indra/llui/llbutton.cpp5
-rw-r--r--linden/indra/llui/llbutton.h3
-rw-r--r--linden/indra/llui/llfloater.cpp8
-rw-r--r--linden/indra/llui/llfocusmgr.cpp84
-rw-r--r--linden/indra/llui/llfocusmgr.h49
-rw-r--r--linden/indra/llui/lliconctrl.cpp6
-rw-r--r--linden/indra/llui/lliconctrl.h2
-rw-r--r--linden/indra/llui/llmultisliderctrl.cpp3
-rw-r--r--linden/indra/llui/llpanel.cpp19
-rw-r--r--linden/indra/llui/llpanel.h3
-rw-r--r--linden/indra/llui/llsliderctrl.cpp2
-rw-r--r--linden/indra/llui/llspinctrl.cpp1
-rw-r--r--linden/indra/llui/lltextparser.cpp48
-rw-r--r--linden/indra/llui/lltextparser.h7
-rw-r--r--linden/indra/llui/llui.cpp1
-rw-r--r--linden/indra/llui/lluictrl.cpp55
-rw-r--r--linden/indra/llui/lluictrl.h26
-rw-r--r--linden/indra/llui/llview.cpp7
-rw-r--r--linden/indra/llui/llview.h14
20 files changed, 186 insertions, 172 deletions
diff --git a/linden/indra/llui/CMakeLists.txt b/linden/indra/llui/CMakeLists.txt
index a0f80b4..e6b3b63 100644
--- a/linden/indra/llui/CMakeLists.txt
+++ b/linden/indra/llui/CMakeLists.txt
@@ -3,11 +3,9 @@
3project(llui) 3project(llui)
4 4
5include(00-Common) 5include(00-Common)
6include(LLAudio)
7include(LLCommon) 6include(LLCommon)
8include(LLImage) 7include(LLImage)
9include(LLMath) 8include(LLMath)
10include(LLMedia)
11include(LLMessage) 9include(LLMessage)
12include(LLRender) 10include(LLRender)
13include(LLWindow) 11include(LLWindow)
@@ -15,11 +13,9 @@ include(LLVFS)
15include(LLXML) 13include(LLXML)
16 14
17include_directories( 15include_directories(
18 ${LLAUDIO_INCLUDE_DIRS}
19 ${LLCOMMON_INCLUDE_DIRS} 16 ${LLCOMMON_INCLUDE_DIRS}
20 ${LLIMAGE_INCLUDE_DIRS} 17 ${LLIMAGE_INCLUDE_DIRS}
21 ${LLMATH_INCLUDE_DIRS} 18 ${LLMATH_INCLUDE_DIRS}
22 ${LLMEDIA_INCLUDE_DIRS}
23 ${LLMESSAGE_INCLUDE_DIRS} 19 ${LLMESSAGE_INCLUDE_DIRS}
24 ${LLRENDER_INCLUDE_DIRS} 20 ${LLRENDER_INCLUDE_DIRS}
25 ${LLWINDOW_INCLUDE_DIRS} 21 ${LLWINDOW_INCLUDE_DIRS}
@@ -141,3 +137,14 @@ set_source_files_properties(${llui_HEADER_FILES}
141list(APPEND llui_SOURCE_FILES ${llui_HEADER_FILES}) 137list(APPEND llui_SOURCE_FILES ${llui_HEADER_FILES})
142 138
143add_library (llui ${llui_SOURCE_FILES}) 139add_library (llui ${llui_SOURCE_FILES})
140# Libraries on which this library depends, needed for Linux builds
141# Sort by high-level to low-level
142target_link_libraries(llui
143 llrender
144 llwindow
145 llimage
146 llvfs # ugh, just for LLDir
147 llxml
148 llcommon # must be after llimage, llwindow, llrender
149 llmath
150 )
diff --git a/linden/indra/llui/llbutton.cpp b/linden/indra/llui/llbutton.cpp
index 1a6c705..702e34e 100644
--- a/linden/indra/llui/llbutton.cpp
+++ b/linden/indra/llui/llbutton.cpp
@@ -840,6 +840,11 @@ void LLButton::setColor(const LLColor4& color)
840 setImageColor(color); 840 setImageColor(color);
841} 841}
842 842
843void LLButton::setAlpha(F32 alpha)
844{
845 mImageColor.setAlpha(alpha);
846 mDisabledImageColor.setAlpha(alpha * 0.5f);
847}
843 848
844void LLButton::setImageDisabled(LLPointer<LLUIImage> image) 849void LLButton::setImageDisabled(LLPointer<LLUIImage> image)
845{ 850{
diff --git a/linden/indra/llui/llbutton.h b/linden/indra/llui/llbutton.h
index 724b775..2174d95 100644
--- a/linden/indra/llui/llbutton.h
+++ b/linden/indra/llui/llbutton.h
@@ -136,7 +136,8 @@ public:
136 136
137 void setImageColor(const std::string& color_control); 137 void setImageColor(const std::string& color_control);
138 void setImageColor(const LLColor4& c); 138 void setImageColor(const LLColor4& c);
139 virtual void setColor(const LLColor4& c); 139 /*virtual*/ void setColor(const LLColor4& c);
140 /*virtual*/ void setAlpha(F32 alpha);
140 141
141 void setImages(const std::string &image_name, const std::string &selected_name); 142 void setImages(const std::string &image_name, const std::string &selected_name);
142 void setDisabledImages(const std::string &image_name, const std::string &selected_name); 143 void setDisabledImages(const std::string &image_name, const std::string &selected_name);
diff --git a/linden/indra/llui/llfloater.cpp b/linden/indra/llui/llfloater.cpp
index f6451a1..bb42ca3 100644
--- a/linden/indra/llui/llfloater.cpp
+++ b/linden/indra/llui/llfloater.cpp
@@ -1459,9 +1459,9 @@ void LLFloater::draw()
1459 { 1459 {
1460 if (hasFocus() && getDefaultButton()->getEnabled()) 1460 if (hasFocus() && getDefaultButton()->getEnabled())
1461 { 1461 {
1462 LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus(); 1462 LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus();
1463 // is this button a direct descendent and not a nested widget (e.g. checkbox)? 1463 // is this button a direct descendent and not a nested widget (e.g. checkbox)?
1464 BOOL focus_is_child_button = dynamic_cast<LLButton*>(focus_ctrl) != NULL && focus_ctrl->getParent() == this; 1464 BOOL focus_is_child_button = dynamic_cast<LLButton*>(focus_ctrl) != NULL && dynamic_cast<LLButton*>(focus_ctrl)->getParent() == this;
1465 // only enable default button when current focus is not a button 1465 // only enable default button when current focus is not a button
1466 getDefaultButton()->setBorderEnabled(!focus_is_child_button); 1466 getDefaultButton()->setBorderEnabled(!focus_is_child_button);
1467 } 1467 }
@@ -1481,7 +1481,7 @@ void LLFloater::draw()
1481 else 1481 else
1482 { 1482 {
1483 // draw children 1483 // draw children
1484 LLView* focused_child = gFocusMgr.getKeyboardFocus(); 1484 LLView* focused_child = dynamic_cast<LLView*>(gFocusMgr.getKeyboardFocus());
1485 BOOL focused_child_visible = FALSE; 1485 BOOL focused_child_visible = FALSE;
1486 if (focused_child && focused_child->getParent() == this) 1486 if (focused_child && focused_child->getParent() == this)
1487 { 1487 {
@@ -2239,7 +2239,7 @@ BOOL LLFloaterView::allChildrenClosed()
2239 LLView* viewp = *it; 2239 LLView* viewp = *it;
2240 LLFloater* floaterp = (LLFloater*)viewp; 2240 LLFloater* floaterp = (LLFloater*)viewp;
2241 2241
2242 if (floaterp->getVisible() && !floaterp->isDead() && floaterp->canClose()) 2242 if (floaterp->getVisible() && !floaterp->isDead() && floaterp->isCloseable())
2243 { 2243 {
2244 return false; 2244 return false;
2245 } 2245 }
diff --git a/linden/indra/llui/llfocusmgr.cpp b/linden/indra/llui/llfocusmgr.cpp
index 661ffdd..96b01b9 100644
--- a/linden/indra/llui/llfocusmgr.cpp
+++ b/linden/indra/llui/llfocusmgr.cpp
@@ -38,6 +38,68 @@
38 38
39const F32 FOCUS_FADE_TIME = 0.3f; 39const F32 FOCUS_FADE_TIME = 0.3f;
40 40
41// NOTE: the LLFocusableElement implementation has been here from lluictrl.cpp.
42
43LLFocusableElement::LLFocusableElement()
44: mFocusLostCallback(NULL),
45 mFocusReceivedCallback(NULL),
46 mFocusChangedCallback(NULL),
47 mFocusCallbackUserData(NULL)
48{
49}
50
51// virtual
52BOOL LLFocusableElement::handleKey(KEY key, MASK mask, BOOL called_from_parent)
53{
54 return FALSE;
55}
56
57// virtual
58BOOL LLFocusableElement::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent)
59{
60 return FALSE;
61}
62
63// virtual
64LLFocusableElement::~LLFocusableElement()
65{
66}
67
68void LLFocusableElement::onFocusReceived()
69{
70 if( mFocusReceivedCallback )
71 {
72 mFocusReceivedCallback( this, mFocusCallbackUserData );
73 }
74 if( mFocusChangedCallback )
75 {
76 mFocusChangedCallback( this, mFocusCallbackUserData );
77 }
78}
79
80void LLFocusableElement::onFocusLost()
81{
82 if( mFocusLostCallback )
83 {
84 mFocusLostCallback( this, mFocusCallbackUserData );
85 }
86
87 if( mFocusChangedCallback )
88 {
89 mFocusChangedCallback( this, mFocusCallbackUserData );
90 }
91}
92
93BOOL LLFocusableElement::hasFocus() const
94{
95 return gFocusMgr.getKeyboardFocus() == this;
96}
97
98void LLFocusableElement::setFocus(BOOL b)
99{
100}
101
102
41LLFocusMgr gFocusMgr; 103LLFocusMgr gFocusMgr;
42 104
43LLFocusMgr::LLFocusMgr() 105LLFocusMgr::LLFocusMgr()
@@ -87,11 +149,13 @@ void LLFocusMgr::releaseFocusIfNeeded( const LLView* view )
87} 149}
88 150
89 151
90void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystrokes_only) 152void LLFocusMgr::setKeyboardFocus(LLFocusableElement* new_focus, BOOL lock, BOOL keystrokes_only)
91{ 153{
92 if (mLockedView && 154 if (mLockedView &&
93 (new_focus == NULL || 155 (new_focus == NULL ||
94 (new_focus != mLockedView && !new_focus->hasAncestor(mLockedView)))) 156 (new_focus != mLockedView
157 && dynamic_cast<LLView*>(new_focus)
158 && !dynamic_cast<LLView*>(new_focus)->hasAncestor(mLockedView))))
95 { 159 {
96 // don't allow focus to go to anything that is not the locked focus 160 // don't allow focus to go to anything that is not the locked focus
97 // or one of its descendants 161 // or one of its descendants
@@ -121,7 +185,8 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke
121 mFocusTimer.reset(); 185 mFocusTimer.reset();
122 186
123 #ifdef _DEBUG 187 #ifdef _DEBUG
124 mKeyboardFocusName = new_focus ? new_focus->getName() : std::string("none"); 188 LLUICtrl* focus_ctrl = dynamic_cast<LLUICtrl*>(new_focus);
189 mKeyboardFocusName = focus_ctrl ? focus_ctrl->getName() : std::string("none");
125 #endif 190 #endif
126 191
127 // If we've got a default keyboard focus, and the caller is 192 // If we've got a default keyboard focus, and the caller is
@@ -131,8 +196,8 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke
131 mDefaultKeyboardFocus->setFocus(TRUE); 196 mDefaultKeyboardFocus->setFocus(TRUE);
132 } 197 }
133 198
134 LLView* focus_subtree = mKeyboardFocus; 199 LLView* focus_subtree = dynamic_cast<LLView*>(mKeyboardFocus);
135 LLView* viewp = mKeyboardFocus; 200 LLView* viewp = dynamic_cast<LLView*>(mKeyboardFocus);
136 // find root-most focus root 201 // find root-most focus root
137 while(viewp) 202 while(viewp)
138 { 203 {
@@ -146,7 +211,8 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke
146 211
147 if (focus_subtree) 212 if (focus_subtree)
148 { 213 {
149 mFocusHistory[focus_subtree->getHandle()] = mKeyboardFocus ? mKeyboardFocus->getHandle() : LLHandle<LLView>(); 214 LLView* focused_view = dynamic_cast<LLView*>(mKeyboardFocus);
215 mFocusHistory[focus_subtree->getHandle()] = focused_view ? focused_view->getHandle() : LLHandle<LLView>();
150 } 216 }
151 } 217 }
152 218
@@ -160,7 +226,7 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke
160// Returns TRUE is parent or any descedent of parent has keyboard focus. 226// Returns TRUE is parent or any descedent of parent has keyboard focus.
161BOOL LLFocusMgr::childHasKeyboardFocus(const LLView* parent ) const 227BOOL LLFocusMgr::childHasKeyboardFocus(const LLView* parent ) const
162{ 228{
163 LLView* focus_view = mKeyboardFocus; 229 LLView* focus_view = dynamic_cast<LLView*>(mKeyboardFocus);
164 while( focus_view ) 230 while( focus_view )
165 { 231 {
166 if( focus_view == parent ) 232 if( focus_view == parent )
@@ -190,7 +256,7 @@ BOOL LLFocusMgr::childHasMouseCapture( const LLView* parent ) const
190 return FALSE; 256 return FALSE;
191} 257}
192 258
193void LLFocusMgr::removeKeyboardFocusWithoutCallback( const LLView* focus ) 259void LLFocusMgr::removeKeyboardFocusWithoutCallback( const LLFocusableElement* focus )
194{ 260{
195 // should be ok to unlock here, as you have to know the locked view 261 // should be ok to unlock here, as you have to know the locked view
196 // in order to unlock it 262 // in order to unlock it
@@ -313,7 +379,7 @@ void LLFocusMgr::removeTopCtrlWithoutCallback( const LLUICtrl* top_view )
313 379
314void LLFocusMgr::lockFocus() 380void LLFocusMgr::lockFocus()
315{ 381{
316 mLockedView = mKeyboardFocus; 382 mLockedView = dynamic_cast<LLUICtrl*>(mKeyboardFocus);
317} 383}
318 384
319void LLFocusMgr::unlockFocus() 385void LLFocusMgr::unlockFocus()
diff --git a/linden/indra/llui/llfocusmgr.h b/linden/indra/llui/llfocusmgr.h
index aaeb25a..88ede1a 100644
--- a/linden/indra/llui/llfocusmgr.h
+++ b/linden/indra/llui/llfocusmgr.h
@@ -37,10 +37,39 @@
37 37
38#include "llstring.h" 38#include "llstring.h"
39#include "llframetimer.h" 39#include "llframetimer.h"
40#include "llview.h" 40#include "llui.h"
41 41
42class LLUICtrl; 42class LLUICtrl;
43class LLMouseHandler; 43class LLMouseHandler;
44class LLView;
45
46class LLFocusableElement
47{
48 friend class LLFocusMgr; // allow access to focus change handlers
49public:
50 LLFocusableElement();
51 virtual ~LLFocusableElement();
52
53 virtual void setFocus( BOOL b );
54 virtual BOOL hasFocus() const;
55
56 void setFocusLostCallback(void (*cb)(LLFocusableElement* caller, void*), void* user_data = NULL) { mFocusLostCallback = cb; mFocusCallbackUserData = user_data; }
57 void setFocusReceivedCallback( void (*cb)(LLFocusableElement*, void*), void* user_data = NULL) { mFocusReceivedCallback = cb; mFocusCallbackUserData = user_data; }
58 void setFocusChangedCallback( void (*cb)(LLFocusableElement*, void*), void* user_data = NULL ) { mFocusChangedCallback = cb; mFocusCallbackUserData = user_data; }
59
60 // These were brought up the hierarchy from LLView so that we don't have to use dynamic_cast when dealing with keyboard focus.
61 virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
62 virtual BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent);
63
64protected:
65 virtual void onFocusReceived();
66 virtual void onFocusLost();
67 void (*mFocusLostCallback)( LLFocusableElement* caller, void* userdata );
68 void (*mFocusReceivedCallback)( LLFocusableElement* ctrl, void* userdata );
69 void (*mFocusChangedCallback)( LLFocusableElement* ctrl, void* userdata );
70 void* mFocusCallbackUserData;
71};
72
44 73
45class LLFocusMgr 74class LLFocusMgr
46{ 75{
@@ -55,11 +84,11 @@ public:
55 BOOL childHasMouseCapture( const LLView* parent ) const; 84 BOOL childHasMouseCapture( const LLView* parent ) const;
56 85
57 // Keyboard Focus 86 // Keyboard Focus
58 void setKeyboardFocus(LLUICtrl* new_focus, BOOL lock = FALSE, BOOL keystrokes_only = FALSE); // new_focus = NULL to release the focus. 87 void setKeyboardFocus(LLFocusableElement* new_focus, BOOL lock = FALSE, BOOL keystrokes_only = FALSE); // new_focus = NULL to release the focus.
59 LLUICtrl* getKeyboardFocus() const { return mKeyboardFocus; } 88 LLFocusableElement* getKeyboardFocus() const { return mKeyboardFocus; }
60 LLUICtrl* getLastKeyboardFocus() const { return mLastKeyboardFocus; } 89 LLFocusableElement* getLastKeyboardFocus() const { return mLastKeyboardFocus; }
61 BOOL childHasKeyboardFocus( const LLView* parent ) const; 90 BOOL childHasKeyboardFocus( const LLView* parent ) const;
62 void removeKeyboardFocusWithoutCallback( const LLView* focus ); 91 void removeKeyboardFocusWithoutCallback( const LLFocusableElement* focus );
63 BOOL getKeystrokesOnly() { return mKeystrokesOnly; } 92 BOOL getKeystrokesOnly() { return mKeystrokesOnly; }
64 void setKeystrokesOnly(BOOL keystrokes_only) { mKeystrokesOnly = keystrokes_only; } 93 void setKeystrokesOnly(BOOL keystrokes_only) { mKeystrokesOnly = keystrokes_only; }
65 94
@@ -75,8 +104,8 @@ public:
75 104
76 // If setKeyboardFocus(NULL) is called, and there is a non-NULL default 105 // If setKeyboardFocus(NULL) is called, and there is a non-NULL default
77 // keyboard focus view, focus goes there. JC 106 // keyboard focus view, focus goes there. JC
78 void setDefaultKeyboardFocus(LLUICtrl* default_focus) { mDefaultKeyboardFocus = default_focus; } 107 void setDefaultKeyboardFocus(LLFocusableElement* default_focus) { mDefaultKeyboardFocus = default_focus; }
79 LLUICtrl* getDefaultKeyboardFocus() const { return mDefaultKeyboardFocus; } 108 LLFocusableElement* getDefaultKeyboardFocus() const { return mDefaultKeyboardFocus; }
80 109
81 110
82 // Top View 111 // Top View
@@ -98,9 +127,9 @@ private:
98 LLMouseHandler* mMouseCaptor; // Mouse events are premptively routed to this object 127 LLMouseHandler* mMouseCaptor; // Mouse events are premptively routed to this object
99 128
100 // Keyboard Focus 129 // Keyboard Focus
101 LLUICtrl* mKeyboardFocus; // Keyboard events are preemptively routed to this object 130 LLFocusableElement* mKeyboardFocus; // Keyboard events are preemptively routed to this object
102 LLUICtrl* mLastKeyboardFocus; // who last had focus 131 LLFocusableElement* mLastKeyboardFocus; // who last had focus
103 LLUICtrl* mDefaultKeyboardFocus; 132 LLFocusableElement* mDefaultKeyboardFocus;
104 BOOL mKeystrokesOnly; 133 BOOL mKeystrokesOnly;
105 134
106 // Top View 135 // Top View
diff --git a/linden/indra/llui/lliconctrl.cpp b/linden/indra/llui/lliconctrl.cpp
index e73c8fe..0df960e 100644
--- a/linden/indra/llui/lliconctrl.cpp
+++ b/linden/indra/llui/lliconctrl.cpp
@@ -112,6 +112,12 @@ void LLIconCtrl::draw()
112 LLUICtrl::draw(); 112 LLUICtrl::draw();
113} 113}
114 114
115// virtual
116void LLIconCtrl::setAlpha(F32 alpha)
117{
118 mColor.setAlpha(alpha);
119}
120
115// virtual 121// virtual
116void LLIconCtrl::setValue(const LLSD& value ) 122void LLIconCtrl::setValue(const LLSD& value )
117{ 123{
diff --git a/linden/indra/llui/lliconctrl.h b/linden/indra/llui/lliconctrl.h
index 50778cf..2506fb2 100644
--- a/linden/indra/llui/lliconctrl.h
+++ b/linden/indra/llui/lliconctrl.h
@@ -65,6 +65,8 @@ public:
65 virtual void setValue(const LLSD& value ); 65 virtual void setValue(const LLSD& value );
66 virtual LLSD getValue() const; 66 virtual LLSD getValue() const;
67 67
68 /*virtual*/ void setAlpha(F32 alpha);
69
68 void setColor(const LLColor4& color) { mColor = color; } 70 void setColor(const LLColor4& color) { mColor = color; }
69 71
70 virtual LLXMLNodePtr getXML(bool save_children = true) const; 72 virtual LLXMLNodePtr getXML(bool save_children = true) const;
diff --git a/linden/indra/llui/llmultisliderctrl.cpp b/linden/indra/llui/llmultisliderctrl.cpp
index b76c2f6..f9ec6d5 100644
--- a/linden/indra/llui/llmultisliderctrl.cpp
+++ b/linden/indra/llui/llmultisliderctrl.cpp
@@ -34,9 +34,6 @@
34 34
35#include "llmultisliderctrl.h" 35#include "llmultisliderctrl.h"
36 36
37#include "audioengine.h"
38#include "sound_ids.h"
39
40#include "llmath.h" 37#include "llmath.h"
41#include "llfontgl.h" 38#include "llfontgl.h"
42#include "llgl.h" 39#include "llgl.h"
diff --git a/linden/indra/llui/llpanel.cpp b/linden/indra/llui/llpanel.cpp
index 709342b..26137d7 100644
--- a/linden/indra/llui/llpanel.cpp
+++ b/linden/indra/llui/llpanel.cpp
@@ -203,6 +203,12 @@ void LLPanel::draw()
203 LLView::draw(); 203 LLView::draw();
204} 204}
205 205
206/*virtual*/
207void LLPanel::setAlpha(F32 alpha)
208{
209 mBgColorOpaque.setAlpha(alpha);
210}
211
206void LLPanel::updateDefaultBtn() 212void LLPanel::updateDefaultBtn()
207{ 213{
208 // This method does not call LLView::draw() so callers will need 214 // This method does not call LLView::draw() so callers will need
@@ -213,8 +219,7 @@ void LLPanel::updateDefaultBtn()
213 { 219 {
214 if (gFocusMgr.childHasKeyboardFocus( this ) && mDefaultBtn->getEnabled()) 220 if (gFocusMgr.childHasKeyboardFocus( this ) && mDefaultBtn->getEnabled())
215 { 221 {
216 LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus(); 222 LLButton* buttonp = dynamic_cast<LLButton*>(gFocusMgr.getKeyboardFocus());
217 LLButton* buttonp = dynamic_cast<LLButton*>(focus_ctrl);
218 BOOL focus_is_child_button = buttonp && buttonp->getCommitOnReturn(); 223 BOOL focus_is_child_button = buttonp && buttonp->getCommitOnReturn();
219 // only enable default button when current focus is not a return-capturing button 224 // only enable default button when current focus is not a return-capturing button
220 mDefaultBtn->setBorderEnabled(!focus_is_child_button); 225 mDefaultBtn->setBorderEnabled(!focus_is_child_button);
@@ -276,7 +281,7 @@ BOOL LLPanel::handleKeyHere( KEY key, MASK mask )
276{ 281{
277 BOOL handled = FALSE; 282 BOOL handled = FALSE;
278 283
279 LLUICtrl* cur_focus = gFocusMgr.getKeyboardFocus(); 284 LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
280 285
281 // handle user hitting ESC to defocus 286 // handle user hitting ESC to defocus
282 if (key == KEY_ESCAPE) 287 if (key == KEY_ESCAPE)
@@ -800,6 +805,14 @@ void LLPanel::childSetColor(const std::string& id, const LLColor4& color)
800 child->setColor(color); 805 child->setColor(color);
801 } 806 }
802} 807}
808void LLPanel::childSetAlpha(const std::string& id, F32 alpha)
809{
810 LLUICtrl* child = getChild<LLUICtrl>(id, true);
811 if (child)
812 {
813 child->setAlpha(alpha);
814 }
815}
803 816
804LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& id) const 817LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& id) const
805{ 818{
diff --git a/linden/indra/llui/llpanel.h b/linden/indra/llui/llpanel.h
index 756d02e..378b357 100644
--- a/linden/indra/llui/llpanel.h
+++ b/linden/indra/llui/llpanel.h
@@ -82,6 +82,8 @@ public:
82 82
83 // From LLFocusableElement 83 // From LLFocusableElement
84 /*virtual*/ void setFocus( BOOL b ); 84 /*virtual*/ void setFocus( BOOL b );
85 virtual void setAlpha(F32 alpha);
86
85 87
86 // New virtuals 88 // New virtuals
87 virtual void refresh(); // called in setFocus() 89 virtual void refresh(); // called in setFocus()
@@ -174,6 +176,7 @@ public:
174 void childSetUserData(const std::string& id, void* userdata); 176 void childSetUserData(const std::string& id, void* userdata);
175 177
176 void childSetColor(const std::string& id, const LLColor4& color); 178 void childSetColor(const std::string& id, const LLColor4& color);
179 void childSetAlpha(const std::string& id, F32 alpha);
177 180
178 LLCtrlSelectionInterface* childGetSelectionInterface(const std::string& id) const; 181 LLCtrlSelectionInterface* childGetSelectionInterface(const std::string& id) const;
179 LLCtrlListInterface* childGetListInterface(const std::string& id) const; 182 LLCtrlListInterface* childGetListInterface(const std::string& id) const;
diff --git a/linden/indra/llui/llsliderctrl.cpp b/linden/indra/llui/llsliderctrl.cpp
index 8a13ed4..51d43fb 100644
--- a/linden/indra/llui/llsliderctrl.cpp
+++ b/linden/indra/llui/llsliderctrl.cpp
@@ -34,8 +34,6 @@
34 34
35#include "llsliderctrl.h" 35#include "llsliderctrl.h"
36 36
37#include "audioengine.h"
38
39#include "llmath.h" 37#include "llmath.h"
40#include "llfontgl.h" 38#include "llfontgl.h"
41#include "llgl.h" 39#include "llgl.h"
diff --git a/linden/indra/llui/llspinctrl.cpp b/linden/indra/llui/llspinctrl.cpp
index 7eccaca..e66b20e 100644
--- a/linden/indra/llui/llspinctrl.cpp
+++ b/linden/indra/llui/llspinctrl.cpp
@@ -45,7 +45,6 @@
45#include "lltextbox.h" 45#include "lltextbox.h"
46#include "llkeyboard.h" 46#include "llkeyboard.h"
47#include "llmath.h" 47#include "llmath.h"
48#include "audioengine.h"
49#include "llcontrol.h" 48#include "llcontrol.h"
50#include "llfocusmgr.h" 49#include "llfocusmgr.h"
51#include "llresmgr.h" 50#include "llresmgr.h"
diff --git a/linden/indra/llui/lltextparser.cpp b/linden/indra/llui/lltextparser.cpp
index 925b118..707dd0a 100644
--- a/linden/indra/llui/lltextparser.cpp
+++ b/linden/indra/llui/lltextparser.cpp
@@ -1,6 +1,5 @@
1/** 1/**
2 * @file lltexteditor.cpp 2 * @file lltextparser.cpp
3 * @brief LLTextEditor base class
4 * 3 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 4 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 5 *
@@ -32,6 +31,8 @@
32 31
33#include "linden_common.h" 32#include "linden_common.h"
34 33
34#include "lltextparser.h"
35
35#include "llsd.h" 36#include "llsd.h"
36#include "llsdserialize.h" 37#include "llsdserialize.h"
37#include "llerror.h" 38#include "llerror.h"
@@ -40,23 +41,13 @@
40#include "message.h" 41#include "message.h"
41#include "llmath.h" 42#include "llmath.h"
42#include "v4color.h" 43#include "v4color.h"
43#include "audioengine.h"
44#include "llwindow.h"
45#include "lldir.h" 44#include "lldir.h"
46 45
47#include "lltextparser.h"
48//#include "lltexttospeech.h"
49
50// Routines used for parsing text for TextParsers and html 46// Routines used for parsing text for TextParsers and html
51 47
52LLTextParser* LLTextParser::sInstance = NULL; 48LLTextParser* LLTextParser::sInstance = NULL;
53 49
54// 50//
55// Constants
56//
57const F32 SOUND_GAIN = 1.0f;
58
59//
60// Member Functions 51// Member Functions
61// 52//
62 53
@@ -76,38 +67,7 @@ LLTextParser* LLTextParser::getInstance()
76 return sInstance; 67 return sInstance;
77} 68}
78 69
79void LLTextParser::triggerAlerts(LLUUID agent_id, LLVector3d position, std::string text, LLWindow* viewer_window) 70// Moved triggerAlerts() to llfloaterchat.cpp to break llui/llaudio library dependency.
80{
81// bool spoken=FALSE;
82 for (S32 i=0;i<mHighlights.size();i++)
83 {
84 if (findPattern(text,mHighlights[i]) >= 0 )
85 {
86 if(gAudiop)
87 {
88 if ((std::string)mHighlights[i]["sound_lluuid"] != LLUUID::null.asString())
89 {
90 gAudiop->triggerSound(mHighlights[i]["sound_lluuid"].asUUID(), agent_id, SOUND_GAIN, LLAudioEngine::AUDIO_TYPE_UI, position);
91 }
92/*
93 if (!spoken)
94 {
95 LLTextToSpeech* text_to_speech = NULL;
96 text_to_speech = LLTextToSpeech::getInstance();
97 spoken = text_to_speech->speak((LLString)mHighlights[i]["voice"],text);
98 }
99 */
100 }
101 if (mHighlights[i]["flash"])
102 {
103 if (viewer_window && viewer_window->getMinimized())
104 {
105 viewer_window->flashIcon(5.f);
106 }
107 }
108 }
109 }
110}
111 71
112S32 LLTextParser::findPattern(const std::string &text, LLSD highlight) 72S32 LLTextParser::findPattern(const std::string &text, LLSD highlight)
113{ 73{
diff --git a/linden/indra/llui/lltextparser.h b/linden/indra/llui/lltextparser.h
index d69e3a2..32343a2 100644
--- a/linden/indra/llui/lltextparser.h
+++ b/linden/indra/llui/lltextparser.h
@@ -34,12 +34,8 @@
34#ifndef LL_LLTEXTPARSER_H 34#ifndef LL_LLTEXTPARSER_H
35#define LL_LLTEXTPARSER_H 35#define LL_LLTEXTPARSER_H
36 36
37#include <vector> 37#include "llsd.h"
38#include "linden_common.h"
39 38
40#include "lltextparser.h"
41
42class LLSD;
43class LLUUID; 39class LLUUID;
44class LLVector3d; 40class LLVector3d;
45class LLColor4; 41class LLColor4;
@@ -59,7 +55,6 @@ public:
59 S32 findPattern(const std::string &text, LLSD highlight); 55 S32 findPattern(const std::string &text, LLSD highlight);
60 LLSD parsePartialLineHighlights(const std::string &text,const LLColor4 &color,S32 part=WHOLE, S32 index=0); 56 LLSD parsePartialLineHighlights(const std::string &text,const LLColor4 &color,S32 part=WHOLE, S32 index=0);
61 bool parseFullLineHighlights(const std::string &text, LLColor4 *color); 57 bool parseFullLineHighlights(const std::string &text, LLColor4 *color);
62 void triggerAlerts(LLUUID agent_id, LLVector3d position, std::string text, LLWindow* viewer_window);
63 58
64 std::string getFileName(); 59 std::string getFileName();
65 LLSD loadFromDisk(); 60 LLSD loadFromDisk();
diff --git a/linden/indra/llui/llui.cpp b/linden/indra/llui/llui.cpp
index 57ce13c..75a4467 100644
--- a/linden/indra/llui/llui.cpp
+++ b/linden/indra/llui/llui.cpp
@@ -38,7 +38,6 @@
38#include <map> 38#include <map>
39 39
40// Linden library includes 40// Linden library includes
41#include "audioengine.h"
42#include "v2math.h" 41#include "v2math.h"
43#include "v4color.h" 42#include "v4color.h"
44#include "llrender.h" 43#include "llrender.h"
diff --git a/linden/indra/llui/lluictrl.cpp b/linden/indra/llui/lluictrl.cpp
index 9d97312..3f4ab5e 100644
--- a/linden/indra/llui/lluictrl.cpp
+++ b/linden/indra/llui/lluictrl.cpp
@@ -39,54 +39,7 @@
39 39
40static LLRegisterWidget<LLUICtrl> r("ui_ctrl"); 40static LLRegisterWidget<LLUICtrl> r("ui_ctrl");
41 41
42LLFocusableElement::LLFocusableElement() 42// NOTE: the LLFocusableElement implementation has been moved to llfocusmgr.cpp, to mirror the header where the class is defined.
43: mFocusLostCallback(NULL),
44 mFocusReceivedCallback(NULL),
45 mFocusChangedCallback(NULL),
46 mFocusCallbackUserData(NULL)
47{
48}
49
50//virtual
51LLFocusableElement::~LLFocusableElement()
52{
53}
54
55void LLFocusableElement::onFocusReceived()
56{
57 if( mFocusReceivedCallback )
58 {
59 mFocusReceivedCallback( this, mFocusCallbackUserData );
60 }
61 if( mFocusChangedCallback )
62 {
63 mFocusChangedCallback( this, mFocusCallbackUserData );
64 }
65}
66
67void LLFocusableElement::onFocusLost()
68{
69 if( mFocusLostCallback )
70 {
71 mFocusLostCallback( this, mFocusCallbackUserData );
72 }
73
74 if( mFocusChangedCallback )
75 {
76 mFocusChangedCallback( this, mFocusCallbackUserData );
77 }
78}
79
80BOOL LLFocusableElement::hasFocus() const
81{
82 return FALSE;
83}
84
85void LLFocusableElement::setFocus(BOOL b)
86{
87}
88
89
90 43
91LLUICtrl::LLUICtrl() : 44LLUICtrl::LLUICtrl() :
92 mCommitCallback(NULL), 45 mCommitCallback(NULL),
@@ -212,7 +165,7 @@ void LLUICtrl::onFocusReceived()
212 165
213 // find first view in hierarchy above new focus that is a LLUICtrl 166 // find first view in hierarchy above new focus that is a LLUICtrl
214 LLView* viewp = getParent(); 167 LLView* viewp = getParent();
215 LLUICtrl* last_focus = gFocusMgr.getLastKeyboardFocus(); 168 LLUICtrl* last_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getLastKeyboardFocus());
216 169
217 while (viewp && !viewp->isCtrl()) 170 while (viewp && !viewp->isCtrl())
218 { 171 {
@@ -590,6 +543,10 @@ void LLUICtrl::setDoubleClickCallback( void (*cb)(void*) )
590// virtual 543// virtual
591void LLUICtrl::setColor(const LLColor4& color) 544void LLUICtrl::setColor(const LLColor4& color)
592{ } 545{ }
546// virtual
547
548void LLUICtrl::setAlpha(F32 alpha)
549{ }
593 550
594// virtual 551// virtual
595void LLUICtrl::setMinValue(LLSD min_value) 552void LLUICtrl::setMinValue(LLSD min_value)
diff --git a/linden/indra/llui/lluictrl.h b/linden/indra/llui/lluictrl.h
index db41af8..be8e863 100644
--- a/linden/indra/llui/lluictrl.h
+++ b/linden/indra/llui/lluictrl.h
@@ -39,31 +39,8 @@
39#include "llsd.h" 39#include "llsd.h"
40 40
41 41
42class LLFocusableElement
43{
44 friend class LLFocusMgr; // allow access to focus change handlers
45public:
46 LLFocusableElement();
47 virtual ~LLFocusableElement();
48
49 virtual void setFocus( BOOL b );
50 virtual BOOL hasFocus() const;
51
52 void setFocusLostCallback(void (*cb)(LLFocusableElement* caller, void*), void* user_data = NULL) { mFocusLostCallback = cb; mFocusCallbackUserData = user_data; }
53 void setFocusReceivedCallback( void (*cb)(LLFocusableElement*, void*), void* user_data = NULL) { mFocusReceivedCallback = cb; mFocusCallbackUserData = user_data; }
54 void setFocusChangedCallback( void (*cb)(LLFocusableElement*, void*), void* user_data = NULL ) { mFocusChangedCallback = cb; mFocusCallbackUserData = user_data; }
55
56protected:
57 virtual void onFocusReceived();
58 virtual void onFocusLost();
59 void (*mFocusLostCallback)( LLFocusableElement* caller, void* userdata );
60 void (*mFocusReceivedCallback)( LLFocusableElement* ctrl, void* userdata );
61 void (*mFocusChangedCallback)( LLFocusableElement* ctrl, void* userdata );
62 void* mFocusCallbackUserData;
63};
64
65class LLUICtrl 42class LLUICtrl
66: public LLView, public LLFocusableElement 43: public LLView
67{ 44{
68public: 45public:
69 typedef void (*LLUICtrlCallback)(LLUICtrl* ctrl, void* userdata); 46 typedef void (*LLUICtrlCallback)(LLUICtrl* ctrl, void* userdata);
@@ -117,6 +94,7 @@ public:
117 virtual void clear(); 94 virtual void clear();
118 virtual void setDoubleClickCallback( void (*cb)(void*) ); 95 virtual void setDoubleClickCallback( void (*cb)(void*) );
119 virtual void setColor(const LLColor4& color); 96 virtual void setColor(const LLColor4& color);
97 virtual void setAlpha(F32 alpha);
120 virtual void setMinValue(LLSD min_value); 98 virtual void setMinValue(LLSD min_value);
121 virtual void setMaxValue(LLSD max_value); 99 virtual void setMaxValue(LLSD max_value);
122 100
diff --git a/linden/indra/llui/llview.cpp b/linden/indra/llui/llview.cpp
index 8de376f..1f76696 100644
--- a/linden/indra/llui/llview.cpp
+++ b/linden/indra/llui/llview.cpp
@@ -136,11 +136,6 @@ LLView::~LLView()
136{ 136{
137 //llinfos << "Deleting view " << mName << ":" << (void*) this << llendl; 137 //llinfos << "Deleting view " << mName << ":" << (void*) this << llendl;
138// llassert(LLView::sIsDrawing == FALSE); 138// llassert(LLView::sIsDrawing == FALSE);
139 if( gFocusMgr.getKeyboardFocus() == this )
140 {
141 llwarns << "View holding keyboard focus deleted: " << getName() << ". Keyboard focus removed." << llendl;
142 gFocusMgr.removeKeyboardFocusWithoutCallback( this );
143 }
144 139
145 if( hasMouseCapture() ) 140 if( hasMouseCapture() )
146 { 141 {
@@ -1327,7 +1322,7 @@ void LLView::draw()
1327 LLRect screenRect; 1322 LLRect screenRect;
1328 1323
1329 // draw focused control on top of everything else 1324 // draw focused control on top of everything else
1330 LLView* focus_view = gFocusMgr.getKeyboardFocus(); 1325 LLUICtrl* focus_view = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
1331 if (focus_view && focus_view->getParent() != this) 1326 if (focus_view && focus_view->getParent() != this)
1332 { 1327 {
1333 focus_view = NULL; 1328 focus_view = NULL;
diff --git a/linden/indra/llui/llview.h b/linden/indra/llui/llview.h
index 7e09dfa..1c8ab31 100644
--- a/linden/indra/llui/llview.h
+++ b/linden/indra/llui/llview.h
@@ -53,6 +53,7 @@
53#include "stdenums.h" 53#include "stdenums.h"
54#include "lluistring.h" 54#include "lluistring.h"
55#include "llcursortypes.h" 55#include "llcursortypes.h"
56#include "llfocusmgr.h"
56 57
57const U32 FOLLOWS_NONE = 0x00; 58const U32 FOLLOWS_NONE = 0x00;
58const U32 FOLLOWS_LEFT = 0x01; 59const U32 FOLLOWS_LEFT = 0x01;
@@ -207,7 +208,7 @@ public:
207 } 208 }
208}; 209};
209 210
210class LLView : public LLMouseHandler, public LLMortician 211class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElement
211{ 212{
212 213
213public: 214public:
@@ -398,9 +399,11 @@ public:
398 virtual BOOL canSnapTo(const LLView* other_view); 399 virtual BOOL canSnapTo(const LLView* other_view);
399 400
400 virtual void snappedTo(const LLView* snap_view); 401 virtual void snappedTo(const LLView* snap_view);
402
403 // inherited from LLFocusableElement
404 /* virtual */ BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
405 /* virtual */ BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent);
401 406
402 virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
403 virtual BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent);
404 virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, 407 virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
405 EDragAndDropType cargo_type, 408 EDragAndDropType cargo_type,
406 void* cargo_data, 409 void* cargo_data,
@@ -421,8 +424,9 @@ public:
421 BOOL getSaveToXML() const { return mSaveToXML; } 424 BOOL getSaveToXML() const { return mSaveToXML; }
422 void setSaveToXML(BOOL b) { mSaveToXML = b; } 425 void setSaveToXML(BOOL b) { mSaveToXML = b; }
423 426
424 virtual void onFocusLost(); 427 // inherited from LLFocusableElement
425 virtual void onFocusReceived(); 428 /* virtual */ void onFocusLost();
429 /* virtual */ void onFocusReceived();
426 430
427 typedef enum e_hit_test_type 431 typedef enum e_hit_test_type
428 { 432 {