diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 4b6c6156d..057e7d0ca 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -35,6 +35,7 @@ set(llui_SOURCE_FILES lleditmenuhandler.cpp llfiltereditor.cpp llfloater.cpp + llflyoutbutton.cpp llfocusmgr.cpp llfunctorregistry.cpp lliconctrl.cpp @@ -59,7 +60,10 @@ set(llui_SOURCE_FILES llscrollbar.cpp llscrollcontainer.cpp llscrollingpanellist.cpp + llscrolllistcell.cpp + llscrolllistcolumn.cpp llscrolllistctrl.cpp + llscrolllistitem.cpp llsearcheditor.cpp llslider.cpp llsliderctrl.cpp @@ -105,6 +109,7 @@ set(llui_HEADER_FILES lleditmenuhandler.h llfiltereditor.h llfloater.h + llflyoutbutton.h llfocusmgr.h llfunctorregistry.h llhtmlhelp.h @@ -134,7 +139,10 @@ set(llui_HEADER_FILES llscrollbar.h llscrollcontainer.h llscrollingpanellist.h + llscrolllistcell.h + llscrolllistcolumn.h llscrolllistctrl.h + llscrolllistitem.h llslider.h llsliderctrl.h llspinctrl.h diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index 6fd7084df..df3369e89 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -2,31 +2,25 @@ * @file llcombobox.cpp * @brief LLComboBox base class * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * 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. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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 * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -48,6 +42,8 @@ #include "llwindow.h" #include "llfloater.h" #include "llscrollbar.h" +#include "llscrolllistcell.h" +#include "llscrolllistitem.h" #include "llcontrol.h" #include "llfocusmgr.h" #include "lllineeditor.h" @@ -58,10 +54,9 @@ S32 LLCOMBOBOX_HEIGHT = 0; S32 LLCOMBOBOX_WIDTH = 0; S32 MAX_COMBO_WIDTH = 500; -static LLRegisterWidget r1("combo_box"); +static LLRegisterWidget register_combo_box("combo_box"); -LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std::string& label, - commit_callback_t commit_callback) +LLComboBox::LLComboBox(const std::string& name, const LLRect& rect, const std::string& label, commit_callback_t commit_callback) : LLUICtrl(name, rect, TRUE, commit_callback, FOLLOWS_LEFT | FOLLOWS_TOP), mTextEntry(NULL), mTextEntryTentative(TRUE), @@ -81,9 +76,7 @@ LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std:: { // Always use text box // Text label button - mButton = new LLButton(mLabel, - LLRect(), - LLStringUtil::null); + mButton = new LLButton(mLabel, LLRect(), LLStringUtil::null); mButton->setImageUnselected(LLUI::getUIImage("square_btn_32x128.tga")); mButton->setImageSelected(LLUI::getUIImage("square_btn_selected_32x128.tga")); mButton->setImageDisabled(LLUI::getUIImage("square_btn_32x128.tga")); @@ -102,11 +95,11 @@ LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std:: addChild(mButton); // disallow multiple selection - mList = new LLScrollListCtrl(std::string("ComboBox"), LLRect(), + mList = new LLScrollListCtrl(std::string("ComboBox"), LLRect(), boost::bind(&LLComboBox::onItemSelected, this, _2), FALSE); - mList->setVisible(FALSE); + mList->setVisible(false); mList->setBgWriteableColor(mListColor); - mList->setCommitOnKeyboardMovement(FALSE); + mList->setCommitOnKeyboardMovement(false); addChild(mList); // Mouse-down on button will transfer mouse focus to the list @@ -117,12 +110,11 @@ LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std:: mButton->setImageOverlay("combobox_arrow.tga", LLFontGL::RIGHT); updateLayout(); - + mTopLostSignalConnection = setTopLostCallback(boost::bind(&LLComboBox::hideList, this)); } - // virtual LLXMLNodePtr LLComboBox::getXML(bool save_children) const { @@ -131,16 +123,12 @@ LLXMLNodePtr LLComboBox::getXML(bool save_children) const node->setName(LL_COMBO_BOX_TAG); // Attributes - node->createChild("allow_text_entry", TRUE)->setBoolValue(mAllowTextEntry); - node->createChild("max_chars", TRUE)->setIntValue(mMaxChars); // Contents - std::vector data_list = mList->getAllData(); - std::vector::iterator data_itor; - for (data_itor = data_list.begin(); data_itor != data_list.end(); ++data_itor) + for (std::vector::iterator data_itor = data_list.begin(); data_itor != data_list.end(); ++data_itor) { LLScrollListItem* item = *data_itor; LLScrollListCell* cell = item->getColumn(0); @@ -172,9 +160,7 @@ LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory * S32 max_chars = 20; node->getAttributeS32("max_chars", max_chars); - LLComboBox* combo_box = new LLComboBox("combo_box", - rect, - label); + LLComboBox* combo_box = new LLComboBox("combo_box", rect, label); combo_box->setAllowTextEntry(allow_text_entry, max_chars); const std::string& contents = node->getValue(); @@ -257,7 +243,6 @@ void LLComboBox::onCommit() mTextEntry->setValue(getSimple()); mTextEntry->setTentative(FALSE); } - setControlValue(getValue()); LLUICtrl::onCommit(); } @@ -305,7 +290,6 @@ void LLComboBox::resetTextDirty() } } - // add item "name" to menu LLScrollListItem* LLComboBox::add(const std::string& name, EAddPosition pos, BOOL enabled) { @@ -577,7 +561,7 @@ void LLComboBox::updateLayout() if (!mTextEntry) { LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0); - text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth()) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); + text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth()) + 2 * shadow_size; // clear label on button std::string cur_label = mButton->getLabelSelected(); mTextEntry = new LLLineEditor(std::string("combo_text_entry"), @@ -590,9 +574,9 @@ void LLComboBox::updateLayout() mTextEntry->setSelectAllonFocusReceived(TRUE); mTextEntry->setHandleEditKeysDirectly(TRUE); mTextEntry->setCommitOnFocusLost(FALSE); + mTextEntry->setFollows(FOLLOWS_ALL); mTextEntry->setText(cur_label); mTextEntry->setIgnoreTab(TRUE); - mTextEntry->setFollowsAll(); addChild(mTextEntry); } else @@ -617,7 +601,7 @@ void LLComboBox::updateLayout() { mTextEntry->setVisible(FALSE); } - mButton->setFollowsAll(); + mButton->setFollows(FOLLOWS_ALL); } } @@ -755,10 +739,6 @@ void LLComboBox::hideList() } } -//------------------------------------------------------------------ -// static functions -//------------------------------------------------------------------ - void LLComboBox::onButtonMouseDown() { if (!mList->getVisible()) @@ -896,7 +876,10 @@ BOOL LLComboBox::handleKeyHere(KEY key, MASK mask) return FALSE; } // if selection has changed, pop open list - else if (mList->getLastSelectedItem() != last_selected_item) + else if (mList->getLastSelectedItem() != last_selected_item + || ((key == KEY_DOWN || key == KEY_UP) + && mList->getCanSelect() + && !mList->isEmpty())) { showList(); } @@ -1026,7 +1009,7 @@ void LLComboBox::updateSelection() if(mSuppressAutoComplete) { return; } - + LLWString left_wstring = mTextEntry->getWText().substr(0, mTextEntry->getCursor()); // user-entered portion of string, based on assumption that any selected // text was a result of auto-completion @@ -1236,168 +1219,3 @@ BOOL LLComboBox::selectItemRange( S32 first, S32 last ) return mList->selectItemRange(first, last); } - -// -// LLFlyoutButton -// - -static LLRegisterWidget r2("flyout_button"); - -const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24; - -LLFlyoutButton::LLFlyoutButton( - const std::string& name, - const LLRect &rect, - const std::string& label) -: LLComboBox(name, rect, LLStringUtil::null), - mToggleState(FALSE), - mActionButton(NULL) -{ - // Always use text box - // Text label button - mActionButton = new LLButton(label, - LLRect(), LLStringUtil::null, boost::bind(&LLFlyoutButton::onActionButtonClick, this)); - mActionButton->setScaleImage(TRUE); - mActionButton->setFollowsAll(); - mActionButton->setHAlign( LLFontGL::HCENTER ); - mActionButton->setLabel(label); - addChild(mActionButton); - - mActionButtonImage = LLUI::getUIImage("flyout_btn_left.tga"); - mExpanderButtonImage = LLUI::getUIImage("flyout_btn_right.tga"); - mActionButtonImageSelected = LLUI::getUIImage("flyout_btn_left_selected.tga"); - mExpanderButtonImageSelected = LLUI::getUIImage("flyout_btn_right_selected.tga"); - mActionButtonImageDisabled = LLUI::getUIImage("flyout_btn_left_disabled.tga"); - mExpanderButtonImageDisabled = LLUI::getUIImage("flyout_btn_right_disabled.tga"); - - mActionButton->setImageSelected(mActionButtonImageSelected); - mActionButton->setImageUnselected(mActionButtonImage); - mActionButton->setImageDisabled(mActionButtonImageDisabled); - mActionButton->setImageDisabledSelected(LLPointer(NULL)); - - mButton->setImageSelected(mExpanderButtonImageSelected); - mButton->setImageUnselected(mExpanderButtonImage); - mButton->setImageDisabled(mExpanderButtonImageDisabled); - mButton->setImageDisabledSelected(LLPointer(NULL)); - mButton->setRightHPad(6); - - updateLayout(); -} - -// virtual -LLXMLNodePtr LLFlyoutButton::getXML(bool save_children) const -{ - LLXMLNodePtr node = LLComboBox::getXML(); - - node->setName(LL_FLYOUT_BUTTON_TAG); - - LLXMLNodePtr child; - - for (child = node->getFirstChild(); child.notNull();) - { - if (child->hasName("combo_item")) - { - child->setName(LL_FLYOUT_BUTTON_ITEM_TAG); - - //setName does a delete and add, so we have to start over - child = node->getFirstChild(); - } - else - { - child = child->getNextSibling(); - } - } - - return node; -} - -//static -LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) -{ - std::string label(""); - node->getAttributeString("label", label); - - LLRect rect; - createRect(node, rect, parent, LLRect()); - - LLFlyoutButton* flyout_button = new LLFlyoutButton("flyout_button", - rect, - label); - - std::string list_position; - node->getAttributeString("list_position", list_position); - if (list_position == "below") - { - flyout_button->mListPosition = BELOW; - } - else if (list_position == "above") - { - flyout_button->mListPosition = ABOVE; - } - - - flyout_button->initFromXML(node, parent); - - LLXMLNodePtr child; - for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) - { - if (child->hasName("flyout_button_item")) - { - std::string label = child->getTextContents(); - - std::string value = label; - child->getAttributeString("value", value); - - flyout_button->add(label, LLSD(value) ); - } - } - - flyout_button->updateLayout(); - - return flyout_button; -} - -void LLFlyoutButton::updateLayout() -{ - LLComboBox::updateLayout(); - - mButton->setOrigin(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, 0); - mButton->reshape(FLYOUT_BUTTON_ARROW_WIDTH, getRect().getHeight()); - mButton->setFollows(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM); - mButton->setTabStop(FALSE); - mButton->setImageOverlay(mListPosition == BELOW ? "down_arrow.tga" : "up_arrow.tga", LLFontGL::RIGHT); - - mActionButton->setOrigin(0, 0); - mActionButton->reshape(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, getRect().getHeight()); -} - -void LLFlyoutButton::onActionButtonClick() -{ - // remember last list selection? - mList->deselect(); - onCommit(); -} - -void LLFlyoutButton::draw() -{ - mActionButton->setToggleState(mToggleState); - mButton->setToggleState(mToggleState); - - //FIXME: this should be an attribute of comboboxes, whether they have a distinct label or - // the label reflects the last selected item, for now we have to manually remove the label - mButton->setLabel(LLStringUtil::null); - LLComboBox::draw(); -} - -void LLFlyoutButton::setEnabled(BOOL enabled) -{ - mActionButton->setEnabled(enabled); - LLComboBox::setEnabled(enabled); -} - - -void LLFlyoutButton::setToggleState(BOOL state) -{ - mToggleState = state; -} - diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index b6165ae0f..2131ba06c 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -2,31 +2,25 @@ * @file llcombobox.h * @brief LLComboBox base class * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * 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. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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 * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -39,15 +33,12 @@ #include "llbutton.h" #include "lluictrl.h" #include "llctrlselectioninterface.h" -#include "llimagegl.h" #include "llrect.h" +#include "llscrolllistctrl.h" // Classes class LLFontGL; -class LLButton; -class LLSquareButton; -class LLScrollListCtrl; class LLLineEditor; class LLViewBorder; @@ -64,15 +55,12 @@ public: BELOW } EPreferredPosition; - LLComboBox( - const std::string& name, - const LLRect &rect, - const std::string& label, - commit_callback_t commit_callback = NULL - ); virtual ~LLComboBox(); protected: -void prearrangeList(std::string filter = ""); + friend class LLFloaterTestImpl; + friend class LLUICtrlFactory; + LLComboBox(const std::string& name, const LLRect& rect, const std::string& label, commit_callback_t commit_callback = NULL); + void prearrangeList(std::string filter = ""); public: // LLView interface @@ -191,7 +179,6 @@ public: void onButtonMouseDown(); void onListMouseUp(); void onItemSelected(const LLSD& data); - void onTextCommit(const LLSD& data); void setSuppressTentative(bool suppress); @@ -226,34 +213,4 @@ private: S32 mLastSelectedIndex; }; -class LLFlyoutButton : public LLComboBox -{ -public: - LLFlyoutButton( - const std::string& name, - const LLRect &rect, - const std::string& label); - - virtual void updateLayout(); - virtual void draw(); - virtual void setEnabled(BOOL enabled); - - void setToggleState(BOOL state); - - virtual LLXMLNodePtr getXML(bool save_children = true) const; - static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); - void onActionButtonClick(); - void onSelectAction(LLUICtrl* ctrl); - -protected: - LLButton* mActionButton; - LLPointer mActionButtonImage; - LLPointer mExpanderButtonImage; - LLPointer mActionButtonImageSelected; - LLPointer mExpanderButtonImageSelected; - LLPointer mActionButtonImageDisabled; - LLPointer mExpanderButtonImageDisabled; - BOOL mToggleState; -}; - #endif diff --git a/indra/llui/llflyoutbutton.cpp b/indra/llui/llflyoutbutton.cpp new file mode 100644 index 000000000..db16d9ccb --- /dev/null +++ b/indra/llui/llflyoutbutton.cpp @@ -0,0 +1,172 @@ +/** + * @file llflyoutbutton.cpp + * @brief LLFlyoutButton base class + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +// file includes +#include "llflyoutbutton.h" + +static LLRegisterWidget r2("flyout_button"); + +const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24; + +LLFlyoutButton::LLFlyoutButton(const std::string& name, const LLRect& rect, const std::string& label) +: LLComboBox(name, rect, LLStringUtil::null), + mToggleState(FALSE), + mActionButton(NULL) +{ + // Always use text box + // Text label button + mActionButton = new LLButton(label, LLRect(), LLStringUtil::null, boost::bind(&LLFlyoutButton::onActionButtonClick, this, _2)); + mActionButton->setScaleImage(true); + mActionButton->setFollowsAll(); + mActionButton->setHAlign(LLFontGL::HCENTER); + mActionButton->setLabel(label); + addChild(mActionButton); + + mActionButton->setImageSelected(LLUI::getUIImage("flyout_btn_left_selected.tga")); + mActionButton->setImageUnselected(LLUI::getUIImage("flyout_btn_left.tga")); + mActionButton->setImageDisabled(LLUI::getUIImage("flyout_btn_left_disabled.tga")); + mActionButton->setImageDisabledSelected(LLPointer(NULL)); + + mButton->setImageSelected(LLUI::getUIImage("flyout_btn_right_selected.tga")); + mButton->setImageUnselected(LLUI::getUIImage("flyout_btn_right.tga")); + mButton->setImageDisabled(LLUI::getUIImage("flyout_btn_right_disabled.tga")); + mButton->setImageDisabledSelected(LLPointer(NULL)); + mButton->setRightHPad(6); + + updateLayout(); +} + +// virtual +LLXMLNodePtr LLFlyoutButton::getXML(bool save_children) const +{ + LLXMLNodePtr node = LLComboBox::getXML(); + node->setName(LL_FLYOUT_BUTTON_TAG); + + for (LLXMLNodePtr child = node->getFirstChild(); child.notNull();) + { + if (child->hasName("combo_item")) + { + child->setName(LL_FLYOUT_BUTTON_ITEM_TAG); + + //setName does a delete and add, so we have to start over + child = node->getFirstChild(); + } + else + { + child = child->getNextSibling(); + } + } + + return node; +} + +//static +LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory* factory) +{ + std::string label(""); + node->getAttributeString("label", label); + + LLRect rect; + createRect(node, rect, parent, LLRect()); + + LLFlyoutButton* flyout_button = new LLFlyoutButton("flyout_button", rect, label); + + std::string list_position; + node->getAttributeString("list_position", list_position); + if (list_position == "below") + { + flyout_button->mListPosition = BELOW; + } + else if (list_position == "above") + { + flyout_button->mListPosition = ABOVE; + } + + flyout_button->initFromXML(node, parent); + + for (LLXMLNodePtr child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) + { + if (child->hasName(LL_FLYOUT_BUTTON_ITEM_TAG)) + { + std::string label(child->getTextContents()); + std::string value(label); + child->getAttributeString("value", value); + + flyout_button->add(label, LLSD(value)); + } + } + + flyout_button->updateLayout(); + + return flyout_button; +} + +void LLFlyoutButton::updateLayout() +{ + LLComboBox::updateLayout(); + + mButton->setOrigin(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, 0); + mButton->reshape(FLYOUT_BUTTON_ARROW_WIDTH, getRect().getHeight()); + mButton->setFollows(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM); + mButton->setTabStop(false); + mButton->setImageOverlay(mListPosition == BELOW ? "down_arrow.tga" : "up_arrow.tga", LLFontGL::RIGHT); + + mActionButton->setOrigin(0, 0); + mActionButton->reshape(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, getRect().getHeight()); +} + +void LLFlyoutButton::onActionButtonClick(const LLSD& data) +{ + // remember last list selection? + mList->deselect(); + onCommit(); +} + +void LLFlyoutButton::draw() +{ + mActionButton->setToggleState(mToggleState); + mButton->setToggleState(mToggleState); + + //FIXME: this should be an attribute of comboboxes, whether they have a distinct label or + // the label reflects the last selected item, for now we have to manually remove the label + mButton->setLabel(LLStringUtil::null); + LLComboBox::draw(); +} + +void LLFlyoutButton::setEnabled(BOOL enabled) +{ + mActionButton->setEnabled(enabled); + LLComboBox::setEnabled(enabled); +} + +void LLFlyoutButton::setToggleState(BOOL state) +{ + mToggleState = state; +} + + diff --git a/indra/llui/llflyoutbutton.h b/indra/llui/llflyoutbutton.h new file mode 100644 index 000000000..0d9ce80bf --- /dev/null +++ b/indra/llui/llflyoutbutton.h @@ -0,0 +1,59 @@ +/** + * @file llflyoutbutton.h + * @brief LLFlyoutButton base class + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +// A control that displays the name of the chosen item, which when clicked +// shows a scrolling box of choices. + +#ifndef LL_LLFLYOUTBUTTON_H +#define LL_LLFLYOUTBUTTON_H + +#include "llcombobox.h" + +// Classes + +class LLFlyoutButton : public LLComboBox +{ +protected: + LLFlyoutButton(const std::string& name, const LLRect& rect, const std::string& label); + friend class LLUICtrlFactory; +public: + virtual void updateLayout(); + virtual void draw(); + virtual void setEnabled(BOOL enabled); + + void setToggleState(BOOL state); + + virtual LLXMLNodePtr getXML(bool save_children = true) const; + static LLView* fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory* factory); + void onActionButtonClick(const LLSD& data); + void onSelectAction(LLUICtrl* ctrl); + +protected: + LLButton* mActionButton; + BOOL mToggleState; +}; + +#endif // LL_LLFLYOUTBUTTON_H diff --git a/indra/llui/llscrolllistcell.cpp b/indra/llui/llscrolllistcell.cpp new file mode 100644 index 000000000..2eb50d3b2 --- /dev/null +++ b/indra/llui/llscrolllistcell.cpp @@ -0,0 +1,364 @@ +/** + * @file llscrolllistcell.cpp + * @brief Scroll lists are composed of rows (items), each of which + * contains columns (cells). + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llscrolllistcell.h" + +#include "llcheckboxctrl.h" + + +LLScrollListCell::LLScrollListCell(S32 width) +: mWidth(width) +{} + +// virtual +const LLSD LLScrollListCell::getValue() const +{ + return LLStringUtil::null; +} + +// +// LLScrollListIcon +// +LLScrollListIcon::LLScrollListIcon(const LLSD& value, S32 width) +: LLScrollListCell(width), + // + mCallback(NULL), + // + mColor(LLColor4::white) +{ + setValue(value); +} + +LLScrollListIcon::~LLScrollListIcon() +{ +} + +/*virtual*/ +S32 LLScrollListIcon::getHeight() const +{ return mIcon ? mIcon->getHeight() : 0; } + +/*virtual*/ +const LLSD LLScrollListIcon::getValue() const +{ return mIcon.isNull() ? LLStringUtil::null : mIcon->getName(); } + +void LLScrollListIcon::setValue(const LLSD& value) +{ + if (value.isUUID()) + { + // don't use default image specified by LLUUID::null, use no image in that case + LLUUID image_id = value.asUUID(); + mIcon = image_id.notNull() ? LLUI::getUIImageByID(image_id) : LLUIImagePtr(NULL); + } + else + { + std::string value_string = value.asString(); + if (LLUUID::validate(value_string)) + { + setValue(LLUUID(value_string)); + } + else if (!value_string.empty()) + { + mIcon = LLUI::getUIImage(value.asString()); + } + else + { + mIcon = NULL; + } + } +} + + +void LLScrollListIcon::setColor(const LLColor4& color) +{ + mColor = color; +} + +S32 LLScrollListIcon::getWidth() const +{ + // if no specified fix width, use width of icon + if (LLScrollListCell::getWidth() == 0 && mIcon.notNull()) + { + return mIcon->getWidth(); + } + return LLScrollListCell::getWidth(); +} + + +void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_color) const +{ + if (mIcon) + { + mIcon->draw(0, 0, mColor); + } +} + +// +// LLScrollListText +// +U32 LLScrollListText::sCount = 0; + +LLScrollListText::LLScrollListText(const std::string& text, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, LLColor4& color, BOOL use_color, BOOL visible) +: LLScrollListCell(width), + mText(text), + mFont(font), + mColor(color), + mUseColor(use_color), + mFontStyle(font_style), + mFontAlignment(font_alignment), + mVisible(visible), + mHighlightCount( 0 ), + mHighlightOffset( 0 ) +{ + sCount++; + + mTextWidth = getWidth(); + + // initialize rounded rect image + if (!mRoundedRectImage) + { + mRoundedRectImage = LLUI::getUIImage("rounded_square.tga"); + } +} + +//virtual +void LLScrollListText::highlightText(S32 offset, S32 num_chars) +{ + mHighlightOffset = offset; + mHighlightCount = num_chars; +} + +//virtual +BOOL LLScrollListText::isText() const +{ + return TRUE; +} + +//virtual +BOOL LLScrollListText::getVisible() const +{ + return mVisible; +} + +//virtual +S32 LLScrollListText::getHeight() const +{ + return llround(mFont->getLineHeight()); +} + + +LLScrollListText::~LLScrollListText() +{ + sCount--; +} + +S32 LLScrollListText::getContentWidth() const +{ + return mFont->getWidth(mText.getString()); +} + + +void LLScrollListText::setColor(const LLColor4& color) +{ + mColor = color; + mUseColor = TRUE; +} + +void LLScrollListText::setText(const LLStringExplicit& text) +{ + mText = text; +} + +void LLScrollListText::setFontStyle(const U8 font_style) +{ + mFontStyle = font_style; +} + +//virtual +void LLScrollListText::setValue(const LLSD& text) +{ + setText(text.asString()); +} + +//virtual +const LLSD LLScrollListText::getValue() const +{ + return LLSD(mText.getString()); +} + + +void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_color) const +{ + LLColor4 display_color; + if (mUseColor) + { + display_color = mColor; + } + else + { + display_color = color; + } + + if (mHighlightCount > 0) + { + S32 left = 0; + switch(mFontAlignment) + { + case LLFontGL::LEFT: + left = mFont->getWidth(mText.getString(), 0, mHighlightOffset); + break; + case LLFontGL::RIGHT: + left = getWidth() - mFont->getWidth(mText.getString(), mHighlightOffset, S32_MAX); + break; + case LLFontGL::HCENTER: + left = (getWidth() - mFont->getWidth(mText.getString())) / 2; + break; + } + LLRect highlight_rect(left - 2, + llround(mFont->getLineHeight()) + 1, + left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1, + 1); + mRoundedRectImage->draw(highlight_rect, highlight_color); + } + + // Try to draw the entire string + F32 right_x; + U32 string_chars = mText.length(); + F32 start_x = 0.f; + switch(mFontAlignment) + { + case LLFontGL::LEFT: + start_x = (mFontStyle & LLFontGL::ITALIC) ? 2.f : 0.f; //Italic text seems to need a little padding. + break; + case LLFontGL::RIGHT: + start_x = (F32)getWidth(); + break; + case LLFontGL::HCENTER: + start_x = (F32)getWidth() * 0.5f; + break; + } + mFont->render(mText.getWString(), 0, + start_x, 2.f, + display_color, + mFontAlignment, + LLFontGL::BOTTOM, + mFontStyle, + LLFontGL::NO_SHADOW, + string_chars, + getTextWidth(), + &right_x, + FALSE, + TRUE); +} + +// +// LLScrollListCheck +// +LLScrollListCheck::LLScrollListCheck(LLCheckBoxCtrl* check_box, S32 width) +: LLScrollListCell(width) +{ + mCheckBox = check_box; + + LLRect rect(mCheckBox->getRect()); + if (width) + { + rect.mRight = rect.mLeft + width; + mCheckBox->setRect(rect); + setWidth(width); + } + else + { + setWidth(rect.getWidth()); //check_box->getWidth(); + } +} + + +LLScrollListCheck::~LLScrollListCheck() +{ + delete mCheckBox; + mCheckBox = NULL; +} + +void LLScrollListCheck::draw(const LLColor4& color, const LLColor4& highlight_color) const +{ + mCheckBox->draw(); +} + +BOOL LLScrollListCheck::handleClick() +{ + if (mCheckBox->getEnabled()) + { + mCheckBox->toggle(); + } + // don't change selection when clicking on embedded checkbox + return TRUE; +} + +/*virtual*/ +const LLSD LLScrollListCheck::getValue() const +{ + return mCheckBox->getValue(); +} + +/*virtual*/ +void LLScrollListCheck::setValue(const LLSD& value) +{ + mCheckBox->setValue(value); +} + +/*virtual*/ +void LLScrollListCheck::onCommit() +{ + mCheckBox->onCommit(); +} + +/*virtual*/ +void LLScrollListCheck::setEnabled(BOOL enable) +{ + mCheckBox->setEnabled(enable); +} + +// +// LLScrollListDate +// + +LLScrollListDate::LLScrollListDate( const LLDate& date, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, LLColor4& color, BOOL use_color, BOOL visible) +: LLScrollListText(date.asRFC1123(), font, width, font_style, font_alignment, color, use_color, visible), + mDate(date) +{} + +void LLScrollListDate::setValue(const LLSD& value) +{ + mDate = value.asDate(); + LLScrollListText::setValue(mDate.asRFC1123()); +} + +const LLSD LLScrollListDate::getValue() const +{ + return mDate; +} diff --git a/indra/llui/llscrolllistcell.h b/indra/llui/llscrolllistcell.h new file mode 100644 index 000000000..e04635ad7 --- /dev/null +++ b/indra/llui/llscrolllistcell.h @@ -0,0 +1,180 @@ +/** + * @file llscrolllistcell.h + * @brief Scroll lists are composed of rows (items), each of which + * contains columns (cells). + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LLSCROLLLISTCELL_H +#define LLSCROLLLISTCELL_H + +#include "llfontgl.h" // HAlign +#include "llpointer.h" // LLPointer<> +#include "lluistring.h" +#include "v4color.h" +#include "llui.h" + +class LLCheckBoxCtrl; +class LLSD; + +/* + * Represents a cell in a scrollable table. + * + * Sub-classes must return height and other properties + * though width accessors are implemented by the base class. + * It is therefore important for sub-class constructors to call + * setWidth() with realistic values. + */ +class LLScrollListCell +{ +public: + LLScrollListCell(S32 width = 0); + virtual ~LLScrollListCell() {}; + + virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const {}; // truncate to given width, if possible + virtual S32 getWidth() const {return mWidth;} + virtual S32 getContentWidth() const { return 0; } + virtual S32 getHeight() const { return 0; } + virtual const LLSD getValue() const; + virtual void setValue(const LLSD& value) { } + virtual BOOL getVisible() const { return TRUE; } + virtual void setWidth(S32 width) { mWidth = width; } + virtual void highlightText(S32 offset, S32 num_chars) {} + virtual BOOL isText() const { return FALSE; } + virtual void setColor(const LLColor4&) {} + virtual void onCommit() {}; + + virtual BOOL handleClick() { return FALSE; } + virtual void setEnabled(BOOL enable) { } + +private: + S32 mWidth; +}; + +/* + * Cell displaying a text label. + */ +class LLScrollListText : public LLScrollListCell +{ +public: + LLScrollListText(const std::string& text, const LLFontGL* font, S32 width = 0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE); + /*virtual*/ ~LLScrollListText(); + + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ S32 getContentWidth() const; + /*virtual*/ S32 getHeight() const; + /*virtual*/ void setValue(const LLSD& value); + /*virtual*/ const LLSD getValue() const; + /*virtual*/ BOOL getVisible() const; + /*virtual*/ void highlightText(S32 offset, S32 num_chars); + + /*virtual*/ void setColor(const LLColor4&); + /*virtual*/ BOOL isText() const; + + S32 getTextWidth() const { return mTextWidth;} + void setTextWidth(S32 value) { mTextWidth = value;} + virtual void setWidth(S32 width) { LLScrollListCell::setWidth(width); mTextWidth = width; } + + void setText(const LLStringExplicit& text); + void setFontStyle(const U8 font_style); + +private: + LLUIString mText; + S32 mTextWidth; + const LLFontGL* mFont; + LLColor4 mColor; + U8 mUseColor; + U8 mFontStyle; + LLFontGL::HAlign mFontAlignment; + BOOL mVisible; + S32 mHighlightCount; + S32 mHighlightOffset; + + LLPointer mRoundedRectImage; + + static U32 sCount; +}; + +/* + * Cell displaying an image. + */ +class LLScrollListIcon : public LLScrollListCell +{ +public: + LLScrollListIcon( LLUIImagePtr icon, S32 width = 0); + LLScrollListIcon(const LLSD& value, S32 width = 0); + /*virtual*/ ~LLScrollListIcon(); + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ S32 getWidth() const; + /*virtual*/ S32 getHeight() const; + /*virtual*/ const LLSD getValue() const; + /*virtual*/ void setColor(const LLColor4&); + /*virtual*/ void setValue(const LLSD& value); + // + void setClickCallback(boost::function cb) { mCallback = cb; } + /*virtual*/ BOOL handleClick() { return mCallback ? mCallback() : false; } + // + +private: + LLPointer mIcon; + LLColor4 mColor; + // + boost::function mCallback; + // +}; + +/* + * An interactive cell containing a check box. + */ +class LLScrollListCheck : public LLScrollListCell +{ +public: + LLScrollListCheck( LLCheckBoxCtrl* check_box, S32 width = 0); + /*virtual*/ ~LLScrollListCheck(); + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ S32 getHeight() const { return 0; } + /*virtual*/ const LLSD getValue() const; + /*virtual*/ void setValue(const LLSD& value); + /*virtual*/ void onCommit(); + + /*virtual*/ BOOL handleClick(); + /*virtual*/ void setEnabled(BOOL enable); + + LLCheckBoxCtrl* getCheckBox() { return mCheckBox; } + +private: + LLCheckBoxCtrl* mCheckBox; +}; + +class LLScrollListDate : public LLScrollListText +{ +public: + LLScrollListDate( const LLDate& date, const LLFontGL* font, S32 width=0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE); + virtual void setValue(const LLSD& value); + virtual const LLSD getValue() const; + +private: + LLDate mDate; +}; + +#endif diff --git a/indra/llui/llscrolllistcolumn.cpp b/indra/llui/llscrolllistcolumn.cpp new file mode 100644 index 000000000..434dccad8 --- /dev/null +++ b/indra/llui/llscrolllistcolumn.cpp @@ -0,0 +1,484 @@ +/** + * @file llscrollcolumnheader.cpp + * @brief Scroll lists are composed of rows (items), each of which + * contains columns (cells). + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llscrolllistcolumn.h" + +#include "llbutton.h" +#include "llkeyboard.h" // For gKeyboard +#include "llresizebar.h" +#include "lluictrlfactory.h" + +const S32 MIN_COLUMN_WIDTH = 20; + +//--------------------------------------------------------------------------- +// LLScrollColumnHeader +//--------------------------------------------------------------------------- +LLScrollColumnHeader::LLScrollColumnHeader(const std::string& label, const LLRect& rect, LLScrollListColumn* column, const LLFontGL* fontp) +: LLComboBox(label, rect, label), + mColumn(column), + mOrigLabel(label), + mHasResizableElement(FALSE) +{ + mListPosition = LLComboBox::ABOVE; + setCommitCallback(boost::bind(&LLScrollColumnHeader::onSelectSort, this)); + mButton->setTabStop(FALSE); + mButton->setClickedCallback(boost::bind(&LLScrollColumnHeader::onClick, this, _2)); + + mButton->setToolTip(label); + + mAscendingText = std::string("[LOW]...[HIGH](Ascending)"); // *TODO: Translate + mDescendingText = std::string("[HIGH]...[LOW](Descending)"); // *TODO: Translate + + mList->reshape(llmax(mList->getRect().getWidth(), 110, getRect().getWidth()), mList->getRect().getHeight()); + + // resize handles on left and right + const S32 RESIZE_BAR_THICKNESS = 3; + LLResizeBar::Params resize_bar_p; + resize_bar_p.resizing_view(this); + resize_bar_p.rect(LLRect(getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0)); + resize_bar_p.min_size(MIN_COLUMN_WIDTH); + resize_bar_p.side(LLResizeBar::RIGHT); + resize_bar_p.enabled(false); + mResizeBar = LLUICtrlFactory::create(resize_bar_p); + addChild(mResizeBar); + + mImageOverlayAlignment = LLFontGL::HCENTER; + mImageOverlayColor = LLColor4::white; +} + +LLScrollColumnHeader::~LLScrollColumnHeader() +{} + +void LLScrollColumnHeader::draw() +{ + std::string sort_column = mColumn->mParentCtrl->getSortColumnName(); + BOOL draw_arrow = !mColumn->mLabel.empty() + && mColumn->mParentCtrl->isSorted() + // check for indirect sorting column as well as column's sorting name + && (sort_column == mColumn->mSortingColumn || sort_column == mColumn->mName); + + BOOL is_ascending = mColumn->mParentCtrl->getSortAscending(); + if (draw_arrow) + { + mButton->setImageOverlay(is_ascending ? "up_arrow.tga" : "down_arrow.tga", LLFontGL::RIGHT, LLColor4::white); + } + else + { + mButton->setImageOverlay(LLUUID::null); + } + mArrowImage = mButton->getImageOverlay(); + + // Draw children + LLComboBox::draw(); + + if (mImageOverlay.notNull()) //Ugly dupe code from llbutton... + { + BOOL pressed_by_keyboard = FALSE; + if (mButton->hasFocus()) + { + pressed_by_keyboard = gKeyboard->getKeyDown(' ') || (mButton->getCommitOnReturn() && gKeyboard->getKeyDown(KEY_RETURN)); + } + + // Unselected image assignments + S32 local_mouse_x; + S32 local_mouse_y; + LLUI::getMousePositionLocal(mButton, &local_mouse_x, &local_mouse_y); + + BOOL pressed = pressed_by_keyboard + || (mButton->hasMouseCapture() && mButton->pointInView(local_mouse_x, local_mouse_y)) + || mButton->getToggleState(); + + // Now draw special overlay.. + // let overlay image and text play well together + S32 button_width = mButton->getRect().getWidth(); + S32 button_height = mButton->getRect().getHeight(); + S32 text_left = mButton->getLeftHPad(); + S32 text_right = button_width - mButton->getRightHPad(); + S32 text_width = text_right - text_left; + + // draw overlay image + + // get max width and height (discard level 0) + S32 overlay_width = mImageOverlay->getWidth(); + S32 overlay_height = mImageOverlay->getHeight(); + + F32 scale_factor = llmin((F32)button_width / (F32)overlay_width, (F32)button_height / (F32)overlay_height, 1.f); + overlay_width = llround((F32)overlay_width * scale_factor); + overlay_height = llround((F32)overlay_height * scale_factor); + + S32 center_x = mButton->getLocalRect().getCenterX(); + S32 center_y = mButton->getLocalRect().getCenterY(); + + //FUGLY HACK FOR "DEPRESSED" BUTTONS + if (pressed) + { + center_y--; + center_x++; + } + + // fade out overlay images on disabled buttons + LLColor4 overlay_color = mImageOverlayColor; + if (!mButton->getEnabled()) + { + overlay_color.mV[VALPHA] = 0.5f; + } + + switch(mImageOverlayAlignment) + { + case LLFontGL::LEFT: + text_left += overlay_width + 1; + text_width -= overlay_width + 1; + mImageOverlay->draw( + text_left, + center_y - (overlay_height / 2), + overlay_width, + overlay_height, + overlay_color); + break; + case LLFontGL::HCENTER: + mImageOverlay->draw( + center_x - (overlay_width / 2), + center_y - (overlay_height / 2), + overlay_width, + overlay_height, + overlay_color); + break; + case LLFontGL::RIGHT: + text_right -= overlay_width + 1; + text_width -= overlay_width + 1; + mImageOverlay->draw( + text_right - overlay_width, + center_y - (overlay_height / 2), + overlay_width, + overlay_height, + overlay_color); + break; + default: + // draw nothing + break; + } + } + + + if (mList->getVisible()) + { + // sync sort order with list selection every frame + mColumn->mParentCtrl->sortByColumn(mColumn->mSortingColumn, getCurrentIndex() == 0); + } +} + +BOOL LLScrollColumnHeader::handleDoubleClick(S32 x, S32 y, MASK mask) +{ + if (canResize() && mResizeBar->getRect().pointInRect(x, y)) + { + // reshape column to max content width + mColumn->mParentCtrl->calcMaxContentWidth(); + LLRect column_rect = getRect(); + column_rect.mRight = column_rect.mLeft + mColumn->mMaxContentWidth; + setShape(column_rect, true); + } + else + { + onClick(LLSD()); + } + return TRUE; +} + +void LLScrollColumnHeader::setImage(const std::string& image_name) +{ + if (mButton) + { + mButton->setImageSelected(LLUI::getUIImage(image_name)); + mButton->setImageUnselected(LLUI::getUIImage(image_name)); + } +} + +void LLScrollColumnHeader::setImageOverlay(const std::string& image_name, LLFontGL::HAlign alignment, const LLColor4& color) +{ + if (image_name.empty()) + { + mImageOverlay = NULL; + } + else + { + mImageOverlay = LLUI::getUIImage(image_name); + mImageOverlayAlignment = alignment; + mImageOverlayColor = color; + } +} + +void LLScrollColumnHeader::onClick(const LLSD& data) +{ + if (mColumn) + { + if (mList->getVisible()) hideList(); + LLScrollListCtrl::onClickColumn(mColumn); + + // propagate new sort order to sort order list + mList->selectNthItem(mColumn->mParentCtrl->getSortAscending() ? 0 : 1); + mList->setFocus(true); + } +} + +void LLScrollColumnHeader::onSelectSort() +{ + if (!mColumn) return; + LLScrollListCtrl* parent = mColumn->mParentCtrl; + if (!parent) return; + parent->sortByColumn(mColumn->mSortingColumn, getCurrentIndex() == 0); + + // restore original column header + setLabel(mOrigLabel); +} + +LLView* LLScrollColumnHeader::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding) +{ + // this logic assumes dragging on right + llassert(snap_edge == SNAP_RIGHT); + + // use higher snap threshold for column headers + threshold = llmin(threshold, 10); + + LLRect snap_rect = getSnapRect(); + + S32 snap_delta = mColumn->mMaxContentWidth - snap_rect.getWidth(); + + // x coord growing means column growing, so same signs mean we're going in right direction + if (llabs(snap_delta) <= threshold && mouse_dir.mX * snap_delta > 0 ) + { + new_edge_val = snap_rect.mRight + snap_delta; + } + else + { + LLScrollListColumn* next_column = mColumn->mParentCtrl->getColumn(mColumn->mIndex + 1); + while (next_column) + { + if (next_column->mHeader) + { + snap_delta = (next_column->mHeader->getSnapRect().mRight - next_column->mMaxContentWidth) - snap_rect.mRight; + if (llabs(snap_delta) <= threshold && mouse_dir.mX * snap_delta > 0 ) + { + new_edge_val = snap_rect.mRight + snap_delta; + } + break; + } + next_column = mColumn->mParentCtrl->getColumn(next_column->mIndex + 1); + } + } + + return this; +} + +void LLScrollColumnHeader::handleReshape(const LLRect& new_rect, bool by_user) +{ + S32 new_width = new_rect.getWidth(); + S32 delta_width = new_width - (getRect().getWidth() /*+ mColumn->mParentCtrl->getColumnPadding()*/); + + if (delta_width != 0) + { + S32 remaining_width = -delta_width; + S32 col; + for (col = mColumn->mIndex + 1; col < mColumn->mParentCtrl->getNumColumns(); col++) + { + LLScrollListColumn* columnp = mColumn->mParentCtrl->getColumn(col); + if (!columnp) continue; + + if (columnp->mHeader && columnp->mHeader->canResize()) + { + // how many pixels in width can this column afford to give up? + S32 resize_buffer_amt = llmax(0, columnp->getWidth() - MIN_COLUMN_WIDTH); + + // user shrinking column, need to add width to other columns + if (delta_width < 0) + { + if (columnp->getWidth() > 0) + { + // statically sized column, give all remaining width to this column + columnp->setWidth(columnp->getWidth() + remaining_width); + if (columnp->mRelWidth > 0.f) + { + columnp->mRelWidth = (F32)columnp->getWidth() / (F32)mColumn->mParentCtrl->getItemListRect().getWidth(); + } + // all padding went to this widget, we're done + break; + } + } + else + { + // user growing column, need to take width from other columns + remaining_width += resize_buffer_amt; + + if (columnp->getWidth() > 0) + { + columnp->setWidth(columnp->getWidth() - llmin(columnp->getWidth() - MIN_COLUMN_WIDTH, delta_width)); + if (columnp->mRelWidth > 0.f) + { + columnp->mRelWidth = (F32)columnp->getWidth() / (F32)mColumn->mParentCtrl->getItemListRect().getWidth(); + } + } + + if (remaining_width >= 0) + { + // width sucked up from neighboring columns, done + break; + } + } + } + } + + // clamp resize amount to maximum that can be absorbed by other columns + if (delta_width > 0) + { + delta_width += llmin(remaining_width, 0); + } + + // propagate constrained delta_width to new width for this column + new_width = getRect().getWidth() + delta_width - mColumn->mParentCtrl->getColumnPadding(); + + // use requested width + mColumn->setWidth(new_width); + + // update proportional spacing + if (mColumn->mRelWidth > 0.f) + { + mColumn->mRelWidth = (F32)new_width / (F32)mColumn->mParentCtrl->getItemListRect().getWidth(); + } + + // tell scroll list to layout columns again + // do immediate update to get proper feedback to resize handle + // which needs to know how far the resize actually went + mColumn->mParentCtrl->dirtyColumns(); //Must flag as dirty, else updateColumns will probably be a noop. + mColumn->mParentCtrl->updateColumns(); + } +} + +void LLScrollColumnHeader::setHasResizableElement(BOOL resizable) +{ + if (mHasResizableElement != resizable) + { + mColumn->mParentCtrl->dirtyColumns(); + mHasResizableElement = resizable; + } +} + +void LLScrollColumnHeader::updateResizeBars() +{ + S32 num_resizable_columns = 0; + S32 col; + for (col = 0; col < mColumn->mParentCtrl->getNumColumns(); col++) + { + LLScrollListColumn* columnp = mColumn->mParentCtrl->getColumn(col); + if (columnp->mHeader && columnp->mHeader->canResize()) + { + num_resizable_columns++; + } + } + + S32 num_resizers_enabled = 0; + + // now enable/disable resize handles on resizable columns if we have at least two + for (col = 0; col < mColumn->mParentCtrl->getNumColumns(); col++) + { + LLScrollListColumn* columnp = mColumn->mParentCtrl->getColumn(col); + if (!columnp->mHeader) continue; + BOOL enable = num_resizable_columns >= 2 && num_resizers_enabled < (num_resizable_columns - 1) && columnp->mHeader->canResize(); + columnp->mHeader->enableResizeBar(enable); + if (enable) + { + num_resizers_enabled++; + } + } +} + +void LLScrollColumnHeader::enableResizeBar(BOOL enable) +{ + mResizeBar->setEnabled(enable); +} + +BOOL LLScrollColumnHeader::canResize() +{ + return getVisible() && (mHasResizableElement || mColumn->mDynamicWidth); +} + +// +// LLScrollListColumn +// +// Default constructor +LLScrollListColumn::LLScrollListColumn() : mName(), mSortingColumn(), mSortDirection(ASCENDING), mLabel(), mWidth(-1), mRelWidth(-1.0), mDynamicWidth(false), mMaxContentWidth(0), mIndex(-1), mParentCtrl(NULL), mHeader(NULL), mFontAlignment(LLFontGL::LEFT) +{ +} + + +LLScrollListColumn::LLScrollListColumn(const LLSD& sd, LLScrollListCtrl* parent) +: mWidth(0), + mIndex (-1), + mParentCtrl(parent), + mName(sd.get("name").asString()), + mLabel(sd.get("label").asString()), + mHeader(NULL), + mMaxContentWidth(0), + mDynamicWidth(sd.has("dynamicwidth") && sd.get("dynamicwidth").asBoolean()), + mRelWidth(-1.f), + mFontAlignment(LLFontGL::LEFT), + mSortingColumn(sd.has("sort") ? sd.get("sort").asString() : mName) +{ + if (sd.has("sort_ascending")) + { + mSortDirection = sd.get("sort_ascending").asBoolean() ? ASCENDING : DESCENDING; + } + else + { + mSortDirection = ASCENDING; + } + + if (sd.has("relwidth") && sd.get("relwidth").asFloat() > 0) + { + mRelWidth = sd.get("relwidth").asFloat(); + if (mRelWidth > 1) mRelWidth = 1; + mDynamicWidth = false; + } + else if (!mDynamicWidth) + { + setWidth(sd.get("width").asInteger()); + } + + if (sd.has("halign")) + { + mFontAlignment = (LLFontGL::HAlign)llclamp(sd.get("halign").asInteger(), (S32)LLFontGL::LEFT, (S32)LLFontGL::HCENTER); + } +} + +void LLScrollListColumn::setWidth(S32 width) +{ + if (!mDynamicWidth && mRelWidth <= 0.f) + { + mParentCtrl->updateStaticColumnWidth(this, width); + } + mWidth = width; +} diff --git a/indra/llui/llscrolllistcolumn.h b/indra/llui/llscrolllistcolumn.h new file mode 100644 index 000000000..05bb1518a --- /dev/null +++ b/indra/llui/llscrolllistcolumn.h @@ -0,0 +1,116 @@ +/** + * @file llscrollcolumnheader.h + * @brief Scroll lists are composed of rows (items), each of which + * contains columns (cells). + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LLSCROLLLISTCOLUMN_H +#define LLSCROLLLISTCOLUMN_H + +#include "llrect.h" +#include "lluistring.h" +#include "llcombobox.h" + +class LLScrollListColumn; +class LLResizeBar; +class LLScrollListCtrl; + +class LLScrollColumnHeader : public LLComboBox +{ +public: + LLScrollColumnHeader(const std::string& label, const LLRect& rect, LLScrollListColumn* column, const LLFontGL* font = NULL); + ~LLScrollColumnHeader(); + + /*virtual*/ void draw(); + /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); + + /*virtual*/ void showList() {}; // block the normal showList() behavior + /*virtual*/ LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding); + /*virtual*/ void handleReshape(const LLRect& new_rect, bool by_user = false); + + void setImage(const std::string& image_name); + void setImageOverlay(const std::string& overlay_image, LLFontGL::HAlign alignment = LLFontGL::HCENTER, const LLColor4& color = LLColor4::white); + LLScrollListColumn* getColumn() { return mColumn; } + void setHasResizableElement(BOOL resizable); + void updateResizeBars(); + BOOL canResize(); + void enableResizeBar(BOOL enable); + std::string getLabel() { return mOrigLabel; } + + void onSelectSort(); + void onClick(const LLSD& data); + +private: + LLScrollListColumn* mColumn; + LLResizeBar* mResizeBar; + std::string mOrigLabel; + LLUIString mAscendingText; + LLUIString mDescendingText; + BOOL mHasResizableElement; + + LLPointer mImageOverlay; + LLFontGL::HAlign mImageOverlayAlignment; + LLColor4 mImageOverlayColor; +}; + +/* + * A simple data class describing a column within a scroll list. + */ +class LLScrollListColumn +{ +public: + typedef enum e_sort_direction + { + DESCENDING, + ASCENDING + } ESortDirection; + + //NOTE: this is default constructible so we can store it in a map. + LLScrollListColumn(); + LLScrollListColumn(const LLSD& sd, LLScrollListCtrl* parent = NULL); + + void setWidth(S32 width); + S32 getWidth() const { return mWidth; } + +public: + // Public data is fine so long as this remains a simple struct-like data class. + // If it ever gets any smarter than that, these should all become private + // with protected or public accessor methods added as needed. -MG + std::string mName; + std::string mSortingColumn; + ESortDirection mSortDirection; + LLUIString mLabel; + F32 mRelWidth; + BOOL mDynamicWidth; + S32 mMaxContentWidth; + S32 mIndex; + LLScrollListCtrl* mParentCtrl; + LLScrollColumnHeader* mHeader; + LLFontGL::HAlign mFontAlignment; + +private: + S32 mWidth; +}; + +#endif diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 02eff0b19..76062e156 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -1,62 +1,57 @@ /** * @file llscrolllistctrl.cpp - * @brief LLScrollListCtrl base class + * @brief Scroll lists are composed of rows (items), each of which + * contains columns (cells). * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * 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. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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 * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ -#include - #include "linden_common.h" -#include "llstl.h" -#include "llboost.h" #include "llscrolllistctrl.h" -#include "indra_constants.h" +#include + +#include "llstl.h" +#include "llboost.h" +//#include "indra_constants.h" #include "llcheckboxctrl.h" #include "llclipboard.h" #include "llfocusmgr.h" #include "lllocalcliprect.h" -#include "llrender.h" +//#include "llrender.h" #include "llresmgr.h" #include "llscrollbar.h" +#include "llscrolllistcell.h" +#include "llscrolllistcolumn.h" +#include "llscrolllistitem.h" #include "llstring.h" #include "llui.h" #include "lluictrlfactory.h" #include "llwindow.h" #include "llcontrol.h" #include "llkeyboard.h" -#include "llresizebar.h" -const S32 MIN_COLUMN_WIDTH = 20; -const S32 LIST_SNAP_PADDING = 5; static LLRegisterWidget r("scroll_list"); @@ -109,431 +104,7 @@ struct SortScrollListItem }; -// -// LLScrollListIcon -// -LLScrollListIcon::LLScrollListIcon(const LLSD& value, S32 width) - : LLScrollListCell(width), - // - mCallback(NULL), - // - mColor(LLColor4::white) -{ - setValue(value); -} - - -LLScrollListIcon::~LLScrollListIcon() -{ -} - -/*virtual*/ -S32 LLScrollListIcon::getHeight() const -{ return mIcon ? mIcon->getHeight() : 0; } - -/*virtual*/ -const LLSD LLScrollListIcon::getValue() const -{ return mIcon.isNull() ? LLStringUtil::null : mIcon->getName(); } - -void LLScrollListIcon::setValue(const LLSD& value) -{ - if (value.isUUID()) - { - // don't use default image specified by LLUUID::null, use no image in that case - LLUUID image_id = value.asUUID(); - mIcon = image_id.notNull() ? LLUI::getUIImageByID(image_id) : LLUIImagePtr(NULL); - } - else - { - std::string value_string = value.asString(); - if (LLUUID::validate(value_string)) - { - setValue(LLUUID(value_string)); - } - else if (!value_string.empty()) - { - mIcon = LLUI::getUIImage(value.asString()); - } - else - { - mIcon = NULL; - } - } -} - - -void LLScrollListIcon::setColor(const LLColor4& color) -{ - mColor = color; -} - -S32 LLScrollListIcon::getWidth() const -{ - // if no specified fix width, use width of icon - if (LLScrollListCell::getWidth() == 0 && mIcon.notNull()) - { - return mIcon->getWidth(); - } - return LLScrollListCell::getWidth(); -} - -// -void LLScrollListIcon::setClickCallback(boost::function cb) -{ - mCallback = cb; -} - -BOOL LLScrollListIcon::handleClick() -{ - if(mCallback) return mCallback(); - return FALSE; -} -// - -void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_color) const -{ - if (mIcon) - { - mIcon->draw(0, 0, mColor); - } -} - - -// -// LLScrollListText -// -U32 LLScrollListText::sCount = 0; - -LLScrollListText::LLScrollListText( const std::string& text, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, LLColor4& color, BOOL use_color, BOOL visible) -: LLScrollListCell(width), - mText( text ), - mFont( font ), - mColor(color), - mUseColor(use_color), - mFontStyle( font_style ), - mFontAlignment( font_alignment ), - mVisible( visible ), - mHighlightCount( 0 ), - mHighlightOffset( 0 ) -{ - sCount++; - - mTextWidth = getWidth(); - - // initialize rounded rect image - if (!mRoundedRectImage) - { - mRoundedRectImage = LLUI::getUIImage("rounded_square.tga"); - } -} -//virtual -void LLScrollListText::highlightText(S32 offset, S32 num_chars) -{ - mHighlightOffset = offset; - mHighlightCount = num_chars; -} - -//virtual -BOOL LLScrollListText::isText() const -{ - return TRUE; -} - -//virtual -BOOL LLScrollListText::getVisible() const -{ - return mVisible; -} - -//virtual -S32 LLScrollListText::getHeight() const -{ - return llround(mFont->getLineHeight()); -} - - -LLScrollListText::~LLScrollListText() -{ - sCount--; -} - -S32 LLScrollListText::getContentWidth() const -{ - return mFont->getWidth(mText.getString()); -} - - -void LLScrollListText::setColor(const LLColor4& color) -{ - mColor = color; - mUseColor = TRUE; -} - -void LLScrollListText::setText(const LLStringExplicit& text) -{ - mText = text; -} - -void LLScrollListText::setFontStyle(const U8 font_style) -{ - mFontStyle = font_style; -} - -//virtual -void LLScrollListText::setValue(const LLSD& text) -{ - setText(text.asString()); -} - -//virtual -const LLSD LLScrollListText::getValue() const -{ - return LLSD(mText.getString()); -} - - -void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_color) const -{ - LLColor4 display_color; - if (mUseColor) - { - display_color = mColor; - } - else - { - display_color = color; - } - - if (mHighlightCount > 0) - { - S32 left = 0; - switch(mFontAlignment) - { - case LLFontGL::LEFT: - left = mFont->getWidth(mText.getString(), 0, mHighlightOffset); - break; - case LLFontGL::RIGHT: - left = getWidth() - mFont->getWidth(mText.getString(), mHighlightOffset, S32_MAX); - break; - case LLFontGL::HCENTER: - left = (getWidth() - mFont->getWidth(mText.getString())) / 2; - break; - } - LLRect highlight_rect(left - 2, - llround(mFont->getLineHeight()) + 1, - left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1, - 1); - mRoundedRectImage->draw(highlight_rect, highlight_color); - } - - // Try to draw the entire string - F32 right_x; - U32 string_chars = mText.length(); - F32 start_x = 0.f; - switch(mFontAlignment) - { - case LLFontGL::LEFT: - start_x = (mFontStyle & LLFontGL::ITALIC) ? 2.f : 0.f; //Italic text seems need a little padding. - break; - case LLFontGL::RIGHT: - start_x = (F32)getWidth(); - break; - case LLFontGL::HCENTER: - start_x = (F32)getWidth() * 0.5f; - break; - } - mFont->render(mText.getWString(), 0, - start_x, 2.f, - display_color, - mFontAlignment, - LLFontGL::BOTTOM, - mFontStyle, - LLFontGL::NO_SHADOW, - string_chars, - getTextWidth(), - &right_x, - FALSE, - TRUE); -} - -// -// LLScrollListCheck -// -LLScrollListCheck::LLScrollListCheck(LLCheckBoxCtrl* check_box, S32 width) -{ - mCheckBox = check_box; - LLRect rect(mCheckBox->getRect()); - if (width) - { - - rect.mRight = rect.mLeft + width; - mCheckBox->setRect(rect); - setWidth(width); - } - else - { - setWidth(rect.getWidth()); //check_box->getWidth(); - } -} - -LLScrollListCheck::~LLScrollListCheck() -{ - delete mCheckBox; - mCheckBox = NULL; -} - -void LLScrollListCheck::draw(const LLColor4& color, const LLColor4& highlight_color) const -{ - mCheckBox->draw(); -} - -BOOL LLScrollListCheck::handleClick() -{ - if (mCheckBox->getEnabled()) - { - mCheckBox->toggle(); - } - // don't change selection when clicking on embedded checkbox - return TRUE; -} - -/*virtual*/ -const LLSD LLScrollListCheck::getValue() const -{ - return mCheckBox->getValue(); -} - -/*virtual*/ -void LLScrollListCheck::setValue(const LLSD& value) -{ - mCheckBox->setValue(value); -} - -/*virtual*/ -void LLScrollListCheck::onCommit() -{ - mCheckBox->onCommit(); -} - -/*virtual*/ -void LLScrollListCheck::setEnabled(BOOL enable) -{ - mCheckBox->setEnabled(enable); -} - -LLScrollListDate::LLScrollListDate( const LLDate& date, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, LLColor4& color, BOOL use_color, BOOL visible) -: LLScrollListText(date.asRFC1123(), font, width, font_style, font_alignment, color, use_color, visible), - mDate(date) -{ -} - -void LLScrollListDate::setValue(const LLSD& value) -{ - mDate = value.asDate(); - LLScrollListText::setValue(mDate.asRFC1123()); -} - -const LLSD LLScrollListDate::getValue() const -{ - return mDate; -} - -LLScrollListItem::~LLScrollListItem() -{ - std::for_each(mColumns.begin(), mColumns.end(), DeletePointer()); -} - -void LLScrollListItem::setNumColumns(S32 columns) -{ - S32 prev_columns = mColumns.size(); - if (columns < prev_columns) - { - std::for_each(mColumns.begin()+columns, mColumns.end(), DeletePointer()); - } - - mColumns.resize(columns); - - for (S32 col = prev_columns; col < columns; ++col) - { - mColumns[col] = NULL; - } -} - -void LLScrollListItem::setColumn( S32 column, LLScrollListCell *cell ) -{ - if (column < (S32)mColumns.size()) - { - delete mColumns[column]; - mColumns[column] = cell; - } - else - { - llerrs << "LLScrollListItem::setColumn: bad column: " << column << llendl; - } -} - - -S32 LLScrollListItem::getNumColumns() const -{ - return mColumns.size(); -} - -LLScrollListCell* LLScrollListItem::getColumn(const S32 i) const -{ - if (0 <= i && i < (S32)mColumns.size()) - { - return mColumns[i]; - } - return NULL; -} - -std::string LLScrollListItem::getContentsCSV() const -{ - std::string ret; - - S32 count = getNumColumns(); - for (S32 i=0; igetValue().asString(); - if (i < count-1) - { - ret += ", "; - } - } - - return ret; -} - -void LLScrollListItem::draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding) -{ - // draw background rect - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLRect bg_rect = rect; - gl_rect_2d( bg_rect, bg_color ); - - S32 cur_x = rect.mLeft; - S32 num_cols = getNumColumns(); - S32 cur_col = 0; - - for (LLScrollListCell* cell = getColumn(0); cur_col < num_cols; cell = getColumn(++cur_col)) - { - // Two ways a cell could be hidden - if (cell->getWidth() < 0 - || !cell->getVisible()) continue; - - LLUI::pushMatrix(); - { - LLUI::translate((F32) cur_x, (F32) rect.mBottom); - - cell->draw( fg_color, highlight_color ); - } - LLUI::popMatrix(); - - cur_x += cell->getWidth() + column_padding; - } -} - - +//Singu TODO: Get rid of these in favor of making separators out of normal LLScrollListItems like LL // // LLScrollListSeparator // @@ -561,7 +132,7 @@ public: class LLScrollListItemSeparator : public LLScrollListItem { public: - LLScrollListItemSeparator() : LLScrollListItem(FALSE) + LLScrollListItemSeparator() : LLScrollListItem(false) { LLScrollListSeparator* cell = new LLScrollListSeparator(0); setNumColumns(1); @@ -595,13 +166,8 @@ public: // LLScrollListCtrl //--------------------------------------------------------------------------- -LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect, - commit_callback_t commit_callback, - BOOL allow_multiple_selection, - BOOL show_border, - bool draw_heading - ) - : LLUICtrl(name, rect, TRUE, commit_callback), +LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect, commit_callback_t commit_callback, bool multi_select, bool has_border, bool draw_heading) +: LLUICtrl(name, rect, TRUE, commit_callback), mLineHeight(0), mScrollLines(0), mMouseWheelOpaque(true), @@ -616,7 +182,7 @@ LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect, mColumnsDirty(false), mMaxItemCount(INT_MAX), mMaxContentWidth(0), - mDefaultListTextColor( LLUI::sColorsGroup->getColor("DefaultListText") ), + mDefaultListTextColor(LLUI::sColorsGroup->getColor("DefaultListText")), mBorderThickness( 2 ), mOnDoubleClickCallback( NULL ), mOnMaximumSelectCallback( NULL ), @@ -631,20 +197,20 @@ LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect, mSorted(true), mDirty(false), mOriginalSelection(-1), - mLastSelected(NULL), + mLastSelected(NULL), mHeadingHeight(20), - mAllowMultipleSelection( allow_multiple_selection ), + mAllowMultipleSelection(multi_select), mDisplayColumnHeaders(draw_heading), mBackgroundVisible(true), mDrawStripes(true), - mBgWriteableColor( LLUI::sColorsGroup->getColor( "ScrollBgWriteableColor" ) ), - mBgReadOnlyColor( LLUI::sColorsGroup->getColor( "ScrollBgReadOnlyColor" ) ), - mBgSelectedColor( LLUI::sColorsGroup->getColor("ScrollSelectedBGColor") ), - mBgStripeColor( LLUI::sColorsGroup->getColor("ScrollBGStripeColor") ), - mFgSelectedColor( LLUI::sColorsGroup->getColor("ScrollSelectedFGColor") ), - mFgUnselectedColor( LLUI::sColorsGroup->getColor("ScrollUnselectedColor") ), - mFgDisabledColor( LLUI::sColorsGroup->getColor("ScrollDisabledColor") ), - mHighlightedColor( LLUI::sColorsGroup->getColor("ScrollHighlightedColor") ), + mBgWriteableColor(LLUI::sColorsGroup->getColor("ScrollBgWriteableColor")), + mBgReadOnlyColor(LLUI::sColorsGroup->getColor("ScrollBgReadOnlyColor")), + mBgSelectedColor(LLUI::sColorsGroup->getColor("ScrollSelectedBGColor")), + mBgStripeColor(LLUI::sColorsGroup->getColor("ScrollBGStripeColor")), + mFgSelectedColor(LLUI::sColorsGroup->getColor("ScrollSelectedFGColor")), + mFgUnselectedColor(LLUI::sColorsGroup->getColor("ScrollUnselectedColor")), + mFgDisabledColor(LLUI::sColorsGroup->getColor("ScrollDisabledColor")), + mHighlightedColor(LLUI::sColorsGroup->getColor("ScrollHighlightedColor")), mSearchColumn(0), mColumnPadding(5) { @@ -669,16 +235,14 @@ LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect, mScrollLines, getLinesPerPage(), boost::bind(&LLScrollListCtrl::onScrollChange, this, _1, _2) ); - mScrollbar->setFollowsRight(); - mScrollbar->setFollowsTop(); - mScrollbar->setFollowsBottom(); - mScrollbar->setEnabled( TRUE ); + mScrollbar->setFollows(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM); + mScrollbar->setEnabled(true); // scrollbar is visible only when needed - mScrollbar->setVisible(FALSE); + mScrollbar->setVisible(false); addChild(mScrollbar); // Border - if (show_border) + if (has_border) { LLRect border_rect( 0, getRect().getHeight(), getRect().getWidth(), 0 ); mBorder = new LLViewBorder( std::string("dlg border"), border_rect, LLViewBorder::BEVEL_IN, LLViewBorder::STYLE_LINE, 1 ); @@ -687,7 +251,7 @@ LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect, LLTextBox* textBox = new LLTextBox("comment_text",mItemListRect,std::string()); textBox->setBorderVisible(false); - textBox->setFollowsAll(); + textBox->setFollows(FOLLOWS_ALL); textBox->setFontShadow(LLFontGL::NO_SHADOW); textBox->setColor(LLUI::sColorsGroup->getColor("DefaultListText")); addChild(textBox); @@ -788,7 +352,6 @@ std::vector LLScrollListCtrl::getAllSelected() const return ret; } - item_list::const_iterator iter; for(iter = mItemList.begin(); iter != mItemList.end(); iter++) { @@ -819,7 +382,7 @@ S32 LLScrollListCtrl::getNumSelected() const { return 0; } - + S32 numSelected = 0; for(item_list::const_iterator iter = mItemList.begin(); iter != mItemList.end(); ++iter) @@ -841,7 +404,6 @@ S32 LLScrollListCtrl::getFirstSelectedIndex() const return -1; } - S32 CurSelectedIndex = 0; // make sure sort is up to date before returning an index @@ -999,11 +561,8 @@ BOOL LLScrollListCtrl::addItem( LLScrollListItem* item, EAddPosition pos, BOOL r single_sort_column.push_back(std::make_pair(0, TRUE)); mItemList.push_back(item); - std::stable_sort( - mItemList.begin(), - mItemList.end(), - SortScrollListItem(single_sort_column,mSortCallback)); - + std::stable_sort(mItemList.begin(), mItemList.end(), SortScrollListItem(single_sort_column,mSortCallback)); + // ADD_SORTED just sorts by first column... // this might not match user sort criteria, so flag list as being in unsorted state setNeedsSort(); @@ -1080,7 +639,7 @@ S32 LLScrollListCtrl::calcMaxContentWidth() } max_item_width += column->mMaxContentWidth; } - + mMaxContentWidth = max_item_width; return max_item_width; } @@ -1372,7 +931,7 @@ void LLScrollListCtrl::moveToFront(S32 index) { return; } - + LLScrollListCtrl::item_list::iterator it = mItemList.begin(); std::advance(it,index); mItemList.push_front(*it); @@ -1623,7 +1182,6 @@ void LLScrollListCtrl::deselectAllItems(BOOL no_commit_on_change) /////////////////////////////////////////////////////////////////////////////////////////////////// // Use this to add comment text such as "Searching", which ignores column settings of list - void LLScrollListCtrl::setCommentText(const std::string& comment_text) { getChild("comment_text")->setWrappedText(comment_text); @@ -1791,7 +1349,7 @@ LLScrollListItem* LLScrollListCtrl::addStringUUIDItem(const std::string& item_te LLScrollListItem* item = NULL; if (getItemCount() < mMaxItemCount) { - item = new LLScrollListItem( enabled, NULL, id ); + item = new LLScrollListItem(enabled, id); item->addColumn(item_text, LLResMgr::getInstance()->getRes(LLFONT_SANSSERIF_SMALL), column_width); addItem( item, pos ); } @@ -2038,7 +1596,6 @@ BOOL LLScrollListCtrl::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sti BOOL handled = FALSE; // show tooltip for full name of hovered item if it has been truncated LLScrollListItem* hit_item = hitItem(x, y); - if (hit_item) { // If the item has a specific tool tip set by XUI use that first @@ -2048,10 +1605,9 @@ BOOL LLScrollListCtrl::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sti msg=tooltip; return TRUE; } - + LLScrollListCell* hit_cell = hit_item->getColumn(column_index); if (!hit_cell) return FALSE; - //S32 cell_required_width = hit_cell->getContentWidth(); if (hit_cell && hit_cell->isText()) { @@ -2785,6 +2341,7 @@ S32 LLScrollListCtrl::getLinesPerPage() } } + // Called by scrollbar void LLScrollListCtrl::onScrollChange( S32 new_pos, LLScrollbar* scrollbar ) { @@ -2916,25 +2473,16 @@ void LLScrollListCtrl::updateStaticColumnWidth(LLScrollListColumn* col, S32 new_ LLXMLNodePtr LLScrollListCtrl::getXML(bool save_children) const { LLXMLNodePtr node = LLUICtrl::getXML(); - node->setName(LL_SCROLL_LIST_CTRL_TAG); // Attributes - node->createChild("multi_select", TRUE)->setBoolValue(mAllowMultipleSelection); - node->createChild("draw_border", TRUE)->setBoolValue((mBorder != NULL)); - node->createChild("draw_heading", TRUE)->setBoolValue(mDisplayColumnHeaders); - node->createChild("background_visible", TRUE)->setBoolValue(mBackgroundVisible); - node->createChild("draw_stripes", TRUE)->setBoolValue(mDrawStripes); - node->createChild("column_padding", TRUE)->setIntValue(mColumnPadding); - node->createChild("mouse_wheel_opaque", TRUE)->setBoolValue(mMouseWheelOpaque); - addColorXML(node, mBgWriteableColor, "bg_writeable_color", "ScrollBgWriteableColor"); addColorXML(node, mBgReadOnlyColor, "bg_read_only_color", "ScrollBgReadOnlyColor"); addColorXML(node, mBgSelectedColor, "bg_selected_color", "ScrollSelectedBGColor"); @@ -2945,8 +2493,6 @@ LLXMLNodePtr LLScrollListCtrl::getXML(bool save_children) const addColorXML(node, mHighlightedColor, "highlighted_color", "ScrollHighlightedColor"); // Contents - - std::map::const_iterator itor; std::vector sorted_list; sorted_list.resize(mColumns.size()); for (column_map_t::const_iterator itor = mColumns.begin(); itor != mColumns.end(); ++itor) @@ -2954,8 +2500,7 @@ LLXMLNodePtr LLScrollListCtrl::getXML(bool save_children) const sorted_list[itor->second->mIndex] = itor->second; } - std::vector::iterator itor2; - for (itor2 = sorted_list.begin(); itor2 != sorted_list.end(); ++itor2) + for (std::vector::iterator itor2 = sorted_list.begin(); itor2 != sorted_list.end(); ++itor2) { LLXMLNodePtr child_node = node->createChild("column", FALSE); const LLScrollListColumn *column = *itor2; @@ -3041,34 +2586,20 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac LLRect rect; createRect(node, rect, parent, LLRect()); - BOOL multi_select = FALSE; + BOOL multi_select = false; node->getAttributeBOOL("multi_select", multi_select); - - BOOL draw_border = TRUE; + BOOL draw_border = true; node->getAttributeBOOL("draw_border", draw_border); - - BOOL draw_heading = FALSE; + BOOL draw_heading = false; node->getAttributeBOOL("draw_heading", draw_heading); - S32 search_column = 0; node->getAttributeS32("search_column", search_column); - S32 sort_column = -1; node->getAttributeS32("sort_column", sort_column); - - BOOL sort_ascending = TRUE; + BOOL sort_ascending = true; node->getAttributeBOOL("sort_ascending", sort_ascending); - - BOOL mouse_wheel_opaque = TRUE; - node->getAttributeBOOL("mouse_wheel_opaque", mouse_wheel_opaque); - LLScrollListCtrl* scroll_list = new LLScrollListCtrl( - "scroll_list", - rect, - NULL, - multi_select, - draw_border, - draw_heading); + LLScrollListCtrl* scroll_list = new LLScrollListCtrl("scroll_list", rect, NULL, multi_select, draw_border, draw_heading); if (node->hasAttribute("heading_height")) { @@ -3078,52 +2609,40 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac } scroll_list->setScrollListParameters(node); - scroll_list->initFromXML(node, parent); - scroll_list->setSearchColumn(search_column); - + + BOOL mouse_wheel_opaque = true; + node->getAttributeBOOL("mouse_wheel_opaque", mouse_wheel_opaque); scroll_list->mMouseWheelOpaque = mouse_wheel_opaque; LLSD columns; S32 index = 0; - LLXMLNodePtr child; - for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) + for (LLXMLNodePtr child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { if (child->hasName("column")) { std::string labelname(""); child->getAttributeString("label", labelname); - std::string columnname(labelname); child->getAttributeString("name", columnname); - std::string sortname(columnname); child->getAttributeString("sort", sortname); - - BOOL sort_ascending = TRUE; + BOOL sort_ascending = true; child->getAttributeBOOL("sort_ascending", sort_ascending); - std::string imagename; child->getAttributeString("image", imagename); - std::string imageoverlay; child->getAttributeString("image_overlay", imageoverlay); - - BOOL columndynamicwidth = FALSE; + BOOL columndynamicwidth = false; child->getAttributeBOOL("dynamicwidth", columndynamicwidth); - S32 columnwidth = -1; child->getAttributeS32("width", columnwidth); - std::string tooltip; child->getAttributeString("tool_tip", tooltip); - F32 columnrelwidth = 0.f; child->getAttributeF32("relwidth", columnrelwidth); - - LLFontGL::HAlign h_align = LLFontGL::LEFT; - h_align = LLView::selectFontHAlign(child); + LLFontGL::HAlign h_align = LLView::selectFontHAlign(child); columns[index]["name"] = columnname; columns[index]["sort"] = sortname; @@ -3136,8 +2655,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac columns[index]["dynamicwidth"] = columndynamicwidth; columns[index]["halign"] = (S32)h_align; columns[index]["tool_tip"] = tooltip; - - index++; + ++index; } } scroll_list->setColumnHeadings(columns); @@ -3147,7 +2665,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac scroll_list->sortByColumnIndex(sort_column, sort_ascending); } - for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) + for (LLXMLNodePtr child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { if (child->hasName("row") || child->hasName("rows")) { @@ -3163,8 +2681,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac S32 column_idx = 0; bool explicit_column = false; - LLXMLNodePtr row_child; - for (row_child = child->getFirstChild(); row_child.notNull(); row_child = row_child->getNextSibling()) + for (LLXMLNodePtr row_child = child->getFirstChild(); row_child.notNull(); row_child = row_child->getNextSibling()) { if (row_child->hasName("column")) { @@ -3172,10 +2689,8 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac std::string columnname(""); row_child->getAttributeString("name", columnname); - std::string font(""); row_child->getAttributeString("font", font); - std::string font_style(""); row_child->getAttributeString("font-style", font_style); @@ -3183,7 +2698,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac row["columns"][column_idx]["value"] = value; row["columns"][column_idx]["font"] = font; row["columns"][column_idx]["font-style"] = font_style; - column_idx++; + ++column_idx; explicit_column = true; } } @@ -3199,9 +2714,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac } } - std::string contents = node->getTextContents(); - scroll_list->setCommentText(contents); - + scroll_list->setCommentText(node->getTextContents()); return scroll_list; } @@ -3284,15 +2797,14 @@ void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos) // if no column name provided, just use ordinal as name if (name.empty()) { - std::ostringstream new_name; - new_name << mColumnsIndexed.size(); - name = new_name.str(); + name = llformat("%d", mColumnsIndexed.size()); } + if (mColumns.find(name) == mColumns.end()) { // Add column - LLScrollListColumn* new_column = new LLScrollListColumn(column, this); - mColumns[name] = new_column; + mColumns[name] = new LLScrollListColumn(column, this); + LLScrollListColumn* new_column = mColumns[name]; new_column->mParentCtrl = this; new_column->mIndex = mColumns.size()-1; @@ -3326,36 +2838,33 @@ void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos) } } - std::string button_name = "btn_" + name; S32 right = left+new_column->getWidth(); if (new_column->mIndex != (S32)mColumns.size()-1) { right += mColumnPadding; } + LLRect temp_rect = LLRect(left,top+mHeadingHeight,right,top); - new_column->mHeader = new LLScrollColumnHeader(button_name, temp_rect, new_column); - if(column["image"].asString() != "") + + new_column->mHeader = new LLScrollColumnHeader("btn_" + name, temp_rect, new_column); + new_column->mHeader->setToolTip(column["tool_tip"].asString()); + new_column->mHeader->setTabStop(false); + new_column->mHeader->setVisible(mDisplayColumnHeaders); + + if(!column["image"].asString().empty()) { - //new_column->mHeader->setScaleImage(false); - new_column->mHeader->setImage(column["image"].asString()); + new_column->mHeader->setImage(column["image"].asString()); } - else if(column["image_overlay"].asString() != "") + else if(!column["image_overlay"].asString().empty()) { - new_column->mHeader->setImageOverlay(column["image_overlay"].asString()); + new_column->mHeader->setImageOverlay(column["image_overlay"].asString()); } else { - new_column->mHeader->setLabel(new_column->mLabel); - //new_column->mHeader->setLabel(new_column->mLabel); + new_column->mHeader->setLabel(new_column->mLabel.getString()); } - new_column->mHeader->setToolTip(column["tool_tip"].asString()); - - //RN: although it might be useful to change sort order with the keyboard, - // mixing tab stops on child items along with the parent item is not supported yet - new_column->mHeader->setTabStop(FALSE); addChild(new_column->mHeader); - new_column->mHeader->setVisible(mDisplayColumnHeaders); sendChildToFront(mScrollbar); } @@ -3468,7 +2977,7 @@ LLScrollListColumn* LLScrollListCtrl::getColumn(const std::string& name) return NULL; } -void LLScrollListCtrl::setColumnHeadings(LLSD headings) +void LLScrollListCtrl::setColumnHeadings(const LLSD& headings) { mColumns.clear(); LLSD::array_const_iterator itor; @@ -3485,26 +2994,22 @@ void LLScrollListCtrl::setColumnHeadings(LLSD headings) "name" "label" "width" - "dynamic_width" + "dynamic_width" */ -LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition pos, void* userdata) +LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition pos, void* userdata) { - // ID - LLSD id = value["id"]; - - LLScrollListItem *new_item = new LLScrollListItem(id, userdata); - if (value.has("enabled")) - { - new_item->setEnabled( value["enabled"].asBoolean() ); - } + LLScrollListItem *new_item = new LLScrollListItem(!element.has("enabled") || element["enabled"].asBoolean(), element["id"], userdata); + if (!new_item) return NULL; new_item->setNumColumns(mColumns.size()); // Add any columns we don't already have - LLSD columns = value["columns"]; - LLSD::array_const_iterator itor; - S32 col_index = 0 ; - for (itor = columns.beginArray(); itor != columns.endArray(); ++itor) + S32 col_index = 0; + + LLSD columns = element["columns"]; + for (LLSD::array_const_iterator itor = columns.beginArray(); + itor != columns.endArray(); + ++itor) { if (itor->isUndefined()) { @@ -3518,9 +3023,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p // empty columns strings index by ordinal if (column.empty()) { - std::ostringstream new_name; - new_name << col_index; - column = new_name.str(); + column = llformat("%d", col_index); } column_map_t::iterator column_itor = mColumns.find(column); @@ -3554,7 +3057,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p S32 width = columnp->getWidth(); LLFontGL::HAlign font_alignment = columnp->mFontAlignment; LLColor4 fcolor = LLColor4::black; - + LLSD value = (*itor)["value"]; std::string fontname = (*itor)["font"].asString(); std::string fontstyle = (*itor)["font-style"].asString(); @@ -3565,7 +3068,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p LLSD sd_color = (*itor)["font-color"]; fcolor.setValue(sd_color); } - + BOOL has_color = (*itor).has("color"); LLColor4 color = ((*itor)["color"]); BOOL enabled = !(*itor).has("enabled") || (*itor)["enabled"].asBoolean() == true; @@ -3654,20 +3157,12 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p } addItem(new_item, pos); - return new_item; } LLScrollListItem* LLScrollListCtrl::addSimpleElement(const std::string& value, EAddPosition pos, const LLSD& id) { - LLSD entry_id = id; - - if (id.isUndefined()) - { - entry_id = value; - } - - LLScrollListItem *new_item = new LLScrollListItem(entry_id); + LLScrollListItem* new_item = new LLScrollListItem(true, id.isUndefined() ? LLSD(value) : id); const LLFontGL *font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ); @@ -3777,583 +3272,3 @@ void LLScrollListCtrl::onFocusLost() LLUICtrl::onFocusLost(); } -LLScrollColumnHeader::LLScrollColumnHeader(const std::string& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL* fontp) : - LLComboBox(label, rect, label), - mColumn(column), - mOrigLabel(label), - mShowSortOptions(FALSE), - mHasResizableElement(FALSE) -{ - mListPosition = LLComboBox::ABOVE; - setCommitCallback(boost::bind(&LLScrollColumnHeader::onSelectSort, this)); - mButton->setTabStop(FALSE); - // require at least two frames between mouse down and mouse up event to capture intentional "hold" not just bad framerate - mButton->setHeldDownDelay(LLUI::sConfigGroup->getF32("ColumnHeaderDropDownDelay"), 2); - mButton->setHeldDownCallback(boost::bind(&LLScrollColumnHeader::showList, this)); - mButton->setClickedCallback(boost::bind(&LLScrollColumnHeader::onClick, this)); - mButton->setMouseDownCallback(boost::bind(&LLScrollColumnHeader::onMouseDown, this)); - - mButton->setToolTip(label); - - mAscendingText = std::string("[LOW]...[HIGH](Ascending)"); // *TODO: Translate - mDescendingText = std::string("[HIGH]...[LOW](Descending)"); // *TODO: Translate - - mList->reshape(llmax(mList->getRect().getWidth(), 110, getRect().getWidth()), mList->getRect().getHeight()); - - // resize handles on left and right - const S32 RESIZE_BAR_THICKNESS = 3; - LLResizeBar::Params p; - p.name = "resizebar"; - p.resizing_view = this; - p.rect = LLRect( getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0); - p.min_size = MIN_COLUMN_WIDTH; - p.max_size = S32_MAX; - p.side = LLResizeBar::RIGHT; - mResizeBar = LLUICtrlFactory::create(p); - addChild(mResizeBar); - - mResizeBar->setEnabled(FALSE); - - mImageOverlayAlignment = LLFontGL::HCENTER; - mImageOverlayColor = LLColor4::white; -} - -LLScrollColumnHeader::~LLScrollColumnHeader() -{ -} - -void LLScrollColumnHeader::draw() -{ - std::string sort_column = mColumn->mParentCtrl->getSortColumnName(); - BOOL draw_arrow = !mColumn->mLabel.empty() - && mColumn->mParentCtrl->isSorted() - // check for indirect sorting column as well as column's sorting name - && (sort_column == mColumn->mSortingColumn || sort_column == mColumn->mName); - - BOOL is_ascending = mColumn->mParentCtrl->getSortAscending(); - mButton->setImageOverlay(is_ascending ? "up_arrow.tga" : "down_arrow.tga", LLFontGL::RIGHT, draw_arrow ? LLColor4::white : LLColor4::transparent); - mArrowImage = mButton->getImageOverlay(); - - //BOOL clip = getRect().mRight > mColumn->mParentCtrl->getItemListRect().getWidth(); - //LLGLEnable scissor_test(clip ? GL_SCISSOR_TEST : GL_FALSE); - - //LLRect column_header_local_rect(-getRect().mLeft, getRect().getHeight(), mColumn->mParentCtrl->getItemListRect().getWidth() - getRect().mLeft, 0); - //LLUI::setScissorRegionLocal(column_header_local_rect); - - // Draw children - LLComboBox::draw(); - - if (mImageOverlay.notNull()) //Ugly dupe code from llbutton... - { - BOOL pressed_by_keyboard = FALSE; - if (mButton->hasFocus()) - { - pressed_by_keyboard = gKeyboard->getKeyDown(' ') || (mButton->getCommitOnReturn() && gKeyboard->getKeyDown(KEY_RETURN)); - } - - // Unselected image assignments - S32 local_mouse_x; - S32 local_mouse_y; - LLUI::getMousePositionLocal(mButton, &local_mouse_x, &local_mouse_y); - - BOOL pressed = pressed_by_keyboard - || (mButton->hasMouseCapture() && mButton->pointInView(local_mouse_x, local_mouse_y)) - || mButton->getToggleState(); - - // Now draw special overlay.. - // let overlay image and text play well together - S32 button_width = mButton->getRect().getWidth(); - S32 button_height = mButton->getRect().getHeight(); - S32 text_left = mButton->getLeftHPad(); - S32 text_right = button_width - mButton->getRightHPad(); - S32 text_width = text_right - text_left; - - // draw overlay image - - // get max width and height (discard level 0) - S32 overlay_width = mImageOverlay->getWidth(); - S32 overlay_height = mImageOverlay->getHeight(); - - F32 scale_factor = llmin((F32)button_width / (F32)overlay_width, (F32)button_height / (F32)overlay_height, 1.f); - overlay_width = llround((F32)overlay_width * scale_factor); - overlay_height = llround((F32)overlay_height * scale_factor); - - S32 center_x = mButton->getLocalRect().getCenterX(); - S32 center_y = mButton->getLocalRect().getCenterY(); - - //FUGLY HACK FOR "DEPRESSED" BUTTONS - if (pressed) - { - center_y--; - center_x++; - } - - // fade out overlay images on disabled buttons - LLColor4 overlay_color = mImageOverlayColor; - if (!mButton->getEnabled()) - { - overlay_color.mV[VALPHA] = 0.5f; - } - - switch(mImageOverlayAlignment) - { - case LLFontGL::LEFT: - text_left += overlay_width + 1; - text_width -= overlay_width + 1; - mImageOverlay->draw( - text_left, - center_y - (overlay_height / 2), - overlay_width, - overlay_height, - overlay_color); - break; - case LLFontGL::HCENTER: - mImageOverlay->draw( - center_x - (overlay_width / 2), - center_y - (overlay_height / 2), - overlay_width, - overlay_height, - overlay_color); - break; - case LLFontGL::RIGHT: - text_right -= overlay_width + 1; - text_width -= overlay_width + 1; - mImageOverlay->draw( - text_right - overlay_width, - center_y - (overlay_height / 2), - overlay_width, - overlay_height, - overlay_color); - break; - default: - // draw nothing - break; - } - } - - - if (mList->getVisible()) - { - // sync sort order with list selection every frame - mColumn->mParentCtrl->sortByColumn(mColumn->mSortingColumn, getCurrentIndex() == 0); - } -} - -BOOL LLScrollColumnHeader::handleDoubleClick(S32 x, S32 y, MASK mask) -{ - if (canResize() && mResizeBar->getRect().pointInRect(x, y)) - { - // reshape column to max content width - mColumn->mParentCtrl->calcMaxContentWidth(); - LLRect column_rect = getRect(); - column_rect.mRight = column_rect.mLeft + mColumn->mMaxContentWidth; - setShape(column_rect,true); - } - else - { - onClick(); - } - return TRUE; -} - -void LLScrollColumnHeader::setImage(const std::string &image_name) -{ - if (mButton) - { - mButton->setImageSelected(LLUI::getUIImage(image_name)); - mButton->setImageUnselected(LLUI::getUIImage(image_name)); - } -} - -void LLScrollColumnHeader::setImageOverlay(const std::string &image_name, LLFontGL::HAlign alignment, const LLColor4& color) -{ - if (image_name.empty()) - { - mImageOverlay = NULL; - } - else - { - mImageOverlay = LLUI::getUIImage(image_name); - mImageOverlayAlignment = alignment; - mImageOverlayColor = color; - } -} - -void LLScrollColumnHeader::onClick() -{ - if (!mColumn) return; - - if (mList->getVisible()) - { - hideList(); - } - - LLScrollListCtrl::onClickColumn(mColumn); - - // propagate new sort order to sort order list - mList->selectNthItem(mColumn->mParentCtrl->getSortAscending() ? 0 : 1); - - mList->setFocus(TRUE); -} - -void LLScrollColumnHeader::onMouseDown() -{ - // for now, do nothing but block the normal showList() behavior - return; -} - -void LLScrollColumnHeader::showList() -{ - if (mShowSortOptions) - { - //LLSD item_val = mColumn->mParentCtrl->getFirstData()->getValue(); - mOrigLabel = mButton->getLabelSelected(); - - // move sort column over to this column and do initial sort - mColumn->mParentCtrl->sortByColumn(mColumn->mSortingColumn, mColumn->mParentCtrl->getSortAscending()); - - std::string low_item_text; - std::string high_item_text; - - LLScrollListItem* itemp = mColumn->mParentCtrl->getFirstData(); - if (itemp) - { - LLScrollListCell* cell = itemp->getColumn(mColumn->mIndex); - if (cell && cell->isText()) - { - if (mColumn->mParentCtrl->getSortAscending()) - { - low_item_text = cell->getValue().asString(); - } - else - { - high_item_text = cell->getValue().asString(); - } - } - } - - itemp = mColumn->mParentCtrl->getLastData(); - if (itemp) - { - LLScrollListCell* cell = itemp->getColumn(mColumn->mIndex); - if (cell && cell->isText()) - { - if (mColumn->mParentCtrl->getSortAscending()) - { - high_item_text = cell->getValue().asString(); - } - else - { - low_item_text = cell->getValue().asString(); - } - } - } - - LLStringUtil::truncate(low_item_text, 3); - LLStringUtil::truncate(high_item_text, 3); - - std::string ascending_string; - std::string descending_string; - - if (low_item_text.empty() || high_item_text.empty()) - { - ascending_string = "Ascending"; - descending_string = "Descending"; - } - else - { - mAscendingText.setArg("[LOW]", low_item_text); - mAscendingText.setArg("[HIGH]", high_item_text); - mDescendingText.setArg("[LOW]", low_item_text); - mDescendingText.setArg("[HIGH]", high_item_text); - ascending_string = mAscendingText.getString(); - descending_string = mDescendingText.getString(); - } - - S32 text_width = LLFontGL::getFontSansSerifSmall()->getWidth(ascending_string); - text_width = llmax(text_width, LLFontGL::getFontSansSerifSmall()->getWidth(descending_string)) + 10; - text_width = llmax(text_width, getRect().getWidth() - 30); - - mList->getColumn(0)->setWidth(text_width); - mList->getFirstData()->getColumn(0)->setValue(ascending_string); - mList->getLastData()->getColumn(0)->setValue(descending_string); - - mList->reshape(llmax(text_width + 30, 110, getRect().getWidth()), mList->getRect().getHeight()); - - LLComboBox::showList(); - } -} - -void LLScrollColumnHeader::onSelectSort() -{ - if (!mColumn) return; - LLScrollListCtrl* parent = mColumn->mParentCtrl; - if (!parent) return; - - if (getCurrentIndex() == 0) - { - // ascending - parent->sortByColumn(mColumn->mSortingColumn, TRUE); - } - else - { - // descending - parent->sortByColumn(mColumn->mSortingColumn, FALSE); - } - - // restore original column header - setLabel(mOrigLabel); -} - -LLView* LLScrollColumnHeader::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding) -{ - // this logic assumes dragging on right - llassert(snap_edge == SNAP_RIGHT); - - // use higher snap threshold for column headers - threshold = llmin(threshold, 10); - - LLRect snap_rect = getSnapRect(); - - S32 snap_delta = mColumn->mMaxContentWidth - snap_rect.getWidth(); - - // x coord growing means column growing, so same signs mean we're going in right direction - if (llabs(snap_delta) <= threshold && mouse_dir.mX * snap_delta > 0 ) - { - new_edge_val = snap_rect.mRight + snap_delta; - } - else - { - LLScrollListColumn* next_column = mColumn->mParentCtrl->getColumn(mColumn->mIndex + 1); - while (next_column) - { - if (next_column->mHeader) - { - snap_delta = (next_column->mHeader->getSnapRect().mRight - next_column->mMaxContentWidth) - snap_rect.mRight; - if (llabs(snap_delta) <= threshold && mouse_dir.mX * snap_delta > 0 ) - { - new_edge_val = snap_rect.mRight + snap_delta; - } - break; - } - next_column = mColumn->mParentCtrl->getColumn(next_column->mIndex + 1); - } - } - - return this; -} - -void LLScrollColumnHeader::handleReshape(const LLRect& new_rect, bool by_user) -{ - S32 new_width = new_rect.getWidth(); - S32 delta_width = new_width - (getRect().getWidth() /*+ mColumn->mParentCtrl->getColumnPadding()*/); - - if (delta_width != 0) - { - S32 remaining_width = -delta_width; - S32 col; - for (col = mColumn->mIndex + 1; col < mColumn->mParentCtrl->getNumColumns(); col++) - { - LLScrollListColumn* columnp = mColumn->mParentCtrl->getColumn(col); - if (!columnp) continue; - - if (columnp->mHeader && columnp->mHeader->canResize()) - { - // how many pixels in width can this column afford to give up? - S32 resize_buffer_amt = llmax(0, columnp->getWidth() - MIN_COLUMN_WIDTH); - - // user shrinking column, need to add width to other columns - if (delta_width < 0) - { - if (/*!columnp->mDynamicWidth && */columnp->getWidth() > 0) - { - // statically sized column, give all remaining width to this column - columnp->setWidth(columnp->getWidth() + remaining_width); - if (columnp->mRelWidth > 0.f) - { - columnp->mRelWidth = (F32)columnp->getWidth() / (F32)mColumn->mParentCtrl->getItemListRect().getWidth(); - } - // all padding went to this widget, we're done - break; - } - } - else - { - // user growing column, need to take width from other columns - remaining_width += resize_buffer_amt; - - if (/*!columnp->mDynamicWidth && */columnp->getWidth() > 0) - { - columnp->setWidth(columnp->getWidth() - llmin(columnp->getWidth() - MIN_COLUMN_WIDTH, delta_width)); - if (columnp->mRelWidth > 0.f) - { - columnp->mRelWidth = (F32)columnp->getWidth() / (F32)mColumn->mParentCtrl->getItemListRect().getWidth(); - } - } - - if (remaining_width >= 0) - { - // width sucked up from neighboring columns, done - break; - } - } - } - } - - // clamp resize amount to maximum that can be absorbed by other columns - if (delta_width > 0) - { - delta_width += llmin(remaining_width, 0); - } - - // propagate constrained delta_width to new width for this column - new_width = getRect().getWidth() + delta_width - mColumn->mParentCtrl->getColumnPadding(); - - // use requested width - mColumn->setWidth(new_width); - - // update proportional spacing - if (mColumn->mRelWidth > 0.f) - { - mColumn->mRelWidth = (F32)new_width / (F32)mColumn->mParentCtrl->getItemListRect().getWidth(); - } - - // tell scroll list to layout columns again - // do immediate update to get proper feedback to resize handle - // which needs to know how far the resize actually went - mColumn->mParentCtrl->dirtyColumns(); //Must flag as dirty, else updateColumns will probably be a noop. - mColumn->mParentCtrl->updateColumns(); - } -} - -void LLScrollColumnHeader::setHasResizableElement(BOOL resizable) -{ - // for now, dynamically spaced columns can't be resized -// if (mColumn->mDynamicWidth) return; - - if (mHasResizableElement != resizable) - { - mColumn->mParentCtrl->dirtyColumns(); - mHasResizableElement = resizable; - } -} - -void LLScrollColumnHeader::updateResizeBars() -{ - S32 num_resizable_columns = 0; - S32 col; - for (col = 0; col < mColumn->mParentCtrl->getNumColumns(); col++) - { - LLScrollListColumn* columnp = mColumn->mParentCtrl->getColumn(col); - if (columnp->mHeader && columnp->mHeader->canResize()) - { - num_resizable_columns++; - } - } - - S32 num_resizers_enabled = 0; - - // now enable/disable resize handles on resizable columns if we have at least two - for (col = 0; col < mColumn->mParentCtrl->getNumColumns(); col++) - { - LLScrollListColumn* columnp = mColumn->mParentCtrl->getColumn(col); - if (!columnp->mHeader) continue; - BOOL enable = num_resizable_columns >= 2 && num_resizers_enabled < (num_resizable_columns - 1) && columnp->mHeader->canResize(); - columnp->mHeader->enableResizeBar(enable); - if (enable) - { - num_resizers_enabled++; - } - } -} - -void LLScrollColumnHeader::enableResizeBar(BOOL enable) -{ - // for now, dynamically spaced columns can't be resized - //if (!mColumn->mDynamicWidth) - { - mResizeBar->setEnabled(enable); - } -} - -BOOL LLScrollColumnHeader::canResize() -{ - return getVisible() && (mHasResizableElement || mColumn->mDynamicWidth); -} - -// Default constructor -LLScrollListColumn::LLScrollListColumn() : - mName(), - mSortingColumn(), - mSortDirection(ASCENDING), - mLabel(), - mWidth(-1), - mRelWidth(-1.0), - mDynamicWidth(FALSE), - mMaxContentWidth(0), - mIndex(-1), - mParentCtrl(NULL), - mHeader(NULL), - mFontAlignment(LLFontGL::LEFT) -{ } - -LLScrollListColumn::LLScrollListColumn(const LLSD &sd, LLScrollListCtrl* parent) : - mWidth(0), - mIndex (-1), - mParentCtrl(parent), - mHeader(NULL), - mMaxContentWidth(0), - mDynamicWidth(FALSE), - mRelWidth(-1.f) -{ - mName = sd.get("name").asString(); - mSortingColumn = mName; - if (sd.has("sort")) - { - mSortingColumn = sd.get("sort").asString(); - } - if (sd.has("sort_ascending")) - { - mSortDirection = sd.get("sort_ascending").asBoolean() ? ASCENDING : DESCENDING; - } - else - { - mSortDirection = ASCENDING; - } - mLabel = sd.get("label").asString(); - if (sd.has("relwidth") && (F32)sd.get("relwidth").asReal() > 0) - { - mRelWidth = (F32)sd.get("relwidth").asReal(); - if (mRelWidth < 0) mRelWidth = 0; - if (mRelWidth > 1) mRelWidth = 1; - mDynamicWidth = FALSE; - } - else if(sd.has("dynamicwidth") && (BOOL)sd.get("dynamicwidth").asBoolean() == TRUE) - { - mDynamicWidth = TRUE; - mRelWidth = -1; - } - else - { - setWidth(sd.get("width").asInteger()); - } - - if (sd.has("halign")) - { - mFontAlignment = (LLFontGL::HAlign)llclamp(sd.get("halign").asInteger(), (S32)LLFontGL::LEFT, (S32)LLFontGL::HCENTER); - } - else - { - mFontAlignment = LLFontGL::LEFT; - } - -} - -void LLScrollListColumn::setWidth(S32 width) -{ - if (!mDynamicWidth && mRelWidth <= 0.f) - { - mParentCtrl->updateStaticColumnWidth(this, width); - } - mWidth = width; -} diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index a1a8c638c..e4e2d5ddd 100644 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -1,31 +1,28 @@ /** * @file llscrolllistctrl.h + * @brief A scrolling list of items. This is the one you want to use + * in UI code. LLScrollListCell, LLScrollListItem, etc. are utility + * classes. * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -37,293 +34,16 @@ #include "lluictrl.h" #include "llctrlselectioninterface.h" -#include "lldarray.h" +//#include "lldarray.h" #include "llfontgl.h" #include "llui.h" -#include "llstring.h" -#include "llimagegl.h" +#include "llstring.h" // LLWString #include "lleditmenuhandler.h" #include "llframetimer.h" -#include "llcheckboxctrl.h" -#include "llcombobox.h" + #include "llscrollbar.h" -#include "llresizebar.h" -#include "lldate.h" -// -#include -// - -/* - * Represents a cell in a scrollable table. - * - * Sub-classes must return height and other properties - * though width accessors are implemented by the base class. - * It is therefore important for sub-class constructors to call - * setWidth() with realistic values. - */ -class LLScrollListCell -{ -public: - LLScrollListCell(S32 width = 0) : mWidth(width) {}; - virtual ~LLScrollListCell() {}; - virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const = 0; // truncate to given width, if possible - virtual S32 getWidth() const {return mWidth;} - virtual S32 getContentWidth() const { return 0; } - virtual S32 getHeight() const { return 0; } - virtual const LLSD getValue() const { return LLStringUtil::null; } - virtual void setValue(const LLSD& value) { } - virtual BOOL getVisible() const { return TRUE; } - virtual void setWidth(S32 width) { mWidth = width; } - virtual void highlightText(S32 offset, S32 num_chars) {} - virtual BOOL isText() const { return FALSE; } - virtual void setColor(const LLColor4&) {} - virtual void onCommit() {}; - - virtual BOOL handleClick() { return FALSE; } - virtual void setEnabled(BOOL enable) { } - -private: - S32 mWidth; -}; - -/* - * Cell displaying a text label. - */ -class LLScrollListText : public LLScrollListCell -{ -public: - LLScrollListText( const std::string& text, const LLFontGL* font, S32 width = 0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE); - /*virtual*/ ~LLScrollListText(); - - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; - /*virtual*/ S32 getContentWidth() const; - /*virtual*/ S32 getHeight() const; - /*virtual*/ void setValue(const LLSD& value); - /*virtual*/ const LLSD getValue() const; - /*virtual*/ BOOL getVisible() const; - /*virtual*/ void highlightText(S32 offset, S32 num_chars); - - /*virtual*/ void setColor(const LLColor4&); - /*virtual*/ BOOL isText() const; - - S32 getTextWidth() const { return mTextWidth;} - void setTextWidth(S32 value) { mTextWidth = value;} - virtual void setWidth(S32 width) { LLScrollListCell::setWidth(width); mTextWidth = width; } - - void setText(const LLStringExplicit& text); - void setFontStyle(const U8 font_style); - -private: - LLUIString mText; - S32 mTextWidth; - const LLFontGL* mFont; - LLColor4 mColor; - U8 mUseColor; - U8 mFontStyle; - LLFontGL::HAlign mFontAlignment; - BOOL mVisible; - S32 mHighlightCount; - S32 mHighlightOffset; - - LLPointer mRoundedRectImage; - - static U32 sCount; -}; - -/* - * Cell displaying an image. - */ -class LLScrollListIcon : public LLScrollListCell -{ -public: - LLScrollListIcon(const LLSD& value, S32 width = 0); - /*virtual*/ ~LLScrollListIcon(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; - /*virtual*/ S32 getWidth() const; - /*virtual*/ S32 getHeight() const; - /*virtual*/ const LLSD getValue() const; - /*virtual*/ void setColor(const LLColor4&); - /*virtual*/ void setValue(const LLSD& value); - // - void setClickCallback(boost::function cb); - virtual BOOL handleClick(); - // - -private: - LLPointer mIcon; - LLColor4 mColor; - // - boost::function mCallback; - // -}; - -/* - * An interactive cell containing a check box. - */ -class LLScrollListCheck : public LLScrollListCell -{ -public: - LLScrollListCheck( LLCheckBoxCtrl* check_box, S32 width = 0); - /*virtual*/ ~LLScrollListCheck(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; - /*virtual*/ S32 getHeight() const { return 0; } - /*virtual*/ const LLSD getValue() const; - /*virtual*/ void setValue(const LLSD& value); - /*virtual*/ void onCommit(); - - /*virtual*/ BOOL handleClick(); - /*virtual*/ void setEnabled(BOOL enable); - - LLCheckBoxCtrl* getCheckBox() { return mCheckBox; } - -private: - LLCheckBoxCtrl* mCheckBox; -}; - - -class LLScrollListDate : public LLScrollListText -{ -public: - LLScrollListDate( const LLDate& date, const LLFontGL* font, S32 width=0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE); - virtual void setValue(const LLSD& value); - virtual const LLSD getValue() const; - -private: - LLDate mDate; -}; class LLScrollListColumn; -class LLScrollColumnHeader : public LLComboBox -{ -public: - LLScrollColumnHeader(const std::string& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL *font = NULL); - ~LLScrollColumnHeader(); - - /*virtual*/ void draw(); - /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); - - /*virtual*/ void showList(); - /*virtual*/ LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding); - /*virtual*/ void handleReshape(const LLRect& new_rect, bool by_user = false); - - void setImage(const std::string &image_name); - void setImageOverlay(const std::string &overlay_image, LLFontGL::HAlign alignment = LLFontGL::HCENTER, const LLColor4& color = LLColor4::white); - LLScrollListColumn* getColumn() { return mColumn; } - void setHasResizableElement(BOOL resizable); - void updateResizeBars(); - BOOL canResize(); - void enableResizeBar(BOOL enable); - std::string getLabel() { return mOrigLabel; } - - void onSelectSort(); - void onClick(); - void onMouseDown(); - -private: - LLScrollListColumn* mColumn; - LLResizeBar* mResizeBar; - std::string mOrigLabel; - LLUIString mAscendingText; - LLUIString mDescendingText; - BOOL mShowSortOptions; - BOOL mHasResizableElement; - - LLPointer mImageOverlay; - LLFontGL::HAlign mImageOverlayAlignment; - LLColor4 mImageOverlayColor; -}; - -/* - * A simple data class describing a column within a scroll list. - */ -class LLScrollListColumn -{ -public: - typedef enum e_sort_direction - { - DESCENDING, - ASCENDING - } ESortDirection; - LLScrollListColumn(); - LLScrollListColumn(const LLSD &sd, LLScrollListCtrl* parent); - - void setWidth(S32 width); - S32 getWidth() const { return mWidth; } - - // Public data is fine so long as this remains a simple struct-like data class. - // If it ever gets any smarter than that, these should all become private - // with protected or public accessor methods added as needed. -MG - std::string mName; - std::string mSortingColumn; - ESortDirection mSortDirection; - std::string mLabel; - F32 mRelWidth; - BOOL mDynamicWidth; - S32 mMaxContentWidth; - S32 mIndex; - LLScrollListCtrl* mParentCtrl; - LLScrollColumnHeader* mHeader; - LLFontGL::HAlign mFontAlignment; - -private: - S32 mWidth; - -}; - -class LLScrollListItem : public LLHandleProvider -{ -public: - LLScrollListItem( BOOL enabled = TRUE, void* userdata = NULL, const LLUUID& uuid = LLUUID::null ) - : mSelected(FALSE), mEnabled( enabled ), mUserdata( userdata ), mItemValue( uuid ), mColumns() {} - LLScrollListItem( LLSD item_value, void* userdata = NULL ) - : mSelected(FALSE), mEnabled( TRUE ), mUserdata( userdata ), mItemValue( item_value ), mColumns() {} - - virtual ~LLScrollListItem(); - - void setSelected( BOOL b ) { mSelected = b; } - BOOL getSelected() const { return mSelected; } - - void setEnabled( BOOL b ) { mEnabled = b; } - BOOL getEnabled() const { return mEnabled; } - - void setUserdata( void* userdata ) { mUserdata = userdata; } - void* getUserdata() const { return mUserdata; } - - void setToolTip(const std::string tool_tip) { mToolTip=tool_tip; } - std::string getToolTip() { return mToolTip; } - - virtual LLUUID getUUID() const { return mItemValue.asUUID(); } - LLSD getValue() const { return mItemValue; } - - void setRect(LLRect rect) { mRectangle = rect; } - LLRect getRect() const { return mRectangle; } - - // If width = 0, just use the width of the text. Otherwise override with - // specified width in pixels. - void addColumn( const std::string& text, const LLFontGL* font, S32 width = 0 , U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, BOOL visible = TRUE) - { mColumns.push_back( new LLScrollListText(text, font, width, font_style, font_alignment, LLColor4::black, FALSE, visible) ); } - - void setNumColumns(S32 columns); - - void setColumn( S32 column, LLScrollListCell *cell ); - - S32 getNumColumns() const; - - LLScrollListCell *getColumn(const S32 i) const; - - std::string getContentsCSV() const; - - virtual void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding); - -private: - BOOL mSelected; - BOOL mEnabled; - void* mUserdata; - LLSD mItemValue; - std::string mToolTip; - std::vector mColumns; - LLRect mRectangle; -}; class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler, public LLCtrlListInterface, public LLCtrlScrollInterface @@ -354,13 +74,10 @@ public: typedef boost::signals2::signal > sort_signal_t; - LLScrollListCtrl( - const std::string& name, - const LLRect& rect, - commit_callback_t commit_callback, - BOOL allow_multiple_selection, - BOOL draw_border = TRUE, bool draw_heading = false); + LLScrollListCtrl(const std::string& name, const LLRect& rect, commit_callback_t commit_callback, bool multi_select, bool has_border = true, bool draw_heading = false); + +public: virtual ~LLScrollListCtrl(); virtual LLXMLNodePtr getXML(bool save_children = true) const; @@ -372,7 +89,7 @@ public: void deleteAllItems() { clearRows(); } // Sets an array of column descriptors - void setColumnHeadings(LLSD headings); + void setColumnHeadings(const LLSD& headings); void sortByColumnIndex(U32 column, BOOL ascending); // LLCtrlListInterface functions @@ -381,7 +98,6 @@ public: virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM); virtual void clearColumns(); virtual void setColumnLabel(const std::string& column, const std::string& label); - virtual LLScrollListColumn* getColumn(S32 index); virtual LLScrollListColumn* getColumn(const std::string& name); virtual S32 getNumColumns() const { return mColumnsIndexed.size(); } @@ -389,7 +105,7 @@ public: // Adds a single element, from an array of: // "columns" => [ "column" => column name, "value" => value, "type" => type, "font" => font, "font-style" => style ], "id" => uuid // Creates missing columns automatically. - virtual LLScrollListItem* addElement(const LLSD& value, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL); + virtual LLScrollListItem* addElement(const LLSD& element, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL); // Simple add element. Takes a single array of: // [ "value" => value, "font" => font, "font-style" => style ] virtual void clearRows(); // clears all elements @@ -441,8 +157,8 @@ public: S32 getHighlightedItemInx() const { return mHighlightedItem; } void setDoubleClickCallback( callback_t cb ) { mOnDoubleClickCallback = cb; } - void setMaximumSelectCallback( callback_t cb ) { mOnMaximumSelectCallback = cb; } - void setSortChangedCallback( callback_t cb ) { mOnSortChangedCallback = cb; } + void setMaximumSelectCallback( callback_t cb) { mOnMaximumSelectCallback = cb; } + void setSortChangedCallback( callback_t cb) { mOnSortChangedCallback = cb; } // Convenience function; *TODO: replace with setter above + boost::bind() in calling code void setDoubleClickCallback( boost::function cb, void* userdata) { mOnDoubleClickCallback = boost::bind(cb, userdata); } @@ -463,7 +179,6 @@ public: // one of which can be selected at a time. virtual LLScrollListItem* addSimpleElement(const std::string& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD()); - BOOL selectItemByLabel( const std::string& item, BOOL case_sensitive = TRUE ); // FALSE if item not found BOOL selectItemByPrefix(const std::string& target, BOOL case_sensitive = TRUE); BOOL selectItemByPrefix(const LLWString& target, BOOL case_sensitive = TRUE); @@ -499,7 +214,7 @@ public: void setBgStripeColor(const LLColor4& c) { mBgStripeColor = c; } void setFgSelectedColor(const LLColor4 &c) { mFgSelectedColor = c; } void setFgUnselectedColor(const LLColor4 &c){ mFgUnselectedColor = c; } - void setHighlightedColor(const LLColor4 &c) { mHighlightedColor = c; } + void setHighlightedColor(const LLColor4 &c) { mHighlightedColor = c; } void setFgDisableColor(const LLColor4 &c) { mFgDisabledColor = c; } void setBackgroundVisible(BOOL b) { mBackgroundVisible = b; } @@ -516,11 +231,11 @@ public: virtual S32 getScrollPos() const; virtual void setScrollPos( S32 pos ); - + // S32 getPageLines() { return mPageLines; } // - + S32 getSearchColumn(); void setSearchColumn(S32 column) { mSearchColumn = column; } S32 getColumnIndexFromOffset(S32 x); @@ -560,7 +275,7 @@ public: LLRect getCellRect(S32 row_index, S32 column_index); // Used "internally" by the scroll bar. - void onScrollChange( S32 new_pos, LLScrollbar* src); + void onScrollChange( S32 new_pos, LLScrollbar* src ); static void onClickColumn(void *userdata); @@ -628,6 +343,7 @@ public: return mSortCallback->connect(cb); } + protected: // "Full" interface: use this when you're creating a list that has one or more of the following: // * contains icons @@ -741,5 +457,4 @@ private: sort_signal_t* mSortCallback; }; // end class LLScrollListCtrl - #endif // LL_SCROLLLISTCTRL_H diff --git a/indra/llui/llscrolllistitem.cpp b/indra/llui/llscrolllistitem.cpp new file mode 100644 index 000000000..936fb6691 --- /dev/null +++ b/indra/llui/llscrolllistitem.cpp @@ -0,0 +1,147 @@ +/** + * @file llscrolllistitem.cpp + * @brief Scroll lists are composed of rows (items), each of which + * contains columns (cells). + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llscrolllistitem.h" + + +//--------------------------------------------------------------------------- +// LLScrollListItem +//--------------------------------------------------------------------------- + +LLScrollListItem::LLScrollListItem( bool enabled, const LLSD& value, void* userdata ) +: mSelected(FALSE), + mEnabled(enabled), + mUserdata(userdata), + mItemValue(value), + mColumns() +{ +} + + +LLScrollListItem::~LLScrollListItem() +{ + std::for_each(mColumns.begin(), mColumns.end(), DeletePointer()); +} + +void LLScrollListItem::addColumn(const std::string& text, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, bool visible) +{ + mColumns.push_back(new LLScrollListText(text, font, width, font_style, font_alignment, LLColor4::black, false, visible)); +} + +void LLScrollListItem::setNumColumns(S32 columns) +{ + S32 prev_columns = mColumns.size(); + if (columns < prev_columns) + { + std::for_each(mColumns.begin()+columns, mColumns.end(), DeletePointer()); + } + + mColumns.resize(columns); + + for (S32 col = prev_columns; col < columns; ++col) + { + mColumns[col] = NULL; + } +} + +void LLScrollListItem::setColumn( S32 column, LLScrollListCell *cell ) +{ + if (column < (S32)mColumns.size()) + { + delete mColumns[column]; + mColumns[column] = cell; + } + else + { + llerrs << "LLScrollListItem::setColumn: bad column: " << column << llendl; + } +} + + +S32 LLScrollListItem::getNumColumns() const +{ + return mColumns.size(); +} + +LLScrollListCell* LLScrollListItem::getColumn(const S32 i) const +{ + if (0 <= i && i < (S32)mColumns.size()) + { + return mColumns[i]; + } + return NULL; +} + +std::string LLScrollListItem::getContentsCSV() const +{ + std::string ret; + + S32 count = getNumColumns(); + for (S32 i=0; igetValue().asString(); + if (i < count-1) + { + ret += ", "; + } + } + + return ret; +} + + +void LLScrollListItem::draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding) +{ + // draw background rect + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + LLRect bg_rect = rect; + gl_rect_2d( bg_rect, bg_color ); + + S32 cur_x = rect.mLeft; + S32 num_cols = getNumColumns(); + S32 cur_col = 0; + + for (LLScrollListCell* cell = getColumn(0); cur_col < num_cols; cell = getColumn(++cur_col)) + { + // Two ways a cell could be hidden + if (cell->getWidth() < 0 + || !cell->getVisible()) continue; + + LLUI::pushMatrix(); + { + LLUI::translate((F32) cur_x, (F32) rect.mBottom); + + cell->draw( fg_color, highlight_color ); + } + LLUI::popMatrix(); + + cur_x += cell->getWidth() + column_padding; + } +} + diff --git a/indra/llui/llscrolllistitem.h b/indra/llui/llscrolllistitem.h new file mode 100644 index 000000000..f3f186acb --- /dev/null +++ b/indra/llui/llscrolllistitem.h @@ -0,0 +1,92 @@ +/** + * @file llscrolllistitem.h + * @brief Scroll lists are composed of rows (items), each of which + * contains columns (cells). + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LLSCROLLLISTITEM_H +#define LLSCROLLLISTITEM_H + +#include "llrefcount.h" +#include "llhandle.h" +#include "llsd.h" +#include "llscrolllistcell.h" + +//--------------------------------------------------------------------------- +// LLScrollListItem +//--------------------------------------------------------------------------- +class LLScrollListItem + : public LLHandleProvider // Singu TODO: Break out into LLNameListItem +{ + friend class LLScrollListCtrl; +public: + + virtual ~LLScrollListItem(); + + void setSelected( BOOL b ) { mSelected = b; } + BOOL getSelected() const { return mSelected; } + + void setEnabled( BOOL b ) { mEnabled = b; } + BOOL getEnabled() const { return mEnabled; } + + void setUserdata( void* userdata ) { mUserdata = userdata; } + void* getUserdata() const { return mUserdata; } + + void setToolTip(const std::string tool_tip) { mToolTip=tool_tip; } + std::string getToolTip() { return mToolTip; } + + virtual LLUUID getUUID() const { return mItemValue.asUUID(); } + LLSD getValue() const { return mItemValue; } + + void setRect(LLRect rect) { mRectangle = rect; } + LLRect getRect() const { return mRectangle; } + + void addColumn( const std::string& text, const LLFontGL* font, S32 width = 0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, bool visible = true ); + + void setNumColumns(S32 columns); + + void setColumn( S32 column, LLScrollListCell *cell ); + + S32 getNumColumns() const; + + LLScrollListCell *getColumn(const S32 i) const; + + std::string getContentsCSV() const; + + virtual void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding); + +protected: + LLScrollListItem( bool enabled = true, const LLSD& value = LLSD(), void* userdata = NULL ); + +private: + BOOL mSelected; + BOOL mEnabled; + void* mUserdata; + LLSD mItemValue; + std::string mToolTip; + std::vector mColumns; + LLRect mRectangle; +}; + +#endif diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 95f2971b9..898aae654 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4326,17 +4326,6 @@ This should be as low as possible, but too low may break functionality 1.0 - ColumnHeaderDropDownDelay - - Comment - Time in seconds of mouse click before column header shows sort options list - Persist - 1 - Type - F32 - Value - 0.300000011921 - CompileOutputRect Comment diff --git a/indra/newview/floaterlocalassetbrowse.cpp b/indra/newview/floaterlocalassetbrowse.cpp index ef6de943d..abcb19c98 100644 --- a/indra/newview/floaterlocalassetbrowse.cpp +++ b/indra/newview/floaterlocalassetbrowse.cpp @@ -38,7 +38,6 @@ this feature is still a work in progress. /* basic headers */ #include "llviewerprecompiledheaders.h" -#include "lluictrlfactory.h" /* own class header && upload floater header */ #include "floaterlocalassetbrowse.h" @@ -50,6 +49,12 @@ this feature is still a work in progress. #include "llimagejpeg.h" #include "llimagepng.h" +/* llui headers */ +#include "llcheckboxctrl.h" +#include "llcombobox.h" +#include "llscrolllistitem.h" +#include "lluictrlfactory.h" + /* misc headers */ #include #include @@ -60,13 +65,7 @@ this feature is still a work in progress. #include "llfloaterimagepreview.h" #include "llfile.h" -/* repeated in header */ -#include "lltexturectrl.h" -#include "llscrolllistctrl.h" -#include "llviewercontrol.h" - /* including to force rebakes when needed */ -#include "llagent.h" #include "llvoavatarself.h" /* sculpt refresh */ diff --git a/indra/newview/floaterlocalassetbrowse.h b/indra/newview/floaterlocalassetbrowse.h index 7cd8ab559..b4cbc149f 100644 --- a/indra/newview/floaterlocalassetbrowse.h +++ b/indra/newview/floaterlocalassetbrowse.h @@ -44,6 +44,8 @@ tag: vaa emerald local_asset_browser #include "lldrawable.h" #include "lleventtimer.h" +class LLCheckBoxCtrl; +class LLComboBox; /*=======================================*/ /* Global structs / enums / defines */ diff --git a/indra/newview/hbfloatergrouptitles.cpp b/indra/newview/hbfloatergrouptitles.cpp index f75211730..c96189de1 100644 --- a/indra/newview/hbfloatergrouptitles.cpp +++ b/indra/newview/hbfloatergrouptitles.cpp @@ -41,8 +41,8 @@ #include "llagent.h" #include "llgroupactions.h" +#include "llscrolllistitem.h" #include "lluictrlfactory.h" -#include "llviewercontrol.h" // static variable HBFloaterGroupTitles* HBFloaterGroupTitles::sInstance = NULL; diff --git a/indra/newview/jcfloaterareasearch.cpp b/indra/newview/jcfloaterareasearch.cpp index 0c37a1da8..8b1ac9d77 100644 --- a/indra/newview/jcfloaterareasearch.cpp +++ b/indra/newview/jcfloaterareasearch.cpp @@ -33,16 +33,16 @@ #include "llviewerprecompiledheaders.h" -#include "lluuid.h" -#include "lluictrlfactory.h" +#include "jcfloaterareasearch.h" + +#include "llfiltereditor.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" +#include "lluictrlfactory.h" #include "llagent.h" -#include "llfiltereditor.h" #include "lltracker.h" #include "llviewerobjectlist.h" -#include "llviewercontrol.h" -#include "jcfloaterareasearch.h" const std::string request_string = "JCFloaterAreaSearch::Requested_\xF8\xA7\xB5"; const F32 min_refresh_interval = 0.25f; // Minimum interval between list refreshes in seconds. diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c9b3d6944..d1454847d 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -158,6 +158,7 @@ // Included so that constants/settings might be initialized // in save_settings_to_globals() #include "llbutton.h" +#include "llcombobox.h" #include "llstatusbar.h" #include "llsurface.h" #include "llvosky.h" diff --git a/indra/newview/llfloateravatarlist.cpp b/indra/newview/llfloateravatarlist.cpp index c41e7f1db..4475d093e 100644 --- a/indra/newview/llfloateravatarlist.cpp +++ b/indra/newview/llfloateravatarlist.cpp @@ -20,12 +20,14 @@ #include "llavatarnamecache.h" #include "llfloateravatarlist.h" +#include "llnotificationsutil.h" +#include "llradiogroup.h" +#include "llscrolllistcolumn.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "lluictrlfactory.h" #include "llviewerwindow.h" #include "llwindow.h" -#include "llscrolllistctrl.h" -#include "llradiogroup.h" -#include "llnotificationsutil.h" #include "llvoavatar.h" #include "llimview.h" diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index a9e6bf4b6..05dc86a86 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -43,6 +43,7 @@ #include "llcachename.h" #include "lllineeditor.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "lltabcontainer.h" #include "lluictrlfactory.h" #include "message.h" diff --git a/indra/newview/llfloaterblacklist.cpp b/indra/newview/llfloaterblacklist.cpp index 0f5098e16..bda356078 100644 --- a/indra/newview/llfloaterblacklist.cpp +++ b/indra/newview/llfloaterblacklist.cpp @@ -1,19 +1,22 @@ // #include "llviewerprecompiledheaders.h" + #include "llfloaterblacklist.h" + #include "llaudioengine.h" -#include "llvfs.h" -#include "lluictrlfactory.h" -#include "llsdserialize.h" -#include "llscrolllistctrl.h" -#include "llcheckboxctrl.h" -#include "statemachine/aifilepicker.h" -#include "llviewerwindow.h" -#include "llwindow.h" -#include "llviewercontrol.h" -#include "llviewerobjectlist.h" +#include "llcombobox.h" #include "lldate.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" +#include "llsdserialize.h" +#include "lluictrlfactory.h" +#include "llvfs.h" +#include "llwindow.h" + #include "llagent.h" +#include "llviewerobjectlist.h" +#include "llviewerwindow.h" +#include "statemachine/aifilepicker.h" LLFloaterBlacklist* LLFloaterBlacklist::sInstance; diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp index 92b8e8eeb..5359d8262 100644 --- a/indra/newview/llfloaterbulkpermission.cpp +++ b/indra/newview/llfloaterbulkpermission.cpp @@ -53,6 +53,7 @@ #include "llviewerstats.h" #include "lluictrlfactory.h" #include "llselectmgr.h" +#include "llcheckboxctrl.h" #include "llnotificationsutil.h" #include "roles_constants.h" // for GP_OBJECT_MANIPULATE diff --git a/indra/newview/llfloaterexploresounds.cpp b/indra/newview/llfloaterexploresounds.cpp index 0e3934e2f..d1dacf4e3 100644 --- a/indra/newview/llfloaterexploresounds.cpp +++ b/indra/newview/llfloaterexploresounds.cpp @@ -3,15 +3,16 @@ #include "llviewerprecompiledheaders.h" #include "llfloaterexploresounds.h" -#include "lluictrlfactory.h" + #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" +#include "lluictrlfactory.h" + #include "llagent.h" #include "llagentcamera.h" -#include "llviewerwindow.h" +#include "llfloaterblacklist.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" -#include "llfloaterchat.h" -#include "llfloaterblacklist.h" static const size_t num_collision_sounds = 29; const LLUUID collision_sounds[num_collision_sounds] = diff --git a/indra/newview/llfloaterfriends.cpp b/indra/newview/llfloaterfriends.cpp index c2c958f98..45cedfeac 100644 --- a/indra/newview/llfloaterfriends.cpp +++ b/indra/newview/llfloaterfriends.cpp @@ -46,8 +46,10 @@ #include "lleventtimer.h" #include "llfiltereditor.h" #include "llfloateravatarpicker.h" -#include "llnamelistctrl.h" #include "llnotificationsutil.h" +#include "llscrolllistcolumn.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llsdserialize.h" #include "lltextbox.h" #include "lluictrlfactory.h" diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp index 1f5a9cf24..c342d8d89 100644 --- a/indra/newview/llfloatergroups.cpp +++ b/indra/newview/llfloatergroups.cpp @@ -54,6 +54,7 @@ #include "llgroupactions.h" #include "llselectmgr.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llnotificationsutil.h" #include "lltextbox.h" #include "lluictrlfactory.h" diff --git a/indra/newview/llfloaterinspect.cpp b/indra/newview/llfloaterinspect.cpp index 33d735f42..f8c4afd2c 100644 --- a/indra/newview/llfloaterinspect.cpp +++ b/indra/newview/llfloaterinspect.cpp @@ -37,6 +37,7 @@ #include "llfloatertools.h" #include "llcachename.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llselectmgr.h" #include "lltoolcomp.h" #include "lltoolmgr.h" diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 6aa386ffd..5bd8425ea 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -66,6 +66,7 @@ #include "llpanellandmedia.h" #include "llradiogroup.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llselectmgr.h" #include "llspinctrl.h" #include "lltabcontainer.h" diff --git a/indra/newview/llfloatermessagelog.cpp b/indra/newview/llfloatermessagelog.cpp index 230a4b15a..8847ca2ca 100644 --- a/indra/newview/llfloatermessagelog.cpp +++ b/indra/newview/llfloatermessagelog.cpp @@ -1,19 +1,22 @@ // #include "llviewerprecompiledheaders.h" + #include "llfloatermessagelog.h" -#include "lluictrlfactory.h" -#include "llworld.h" -#include "llnotificationsutil.h" -#include "llviewerregion.h" -#include "llscrolllistctrl.h" -#include "lltexteditor.h" -#include "llviewerwindow.h" // alertXml -#include "llmessagetemplate.h" -#include -#include "llmenugl.h" + #include "lleventtimer.h" +#include "llmenugl.h" +#include "llmessagetemplate.h" +#include "llnotificationsutil.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" +#include "lltexteditor.h" +#include "lluictrlfactory.h" #include "llagent.h" +#include "llviewerregion.h" +#include "llworld.h" +#include + //////////////////////////////// @@ -826,7 +829,7 @@ BOOL LLFloaterMessageLog::onClickCloseCircuit(void* user_data) // static bool LLFloaterMessageLog::onConfirmCloseCircuit(const LLSD& notification, const LLSD& response ) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); LLCircuitData* cdp = gMessageSystem->mCircuitInfo.findCircuit(LLHost(notification["payload"]["circuittoclose"].asString())); if(!cdp) return false; LLViewerRegion* regionp = LLWorld::getInstance()->getRegion(cdp->getHost()); @@ -861,7 +864,7 @@ bool LLFloaterMessageLog::onConfirmCloseCircuit(const LLSD& notification, const // static bool LLFloaterMessageLog::onConfirmRemoveRegion(const LLSD& notification, const LLSD& response ) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if(option == 0) // yes LLWorld::getInstance()->removeRegion(LLHost(notification["payload"]["regionhost"].asString())); return false; diff --git a/indra/newview/llfloatermute.cpp b/indra/newview/llfloatermute.cpp index 624c244a4..6812a75e4 100644 --- a/indra/newview/llfloatermute.cpp +++ b/indra/newview/llfloatermute.cpp @@ -34,27 +34,15 @@ #include "llfloatermute.h" -#include "llfontgl.h" -#include "llrect.h" -#include "llerror.h" -#include "llstring.h" -#include "message.h" +#include "llavatarname.h" #include "llnotificationsutil.h" +#include "llscrolllistitem.h" +#include "lluictrlfactory.h" // project include -#include "llagent.h" -#include "llavatarnamecache.h" #include "llfloateravatarpicker.h" -#include "llbutton.h" -#include "lllineeditor.h" #include "llmutelist.h" #include "llnamelistctrl.h" -#include "llresizehandle.h" -#include "lltextbox.h" -#include "llviewertexteditor.h" -#include "llviewerwindow.h" -#include "lluictrlfactory.h" -#include "llfocusmgr.h" #include diff --git a/indra/newview/llfloaternotificationsconsole.cpp b/indra/newview/llfloaternotificationsconsole.cpp index d4133befe..539a066e0 100644 --- a/indra/newview/llfloaternotificationsconsole.cpp +++ b/indra/newview/llfloaternotificationsconsole.cpp @@ -36,6 +36,7 @@ #include "lluictrlfactory.h" #include "llbutton.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llpanel.h" #include "llcombobox.h" #include "llviewertexteditor.h" diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp index 69b4bce60..30ec69986 100644 --- a/indra/newview/llfloaterpathfindinglinksets.cpp +++ b/indra/newview/llfloaterpathfindinglinksets.cpp @@ -43,7 +43,7 @@ #include "llpathfindinglinkset.h" #include "llpathfindinglinksetlist.h" #include "llpathfindingmanager.h" -#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llsd.h" #include "lltextbox.h" #include "llui.h" diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 017278719..39b7a383b 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -49,6 +49,7 @@ #include "llpathfindingmanager.h" #include "llresmgr.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llselectmgr.h" #include "llsd.h" #include "llstring.h" diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 3a139d595..e05e2f5e1 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -37,7 +37,6 @@ #include #include -#include "llcachename.h" #include "lldir.h" #include "lldispatcher.h" #include "llglheaders.h" @@ -69,6 +68,7 @@ #include "llnotifications.h" #include "llnotificationsutil.h" #include "llregioninfomodel.h" +#include "llscrolllistitem.h" #include "llsliderctrl.h" #include "llspinctrl.h" #include "lltabcontainer.h" diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp index 70022a6e2..84c2ff953 100644 --- a/indra/newview/llfloaterscriptlimits.cpp +++ b/indra/newview/llfloaterscriptlimits.cpp @@ -26,7 +26,6 @@ */ #include "llviewerprecompiledheaders.h" -#include "llhttpclient.h" #include "llfloaterscriptlimits.h" // library includes @@ -39,7 +38,9 @@ #include "llfloateravatarpicker.h" #include "llfloaterland.h" #include "llregionhandle.h" +#include "llscrolllistcolumn.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llparcel.h" #include "lltabcontainer.h" #include "lltracker.h" @@ -223,7 +224,7 @@ void fetchScriptLimitsRegionInfoResponder::result(const LLSD& content) void fetchScriptLimitsRegionInfoResponder::error(U32 status, const std::string& reason) { - llwarns << "Error from responder " << reason << llendl; + llwarns << "fetchScriptLimitsRegionInfoResponder error [status:" << status << "]: " << reason << llendl; } void fetchScriptLimitsRegionSummaryResponder::result(const LLSD& content_ref) @@ -310,7 +311,7 @@ void fetchScriptLimitsRegionSummaryResponder::result(const LLSD& content_ref) void fetchScriptLimitsRegionSummaryResponder::error(U32 status, const std::string& reason) { - llwarns << "Error from responder " << reason << llendl; + llwarns << "fetchScriptLimitsRegionSummaryResponder error [status:" << status << "]: " << reason << llendl; } void fetchScriptLimitsRegionDetailsResponder::result(const LLSD& content_ref) @@ -419,7 +420,7 @@ result (map) void fetchScriptLimitsRegionDetailsResponder::error(U32 status, const std::string& reason) { - llwarns << "Error from responder " << reason << llendl; + llwarns << "fetchScriptLimitsRegionDetailsResponder error [status:" << status << "]: " << reason << llendl; } void fetchScriptLimitsAttachmentInfoResponder::result(const LLSD& content_ref) @@ -515,7 +516,7 @@ void fetchScriptLimitsAttachmentInfoResponder::result(const LLSD& content_ref) void fetchScriptLimitsAttachmentInfoResponder::error(U32 status, const std::string& reason) { - llwarns << "Error from responder " << reason << llendl; + llwarns << "fetchScriptLimitsAttachmentInfoResponder error [status:" << status << "]: " << reason << llendl; } ///---------------------------------------------------------------------------- @@ -603,14 +604,7 @@ void LLPanelScriptLimitsRegionMemory::onNameCache( } std::string name; - if (LLAvatarNameCache::useDisplayNames()) - { - name = LLCacheName::buildUsername(full_name); - } - else - { - name = full_name; - } + LLAvatarNameCache::getPNSName(id, name); std::vector::iterator id_itor; for (id_itor = mObjectListItems.begin(); id_itor != mObjectListItems.end(); ++id_itor) diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp index f95e8b365..5d6bf3a83 100644 --- a/indra/newview/llfloatersettingsdebug.cpp +++ b/indra/newview/llfloatersettingsdebug.cpp @@ -39,6 +39,7 @@ #include "llfloater.h" #include "llfiltereditor.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llspinctrl.h" #include "lltexteditor.h" #include "lluictrlfactory.h" diff --git a/indra/newview/llfloaterteleporthistory.cpp b/indra/newview/llfloaterteleporthistory.cpp index 173aaf5a7..27ad58de6 100644 --- a/indra/newview/llfloaterteleporthistory.cpp +++ b/indra/newview/llfloaterteleporthistory.cpp @@ -32,28 +32,19 @@ #include "llviewerprecompiledheaders.h" -#include "linden_common.h" - -#include - -//MK -#include "llworld.h" -#include "lleventpoll.h" -#include "llagent.h" -//mk -#include "llappviewer.h" #include "llfloaterteleporthistory.h" + +#include "llappviewer.h" #include "llfloaterworldmap.h" +#include "llscrolllistcolumn.h" +#include "llscrolllistitem.h" +#include "llsdserialize.h" #include "llslurl.h" -#include "lltimer.h" #include "lluictrlfactory.h" -#include "llurldispatcher.h" -#include "llviewercontrol.h" +#include "llurlaction.h" #include "llviewerwindow.h" #include "llwindow.h" #include "llweb.h" -#include "llsdserialize.h" -#include "llurlaction.h" // [RLVa:KB] #include "rlvhandler.h" diff --git a/indra/newview/llfloatertopobjects.cpp b/indra/newview/llfloatertopobjects.cpp index 6b181433d..215a8940e 100644 --- a/indra/newview/llfloatertopobjects.cpp +++ b/indra/newview/llfloatertopobjects.cpp @@ -44,6 +44,7 @@ #include "llnotificationsutil.h" #include "llparcel.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "lllineeditor.h" #include "lltextbox.h" #include "lltracker.h" diff --git a/indra/newview/llfloatervoiceeffect.cpp b/indra/newview/llfloatervoiceeffect.cpp index 415798086..fc74c9e87 100644 --- a/indra/newview/llfloatervoiceeffect.cpp +++ b/indra/newview/llfloatervoiceeffect.cpp @@ -30,6 +30,7 @@ #include "llfloatervoiceeffect.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "lltexteditor.h" // For linked text hack #include "lltrans.h" #include "lluictrlfactory.h" diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp index 49f26ad4e..38b9e5e2e 100644 --- a/indra/newview/llnamelistctrl.cpp +++ b/indra/newview/llnamelistctrl.cpp @@ -37,10 +37,11 @@ #include #include "llavatarnamecache.h" - #include "llcachename.h" #include "llagent.h" #include "llinventory.h" +#include "llscrolllistitem.h" +#include "llscrolllistcolumn.h" #include "lltrans.h" static LLRegisterWidget r("name_list"); diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index 85845e7f0..3eebe22c1 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -60,6 +60,7 @@ #include "llpreviewtexture.h" #include "llpluginclassmedia.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "lltabcontainer.h" #include "lluictrlfactory.h" #include "llviewerwindow.h" diff --git a/indra/newview/llpaneldirland.cpp b/indra/newview/llpaneldirland.cpp index 79c3a60a2..9c249a81d 100644 --- a/indra/newview/llpaneldirland.cpp +++ b/indra/newview/llpaneldirland.cpp @@ -46,6 +46,7 @@ #include "llcombobox.h" #include "lllineeditor.h" #include "llnotificationsutil.h" +#include "llscrolllistcolumn.h" #include "llscrolllistctrl.h" #include "llstatusbar.h" #include "lluiconstants.h" diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index 6b4d0e680..0dcb15f48 100644 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -43,6 +43,7 @@ #include "llgroupmgr.h" #include "llnamelistctrl.h" #include "llnotificationsutil.h" +#include "llscrolllistitem.h" #include "llspinctrl.h" #include "lltextbox.h" #include "llviewerobject.h" diff --git a/indra/newview/llpanelgrouplandmoney.cpp b/indra/newview/llpanelgrouplandmoney.cpp index 26e77c6ba..dec32551a 100644 --- a/indra/newview/llpanelgrouplandmoney.cpp +++ b/indra/newview/llpanelgrouplandmoney.cpp @@ -45,6 +45,7 @@ #include "lllineeditor.h" #include "llproductinforequest.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "lltextbox.h" #include "lltabcontainer.h" #include "lltexteditor.h" diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp index 3deb47999..87e237369 100644 --- a/indra/newview/llpanelgroupnotices.cpp +++ b/indra/newview/llpanelgroupnotices.cpp @@ -41,10 +41,9 @@ #include "llviewerinventory.h" #include "llinventorydefines.h" #include "llinventoryfunctions.h" -#include "llinventorymodel.h" #include "llinventoryicon.h" +#include "llinventorymodel.h" #include "llagent.h" -#include "lltooldraganddrop.h" #include "lllineeditor.h" #include "lltexteditor.h" @@ -52,11 +51,11 @@ #include "lliconctrl.h" #include "llcheckboxctrl.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "lltextbox.h" #include "roles_constants.h" #include "llviewerwindow.h" -#include "llviewercontrol.h" #include "llviewermessage.h" #include "llnotificationsutil.h" #include "llgiveinventory.h" @@ -86,16 +85,15 @@ public: EAcceptance* accept, std::string& tooltip_msg); static LLView* fromXML(LLXMLNodePtr node, LLView* parent, class LLUICtrlFactory* factory); + void setPanel(LLPanelGroupNotices* panel) { mGroupNoticesPanel = panel; } - void setGroupNoticesPanel(LLPanelGroupNotices* panel) { mGroupNoticesPanel = panel; } protected: LLPanelGroupNotices* mGroupNoticesPanel; }; LLGroupDropTarget::LLGroupDropTarget(const LLDropTarget::Params& p) : LLDropTarget(p) -{ -} +{} // static LLView* LLGroupDropTarget::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory* factory) @@ -144,6 +142,7 @@ BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, case DAD_BODYPART: case DAD_ANIMATION: case DAD_GESTURE: + case DAD_CALLINGCARD: { LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data; if(gInventory.getItem(inv_item->getUUID()) @@ -167,7 +166,6 @@ BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, break; } case DAD_CATEGORY: - case DAD_CALLINGCARD: default: *accept = ACCEPT_NO; break; @@ -269,9 +267,9 @@ BOOL LLPanelGroupNotices::postBuild() mPanelCreateNotice = getChild("panel_create_new_notice",recurse); mPanelViewNotice = getChild("panel_view_past_notice",recurse); - LLGroupDropTarget* group_drop_target = getChild("drop_target",recurse); - group_drop_target->setEntityID(mGroupID); - group_drop_target->setGroupNoticesPanel(this); + LLGroupDropTarget* target = getChild("drop_target",recurse); + target->setPanel(this); + target->setEntityID(mGroupID); arrangeNoticeView(VIEW_PAST_NOTICE); @@ -538,8 +536,7 @@ void LLPanelGroupNotices::showNotice(const std::string& subject, mInventoryOffer = inventory_offer; std::string icon_name = LLInventoryIcon::getIconName(mInventoryOffer->mType, - LLInventoryType::IT_TEXTURE, - 0, FALSE); + LLInventoryType::IT_TEXTURE); mViewInventoryIcon->setImage(icon_name); mViewInventoryIcon->setVisible(TRUE); diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index 0b5acb543..91edb183a 100644 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -46,6 +46,7 @@ #include "llnotificationsutil.h" #include "llpanelgrouproles.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "lltabcontainer.h" #include "lltextbox.h" #include "lltexteditor.h" @@ -503,13 +504,11 @@ void LLPanelGroupSubTab::setSearchFilter(const std::string& filter) void LLPanelGroupSubTab::activate() { - lldebugs << "LLPanelGroupSubTab::activate()" << llendl; setOthersVisible(TRUE); } void LLPanelGroupSubTab::deactivate() { - lldebugs << "LLPanelGroupSubTab::deactivate()" << llendl; setOthersVisible(FALSE); } @@ -519,19 +518,11 @@ void LLPanelGroupSubTab::setOthersVisible(BOOL b) { mHeader->setVisible( b ); } - else - { - llwarns << "LLPanelGroupSubTab missing header!" << llendl; - } if (mFooter) { mFooter->setVisible( b ); } - else - { - llwarns << "LLPanelGroupSubTab missing footer!" << llendl; - } } bool LLPanelGroupSubTab::matchesActionSearchFilter(std::string action) @@ -1068,7 +1059,7 @@ void LLPanelGroupMembersSubTab::onEjectMembers(void *userdata) void LLPanelGroupMembersSubTab::handleEjectMembers() { //send down an eject message - std::vector selected_members; + uuid_vec_t selected_members; std::vector selection = mMembersList->getAllSelected(); if (selection.empty()) return; @@ -1111,6 +1102,7 @@ void LLPanelGroupMembersSubTab::handleRoleCheck(const LLUUID& role_id, for (std::vector::iterator itor = selection.begin() ; itor != selection.end(); ++itor) { + member_id = (*itor)->getUUID(); //see if we requested a change for this member before @@ -1403,7 +1395,7 @@ U64 LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges(const LLUUID& ag if ( role_change_datap ) { - std::vector roles_to_be_removed; + uuid_vec_t roles_to_be_removed; for (role_change_data_map_t::iterator role = role_change_datap->begin(); role != role_change_datap->end(); ++ role) @@ -1678,6 +1670,7 @@ LLPanelGroupRolesSubTab::LLPanelGroupRolesSubTab(const std::string& name, const mMemberVisibleCheck(NULL), mDeleteRoleButton(NULL), mCreateRoleButton(NULL), + mHasRoleChange(FALSE) { } @@ -2084,8 +2077,8 @@ void LLPanelGroupRolesSubTab::buildMembersList() LLGroupRoleData* rdatap = (*rit).second; if (rdatap) { - std::vector::const_iterator mit = rdatap->getMembersBegin(); - std::vector::const_iterator end = rdatap->getMembersEnd(); + uuid_vec_t::const_iterator mit = rdatap->getMembersBegin(); + uuid_vec_t::const_iterator end = rdatap->getMembersEnd(); for ( ; mit != end; ++mit) { mAssignedMembersList->addNameItem((*mit)); @@ -2423,9 +2416,7 @@ BOOL LLPanelGroupActionsSubTab::postBuildSubTab(LLView* root) void LLPanelGroupActionsSubTab::activate() { LLPanelGroupSubTab::activate(); - lldebugs << "LLPanelGroupActionsSubTab::activate()" << llendl; - update(GC_ALL); } diff --git a/indra/newview/llpanelgroupvoting.cpp b/indra/newview/llpanelgroupvoting.cpp index 2b03523b8..f45cd2818 100644 --- a/indra/newview/llpanelgroupvoting.cpp +++ b/indra/newview/llpanelgroupvoting.cpp @@ -32,24 +32,19 @@ #include "llviewerprecompiledheaders.h" -#include "roles_constants.h" +#include "llpanelgroupvoting.h" -#include "lllineeditor.h" +#include "llbutton.h" #include "llnotificationsutil.h" +#include "llradiogroup.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" +#include "llspinctrl.h" #include "lltextbox.h" #include "lltexteditor.h" -#include "llscrolllistctrl.h" -#include "llradiogroup.h" -#include "llspinctrl.h" -#include "llpanelgroupvoting.h" -#include "llnamelistctrl.h" -#include "llbutton.h" -#include "llnotify.h" #include "llagent.h" -#include "llfocusmgr.h" #include "llviewercontrol.h" -#include "llviewerwindow.h" #include "llviewerregion.h" class AIHTTPTimeoutPolicy; diff --git a/indra/newview/llpanelmediasettingssecurity.cpp b/indra/newview/llpanelmediasettingssecurity.cpp index 509560b37..28422a4f8 100644 --- a/indra/newview/llpanelmediasettingssecurity.cpp +++ b/indra/newview/llpanelmediasettingssecurity.cpp @@ -32,6 +32,7 @@ #include "llcheckboxctrl.h" #include "llnotificationsutil.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "lluictrlfactory.h" #include "llwindow.h" #include "llviewerwindow.h" diff --git a/indra/newview/llpanelmsgs.cpp b/indra/newview/llpanelmsgs.cpp index 95bb24e0a..949dbb3b5 100644 --- a/indra/newview/llpanelmsgs.cpp +++ b/indra/newview/llpanelmsgs.cpp @@ -33,10 +33,12 @@ #include "llpanelmsgs.h" -#include "llscrolllistctrl.h" -#include "lluictrlfactory.h" -#include "llfirstuse.h" #include "llnotificationtemplate.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" +#include "lluictrlfactory.h" + +#include "llfirstuse.h" LLPanelMsgs::LLPanelMsgs() { diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 9438dfa79..e5751ebd2 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -33,7 +33,9 @@ #include "llcombobox.h" #include "llresizebar.h" #include "llresizehandle.h" +#include "llscrolllistcolumn.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llslider.h" #include "llsliderctrl.h" #include "llagent.h" diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp index ee27ead48..86db29ccb 100644 --- a/indra/newview/llparticipantlist.cpp +++ b/indra/newview/llparticipantlist.cpp @@ -31,6 +31,7 @@ #include "llmutelist.h" #include "llparticipantlist.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llspeakers.h" #include "llviewerwindow.h" #include "llvoiceclient.h" diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index c5ffefffe..eb5a75972 100644 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -31,49 +31,38 @@ */ #include "llviewerprecompiledheaders.h" - -#include - #include "llpreviewgesture.h" -// libraries -#include "lldatapacker.h" -#include "lldarray.h" -#include "llinventorydefines.h" -#include "llstring.h" -#include "lldir.h" -#include "llmultigesture.h" -#include "llvfile.h" -#include "lltrans.h" - -// newview -#include "llagent.h" // todo: remove +#include "llagent.h" +#include "llanimstatelabels.h" #include "llanimationstates.h" +#include "llappviewer.h" // gVFS #include "llassetuploadresponders.h" #include "llbutton.h" #include "llcheckboxctrl.h" #include "llcombobox.h" +#include "lldatapacker.h" #include "lldelayedgestureerror.h" #include "llfloatergesture.h" // for some label constants #include "llgesturemgr.h" +#include "llinventorydefines.h" #include "llinventoryfunctions.h" #include "llinventorymodelbackgroundfetch.h" #include "llkeyboard.h" #include "lllineeditor.h" +#include "llmultigesture.h" #include "llnotificationsutil.h" #include "llradiogroup.h" +#include "llresmgr.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "lltextbox.h" +#include "lltrans.h" #include "lluictrlfactory.h" -#include "llviewerinventory.h" -#include "llviewerobject.h" +#include "llvfile.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "llviewerstats.h" -#include "llviewerwindow.h" // busycount -#include "llappviewer.h" // gVFS -#include "llanimstatelabels.h" -#include "llresmgr.h" // *TODO: Translate? @@ -98,7 +87,7 @@ void LLInventoryGestureAvailable::done() { for(uuid_vec_t::iterator it = mComplete.begin(); it != mComplete.end(); ++it) { - LLPreview *preview = LLPreview::find((*it)); + LLPreview* preview = LLPreview::find((*it)); if(preview) { preview->refresh(); @@ -557,6 +546,7 @@ static const std::string valid_key_to_string(KEY key) void LLPreviewGesture::addKeys() { LLComboBox* combo = mKeyCombo; + combo->add( NONE_LABEL ); for (KEY key = ' '; key < KEY_NONE; key++) { @@ -686,7 +676,7 @@ void LLPreviewGesture::refresh() if (mPreviewGesture || !is_complete) { - childSetEnabled("desc", FALSE); + getChildView("desc")->setEnabled(FALSE); //mDescEditor->setEnabled(FALSE); mTriggerEditor->setEnabled(FALSE); mReplaceText->setEnabled(FALSE); @@ -720,7 +710,7 @@ void LLPreviewGesture::refresh() BOOL modifiable = item->getPermissions().allowModifyBy(gAgent.getID()); - childSetEnabled("desc", modifiable); + getChildView("desc")->setEnabled(modifiable); mTriggerEditor->setEnabled(TRUE); mLibraryList->setEnabled(modifiable); mStepList->setEnabled(modifiable); diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 6613a0055..c9f1adffc 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -40,28 +40,28 @@ #include "llcheckboxctrl.h" #include "llcombobox.h" #include "lldir.h" +#include "llexternaleditor.h" +#include "statemachine/aifilepicker.h" #include "llinventorydefines.h" #include "llinventorymodel.h" #include "llkeyboard.h" #include "lllineeditor.h" - #include "lllivefile.h" -#include "llexternaleditor.h" #include "llnotificationsutil.h" #include "llresmgr.h" #include "llscrollbar.h" #include "llscrollcontainer.h" #include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llslider.h" //#include "lscript_rt_interface.h" +//#include "lscript_library.h" //#include "lscript_export.h" #include "lltextbox.h" #include "lltooldraganddrop.h" #include "llvfile.h" -#include "statemachine/aifilepicker.h" #include "llagent.h" -#include "llnotify.h" #include "llmenugl.h" #include "roles_constants.h" #include "llselectmgr.h" @@ -80,7 +80,6 @@ #include "llslider.h" #include "lldir.h" #include "llcombobox.h" -//#include "llfloaterchat.h" #include "llfloatersearchreplace.h" #include "llviewerstats.h" #include "llviewertexteditor.h" @@ -91,7 +90,6 @@ #include "lltrans.h" #include "llviewercontrol.h" #include "llappviewer.h" -#include "llpanelobjectinventory.h" #include "llsdserialize.h" @@ -750,7 +748,7 @@ BOOL LLScriptEdCore::canClose() bool LLScriptEdCore::handleSaveChangesDialog(const LLSD& notification, const LLSD& response ) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); switch( option ) { case 0: // "Yes" @@ -782,7 +780,7 @@ bool LLScriptEdCore::handleSaveChangesDialog(const LLSD& notification, const LLS // static bool LLScriptEdCore::onHelpWebDialog(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); switch(option) { @@ -1142,8 +1140,7 @@ void LLScriptEdCore::onErrorList(LLUICtrl*, void* user_data) LLScrollListItem* item = self->mErrorList->getFirstSelected(); if(item) { - // *FIX: This fucked up little hack is here because we don't - // have a grep library. This is very brittle code. + // *FIX: replace with boost grep S32 row = 0; S32 column = 0; const LLScrollListCell* cell = item->getColumn(0); @@ -1161,7 +1158,7 @@ void LLScriptEdCore::onErrorList(LLUICtrl*, void* user_data) bool LLScriptEdCore::handleReloadFromServerDialog(const LLSD& notification, const LLSD& response ) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); switch( option ) { case 0: // "Yes" @@ -1454,8 +1451,7 @@ void LLPreviewLSL::onSave(void* userdata, BOOL close_after_save) // Save needs to compile the text in the buffer. If the compile // succeeds, then save both assets out to the database. If the compile -// fails, go ahead and save the text anyway so that the user doesn't -// get too fucked. +// fails, go ahead and save the text anyway. void LLPreviewLSL::saveIfNeeded() { // llinfos << "LLPreviewLSL::saveIfNeeded()" << llendl; diff --git a/indra/newview/lltoolbar.cpp b/indra/newview/lltoolbar.cpp index 791f8f248..2d07e1c05 100644 --- a/indra/newview/lltoolbar.cpp +++ b/indra/newview/lltoolbar.cpp @@ -35,41 +35,30 @@ #include "lltoolbar.h" -#include "imageids.h" -#include "llfontgl.h" -#include "llrect.h" -#include "llparcel.h" +#include "llbutton.h" +#include "llflyoutbutton.h" +#include "llscrolllistitem.h" +#include "llui.h" #include "llagent.h" #include "llagentcamera.h" #include "llagentwearables.h" -#include "llbutton.h" -#include "llfocusmgr.h" -#include "llviewercontrol.h" -#include "llmenucommands.h" -#include "llimview.h" -#include "lluiconstants.h" -#include "llvoavatarself.h" -#include "lltooldraganddrop.h" -#include "llfloaterchatterbox.h" -#include "llfloaterfriends.h" -#include "llfloaterinventory.h" -#include "llfloatersnapshot.h" -#include "llfloateravatarlist.h" -#include "lltoolmgr.h" -#include "llui.h" -#include "llviewermenu.h" #include "llfirstuse.h" #include "llviewerparcelmgr.h" -#include "lluictrlfactory.h" -#include "llviewerwindow.h" -#include "lltoolgrab.h" -#include "llcombobox.h" +#include "llfloateravatarlist.h" #include "llfloaterchat.h" -#include "llfloatermute.h" -#include "llimpanel.h" -#include "llscrolllistctrl.h" +#include "llfloaterchatterbox.h" #include "llfloatercustomize.h" +#include "llfloaterfriends.h" +#include "llfloaterinventory.h" +#include "llfloatermute.h" +#include "llfloatersnapshot.h" +#include "llimpanel.h" +#include "llimview.h" +#include "llmenucommands.h" +#include "lltoolmgr.h" +#include "lltoolgrab.h" +#include "llvoavatarself.h" // [RLVa:KB] #include "rlvhandler.h" @@ -78,6 +67,7 @@ #if LL_DARWIN #include "llresizehandle.h" + #include "llviewerwindow.h" // This class draws like an LLResizeHandle but has no interactivity. // It's just there to provide a cue to the user that the lower right corner of the window functions as a resize handle. @@ -343,7 +333,7 @@ void LLToolBar::refresh() mBuildBtn->setEnabled(!(gRlvHandler.hasBehaviour(RLV_BHVR_REZ) && gRlvHandler.hasBehaviour(RLV_BHVR_EDIT))); mMapBtn->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWWORLDMAP)); - mRadarBtn->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWMINIMAP)); + mRadarBtn->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWMINIMAP) && !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)); mInventoryBtn->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWINV)); } // [/RLVa:KB]