aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lluictrl.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llui/lluictrl.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-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/lluictrl.cpp')
-rw-r--r--linden/indra/llui/lluictrl.cpp203
1 files changed, 174 insertions, 29 deletions
diff --git a/linden/indra/llui/lluictrl.cpp b/linden/indra/llui/lluictrl.cpp
index 63db1cc..0e6c155 100644
--- a/linden/indra/llui/lluictrl.cpp
+++ b/linden/indra/llui/lluictrl.cpp
@@ -32,20 +32,9 @@
32 32
33//#include "llviewerprecompiledheaders.h" 33//#include "llviewerprecompiledheaders.h"
34#include "linden_common.h" 34#include "linden_common.h"
35
36#include "lluictrl.h" 35#include "lluictrl.h"
37
38#include "llgl.h"
39#include "llui.h"
40#include "lluiconstants.h"
41#include "llfocusmgr.h" 36#include "llfocusmgr.h"
42#include "v3color.h"
43
44#include "llstring.h"
45#include "llfontgl.h"
46#include "llkeyboard.h"
47 37
48const U32 MAX_STRING_LENGTH = 10;
49 38
50LLFocusableElement::LLFocusableElement() 39LLFocusableElement::LLFocusableElement()
51: mFocusLostCallback(NULL), 40: mFocusLostCallback(NULL),
@@ -55,6 +44,11 @@ LLFocusableElement::LLFocusableElement()
55{ 44{
56} 45}
57 46
47//virtual
48LLFocusableElement::~LLFocusableElement()
49{
50}
51
58void LLFocusableElement::onFocusReceived() 52void LLFocusableElement::onFocusReceived()
59{ 53{
60 if( mFocusReceivedCallback ) 54 if( mFocusReceivedCallback )
@@ -138,6 +132,18 @@ void LLUICtrl::onCommit()
138 } 132 }
139} 133}
140 134
135//virtual
136BOOL LLUICtrl::isCtrl() const
137{
138 return TRUE;
139}
140
141//virtual
142LLSD LLUICtrl::getValue() const
143{
144 return LLSD();
145}
146
141// virtual 147// virtual
142BOOL LLUICtrl::setTextArg( const LLString& key, const LLStringExplicit& text ) 148BOOL LLUICtrl::setTextArg( const LLString& key, const LLStringExplicit& text )
143{ 149{
@@ -176,7 +182,7 @@ BOOL LLUICtrl::hasFocus() const
176void LLUICtrl::setFocus(BOOL b) 182void LLUICtrl::setFocus(BOOL b)
177{ 183{
178 // focus NEVER goes to ui ctrls that are disabled! 184 // focus NEVER goes to ui ctrls that are disabled!
179 if (!mEnabled) 185 if (!getEnabled())
180 { 186 {
181 return; 187 return;
182 } 188 }
@@ -266,6 +272,17 @@ BOOL LLUICtrl::acceptsTextInput() const
266 return FALSE; 272 return FALSE;
267} 273}
268 274
275//virtual
276BOOL LLUICtrl::isDirty() const
277{
278 return FALSE;
279};
280
281//virtual
282void LLUICtrl::resetDirty()
283{
284}
285
269// virtual 286// virtual
270void LLUICtrl::onTabInto() 287void LLUICtrl::onTabInto()
271{ 288{
@@ -285,8 +302,6 @@ void LLUICtrl::setIsChrome(BOOL is_chrome)
285// virtual 302// virtual
286BOOL LLUICtrl::getIsChrome() const 303BOOL LLUICtrl::getIsChrome() const
287{ 304{
288 // am I or any of my ancestors flagged as "chrome"?
289 if (mIsChrome) return TRUE;
290 305
291 LLView* parent_ctrl = getParent(); 306 LLView* parent_ctrl = getParent();
292 while(parent_ctrl) 307 while(parent_ctrl)
@@ -300,11 +315,12 @@ BOOL LLUICtrl::getIsChrome() const
300 315
301 if(parent_ctrl) 316 if(parent_ctrl)
302 { 317 {
303 // recurse into parent_ctrl and ask if it is in a chrome subtree 318 return mIsChrome || ((LLUICtrl*)parent_ctrl)->getIsChrome();
304 return ((LLUICtrl*)parent_ctrl)->getIsChrome(); 319 }
320 else
321 {
322 return mIsChrome ;
305 } 323 }
306
307 return FALSE;
308} 324}
309 325
310// this comparator uses the crazy disambiguating logic of LLCompareByTabOrder, 326// this comparator uses the crazy disambiguating logic of LLCompareByTabOrder,
@@ -316,7 +332,7 @@ public:
316 CompareByDefaultTabGroup(LLView::child_tab_order_t order, S32 default_tab_group): 332 CompareByDefaultTabGroup(LLView::child_tab_order_t order, S32 default_tab_group):
317 LLCompareByTabOrder(order), 333 LLCompareByTabOrder(order),
318 mDefaultTabGroup(default_tab_group) {} 334 mDefaultTabGroup(default_tab_group) {}
319protected: 335private:
320 /*virtual*/ bool compareTabOrders(const LLView::tab_order_t & a, const LLView::tab_order_t & b) const 336 /*virtual*/ bool compareTabOrders(const LLView::tab_order_t & a, const LLView::tab_order_t & b) const
321 { 337 {
322 S32 ag = a.first; // tab group for a 338 S32 ag = a.first; // tab group for a
@@ -330,8 +346,10 @@ protected:
330 S32 mDefaultTabGroup; 346 S32 mDefaultTabGroup;
331}; 347};
332 348
333// sorter for plugging into the query 349
334class DefaultTabGroupFirstSorter : public LLQuerySorter, public LLSingleton<DefaultTabGroupFirstSorter> 350// Sorter for plugging into the query.
351// I'd have defined it local to the one method that uses it but that broke the VS 05 compiler. -MG
352class LLUICtrl::DefaultTabGroupFirstSorter : public LLQuerySorter, public LLSingleton<DefaultTabGroupFirstSorter>
335{ 353{
336public: 354public:
337 /*virtual*/ void operator() (LLView * parent, viewList_t &children) const 355 /*virtual*/ void operator() (LLView * parent, viewList_t &children) const
@@ -340,14 +358,47 @@ public:
340 } 358 }
341}; 359};
342 360
343 361BOOL LLUICtrl::focusFirstItem(BOOL prefer_text_fields, BOOL focus_flash)
344BOOL LLUICtrl::focusFirstItem(BOOL prefer_text_fields)
345{ 362{
346 // try to select default tab group child 363 // try to select default tab group child
347 LLCtrlQuery query = LLView::getTabOrderQuery(); 364 LLCtrlQuery query = getTabOrderQuery();
348 // sort things such that the default tab group is at the front 365 // sort things such that the default tab group is at the front
349 query.setSorter(DefaultTabGroupFirstSorter::getInstance()); 366 query.setSorter(DefaultTabGroupFirstSorter::getInstance());
350 LLView::child_list_t result = query(this); 367 child_list_t result = query(this);
368 if(result.size() > 0)
369 {
370 LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.front());
371 if(!ctrl->hasFocus())
372 {
373 ctrl->setFocus(TRUE);
374 ctrl->onTabInto();
375 if(focus_flash)
376 {
377 gFocusMgr.triggerFocusFlash();
378 }
379 }
380 return TRUE;
381 }
382 // search for text field first
383 if(prefer_text_fields)
384 {
385 LLCtrlQuery query = getTabOrderQuery();
386 query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance());
387 child_list_t result = query(this);
388 if(result.size() > 0)
389 {
390 LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.front());
391 if(!ctrl->hasFocus())
392 {
393 ctrl->setFocus(TRUE);
394 ctrl->onTabInto();
395 gFocusMgr.triggerFocusFlash();
396 }
397 return TRUE;
398 }
399 }
400 // no text field found, or we don't care about text fields
401 result = getTabOrderQuery().run(this);
351 if(result.size() > 0) 402 if(result.size() > 0)
352 { 403 {
353 LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.front()); 404 LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.front());
@@ -359,10 +410,85 @@ BOOL LLUICtrl::focusFirstItem(BOOL prefer_text_fields)
359 } 410 }
360 return TRUE; 411 return TRUE;
361 } 412 }
362 // fall back on default behavior if we didn't find anything 413 return FALSE;
363 return LLView::focusFirstItem(prefer_text_fields);
364} 414}
365 415
416BOOL LLUICtrl::focusLastItem(BOOL prefer_text_fields)
417{
418 // search for text field first
419 if(prefer_text_fields)
420 {
421 LLCtrlQuery query = getTabOrderQuery();
422 query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance());
423 child_list_t result = query(this);
424 if(result.size() > 0)
425 {
426 LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.back());
427 if(!ctrl->hasFocus())
428 {
429 ctrl->setFocus(TRUE);
430 ctrl->onTabInto();
431 gFocusMgr.triggerFocusFlash();
432 }
433 return TRUE;
434 }
435 }
436 // no text field found, or we don't care about text fields
437 child_list_t result = getTabOrderQuery().run(this);
438 if(result.size() > 0)
439 {
440 LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.back());
441 if(!ctrl->hasFocus())
442 {
443 ctrl->setFocus(TRUE);
444 ctrl->onTabInto();
445 gFocusMgr.triggerFocusFlash();
446 }
447 return TRUE;
448 }
449 return FALSE;
450}
451
452BOOL LLUICtrl::focusNextItem(BOOL text_fields_only)
453{
454 // this assumes that this method is called on the focus root.
455 LLCtrlQuery query = getTabOrderQuery();
456 if(text_fields_only || LLUI::sConfigGroup->getBOOL("TabToTextFieldsOnly"))
457 {
458 query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance());
459 }
460 child_list_t result = query(this);
461 return focusNext(result);
462}
463
464BOOL LLUICtrl::focusPrevItem(BOOL text_fields_only)
465{
466 // this assumes that this method is called on the focus root.
467 LLCtrlQuery query = getTabOrderQuery();
468 if(text_fields_only || LLUI::sConfigGroup->getBOOL("TabToTextFieldsOnly"))
469 {
470 query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance());
471 }
472 child_list_t result = query(this);
473 return focusPrev(result);
474}
475
476const LLUICtrl* LLUICtrl::findRootMostFocusRoot() const
477{
478 const LLUICtrl* focus_root = NULL;
479 const LLUICtrl* next_view = this;
480 while(next_view)
481 {
482 if (next_view->isFocusRoot())
483 {
484 focus_root = next_view;
485 }
486 next_view = next_view->getParentUICtrl();
487 }
488 return focus_root;
489}
490
491
366/* 492/*
367// Don't let the children handle the tool tip. Handle it here instead. 493// Don't let the children handle the tool tip. Handle it here instead.
368BOOL LLUICtrl::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) 494BOOL LLUICtrl::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen)
@@ -379,7 +505,7 @@ BOOL LLUICtrl::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_sc
379 0, 0, 505 0, 0,
380 &(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) ); 506 &(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) );
381 localPointToScreen( 507 localPointToScreen(
382 mRect.getWidth(), mRect.getHeight(), 508 getRect().getWidth(), getRect().getHeight(),
383 &(sticky_rect_screen->mRight), &(sticky_rect_screen->mTop) ); 509 &(sticky_rect_screen->mRight), &(sticky_rect_screen->mTop) );
384 510
385 handled = TRUE; 511 handled = TRUE;
@@ -423,7 +549,26 @@ LLPanel* LLUICtrl::getParentPanel() const
423 { 549 {
424 parent = parent->getParent(); 550 parent = parent->getParent();
425 } 551 }
426 return reinterpret_cast<LLPanel*>(parent); 552 return (LLPanel*)(parent);
553}
554
555// Skip over any parents that are not LLUICtrl's
556// Used in focus logic since only LLUICtrl elements can have focus
557LLUICtrl* LLUICtrl::getParentUICtrl() const
558{
559 LLView* parent = getParent();
560 while (parent)
561 {
562 if (parent->isCtrl())
563 {
564 return (LLUICtrl*)(parent);
565 }
566 else
567 {
568 parent = parent->getParent();
569 }
570 }
571 return NULL;
427} 572}
428 573
429// virtual 574// virtual