diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 412901693c..c0901c9413 100755 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -141,6 +141,7 @@ set(llui_HEADER_FILES CMakeLists.txt fsregistrarutils.h + fssearchablecontrol.h llaccordionctrl.h llaccordionctrltab.h diff --git a/indra/llui/fssearchablecontrol.h b/indra/llui/fssearchablecontrol.h new file mode 100644 index 0000000000..40aac254d0 --- /dev/null +++ b/indra/llui/fssearchablecontrol.h @@ -0,0 +1,70 @@ +#ifndef FS_SEARCHABLE_CONTROL_H +#define FS_SEARCHABLE_CONTROL_H + +/** + * $LicenseInfo:firstyear=2014&license=fsviewerlgpl$ + * Phoenix Firestorm Viewer Source Code + * Copyright (C) 2014, Nicky Dasmijn + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA + * http://www.firestormviewer.org + * $/LicenseInfo$ + */ + +#include "lluicolortable.h" +#include "lluicolor.h" + +namespace nd +{ + namespace ui + { + class SearchableControl + { + mutable bool mIsHighlighed; + public: + SearchableControl() + : mIsHighlighed( false ) + { } + virtual ~SearchableControl() + { } + + LLColor4 getHighlightColor( ) const + { + static LLUIColor highlight_color = LLUIColorTable::instance().getColor("SearchableControlHighlightColor", LLColor4::red); + return highlight_color.get(); + } + + void setHighlighted( bool aVal ) const + { + mIsHighlighed = aVal; + onSetHighlight( ); + } + bool getHighlighted( ) const + { return mIsHighlighed; } + + std::string getSearchText() const + { return _getSearchText(); } + protected: + virtual std::string _getSearchText() const = 0; + virtual void onSetHighlight( ) const + { } + }; + } +} + + +#endif diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 6ebde23155..61739143f8 100755 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -38,49 +38,11 @@ #include "llview.h" #include "llviewmodel.h" // *TODO move dependency to .cpp file +#include "fssearchablecontrol.h" + const BOOL TAKE_FOCUS_YES = TRUE; const BOOL TAKE_FOCUS_NO = FALSE; -// To search in prefs. A control which can advertise a searchable text and can be highlighted for matching. -namespace nd -{ - namespace ui - { - class SearchableControl - { - mutable bool mIsHighlighed; - public: - SearchableControl() - : mIsHighlighed( false ) - { } - virtual ~SearchableControl() - { } - - LLColor4 getHighlightColor( ) const - { - static LLUIColor highlight_color = LLUIColorTable::instance().getColor("SearchableControlHighlightColor", LLColor4::red); - return highlight_color.get(); - } - - void setHighlighted( bool aVal ) const - { - mIsHighlighed = aVal; - onSetHighlight( ); - } - bool getHighlighted( ) const - { return mIsHighlighed; } - - std::string getSearchText() const - { return _getSearchText(); } - protected: - virtual std::string _getSearchText() const = 0; - virtual void onSetHighlight( ) const - { } - }; - } -} -// - class LLUICtrl : public LLView, public boost::signals2::trackable { diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 9ed2f542f7..9271ef6f74 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -195,6 +195,7 @@ set(viewer_SOURCE_FILES fsradarmenu.cpp fsscriptlibrary.cpp fsscrolllistctrl.cpp + fssearchableui.cpp fsslurlcommand.cpp fswsassetblacklist.cpp groupchatlistener.cpp @@ -907,6 +908,7 @@ set(viewer_HEADER_FILES fsradarmenu.h fsscriptlibrary.h fsscrolllistctrl.h + fssearchableui.h fsslurl.h fsslurlcommand.h fswsassetblacklist.h diff --git a/indra/newview/fssearchableui.cpp b/indra/newview/fssearchableui.cpp new file mode 100644 index 0000000000..bc60c25d68 --- /dev/null +++ b/indra/newview/fssearchableui.cpp @@ -0,0 +1,153 @@ +/** + * $LicenseInfo:firstyear=2014&license=fsviewerlgpl$ + * Phoenix Firestorm Viewer Source Code + * Copyright (C) 2014, Nicky Dasmijn + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA + * http://www.firestormviewer.org + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "fssearchableui.h" + +#include "llview.h" +#include "lltabcontainer.h" +#include "llmenugl.h" + +nd::prefs::SearchableItem::~SearchableItem() +{} + +void nd::prefs::SearchableItem::setNotHighlighted() +{ + mCtrl->setHighlighted( false ); +} + +bool nd::prefs::SearchableItem::hightlightAndHide( LLWString const &aFilter ) +{ + if( mCtrl->getHighlighted() ) + return true; + + LLView const *pView = dynamic_cast< LLView const* >( mCtrl ); + if( pView && !pView->getVisible() ) + return false; + + if( aFilter.empty() ) + { + mCtrl->setHighlighted( false ); + return true; + } + + if( mLabel.find( aFilter ) != LLWString::npos ) + { + mCtrl->setHighlighted( true ); + return true; + } + + return false; +} + +nd::prefs::PanelData::~PanelData() +{} + +bool nd::prefs::PanelData::hightlightAndHide( LLWString const &aFilter ) +{ + for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) + (*itr)->setNotHighlighted( ); + + bool bVisible(false); + for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) + bVisible |= (*itr)->hightlightAndHide( aFilter ); + + for( tPanelDataList::iterator itr = mChildPanel.begin(); itr != mChildPanel.end(); ++itr ) + bVisible |= (*itr)->hightlightAndHide( aFilter ); + + return bVisible; +} + +bool nd::prefs::TabContainerData::hightlightAndHide( LLWString const &aFilter ) +{ + for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) + (*itr)->setNotHighlighted( ); + + bool bVisible(false); + for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) + bVisible |= (*itr)->hightlightAndHide( aFilter ); + + for( tPanelDataList::iterator itr = mChildPanel.begin(); itr != mChildPanel.end(); ++itr ) + { + bool bPanelVisible = (*itr)->hightlightAndHide( aFilter ); + if( (*itr)->mPanel ) + mTabContainer->setTabVisibility( (*itr)->mPanel, bPanelVisible ); + bVisible |= bPanelVisible; + } + + return bVisible; +} + +nd::statusbar::SearchableItem::SearchableItem() + : mMenu(0) + , mCtrl(0) + , mWasHiddenBySearch( false ) +{ } + +void nd::statusbar::SearchableItem::setNotHighlighted( ) +{ + for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) + (*itr)->setNotHighlighted( ); + + if( mCtrl ) + { + mCtrl->setHighlighted( false ); + + if( mWasHiddenBySearch ) + mMenu->setVisible( TRUE ); + } +} + +bool nd::statusbar::SearchableItem::hightlightAndHide( LLWString const &aFilter ) +{ + if( mMenu && !mMenu->getVisible() && !mWasHiddenBySearch ) + return false; + + setNotHighlighted( ); + + bool bVisible(false); + for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) + bVisible |= (*itr)->hightlightAndHide( aFilter ); + + if( aFilter.empty() ) + { + if( mCtrl ) + mCtrl->setHighlighted( false ); + return true; + } + + if( mLabel.find( aFilter ) != LLWString::npos ) + { + if( mCtrl ) + mCtrl->setHighlighted( true ); + return true; + } + + if( mCtrl && !bVisible ) + { + mWasHiddenBySearch = true; + mMenu->setVisible(FALSE); + } + return bVisible; +} diff --git a/indra/newview/fssearchableui.h b/indra/newview/fssearchableui.h new file mode 100644 index 0000000000..b4f712368e --- /dev/null +++ b/indra/newview/fssearchableui.h @@ -0,0 +1,120 @@ +#ifndef FS_SEARCHABLE_UI_H +#define FS_SEARCHABLE_UI_H + +/** + * $LicenseInfo:firstyear=2014&license=fsviewerlgpl$ + * Phoenix Firestorm Viewer Source Code + * Copyright (C) 2014, Nicky Dasmijn + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA + * http://www.firestormviewer.org + * $/LicenseInfo$ + */ + +class LLMenuItemGL; +class LLView; +class LLPanel; +class LLTabContainer; + +#include "fssearchablecontrol.h" + +namespace nd +{ + namespace prefs + { + struct SearchableItem; + struct PanelData; + struct TabContainerData; + + typedef boost::shared_ptr< SearchableItem > SearchableItemPtr; + typedef boost::shared_ptr< PanelData > PanelDataPtr; + typedef boost::shared_ptr< TabContainerData > TabContainerDataPtr; + + typedef std::vector< TabContainerData > tTabContainerDataList; + typedef std::vector< SearchableItemPtr > tSearchableItemList; + typedef std::vector< PanelDataPtr > tPanelDataList; + + struct SearchableItem + { + LLWString mLabel; + LLView const *mView; + nd::ui::SearchableControl const *mCtrl; + + std::vector< boost::shared_ptr< SearchableItem > > mChildren; + + virtual ~SearchableItem(); + + void setNotHighlighted(); + virtual bool hightlightAndHide( LLWString const &aFilter ); + }; + + struct PanelData + { + LLPanel const *mPanel; + std::string mLabel; + + std::vector< boost::shared_ptr< SearchableItem > > mChildren; + std::vector< boost::shared_ptr< PanelData > > mChildPanel; + + virtual ~PanelData(); + + virtual bool hightlightAndHide( LLWString const &aFilter ); + }; + + struct TabContainerData: public PanelData + { + LLTabContainer *mTabContainer; + virtual bool hightlightAndHide( LLWString const &aFilter ); + }; + + struct SearchData + { + TabContainerDataPtr mRootTab; + LLWString mLastFilter; + }; + } + namespace statusbar + { + struct SearchableItem; + + typedef boost::shared_ptr< SearchableItem > SearchableItemPtr; + + typedef std::vector< SearchableItemPtr > tSearchableItemList; + + struct SearchableItem + { + LLWString mLabel; + LLMenuItemGL *mMenu; + tSearchableItemList mChildren; + nd::ui::SearchableControl const *mCtrl; + bool mWasHiddenBySearch; + + SearchableItem(); + + void setNotHighlighted( ); + bool hightlightAndHide( LLWString const &aFilter ); + }; + + struct SearchData + { + SearchableItemPtr mRootMenu; + LLWString mLastFilter; + }; + } +} + +#endif diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 64f5c45783..293b6750e6 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -137,127 +137,7 @@ #include "NACLantispam.h" #include "../llcrashlogger/llcrashlogger.h" -// To search in prefs: Data that is collected from all floater -namespace nd -{ - namespace prefs - { - struct SearchableItem; - struct PanelData; - struct TabContainerData; - - typedef boost::shared_ptr< SearchableItem > SearchableItemPtr; - typedef boost::shared_ptr< PanelData > PanelDataPtr; - typedef boost::shared_ptr< TabContainerData > TabContainerDataPtr; - - typedef std::vector< TabContainerData > tTabContainerDataList; - typedef std::vector< SearchableItemPtr > tSearchableItemList; - typedef std::vector< PanelDataPtr > tPanelDataList; - - struct SearchableItem - { - LLWString mLabel; - LLView const *mView; - nd::ui::SearchableControl const *mCtrl; - - std::vector< boost::shared_ptr< SearchableItem > > mChildren; - - virtual ~SearchableItem() - {} - - void setNotHighlighted() - { - mCtrl->setHighlighted( false ); - } - - virtual bool hightlightAndHide( LLWString const &aFilter ) - { - if( mCtrl->getHighlighted() ) - return true; - - LLView const *pView = dynamic_cast< LLView const* >( mCtrl ); - if( pView && !pView->getVisible() ) - return false; - - if( aFilter.empty() ) - { - mCtrl->setHighlighted( false ); - return true; - } - - if( mLabel.find( aFilter ) != LLWString::npos ) - { - mCtrl->setHighlighted( true ); - return true; - } - - return false; - } - }; - - struct PanelData - { - LLPanel const *mPanel; - std::string mLabel; - - std::vector< boost::shared_ptr< SearchableItem > > mChildren; - std::vector< boost::shared_ptr< PanelData > > mChildPanel; - - virtual ~PanelData() - {} - - virtual bool hightlightAndHide( LLWString const &aFilter ) - { - for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) - (*itr)->setNotHighlighted( ); - - bool bVisible(false); - for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) - bVisible |= (*itr)->hightlightAndHide( aFilter ); - - for( tPanelDataList::iterator itr = mChildPanel.begin(); itr != mChildPanel.end(); ++itr ) - bVisible |= (*itr)->hightlightAndHide( aFilter ); - - return bVisible; - } - }; - - struct TabContainerData: public PanelData - { - LLTabContainer *mTabContainer; - virtual bool hightlightAndHide( LLWString const &aFilter ) - { - for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) - (*itr)->setNotHighlighted( ); - - bool bVisible(false); - for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) - bVisible |= (*itr)->hightlightAndHide( aFilter ); - - for( tPanelDataList::iterator itr = mChildPanel.begin(); itr != mChildPanel.end(); ++itr ) - { - bool bPanelVisible = (*itr)->hightlightAndHide( aFilter ); - if( (*itr)->mPanel ) - mTabContainer->setTabVisibility( (*itr)->mPanel, bPanelVisible ); - bVisible |= bPanelVisible; - } - - return bVisible; - } - }; - - struct SearchData - { - ~SearchData() - { - } - - TabContainerDataPtr mRootTab; - LLWString mLastFilter; - }; - } -} -// +#include "fssearchableui.h" const F32 MAX_USER_FAR_CLIP = 512.f; const F32 MIN_USER_FAR_CLIP = 64.f; diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index e076ca1017..85f3e58fc9 100755 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -107,90 +107,13 @@ #include "llviewernetwork.h" #endif // OPENSIM // + +#include "fssearchableui.h" + // // Globals // -namespace nd -{ - namespace statusbar - { - struct SearchableItem; - - typedef boost::shared_ptr< SearchableItem > SearchableItemPtr; - - typedef std::vector< SearchableItemPtr > tSearchableItemList; - - struct SearchableItem - { - LLWString mLabel; - LLMenuItemGL *mMenu; - tSearchableItemList mChildren; - nd::ui::SearchableControl const *mCtrl; - bool mWasHiddenBySearch; - - SearchableItem() - : mMenu(0) - , mCtrl(0) - , mWasHiddenBySearch( false ) - { } - - void setNotHighlighted( ) - { - for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) - (*itr)->setNotHighlighted( ); - - if( mCtrl ) - { - mCtrl->setHighlighted( false ); - - if( mWasHiddenBySearch ) - mMenu->setVisible( TRUE ); - } - } - - bool hightlightAndHide( LLWString const &aFilter ) - { - if( mMenu && !mMenu->getVisible() && !mWasHiddenBySearch ) - return false; - - setNotHighlighted( ); - - bool bVisible(false); - for( tSearchableItemList::iterator itr = mChildren.begin(); itr != mChildren.end(); ++itr ) - bVisible |= (*itr)->hightlightAndHide( aFilter ); - - if( aFilter.empty() ) - { - if( mCtrl ) - mCtrl->setHighlighted( false ); - return true; - } - - if( mLabel.find( aFilter ) != LLWString::npos ) - { - if( mCtrl ) - mCtrl->setHighlighted( true ); - return true; - } - - if( mCtrl && !bVisible ) - { - mWasHiddenBySearch = true; - mMenu->setVisible(FALSE); - } - return bVisible; - } - }; - - struct SearchData - { - SearchableItemPtr mRootMenu; - LLWString mLastFilter; - }; - } -} - LLStatusBar *gStatusBar = NULL; S32 STATUS_BAR_HEIGHT = 26; extern S32 MENU_BAR_HEIGHT;