summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llaccordionctrl.cpp5
-rw-r--r--indra/llui/llbutton.cpp1
-rw-r--r--indra/llui/llflatlistview.cpp30
-rw-r--r--indra/llui/llflatlistview.h12
-rw-r--r--indra/llui/lltextbase.cpp56
-rw-r--r--indra/llui/lltextbase.h18
-rw-r--r--indra/llui/lltexteditor.cpp2
-rw-r--r--indra/llui/lluictrl.cpp7
-rw-r--r--indra/llui/lluictrlfactory.h2
-rw-r--r--indra/llui/lluistring.cpp13
-rw-r--r--indra/llui/llview.h7
-rw-r--r--indra/llui/llviewquery.cpp14
-rw-r--r--indra/llui/llviewquery.h2
13 files changed, 113 insertions, 56 deletions
diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp
index 28125ccaaf..673631f99a 100644
--- a/indra/llui/llaccordionctrl.cpp
+++ b/indra/llui/llaccordionctrl.cpp
@@ -40,8 +40,6 @@
#include "llfocusmgr.h"
#include "lllocalcliprect.h"
-#include "lltrans.h"
-
#include "boost/bind.hpp"
static const S32 DRAGGER_BAR_MARGIN = 4;
@@ -74,7 +72,6 @@ LLAccordionCtrl::LLAccordionCtrl(const Params& params):LLPanel(params)
{
initNoTabsWidget(params.no_matched_tabs_text);
- mNoVisibleTabsOrigString = LLTrans::getString(params.no_visible_tabs_text.initial_value().asString());
mSingleExpansion = params.single_expansion;
if(mFitParent && !mSingleExpansion)
{
@@ -389,7 +386,7 @@ void LLAccordionCtrl::initNoTabsWidget(const LLTextBox::Params& tb_params)
{
LLTextBox::Params tp = tb_params;
tp.rect(getLocalRect());
- mNoMatchedTabsOrigString = LLTrans::getString(tp.initial_value().asString());
+ mNoMatchedTabsOrigString = tp.initial_value().asString();
mNoVisibleTabsHelpText = LLUICtrlFactory::create<LLTextBox>(tp, this);
}
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 39e46a7ccb..aeedf62379 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -1,3 +1,4 @@
+
/**
* @file llbutton.cpp
* @brief LLButton base class
diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp
index f9e08a3f4c..a80a3f206f 100644
--- a/indra/llui/llflatlistview.cpp
+++ b/indra/llui/llflatlistview.cpp
@@ -157,7 +157,7 @@ bool LLFlatListView::insertItemAfter(LLPanel* after_item, LLPanel* item_to_add,
}
-bool LLFlatListView::removeItem(LLPanel* item)
+bool LLFlatListView::removeItem(LLPanel* item, bool rearrange)
{
if (!item) return false;
if (item->getParent() != mItemsPanel) return false;
@@ -165,22 +165,22 @@ bool LLFlatListView::removeItem(LLPanel* item)
item_pair_t* item_pair = getItemPair(item);
if (!item_pair) return false;
- return removeItemPair(item_pair);
+ return removeItemPair(item_pair, rearrange);
}
-bool LLFlatListView::removeItemByValue(const LLSD& value)
+bool LLFlatListView::removeItemByValue(const LLSD& value, bool rearrange)
{
if (value.isUndefined()) return false;
item_pair_t* item_pair = getItemPair(value);
if (!item_pair) return false;
- return removeItemPair(item_pair);
+ return removeItemPair(item_pair, rearrange);
}
-bool LLFlatListView::removeItemByUUID(const LLUUID& uuid)
+bool LLFlatListView::removeItemByUUID(const LLUUID& uuid, bool rearrange)
{
- return removeItemByValue(LLSD(uuid));
+ return removeItemByValue(LLSD(uuid), rearrange);
}
LLPanel* LLFlatListView::getItemByValue(const LLSD& value) const
@@ -327,6 +327,9 @@ U32 LLFlatListView::size(const bool only_visible_items) const
void LLFlatListView::clear()
{
+ // This will clear mSelectedItemPairs, calling all appropriate callbacks.
+ resetSelection();
+
// do not use LLView::deleteAllChildren to avoid removing nonvisible items. drag-n-drop for ex.
for (pairs_iterator_t it = mItemPairs.begin(); it != mItemPairs.end(); ++it)
{
@@ -335,7 +338,6 @@ void LLFlatListView::clear()
delete *it;
}
mItemPairs.clear();
- mSelectedItemPairs.clear();
// also set items panel height to zero. Reshape it to allow reshaping of non-item children
LLRect rc = mItemsPanel->getRect();
@@ -982,11 +984,12 @@ bool LLFlatListView::isSelected(item_pair_t* item_pair) const
return std::find(mSelectedItemPairs.begin(), it_end, item_pair) != it_end;
}
-bool LLFlatListView::removeItemPair(item_pair_t* item_pair)
+bool LLFlatListView::removeItemPair(item_pair_t* item_pair, bool rearrange)
{
llassert(item_pair);
bool deleted = false;
+ bool selection_changed = false;
for (pairs_iterator_t it = mItemPairs.begin(); it != mItemPairs.end(); ++it)
{
item_pair_t* _item_pair = *it;
@@ -1006,6 +1009,7 @@ bool LLFlatListView::removeItemPair(item_pair_t* item_pair)
if (selected_item_pair == item_pair)
{
it = mSelectedItemPairs.erase(it);
+ selection_changed = true;
break;
}
}
@@ -1014,8 +1018,16 @@ bool LLFlatListView::removeItemPair(item_pair_t* item_pair)
item_pair->first->die();
delete item_pair;
+ if (rearrange)
+ {
rearrangeItems();
notifyParentItemsRectChanged();
+ }
+
+ if (selection_changed && mCommitOnSelectionChange)
+ {
+ onCommit();
+ }
return true;
}
@@ -1111,7 +1123,7 @@ void LLFlatListView::onFocusReceived()
{
if (size())
{
- mSelectedItemsBorder->setVisible(TRUE);
+ mSelectedItemsBorder->setVisible(TRUE);
}
gEditMenuHandler = this;
}
diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h
index bf72289c47..2c391fdf91 100644
--- a/indra/llui/llflatlistview.h
+++ b/indra/llui/llflatlistview.h
@@ -117,6 +117,9 @@ public:
Params();
};
+ // disable traversal when finding widget to hand focus off to
+ /*virtual*/ BOOL canFocusChildren() const { return FALSE; }
+
/**
* Connects callback to signal called when Return key is pressed.
*/
@@ -149,19 +152,19 @@ public:
* Remove specified item
* @return true if the item was removed, false otherwise
*/
- virtual bool removeItem(LLPanel* item);
+ virtual bool removeItem(LLPanel* item, bool rearrange = true);
/**
* Remove an item specified by value
* @return true if the item was removed, false otherwise
*/
- virtual bool removeItemByValue(const LLSD& value);
+ virtual bool removeItemByValue(const LLSD& value, bool rearrange = true);
/**
* Remove an item specified by uuid
* @return true if the item was removed, false otherwise
*/
- virtual bool removeItemByUUID(const LLUUID& uuid);
+ virtual bool removeItemByUUID(const LLUUID& uuid, bool rearrange = true);
/**
* Get an item by value
@@ -262,6 +265,7 @@ public:
void setAllowSelection(bool can_select) { mAllowSelection = can_select; }
/** Sets flag whether onCommit should be fired if selection was changed */
+ // FIXME: this should really be a separate signal, since "Commit" implies explicit user action, and selection changes can happen more indirectly.
void setCommitOnSelectionChange(bool b) { mCommitOnSelectionChange = b; }
/** Get number of selected items in the list */
@@ -350,7 +354,7 @@ protected:
virtual bool isSelected(item_pair_t* item_pair) const;
- virtual bool removeItemPair(item_pair_t* item_pair);
+ virtual bool removeItemPair(item_pair_t* item_pair, bool rearrange);
/**
* Notify parent about changed size of internal controls with "size_changes" action
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 223998569b..ed03645944 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -66,7 +66,10 @@ bool LLTextBase::compare_segment_end::operator()(const LLTextSegmentPtr& a, cons
{
return a->getStart() < b->getStart();
}
- return a->getEnd() < b->getEnd();
+ else
+ {
+ return a->getEnd() < b->getEnd();
+ }
}
@@ -174,7 +177,7 @@ LLTextBase::Params::Params()
LLTextBase::LLTextBase(const LLTextBase::Params &p)
: LLUICtrl(p, LLTextViewModelPtr(new LLTextViewModel)),
- mURLClickSignal(),
+ mURLClickSignal(NULL),
mMaxTextByteLength( p.max_text_length ),
mDefaultFont(p.font),
mFontShadow(p.font_shadow),
@@ -209,7 +212,8 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
mParseHTML(p.allow_html),
mParseHighlights(p.parse_highlights),
mBGVisible(p.bg_visible),
- mScroller(NULL)
+ mScroller(NULL),
+ mStyleDirty(true)
{
if(p.allow_scroll)
{
@@ -248,9 +252,8 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
LLTextBase::~LLTextBase()
{
- // Menu, like any other LLUICtrl, is deleted by its parent - gMenuHolder
-
mSegments.clear();
+ delete mURLClickSignal;
}
void LLTextBase::initFromParams(const LLTextBase::Params& p)
@@ -296,13 +299,18 @@ bool LLTextBase::truncate()
return did_truncate;
}
-LLStyle::Params LLTextBase::getDefaultStyleParams()
+const LLStyle::Params& LLTextBase::getDefaultStyleParams()
{
- return LLStyle::Params()
- .color(LLUIColor(&mFgColor))
- .readonly_color(LLUIColor(&mReadOnlyFgColor))
- .font(mDefaultFont)
- .drop_shadow(mFontShadow);
+ if (mStyleDirty)
+ {
+ mDefaultStyle
+ .color(LLUIColor(&mFgColor))
+ .readonly_color(LLUIColor(&mReadOnlyFgColor))
+ .font(mDefaultFont)
+ .drop_shadow(mFontShadow);
+ mStyleDirty = false;
+ }
+ return mDefaultStyle;
}
void LLTextBase::onValueChange(S32 start, S32 end)
@@ -861,11 +869,12 @@ BOOL LLTextBase::handleMouseUp(S32 x, S32 y, MASK mask)
if (cur_segment && cur_segment->handleMouseUp(x, y, mask))
{
// Did we just click on a link?
- if (cur_segment->getStyle()
+ if (mURLClickSignal
+ && cur_segment->getStyle()
&& cur_segment->getStyle()->isLink())
{
// *TODO: send URL here?
- mURLClickSignal(this, LLSD() );
+ (*mURLClickSignal)(this, LLSD() );
}
return TRUE;
}
@@ -1039,12 +1048,14 @@ void LLTextBase::draw()
void LLTextBase::setColor( const LLColor4& c )
{
mFgColor = c;
+ mStyleDirty = true;
}
//virtual
void LLTextBase::setReadOnlyColor(const LLColor4 &c)
{
mReadOnlyFgColor = c;
+ mStyleDirty = true;
}
//virtual
@@ -1488,12 +1499,22 @@ void LLTextBase::getSegmentAndOffset( S32 startpos, segment_set_t::iterator* seg
LLTextBase::segment_set_t::iterator LLTextBase::getSegIterContaining(S32 index)
{
+ if (index > getLength()) { return mSegments.end(); }
+
+ // when there are no segments, we return the end iterator, which must be checked by caller
+ if (mSegments.size() <= 1) { return mSegments.begin(); }
+
segment_set_t::iterator it = mSegments.upper_bound(new LLIndexSegment(index));
return it;
}
LLTextBase::segment_set_t::const_iterator LLTextBase::getSegIterContaining(S32 index) const
{
+ if (index > getLength()) { return mSegments.end(); }
+
+ // when there are no segments, we return the end iterator, which must be checked by caller
+ if (mSegments.size() <= 1) { return mSegments.begin(); }
+
LLTextBase::segment_set_t::const_iterator it = mSegments.upper_bound(new LLIndexSegment(index));
return it;
}
@@ -2324,6 +2345,15 @@ LLRect LLTextBase::getVisibleDocumentRect() const
}
}
+boost::signals2::connection LLTextBase::setURLClickedCallback(const commit_signal_t::slot_type& cb)
+{
+ if (!mURLClickSignal)
+ {
+ mURLClickSignal = new commit_signal_t();
+ }
+ return mURLClickSignal->connect(cb);
+}
+
//
// LLTextSegment
//
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 300ee0f05f..4b0eeeb7d6 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -361,10 +361,7 @@ public:
virtual void appendLineBreakSegment(const LLStyle::Params& style_params);
virtual void appendImageSegment(const LLStyle::Params& style_params);
virtual void appendWidget(const LLInlineViewSegment::Params& params, const std::string& text, bool allow_undo);
-
-public:
- // Fired when a URL link is clicked
- commit_signal_t mURLClickSignal;
+ boost::signals2::connection setURLClickedCallback(const commit_signal_t::slot_type& cb);
protected:
// helper structs
@@ -457,7 +454,7 @@ protected:
void createDefaultSegment();
virtual void updateSegments();
void insertSegment(LLTextSegmentPtr segment_to_insert);
- LLStyle::Params getDefaultStyleParams();
+ const LLStyle::Params& getDefaultStyleParams();
// manage lines
S32 getLineStart( S32 line ) const;
@@ -497,6 +494,12 @@ protected:
LLRect mVisibleTextRect; // The rect in which text is drawn. Excludes borders.
LLRect mTextBoundingRect;
+ // default text style
+ LLStyle::Params mDefaultStyle;
+ bool mStyleDirty;
+ const LLFontGL* const mDefaultFont; // font that is used when none specified, can only be set by constructor
+ const LLFontGL::ShadowType mFontShadow; // shadow style, can only be set by constructor
+
// colors
LLUIColor mCursorColor;
LLUIColor mFgColor;
@@ -523,8 +526,6 @@ protected:
LLFontGL::VAlign mVAlign;
F32 mLineSpacingMult; // multiple of line height used as space for a single line of text (e.g. 1.5 to get 50% padding)
S32 mLineSpacingPixels; // padding between lines
- const LLFontGL* mDefaultFont; // font that is used when none specified
- LLFontGL::ShadowType mFontShadow;
bool mBorderVisible;
bool mParseHTML; // make URLs interactive
bool mParseHighlights; // highlight user-defined keywords
@@ -547,6 +548,9 @@ protected:
bool mScrollNeeded; // need to change scroll region because of change to cursor position
S32 mScrollIndex; // index of first character to keep visible in scroll region
+ // Fired when a URL link is clicked
+ commit_signal_t* mURLClickSignal;
+
};
#endif
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index c9474d66b7..130cda3784 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -264,8 +264,6 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) :
mContextMenu(NULL),
mShowContextMenu(p.show_context_menu)
{
- mDefaultFont = p.font;
-
mSourceID.generate();
//FIXME: use image?
diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp
index 3ade46d367..ff330f863a 100644
--- a/indra/llui/lluictrl.cpp
+++ b/indra/llui/lluictrl.cpp
@@ -675,7 +675,7 @@ BOOL LLUICtrl::getIsChrome() const
class CompareByDefaultTabGroup: public LLCompareByTabOrder
{
public:
- CompareByDefaultTabGroup(LLView::child_tab_order_t order, S32 default_tab_group):
+ CompareByDefaultTabGroup(const LLView::child_tab_order_t& order, S32 default_tab_group):
LLCompareByTabOrder(order),
mDefaultTabGroup(default_tab_group) {}
private:
@@ -699,13 +699,16 @@ class LLUICtrl::DefaultTabGroupFirstSorter : public LLQuerySorter, public LLSing
{
public:
/*virtual*/ void operator() (LLView * parent, viewList_t &children) const
- {
+ {
children.sort(CompareByDefaultTabGroup(parent->getCtrlOrder(), parent->getDefaultTabGroup()));
}
};
+LLFastTimer::DeclareTimer FTM_FOCUS_FIRST_ITEM("Focus First Item");
+
BOOL LLUICtrl::focusFirstItem(BOOL prefer_text_fields, BOOL focus_flash)
{
+ LLFastTimer _(FTM_FOCUS_FIRST_ITEM);
// try to select default tab group child
LLCtrlQuery query = getTabOrderQuery();
// sort things such that the default tab group is at the front
diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h
index c99acee48e..dc43b311a7 100644
--- a/indra/llui/lluictrlfactory.h
+++ b/indra/llui/lluictrlfactory.h
@@ -182,7 +182,7 @@ public:
void popFactoryFunctions();
template<typename T>
- static T* createWidget(typename T::Params& params, LLView* parent = NULL)
+ static T* createWidget(const typename T::Params& params, LLView* parent = NULL)
{
T* widget = NULL;
diff --git a/indra/llui/lluistring.cpp b/indra/llui/lluistring.cpp
index f7a53e87de..ac9e71665f 100644
--- a/indra/llui/lluistring.cpp
+++ b/indra/llui/lluistring.cpp
@@ -135,9 +135,16 @@ void LLUIString::updateResult() const
mResult = mOrig;
// get the defailt args + local args
- LLStringUtil::format_map_t combined_args = LLTrans::getDefaultArgs();
- combined_args.insert(mArgs.begin(), mArgs.end());
- LLStringUtil::format(mResult, combined_args);
+ if (mArgs.empty())
+ {
+ LLStringUtil::format(mResult, LLTrans::getDefaultArgs());
+ }
+ else
+ {
+ LLStringUtil::format_map_t combined_args = LLTrans::getDefaultArgs();
+ combined_args.insert(mArgs.begin(), mArgs.end());
+ LLStringUtil::format(mResult, combined_args);
+ }
}
void LLUIString::updateWResult() const
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index aba6c310f1..8e705ed701 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -265,7 +265,7 @@ public:
virtual BOOL postBuild() { return TRUE; }
- child_tab_order_t getCtrlOrder() const { return mCtrlOrder; }
+ const child_tab_order_t& getCtrlOrder() const { return mCtrlOrder; }
ctrl_list_t getCtrlList() const;
ctrl_list_t getCtrlListSorted() const;
@@ -620,12 +620,13 @@ public:
class LLCompareByTabOrder
{
public:
- LLCompareByTabOrder(LLView::child_tab_order_t order) : mTabOrder(order) {}
+ LLCompareByTabOrder(const LLView::child_tab_order_t& order) : mTabOrder(order) {}
virtual ~LLCompareByTabOrder() {}
bool operator() (const LLView* const a, const LLView* const b) const;
private:
virtual bool compareTabOrders(const LLView::tab_order_t & a, const LLView::tab_order_t & b) const { return a < b; }
- LLView::child_tab_order_t mTabOrder;
+ // ok to store a reference, as this should only be allocated on stack during view query operations
+ const LLView::child_tab_order_t& mTabOrder;
};
template <class T> T* LLView::getChild(const std::string& name, BOOL recurse) const
diff --git a/indra/llui/llviewquery.cpp b/indra/llui/llviewquery.cpp
index bdb3d223a6..1b44cc528e 100644
--- a/indra/llui/llviewquery.cpp
+++ b/indra/llui/llviewquery.cpp
@@ -95,8 +95,8 @@ viewList_t LLViewQuery::run(LLView* view) const
if (pre.first)
{
post = runFilters(view, filtered_children, mPostFilters);
+ }
}
- }
if(pre.first && post.first)
{
@@ -119,12 +119,12 @@ void LLViewQuery::filterChildren(LLView * view, viewList_t & filtered_children)
(*mSorterp)(view, views); // sort the children per the sorter
}
for(LLView::child_list_iter_t iter = views.begin();
- iter != views.end();
- iter++)
- {
- viewList_t indiv_children = this->run(*iter);
- filtered_children.insert(filtered_children.end(), indiv_children.begin(), indiv_children.end());
- }
+ iter != views.end();
+ iter++)
+ {
+ viewList_t indiv_children = this->run(*iter);
+ filtered_children.splice(filtered_children.end(), indiv_children);
+ }
}
filterResult_t LLViewQuery::runFilters(LLView * view, const viewList_t children, const filterList_t filters) const
diff --git a/indra/llui/llviewquery.h b/indra/llui/llviewquery.h
index 98d9bf8796..68af31933d 100644
--- a/indra/llui/llviewquery.h
+++ b/indra/llui/llviewquery.h
@@ -122,7 +122,7 @@ public:
viewList_t operator () (LLView * view) const { return run(view); }
// override this method to provide iteration over other types of children
- virtual void filterChildren(LLView * view, viewList_t & filtered_children) const;
+ virtual void filterChildren(LLView * view, viewList_t& filtered_children) const;
private: