From fdc848cf72f755b3ce924e12625ec9923495f9bc Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Tue, 20 Oct 2009 22:05:00 +0000 Subject: removed unnecessary static variable instantiations to improve compile times moved a bunch of template class statics to cpp files also added filename parameter to LLXUIParser::readXUI for better debugging of XUI errors reviewed by James --- indra/llui/llhandle.h | 14 ++++++------ indra/llui/lllayoutstack.cpp | 2 +- indra/llui/llnotifications.cpp | 1 + indra/llui/llnotifications.h | 3 +-- indra/llui/llpanel.cpp | 7 +++--- indra/llui/llrngwriter.cpp | 3 ++- indra/llui/lluicolortable.cpp | 2 +- indra/llui/lluictrlfactory.cpp | 40 ++++++++++++++++++++++++++++++++- indra/llui/lluictrlfactory.h | 50 +++++++++++++++++++++--------------------- indra/llui/lluistring.cpp | 2 -- indra/llui/lluistring.h | 2 -- 11 files changed, 81 insertions(+), 45 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llhandle.h b/indra/llui/llhandle.h index 10a7fd4544..899f6b9326 100644 --- a/indra/llui/llhandle.h +++ b/indra/llui/llhandle.h @@ -60,7 +60,7 @@ template class LLHandle { public: - LLHandle() : mTombStone(sDefaultTombStone) {} + LLHandle() : mTombStone(getDefaultTombStone()) {} const LLHandle& operator =(const LLHandle& other) { mTombStone = other.mTombStone; @@ -74,7 +74,7 @@ public: void markDead() { - mTombStone = sDefaultTombStone; + mTombStone = getDefaultTombStone(); } T* get() const @@ -104,13 +104,13 @@ protected: LLPointer > mTombStone; private: - static LLPointer > sDefaultTombStone; + static LLPointer >& getDefaultTombStone() + { + static LLPointer > sDefaultTombStone = new LLTombStone; + return sDefaultTombStone; + } }; -// initialize static "empty" tombstone pointer -template LLPointer > LLHandle::sDefaultTombStone = new LLTombStone(); - - template class LLRootHandle : public LLHandle { diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 5eade72b61..24fd380bb1 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -229,7 +229,7 @@ static void get_attribute_bool_and_write(LLXMLNodePtr node, LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node) { LLLayoutStack::Params p(LLUICtrlFactory::getDefaultParams()); - LLXUIParser::instance().readXUI(node, p); + LLXUIParser::instance().readXUI(node, p, LLUICtrlFactory::getInstance()->getCurFileName()); // Export must happen before setupParams() mungles rectangles and before // this item gets added to parent (otherwise screws up last_child_rect diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 25e2475f59..a0e51151c9 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -34,6 +34,7 @@ #include "llnotifications.h" +#include "llxmlnode.h" #include "lluictrl.h" #include "lluictrlfactory.h" #include "lldir.h" diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 19895c3293..cd05db3c30 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -102,7 +102,6 @@ #include "llfunctorregistry.h" #include "llpointer.h" #include "llinitparam.h" -#include "llxmlnode.h" class LLNotification; typedef boost::shared_ptr LLNotificationPtr; @@ -160,7 +159,7 @@ public: LLNotificationForm(); LLNotificationForm(const LLSD& sd); LLNotificationForm(const std::string& name, - const LLPointer xml_node); + const LLPointer xml_node); LLSD asLLSD() const; diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 742427525b..095200ddc3 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -474,7 +474,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu { //if we are exporting, we want to export the current xml //not the referenced xml - LLXUIParser::instance().readXUI(node, params); + LLXUIParser::instance().readXUI(node, params, xml_filename); Params output_params(params); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); @@ -490,14 +490,15 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu return FALSE; } - LLXUIParser::instance().readXUI(referenced_xml, params); + LLXUIParser::instance().readXUI(referenced_xml, params, xml_filename); // add children using dimensions from referenced xml for consistent layout setShape(params.rect); LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance()); } - LLXUIParser::instance().readXUI(node, params); + // ask LLUICtrlFactory for filename, since xml_filename might be empty + LLXUIParser::instance().readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName()); if (output_node) { diff --git a/indra/llui/llrngwriter.cpp b/indra/llui/llrngwriter.cpp index cf23e3af15..7e3d4b92d3 100644 --- a/indra/llui/llrngwriter.cpp +++ b/indra/llui/llrngwriter.cpp @@ -108,7 +108,8 @@ void LLRNGWriter::addDefinition(const std::string& type_name, const LLInitParam: LLXMLNodePtr old_element_node = mElementNode; LLXMLNodePtr old_child_node = mChildrenNode; - addDefinition(child_name, (*LLDefaultParamBlockRegistry::instance().getValue(type))()); + //FIXME: add LLDefaultParamBlockRegistry back when working on schema generation + //addDefinition(child_name, (*LLDefaultParamBlockRegistry::instance().getValue(type))()); mElementNode = old_element_node; mChildrenNode = old_child_node; diff --git a/indra/llui/lluicolortable.cpp b/indra/llui/lluicolortable.cpp index 087a99c2b0..5827c0d627 100644 --- a/indra/llui/lluicolortable.cpp +++ b/indra/llui/lluicolortable.cpp @@ -278,7 +278,7 @@ bool LLUIColorTable::loadFromFilename(const std::string& filename) } Params params; - LLXUIParser::instance().readXUI(root, params); + LLXUIParser::instance().readXUI(root, params, filename); if(params.validateBlock()) { diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index 209ee76940..e2368cc05c 100644 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -34,6 +34,8 @@ #include "lluictrlfactory.h" +#include "llxmlnode.h" + #include #include @@ -94,7 +96,7 @@ void LLUICtrlFactory::loadWidgetTemplate(const std::string& widget_tag, LLInitPa if (LLUICtrlFactory::getLayeredXMLNode(filename, root_node)) { - LLXUIParser::instance().readXUI(root_node, block); + LLXUIParser::instance().readXUI(root_node, block, filename); } } @@ -410,3 +412,39 @@ void LLUICtrlFactory::popFactoryFunctions() mFactoryStack.pop_back(); } } + +//static +void LLUICtrlFactory::copyName(LLXMLNodePtr src, LLXMLNodePtr dest) +{ + dest->setName(src->getName()->mString); +} + +// adds a widget and its param block to various registries +//static +void LLUICtrlFactory::registerWidget(const std::type_info* widget_type, const std::type_info* param_block_type, dummy_widget_creator_func_t creator_func, const std::string& tag) +{ + // associate parameter block type with template .xml file + std::string* existing_tag = LLWidgetNameRegistry::instance().getValue(param_block_type); + if (existing_tag != NULL && *existing_tag != tag) + { + llerrs << "Duplicate entry for T::Params, try creating empty param block in derived classes that inherit T::Params" << llendl; + } + LLWidgetNameRegistry ::instance().defaultRegistrar().add(param_block_type, tag); + // associate widget type with factory function + LLDefaultWidgetRegistry::instance().defaultRegistrar().add(widget_type, creator_func); + LLWidgetTypeRegistry::instance().defaultRegistrar().add(tag, widget_type); + //FIXME: comment this in when working on schema generation + //LLDefaultParamBlockRegistry::instance().defaultRegistrar().add(widget_type, &getEmptyParamBlock); +} + +//static +dummy_widget_creator_func_t* LLUICtrlFactory::getDefaultWidgetFunc(const std::type_info* widget_type) +{ + return LLDefaultWidgetRegistry::instance().getValue(widget_type); +} + +//static +const std::string* LLUICtrlFactory::getWidgetTag(const std::type_info* widget_type) +{ + return LLWidgetNameRegistry::instance().getValue(widget_type); +} diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 5e6dad312c..17e32dc7a9 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -36,7 +36,7 @@ #include "llcallbackmap.h" #include "llinitparam.h" #include "llregistry.h" -#include "llxmlnode.h" +#include "v4color.h" #include "llfasttimer.h" #include "llxuiparser.h" @@ -98,10 +98,11 @@ class LLDefaultWidgetRegistry {}; // lookup function for generating empty param block by widget type -typedef const LLInitParam::BaseBlock& (*empty_param_block_func_t)(); -class LLDefaultParamBlockRegistry -: public LLRegistrySingleton -{}; +// this is used for schema generation +//typedef const LLInitParam::BaseBlock& (*empty_param_block_func_t)(); +//class LLDefaultParamBlockRegistry +//: public LLRegistrySingleton +//{}; extern LLFastTimer::DeclareTimer FTM_WIDGET_SETUP; extern LLFastTimer::DeclareTimer FTM_WIDGET_CONSTRUCTION; @@ -124,7 +125,7 @@ private: // recursively initialize from base class param block ((typename PARAM_BLOCK::base_block_t&)mPrototype).fillFrom(ParamDefaults::instance().get()); // after initializing base classes, look up template file for this param block - std::string* param_block_tag = LLWidgetNameRegistry::instance().getValue(&typeid(PARAM_BLOCK)); + const std::string* param_block_tag = getWidgetTag(&typeid(PARAM_BLOCK)); if (param_block_tag) { LLUICtrlFactory::loadWidgetTemplate(*param_block_tag, mPrototype); @@ -241,7 +242,7 @@ fail: template static T* getDefaultWidget(const std::string& name) { - dummy_widget_creator_func_t* dummy_func = LLDefaultWidgetRegistry::instance().getValue(&typeid(T)); + dummy_widget_creator_func_t* dummy_func = getDefaultWidgetFunc(&typeid(T)); return dummy_func ? dynamic_cast((*dummy_func)(name)) : NULL; } @@ -254,6 +255,8 @@ fail: return create(params); } + static void copyName(LLXMLNodePtr src, LLXMLNodePtr dest); + template static T* defaultBuilder(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node) { @@ -262,7 +265,7 @@ fail: //#pragma message("Generating LLUICtrlFactory::defaultBuilder") typename T::Params params(getDefaultParams()); - LLXUIParser::instance().readXUI(node, params); + LLXUIParser::instance().readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName()); if (output_node) { @@ -271,7 +274,7 @@ fail: T::setupParamsForExport(output_params, parent); // Export only the differences between this any default params typename T::Params default_params(getDefaultParams()); - output_node->setName(node->getName()->mString); + copyName(node, output_node); LLXUIParser::instance().writeXUI( output_node, output_params, &default_params); } @@ -320,7 +323,15 @@ fail: static void loadWidgetTemplate(const std::string& widget_tag, LLInitParam::BaseBlock& block); + // helper function for adding widget type info to various registries + static void registerWidget(const std::type_info* widget_type, const std::type_info* param_block_type, dummy_widget_creator_func_t creator_func, const std::string& tag); + private: + // return default widget instance factory func for a given type + static dummy_widget_creator_func_t* getDefaultWidgetFunc(const std::type_info* widget_type); + + static const std::string* getWidgetTag(const std::type_info* widget_type); + // this exists to get around dependency on llview static void setCtrlParent(LLView* view, LLView* parent, S32 tab_group); @@ -347,23 +358,12 @@ template LLChildRegistry::Register::Register(const char* tag, LLWidgetCreatorFunc func) : LLChildRegistry::StaticRegistrar(tag, func.empty() ? (LLWidgetCreatorFunc)&LLUICtrlFactory::defaultBuilder : func) { - const std::type_info* widget_type_infop = &typeid(T); - // associate parameter block type with template .xml file - std::string* existing_tag = LLWidgetNameRegistry ::instance().getValue(&typeid(typename T::Params)); - if (existing_tag != NULL && *existing_tag != tag) - { - // duplicate entry for T::Params - // try creating empty param block in derived classes that inherit T::Params - int* crash = 0; - *crash = 0; - } - LLWidgetNameRegistry ::instance().defaultRegistrar().add(&typeid(typename T::Params), tag); - // associate widget type with factory function - LLDefaultWidgetRegistry::instance().defaultRegistrar().add(widget_type_infop, &LLUICtrlFactory::createDefaultWidget); - LLWidgetTypeRegistry::instance().defaultRegistrar().add(tag, widget_type_infop); - LLDefaultParamBlockRegistry::instance().defaultRegistrar().add(widget_type_infop, &getEmptyParamBlock); + // add this widget to various registries + LLUICtrlFactory::instance().registerWidget(&typeid(T), &typeid(typename T::Params), &LLUICtrlFactory::createDefaultWidget, tag); + + // since registry_t depends on T, do this in line here typedef typename T::child_registry_t registry_t; - LLChildRegistryRegistry::instance().defaultRegistrar().add(widget_type_infop, registry_t::instance()); + LLChildRegistryRegistry::instance().defaultRegistrar().add(&typeid(T), registry_t::instance()); } diff --git a/indra/llui/lluistring.cpp b/indra/llui/lluistring.cpp index 20ff71378e..3a1e656364 100644 --- a/indra/llui/lluistring.cpp +++ b/indra/llui/lluistring.cpp @@ -35,8 +35,6 @@ #include "llsd.h" #include "lltrans.h" -const LLStringUtil::format_map_t LLUIString::sNullArgs; - LLFastTimer::DeclareTimer FTM_UI_STRING("UI String"); diff --git a/indra/llui/lluistring.h b/indra/llui/lluistring.h index 195f21a6a7..763de4d6a3 100644 --- a/indra/llui/lluistring.h +++ b/indra/llui/lluistring.h @@ -95,8 +95,6 @@ public: void insert(S32 charidx, const LLWString& wchars); void replace(S32 charidx, llwchar wc); - static const LLStringUtil::format_map_t sNullArgs; - private: void format(); -- cgit v1.2.3 From 2c1aacf814142b23049eff2a691a7cd2902bcf1d Mon Sep 17 00:00:00 2001 From: Steven Bennetts Date: Wed, 21 Oct 2009 04:47:55 +0000 Subject: Merging revisions 2102-2104 of https://svn.aws.productengine.com/secondlife/pe/stable-2 into P:\svn\viewer-2.0.0, respecting ancestry * Bugs: EXT-1609 EXT-1255 EXT-1299 --- indra/llui/CMakeLists.txt | 2 -- indra/llui/lldockablefloater.cpp | 12 +++++++++++- indra/llui/lldockablefloater.h | 2 ++ indra/llui/lldockcontrol.h | 4 ++++ 4 files changed, 17 insertions(+), 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index d9169f57f9..f4d1284095 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -86,7 +86,6 @@ set(llui_SOURCE_FILES lltextbox.cpp lltexteditor.cpp lltextparser.cpp - lltransientfloatermgr.cpp lltransutil.cpp lltoggleablemenu.cpp lltooltip.cpp @@ -176,7 +175,6 @@ set(llui_HEADER_FILES lltextparser.h lltoggleablemenu.h lltooltip.h - lltransientfloatermgr.h lltransutil.h lluicolortable.h lluiconstants.h diff --git a/indra/llui/lldockablefloater.cpp b/indra/llui/lldockablefloater.cpp index 228d0e701f..35b3e486af 100644 --- a/indra/llui/lldockablefloater.cpp +++ b/indra/llui/lldockablefloater.cpp @@ -99,7 +99,7 @@ void LLDockableFloater::toggleInstance(const LLSD& sdname) { instance->setMinimized(FALSE); instance->setVisible(TRUE); - instance->setFocus(TRUE); + gFloaterView->bringToFront(instance); } } @@ -141,6 +141,16 @@ void LLDockableFloater::setMinimized(BOOL minimize) LLFloater::setMinimized(minimize); } +LLView * LLDockableFloater::getDockWidget() +{ + LLView * res = NULL; + if (getDockControl() != NULL) { + res = getDockControl()->getDock(); + } + + return res; +} + void LLDockableFloater::onDockHidden() { setCanDock(FALSE); diff --git a/indra/llui/lldockablefloater.h b/indra/llui/lldockablefloater.h index 499ce9ae8d..46491d8a29 100644 --- a/indra/llui/lldockablefloater.h +++ b/indra/llui/lldockablefloater.h @@ -78,6 +78,8 @@ public: */ /*virtual*/ void setMinimized(BOOL minimize); + LLView * getDockWidget(); + virtual void onDockHidden(); virtual void onDockShown(); diff --git a/indra/llui/lldockcontrol.h b/indra/llui/lldockcontrol.h index e8ffcac0ac..756a2900d3 100644 --- a/indra/llui/lldockcontrol.h +++ b/indra/llui/lldockcontrol.h @@ -63,6 +63,10 @@ public: void on(); void off(); void setDock(LLView* dockWidget); + LLView* getDock() + { + return mDockWidget; + } void repositionDockable(); void drawToungue(); bool isDockVisible(); -- cgit v1.2.3 From b3d1eb82fadbf3a098abb49d2ef23cade4c6fe95 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 21 Oct 2009 21:30:40 +0000 Subject: fix for chat history layout bugs EXT-1728 - there is no new line in the text copied on junction of 2 panels EXT-1670 - fix chat history use of widgets reviewed by James --- indra/llui/llscrollbar.cpp | 18 +++++------ indra/llui/llscrollbar.h | 4 +-- indra/llui/lltextbase.cpp | 68 +++++++++++++++++++++++++++++------------- indra/llui/lltextbase.h | 5 +++- indra/llui/lltexteditor.cpp | 4 +-- indra/llui/lltexteditor.h | 2 +- indra/llui/lluictrlfactory.cpp | 5 ++-- 7 files changed, 67 insertions(+), 39 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index 0d674528dc..dfd315d451 100644 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -149,7 +149,8 @@ void LLScrollbar::setDocParams( S32 size, S32 pos ) updateThumbRect(); } -void LLScrollbar::setDocPos(S32 pos, BOOL update_thumb) +// returns true if document position really changed +bool LLScrollbar::setDocPos(S32 pos, BOOL update_thumb) { pos = llclamp(pos, 0, getDocPosMax()); if (pos != mDocPos) @@ -166,7 +167,9 @@ void LLScrollbar::setDocPos(S32 pos, BOOL update_thumb) { updateThumbRect(); } + return true; } + return false; } void LLScrollbar::setDocSize(S32 size) @@ -409,13 +412,8 @@ BOOL LLScrollbar::handleHover(S32 x, S32 y, MASK mask) BOOL LLScrollbar::handleScrollWheel(S32 x, S32 y, S32 clicks) { - S32 pos = llclamp(mDocPos + clicks * mStepSize, 0, getDocPosMax()); - if (pos != mDocPos) - { - setDocPos(pos, TRUE); - return TRUE; - } - return FALSE; + BOOL handled = changeLine( clicks * mStepSize, TRUE ); + return handled; } BOOL LLScrollbar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, @@ -578,9 +576,9 @@ void LLScrollbar::draw() } // end draw -void LLScrollbar::changeLine( S32 delta, BOOL update_thumb ) +bool LLScrollbar::changeLine( S32 delta, BOOL update_thumb ) { - setDocPos(mDocPos + delta, update_thumb); + return setDocPos(mDocPos + delta, update_thumb); } void LLScrollbar::setValue(const LLSD& value) diff --git a/indra/llui/llscrollbar.h b/indra/llui/llscrollbar.h index 865a1db409..a9f028f9ae 100644 --- a/indra/llui/llscrollbar.h +++ b/indra/llui/llscrollbar.h @@ -109,7 +109,7 @@ public: // How many "lines" the "document" has scrolled. // 0 <= DocPos <= DocSize - DocVisibile - void setDocPos( S32 pos, BOOL update_thumb = TRUE ); + bool setDocPos( S32 pos, BOOL update_thumb = TRUE ); S32 getDocPos() const { return mDocPos; } BOOL isAtBeginning(); @@ -133,7 +133,7 @@ public: private: void updateThumbRect(); - void changeLine(S32 delta, BOOL update_thumb ); + bool changeLine(S32 delta, BOOL update_thumb ); callback_t mChangeCallback; diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 1d36a16ea7..22cce755b0 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1825,27 +1825,26 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round return pos; } -LLRect LLTextBase::getLocalRectFromDocIndex(S32 pos) const +// returns rectangle of insertion caret +// in document coordinate frame from given index into text +LLRect LLTextBase::getDocRectFromDocIndex(S32 pos) const { - LLRect local_rect; if (mLineInfoList.empty()) { - local_rect = mTextRect; - local_rect.mBottom = local_rect.mTop - (S32)(mDefaultFont->getLineHeight()); - return local_rect; + return LLRect(); } + LLRect doc_rect; + // clamp pos to valid values pos = llclamp(pos, 0, mLineInfoList.back().mDocIndexEnd - 1); - // find line that contains cursor line_list_t::const_iterator line_iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), pos, line_end_compare()); - LLRect scrolled_view_rect = getVisibleDocumentRect(); - local_rect.mLeft = mTextRect.mLeft - scrolled_view_rect.mLeft + line_iter->mRect.mLeft; - local_rect.mBottom = mTextRect.mBottom + (line_iter->mRect.mBottom - scrolled_view_rect.mBottom); - local_rect.mTop = mTextRect.mBottom + (line_iter->mRect.mTop - scrolled_view_rect.mBottom); + doc_rect.mLeft = line_iter->mRect.mLeft; + doc_rect.mBottom = line_iter->mRect.mBottom; + doc_rect.mTop = line_iter->mRect.mTop; segment_set_t::iterator line_seg_iter; S32 line_seg_offset; @@ -1863,7 +1862,7 @@ LLRect LLTextBase::getLocalRectFromDocIndex(S32 pos) const // cursor advanced to right based on difference in offset of cursor to start of line S32 segment_width, segment_height; segmentp->getDimensions(line_seg_offset, cursor_seg_offset - line_seg_offset, segment_width, segment_height); - local_rect.mLeft += segment_width; + doc_rect.mLeft += segment_width; break; } @@ -1872,7 +1871,7 @@ LLRect LLTextBase::getLocalRectFromDocIndex(S32 pos) const // add remainder of current text segment to cursor position S32 segment_width, segment_height; segmentp->getDimensions(line_seg_offset, (segmentp->getEnd() - segmentp->getStart()) - line_seg_offset, segment_width, segment_height); - local_rect.mLeft += segment_width; + doc_rect.mLeft += segment_width; // offset will be 0 for all segments after the first line_seg_offset = 0; // go to next text segment on this line @@ -1880,7 +1879,31 @@ LLRect LLTextBase::getLocalRectFromDocIndex(S32 pos) const } } - local_rect.mRight = local_rect.mLeft; + // set rect to 0 width + doc_rect.mRight = doc_rect.mLeft; + + return doc_rect; +} + +LLRect LLTextBase::getLocalRectFromDocIndex(S32 pos) const +{ + LLRect local_rect; + if (mLineInfoList.empty()) + { + // return default height rect in upper left + local_rect = mTextRect; + local_rect.mBottom = local_rect.mTop - (S32)(mDefaultFont->getLineHeight()); + return local_rect; + } + + // get the rect in document coordinates + LLRect doc_rect = getDocRectFromDocIndex(pos); + + // compensate for scrolled, inset view of doc + LLRect scrolled_view_rect = getVisibleDocumentRect(); + local_rect = doc_rect; + local_rect.translate(mTextRect.mLeft - scrolled_view_rect.mLeft, + mTextRect.mBottom - scrolled_view_rect.mBottom); return local_rect; } @@ -2416,10 +2439,12 @@ void LLNormalTextSegment::dump() const // LLInlineViewSegment // -LLInlineViewSegment::LLInlineViewSegment(LLView* view, S32 start, S32 end, bool force_new_line) +LLInlineViewSegment::LLInlineViewSegment(LLView* view, S32 start, S32 end, bool force_new_line, S32 hpad, S32 vpad) : LLTextSegment(start, end), mView(view), - mForceNewLine(force_new_line) + mForceNewLine(force_new_line), + mHPad(hpad), // one sided padding (applied to left and right) + mVPad(vpad) { } @@ -2439,8 +2464,8 @@ void LLInlineViewSegment::getDimensions(S32 first_char, S32 num_chars, S32& widt } else { - width = mView->getRect().getWidth(); - height = mView->getRect().getHeight(); + width = mHPad * 2 + mView->getRect().getWidth(); + height = mVPad * 2 + mView->getRect().getHeight(); } } @@ -2462,14 +2487,15 @@ S32 LLInlineViewSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin void LLInlineViewSegment::updateLayout(const LLTextBase& editor) { - LLRect start_rect = editor.getLocalRectFromDocIndex(mStart); - LLRect doc_rect = editor.getDocumentView()->getRect(); - mView->setOrigin(doc_rect.mLeft + start_rect.mLeft, doc_rect.mBottom + start_rect.mBottom); + LLRect start_rect = editor.getDocRectFromDocIndex(mStart); + mView->setOrigin(start_rect.mLeft + mHPad, start_rect.mBottom + mVPad); } F32 LLInlineViewSegment::draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect) { - return (F32)(draw_rect.mLeft + mView->getRect().getWidth()); + // return padded width of widget + // widget is actually drawn during mDocumentView's draw() + return (F32)(draw_rect.mLeft + mView->getRect().getWidth() + mHPad * 2); } void LLInlineViewSegment::unlinkFromDocument(LLTextBase* editor) diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index c05a31baec..f0b8878491 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -157,6 +157,7 @@ public: S32 getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round ) const; LLRect getLocalRectFromDocIndex(S32 pos) const; + LLRect getDocRectFromDocIndex(S32 pos) const; void setReadOnly(bool read_only) { mReadOnly = read_only; } bool getReadOnly() { return mReadOnly; } @@ -458,7 +459,7 @@ public: class LLInlineViewSegment : public LLTextSegment { public: - LLInlineViewSegment(LLView* widget, S32 start, S32 end, bool force_new_line); + LLInlineViewSegment(LLView* widget, S32 start, S32 end, bool force_new_line, S32 hpad = 0, S32 vpad = 0); ~LLInlineViewSegment(); /*virtual*/ void getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; /*virtual*/ S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const; @@ -469,6 +470,8 @@ public: /*virtual*/ void linkToDocument(class LLTextBase* editor); private: + S32 mHPad; + S32 mVPad; LLView* mView; bool mForceNewLine; }; diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 953c5b292f..d507cf7ce4 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -2276,7 +2276,7 @@ void LLTextEditor::insertText(const std::string &new_text) setEnabled( enabled ); } -void LLTextEditor::appendWidget(LLView* widget, const std::string &widget_text, bool allow_undo, bool force_new_line) +void LLTextEditor::appendWidget(LLView* widget, const std::string &widget_text, bool allow_undo, bool force_new_line, S32 hpad, S32 vpad) { // Save old state S32 selection_start = mSelectionStart; @@ -2295,7 +2295,7 @@ void LLTextEditor::appendWidget(LLView* widget, const std::string &widget_text, // Add carriage return if not first line widget_wide_text = utf8str_to_wstring(widget_text); - LLTextSegmentPtr segment = new LLInlineViewSegment(widget, old_length, old_length + widget_text.size(), force_new_line); + LLTextSegmentPtr segment = new LLInlineViewSegment(widget, old_length, old_length + widget_text.size(), force_new_line, hpad, vpad); insert(getLength(), widget_wide_text, FALSE, segment); needsReflow(); diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 82f3956855..481a4d1a78 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -165,7 +165,7 @@ public: // inserts text at cursor void insertText(const std::string &text); - void appendWidget(LLView* widget, const std::string &widget_text, bool allow_undo, bool force_newline); + void appendWidget(LLView* widget, const std::string &widget_text, bool allow_undo, bool force_newline, S32 hpad, S32 vpad); // Non-undoable void setText(const LLStringExplicit &utf8str); diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index e2368cc05c..c3c0daed0f 100644 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -85,8 +85,9 @@ LLUICtrlFactory::LLUICtrlFactory() LLUICtrlFactory::~LLUICtrlFactory() { - delete mDummyPanel; - mDummyPanel = NULL; + // go ahead and leak mDummyPanel since this is static destructor time + //delete mDummyPanel; + //mDummyPanel = NULL; } void LLUICtrlFactory::loadWidgetTemplate(const std::string& widget_tag, LLInitParam::BaseBlock& block) -- cgit v1.2.3 From eda3c6386e69d4d3116d5cb81c852577ac009b87 Mon Sep 17 00:00:00 2001 From: Steven Bennetts Date: Thu, 22 Oct 2009 05:54:50 +0000 Subject: Deleted some files that were deleted by PE but missed during merges. Added some missing licensing info. --- indra/llui/lluicolortable.cpp | 23 +++++++++++++++++++++++ indra/llui/lluicolortable.h | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/lluicolortable.cpp b/indra/llui/lluicolortable.cpp index 5827c0d627..851091f0ca 100644 --- a/indra/llui/lluicolortable.cpp +++ b/indra/llui/lluicolortable.cpp @@ -3,7 +3,30 @@ * @brief brief LLUIColorTable class implementation file * * $LicenseInfo:firstyear=2009&license=viewergpl$ + * * Copyright (c) 2009, Linden Research, Inc. + * + * 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 + * + * 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 + * + * 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. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ diff --git a/indra/llui/lluicolortable.h b/indra/llui/lluicolortable.h index f102a573b8..59be0c4f9a 100644 --- a/indra/llui/lluicolortable.h +++ b/indra/llui/lluicolortable.h @@ -3,7 +3,30 @@ * @brief brief LLUIColorTable class header file * * $LicenseInfo:firstyear=2009&license=viewergpl$ + * * Copyright (c) 2009, Linden Research, Inc. + * + * 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 + * + * 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 + * + * 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. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ -- cgit v1.2.3 From 8f890c85c3a60726c989e4149300564718e901c9 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Thu, 22 Oct 2009 17:16:24 +0000 Subject: EXT-356 Tab Height background needs to be settable per instance now we have first, middle, last tab art reviewed by richard --- indra/llui/lltabcontainer.cpp | 99 ++++++++++++++++++++++++++++++++++--------- indra/llui/lltabcontainer.h | 32 ++++++++------ 2 files changed, 100 insertions(+), 31 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 3ca05ff0ff..732c01614b 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -105,6 +105,15 @@ struct LLPlaceHolderPanel : public LLPanel static LLDefaultChildRegistry::Register r1("placeholder"); static LLDefaultChildRegistry::Register r2("tab_container"); +LLTabContainer::TabParams::TabParams() +: tab_top_image_unselected("tab_top_image_unselected"), + tab_top_image_selected("tab_top_image_selected"), + tab_bottom_image_unselected("tab_bottom_image_unselected"), + tab_bottom_image_selected("tab_bottom_image_selected"), + tab_left_image_unselected("tab_left_image_unselected"), + tab_left_image_selected("tab_left_image_selected") +{} + LLTabContainer::Params::Params() : tab_width("tab_width"), tab_min_width("tab_min_width"), @@ -113,12 +122,9 @@ LLTabContainer::Params::Params() tab_position("tab_position"), hide_tabs("hide_tabs", false), tab_padding_right("tab_padding_right"), - tab_top_image_unselected("tab_top_image_unselected"), - tab_top_image_selected("tab_top_image_selected"), - tab_bottom_image_unselected("tab_bottom_image_unselected"), - tab_bottom_image_selected("tab_bottom_image_selected"), - tab_left_image_unselected("tab_left_image_unselected"), - tab_left_image_selected("tab_left_image_selected") + first_tab("first_tab"), + middle_tab("middle_tab"), + last_tab("last_tab") { name(std::string("tab_container")); mouse_opaque = false; @@ -147,12 +153,9 @@ LLTabContainer::LLTabContainer(const LLTabContainer::Params& p) mRightTabBtnOffset(p.tab_padding_right), mTotalTabWidth(0), mTabPosition(p.tab_position), - mImageTopUnselected(p.tab_top_image_unselected), - mImageTopSelected(p.tab_top_image_selected), - mImageBottomUnselected(p.tab_bottom_image_unselected), - mImageBottomSelected(p.tab_bottom_image_selected), - mImageLeftUnselected(p.tab_left_image_unselected), - mImageLeftSelected(p.tab_left_image_selected) + mFirstTabParams(p.first_tab), + mMiddleTabParams(p.middle_tab), + mLastTabParams(p.last_tab) { static LLUICachedControl tabcntr_vert_tab_min_width ("UITabCntrVertTabMinWidth", 0); @@ -791,6 +794,29 @@ void LLTabContainer::addTabPanel(LLPanel* panelp) addTabPanel(TabPanelParams().panel(panelp)); } +// function to update images +void LLTabContainer::update_images(LLTabTuple* tuple, TabParams params, LLTabContainer::TabPosition pos) +{ + if (tuple && tuple->mButton) + { + if (pos == LLTabContainer::TOP) + { + tuple->mButton->setImageUnselected(static_cast(params.tab_top_image_unselected)); + tuple->mButton->setImageSelected(static_cast(params.tab_top_image_selected)); + } + else if (pos == LLTabContainer::BOTTOM) + { + tuple->mButton->setImageUnselected(static_cast(params.tab_bottom_image_unselected)); + tuple->mButton->setImageSelected(static_cast(params.tab_bottom_image_selected)); + } + else if (pos == LLTabContainer::LEFT) + { + tuple->mButton->setImageUnselected(static_cast(params.tab_left_image_unselected)); + tuple->mButton->setImageSelected(static_cast(params.tab_left_image_selected)); + } + } +} + void LLTabContainer::addTabPanel(const TabPanelParams& panel) { LLPanel* child = panel.panel(); @@ -888,14 +914,14 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) else if( getTabPosition() == LLTabContainer::TOP ) { btn_rect.setLeftTopAndSize( 0, getRect().getHeight() - getTopBorderHeight() + tab_fudge, button_width, mTabHeight); - tab_img = mImageTopUnselected.get(); - tab_selected_img = mImageTopSelected.get(); + tab_img = mMiddleTabParams.tab_top_image_unselected; + tab_selected_img = mMiddleTabParams.tab_top_image_selected; } else { btn_rect.setOriginAndSize( 0, 0 + tab_fudge, button_width, mTabHeight); - tab_img = mImageBottomUnselected.get(); - tab_selected_img = mImageBottomSelected.get(); + tab_img = mMiddleTabParams.tab_bottom_image_unselected; + tab_selected_img = mMiddleTabParams.tab_bottom_image_selected; } LLTextBox* textbox = NULL; @@ -926,8 +952,8 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) p.click_callback.function(boost::bind(&LLTabContainer::onTabBtn, this, _2, child)); p.font(font); p.label(trimmed_label); - p.image_unselected(mImageLeftUnselected); - p.image_selected(mImageLeftSelected); + p.image_unselected(mMiddleTabParams.tab_left_image_unselected); + p.image_selected(mMiddleTabParams.tab_left_image_selected); p.scale_image(true); p.font_halign = LLFontGL::LEFT; p.tab_stop(false); @@ -983,6 +1009,31 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) LLTabTuple* tuple = new LLTabTuple( this, child, btn, textbox ); insertTuple( tuple, insertion_point ); + // if new tab was added as a first or last tab, update button image + // and update button image of any tab it may have affected + if (tuple == mTabList.front()) + { + update_images(tuple, mFirstTabParams, getTabPosition()); + + if (mTabList.size() == 2) + { + update_images(mTabList[1], mLastTabParams, getTabPosition()); + } + else if (mTabList.size() > 2) + { + update_images(mTabList[1], mMiddleTabParams, getTabPosition()); + } + } + else if (tuple == mTabList.back()) + { + update_images(tuple, mLastTabParams, getTabPosition()); + + if (mTabList.size() > 2) + { + update_images(mTabList[mTabList.size()-2], mMiddleTabParams, getTabPosition()); + } + } + //Don't add button and textbox if tab buttons are invisible(EXT - 576) if (!getTabsHidden()) { @@ -1064,7 +1115,17 @@ void LLTabContainer::removeTabPanel(LLPanel* child) LLTabTuple* tuple = *iter; if( tuple->mTabPanel == child ) { - removeChild( tuple->mButton ); + // update tab button images if removing the first or last tab + if ((tuple == mTabList.front()) && (mTabList.size() > 1)) + { + update_images(mTabList[1], mFirstTabParams, getTabPosition()); + } + else if ((tuple == mTabList.back()) && (mTabList.size() > 2)) + { + update_images(mTabList[mTabList.size()-2], mLastTabParams, getTabPosition()); + } + + removeChild( tuple->mButton ); delete tuple->mButton; removeChild( tuple->mTabPanel ); diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index e3af5384b1..a81974cd42 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -61,6 +61,17 @@ public: static void declareValues(); }; + struct TabParams : public LLInitParam::Block + { + Optional tab_top_image_unselected, + tab_top_image_selected, + tab_bottom_image_unselected, + tab_bottom_image_selected, + tab_left_image_unselected, + tab_left_image_selected; + TabParams(); + }; + struct Params : public LLInitParam::Block { @@ -73,12 +84,9 @@ public: Optional hide_tabs; Optional tab_padding_right; - Optional tab_top_image_unselected, - tab_top_image_selected, - tab_bottom_image_unselected, - tab_bottom_image_selected, - tab_left_image_unselected, - tab_left_image_selected; + Optional first_tab, + middle_tab, + last_tab; Params(); }; @@ -215,6 +223,9 @@ private: void updateMaxScrollPos(); void commitHoveredButton(S32 x, S32 y); + // updates tab button images given the tuple, tab position and the corresponding params + void update_images(LLTabTuple* tuple, TabParams params, LLTabContainer::TabPosition pos); + // Variables typedef std::vector tuple_list_t; @@ -252,12 +263,9 @@ private: LLFrameTimer mDragAndDropDelayTimer; - LLPointer mImageTopUnselected; - LLPointer mImageTopSelected; - LLPointer mImageBottomUnselected; - LLPointer mImageBottomSelected; - LLPointer mImageLeftUnselected; - LLPointer mImageLeftSelected; + TabParams mFirstTabParams; + TabParams mMiddleTabParams; + TabParams mLastTabParams; }; #endif // LL_TABCONTAINER_H -- cgit v1.2.3 From b43771cad585cb9820941eb1b24b67390eaa9435 Mon Sep 17 00:00:00 2001 From: Steven Bennetts Date: Fri, 23 Oct 2009 17:20:45 +0000 Subject: Merging revisions 2156-2183 of https://svn.aws.productengine.com/secondlife/pe/stable-2 into P:\svn\viewer-2.0.0-3, respecting ancestry * Bugs: EXT-1590 EXT-1694 EXT-1660 EXT-1646 EXT-1694 EXT-1316 EXT-1775 EXT-1798 EXT-1799 EXT-1117 EXT-1571 EXT-1572 * Dev: EXT-1757 EXT-991 EXT-1758 EXT-1770 EXT-1192 EXT-1613 EXT-1611 EXT-1256 EXT-1758 EXT-747 --- indra/llui/llbutton.cpp | 5 +++-- indra/llui/llbutton.h | 4 ++++ indra/llui/lldockablefloater.cpp | 15 ++++++++++++-- indra/llui/lldockcontrol.cpp | 45 ++++++++++++++++++++++++++++++++++------ indra/llui/lldockcontrol.h | 2 ++ indra/llui/llflatlistview.cpp | 18 ++++++++++++++-- indra/llui/llflatlistview.h | 2 ++ indra/llui/lllayoutstack.cpp | 28 +++++++++++++++++++++++++ indra/llui/lllayoutstack.h | 3 +++ 9 files changed, 110 insertions(+), 12 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index f28fca35c5..fd369730d6 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -147,7 +147,8 @@ LLButton::LLButton(const LLButton::Params& p) mHoverGlowStrength(p.hover_glow_amount), mCommitOnReturn(p.commit_on_return), mFadeWhenDisabled(FALSE), - mForcePressedState(FALSE) + mForcePressedState(FALSE), + mLastDrawCharsCount(0) { static LLUICachedControl llbutton_orig_h_pad ("UIButtonOrigHPad", 0); static Params default_params(LLUICtrlFactory::getDefaultParams()); @@ -814,7 +815,7 @@ void LLButton::draw() // LLFontGL::render expects S32 max_chars variable but process in a separate way -1 value. // Due to U32_MAX is equal to S32 -1 value I have rest this value for non-ellipses mode. // Not sure if it is really needed. Probably S32_MAX should be always passed as max_chars. - mGLFont->render(label, 0, (F32)x, (F32)(LLBUTTON_V_PAD + y_offset), + mLastDrawCharsCount = mGLFont->render(label, 0, (F32)x, (F32)(LLBUTTON_V_PAD + y_offset), label_color % alpha, mHAlign, LLFontGL::BOTTOM, LLFontGL::NORMAL, diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 7ca520b935..7fc4997133 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -210,6 +210,9 @@ public: void setFont(const LLFontGL *font) { mGLFont = ( font ? font : LLFontGL::getFontSansSerif()); } + + S32 getLastDrawCharsCount() const { return mLastDrawCharsCount; } + void setScaleImage(BOOL scale) { mScaleImage = scale; } BOOL getScaleImage() const { return mScaleImage; } @@ -260,6 +263,7 @@ private: S32 mMouseHeldDownCount; // Counter for parameter passed to held-down callback F32 mHeldDownDelay; // seconds, after which held-down callbacks get called S32 mHeldDownFrameDelay; // frames, after which held-down callbacks get called + S32 mLastDrawCharsCount; LLPointer mImageOverlay; LLFontGL::HAlign mImageOverlayAlignment; diff --git a/indra/llui/lldockablefloater.cpp b/indra/llui/lldockablefloater.cpp index 35b3e486af..f56cb2eee7 100644 --- a/indra/llui/lldockablefloater.cpp +++ b/indra/llui/lldockablefloater.cpp @@ -136,7 +136,15 @@ void LLDockableFloater::setMinimized(BOOL minimize) { setVisible(FALSE); } - setCanDock(!minimize); + + if (minimize) + { + setCanDock(false); + } + else if (!minimize && mDockControl.get() != NULL && mDockControl.get()->isDockVisible()) + { + setCanDock(true); + } LLFloater::setMinimized(minimize); } @@ -158,7 +166,10 @@ void LLDockableFloater::onDockHidden() void LLDockableFloater::onDockShown() { - setCanDock(TRUE); + if (!isMinimized()) + { + setCanDock(TRUE); + } } void LLDockableFloater::setDocked(bool docked, bool pop_on_undock) diff --git a/indra/llui/lldockcontrol.cpp b/indra/llui/lldockcontrol.cpp index cdcd823b1c..35a854267a 100644 --- a/indra/llui/lldockcontrol.cpp +++ b/indra/llui/lldockcontrol.cpp @@ -37,7 +37,7 @@ LLDockControl::LLDockControl(LLView* dockWidget, LLFloater* dockableFloater, const LLUIImagePtr& dockTongue, DocAt dockAt, get_allowed_rect_callback_t get_allowed_rect_callback) : - mDockWidget(dockWidget), mDockableFloater(dockableFloater), mDockTongue(dockTongue) + mDockWidget(dockWidget), mDockableFloater(dockableFloater), mDockTongue(dockTongue) { mDockAt = dockAt; @@ -63,6 +63,15 @@ LLDockControl::LLDockControl(LLView* dockWidget, LLFloater* dockableFloater, { repositionDockable(); } + + if (mDockWidget != NULL) + { + mDockWidgetVisible = isDockVisible(); + } + else + { + mDockWidgetVisible = false; + } } LLDockControl::~LLDockControl() @@ -75,6 +84,11 @@ void LLDockControl::setDock(LLView* dockWidget) if (mDockWidget != NULL) { repositionDockable(); + mDockWidgetVisible = isDockVisible(); + } + else + { + mDockWidgetVisible = false; } } @@ -88,11 +102,10 @@ void LLDockControl::repositionDockable() LLRect dockRect = mDockWidget->calcScreenRect(); LLRect rootRect; mGetAllowedRectCallback(rootRect); - static BOOL prev_visibility = !mDockWidget->getVisible(); // recalculate dockable position if dock position changed, dock visibility changed, // root view rect changed or recalculation is forced - if (mPrevDockRect != dockRect || prev_visibility != mDockWidget->getVisible() + if (mPrevDockRect != dockRect || mDockWidgetVisible != isDockVisible() || mRootRect != rootRect || mRecalculateDocablePosition) { // undock dockable and off() if dock not visible @@ -125,7 +138,7 @@ void LLDockControl::repositionDockable() mPrevDockRect = dockRect; mRootRect = rootRect; mRecalculateDocablePosition = false; - prev_visibility = mDockWidget->getVisible(); + mDockWidgetVisible = isDockVisible(); } } @@ -143,6 +156,8 @@ bool LLDockControl::isDockVisible() switch (mDockAt) { + case LEFT: // to keep compiler happy + break; case TOP: // check is dock inside parent rect LLRect dockParentRect = @@ -170,8 +185,27 @@ void LLDockControl::moveDockable() LLRect dockableRect = mDockableFloater->calcScreenRect(); S32 x = 0; S32 y = 0; + LLRect dockParentRect; switch (mDockAt) { + case LEFT: + x = dockRect.mLeft; + y = dockRect.mTop + mDockTongue->getHeight() + dockableRect.getHeight(); + // check is dockable inside root view rect + if (x < rootRect.mLeft) + { + x = rootRect.mLeft; + } + if (x + dockableRect.getWidth() > rootRect.mRight) + { + x = rootRect.mRight - dockableRect.getWidth(); + } + + mDockTongueX = x + dockableRect.getWidth()/2 - mDockTongue->getWidth() / 2; + + mDockTongueY = dockRect.mTop; + break; + case TOP: x = dockRect.getCenterX() - dockableRect.getWidth() / 2; y = dockRect.mTop + mDockTongue->getHeight() + dockableRect.getHeight(); @@ -187,8 +221,7 @@ void LLDockControl::moveDockable() // calculate dock tongue position - LLRect dockParentRect = - mDockWidget->getParent()->calcScreenRect(); + dockParentRect = mDockWidget->getParent()->calcScreenRect(); if (dockRect.getCenterX() < dockParentRect.mLeft) { mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2; diff --git a/indra/llui/lldockcontrol.h b/indra/llui/lldockcontrol.h index 756a2900d3..eaedb4c307 100644 --- a/indra/llui/lldockcontrol.h +++ b/indra/llui/lldockcontrol.h @@ -48,6 +48,7 @@ public: enum DocAt { TOP + ,LEFT }; public: @@ -80,6 +81,7 @@ private: get_allowed_rect_callback_t mGetAllowedRectCallback; bool mEnabled; bool mRecalculateDocablePosition; + bool mDockWidgetVisible; DocAt mDockAt; LLView* mDockWidget; LLRect mPrevDockRect; diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index bba5464b00..19f203b80c 100644 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -92,7 +92,7 @@ bool LLFlatListView::addItem(LLPanel * item, const LLSD& value /*= LLUUID::null* //_4 is for MASK item->setMouseDownCallback(boost::bind(&LLFlatListView::onItemMouseClick, this, new_pair, _4)); - item->setRightMouseDownCallback(boost::bind(&LLFlatListView::onItemMouseClick, this, new_pair, _4)); + item->setRightMouseDownCallback(boost::bind(&LLFlatListView::onItemRightMouseClick, this, new_pair, _4)); rearrangeItems(); notifyParentItemsRectChanged(); @@ -137,7 +137,7 @@ bool LLFlatListView::insertItemAfter(LLPanel* after_item, LLPanel* item_to_add, //_4 is for MASK item_to_add->setMouseDownCallback(boost::bind(&LLFlatListView::onItemMouseClick, this, new_pair, _4)); - item_to_add->setRightMouseDownCallback(boost::bind(&LLFlatListView::onItemMouseClick, this, new_pair, _4)); + item_to_add->setRightMouseDownCallback(boost::bind(&LLFlatListView::onItemRightMouseClick, this, new_pair, _4)); rearrangeItems(); notifyParentItemsRectChanged(); @@ -459,6 +459,20 @@ void LLFlatListView::onItemMouseClick(item_pair_t* item_pair, MASK mask) selectItemPair(item_pair, select_item); } +void LLFlatListView::onItemRightMouseClick(item_pair_t* item_pair, MASK mask) +{ + if (!item_pair) + return; + + // Forbid deselecting of items on right mouse button click if mMultipleSelection flag is set on, + // because some of derived classes may have context menu and selected items must be kept. + if ( !(mask & MASK_CONTROL) && mMultipleSelection && isSelected(item_pair) ) + return; + + // else got same behavior as at onItemMouseClick + onItemMouseClick(item_pair, mask); +} + LLFlatListView::item_pair_t* LLFlatListView::getItemPair(LLPanel* item) const { llassert(item); diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h index 888258efdc..97772bc677 100644 --- a/indra/llui/llflatlistview.h +++ b/indra/llui/llflatlistview.h @@ -304,6 +304,8 @@ protected: /** Manage selection on mouse events */ void onItemMouseClick(item_pair_t* item_pair, MASK mask); + void onItemRightMouseClick(item_pair_t* item_pair, MASK mask); + /** * Updates position of items. * It does not take into account invisible items. diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 24fd380bb1..bac5491943 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -401,6 +401,16 @@ void LLLayoutStack::collapsePanel(LLPanel* panel, BOOL collapsed) panel_container->mCollapsed = collapsed; } +void LLLayoutStack::updatePanelAutoResize(const std::string& panel_name, BOOL auto_resize) +{ + LayoutPanel* panel = findEmbeddedPanelByName(panel_name); + + if (panel) + { + panel->mAutoResize = auto_resize; + } +} + void LLLayoutStack::updateLayout(BOOL force_resize) { static LLUICachedControl resize_bar_overlap ("UIResizeBarOverlap", 0); @@ -713,6 +723,24 @@ LLLayoutStack::LayoutPanel* LLLayoutStack::findEmbeddedPanel(LLPanel* panelp) co return NULL; } +LLLayoutStack::LayoutPanel* LLLayoutStack::findEmbeddedPanelByName(const std::string& name) const +{ + LayoutPanel* result = NULL; + + for (e_panel_list_t::const_iterator panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) + { + LayoutPanel* p = *panel_it; + + if (p->mPanel->getName() == name) + { + result = p; + break; + } + } + + return result; +} + // Compute sum of min_width or min_height of children void LLLayoutStack::calcMinExtents() { diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 49cbe7270f..9ded48ef6a 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -80,6 +80,7 @@ public: void collapsePanel(LLPanel* panel, BOOL collapsed = TRUE); S32 getNumPanels() { return mPanels.size(); } + void updatePanelAutoResize(const std::string& panel_name, BOOL auto_resize); protected: LLLayoutStack(const Params&); friend class LLUICtrlFactory; @@ -96,7 +97,9 @@ private: typedef std::vector e_panel_list_t; e_panel_list_t mPanels; + LayoutPanel* findEmbeddedPanel(LLPanel* panelp) const; + LayoutPanel* findEmbeddedPanelByName(const std::string& name) const; S32 mMinWidth; // calculated by calcMinExtents S32 mMinHeight; // calculated by calcMinExtents -- cgit v1.2.3 From 53c972a521cbb92c6c9390c41b250a41dc22cd5a Mon Sep 17 00:00:00 2001 From: Steve Bennetts Date: Sun, 25 Oct 2009 23:05:15 -0700 Subject: * Changes to enable differentiating between icon texture priority and other UI texture priority. * Still need to only request smaller mip maps of icon textures --- indra/llui/lliconctrl.cpp | 7 ++++--- indra/llui/lliconctrl.h | 5 ++++- indra/llui/llui.cpp | 8 ++++---- indra/llui/llui.h | 8 ++++---- 4 files changed, 16 insertions(+), 12 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lliconctrl.cpp b/indra/llui/lliconctrl.cpp index 0330a2b374..66c2ba682f 100644 --- a/indra/llui/lliconctrl.cpp +++ b/indra/llui/lliconctrl.cpp @@ -56,7 +56,8 @@ LLIconCtrl::Params::Params() LLIconCtrl::LLIconCtrl(const LLIconCtrl::Params& p) : LLUICtrl(p), mColor(p.color()), - mImagep(p.image) + mImagep(p.image), + mPriority(0) { if (mImagep.notNull()) { @@ -93,11 +94,11 @@ void LLIconCtrl::setValue(const LLSD& value ) LLUICtrl::setValue(tvalue); if (tvalue.isUUID()) { - mImagep = LLUI::getUIImageByID(tvalue.asUUID()); + mImagep = LLUI::getUIImageByID(tvalue.asUUID(), mPriority); } else { - mImagep = LLUI::getUIImage(tvalue.asString()); + mImagep = LLUI::getUIImage(tvalue.asString(), mPriority); } } diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h index ff25b0d53e..90f1693060 100644 --- a/indra/llui/lliconctrl.h +++ b/indra/llui/lliconctrl.h @@ -72,10 +72,13 @@ public: std::string getImageName() const; void setColor(const LLColor4& color) { mColor = color; } + +protected: + S32 mPriority; private: LLUIColor mColor; - LLPointer mImagep; + LLPointer mImagep; }; #endif diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index da9384f876..48504a1e54 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -1807,11 +1807,11 @@ void LLUI::glRectToScreen(const LLRect& gl, LLRect *screen) } //static -LLPointer LLUI::getUIImageByID(const LLUUID& image_id) +LLPointer LLUI::getUIImageByID(const LLUUID& image_id, S32 priority) { if (sImageProvider) { - return sImageProvider->getUIImageByID(image_id); + return sImageProvider->getUIImageByID(image_id, priority); } else { @@ -1820,10 +1820,10 @@ LLPointer LLUI::getUIImageByID(const LLUUID& image_id) } //static -LLPointer LLUI::getUIImage(const std::string& name) +LLPointer LLUI::getUIImage(const std::string& name, S32 priority) { if (!name.empty() && sImageProvider) - return sImageProvider->getUIImage(name); + return sImageProvider->getUIImage(name, priority); else return NULL; } diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 6ab78ab3cd..efb1b0a36f 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -195,8 +195,8 @@ public: static void getMousePositionLocal(const LLView* viewp, S32 *x, S32 *y); static void setScaleFactor(const LLVector2& scale_factor); static void setLineWidth(F32 width); - static LLPointer getUIImageByID(const LLUUID& image_id); - static LLPointer getUIImage(const std::string& name); + static LLPointer getUIImageByID(const LLUUID& image_id, S32 priority = 0); + static LLPointer getUIImage(const std::string& name, S32 priority = 0); static LLVector2 getWindowSize(); static void screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y); static void glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y); @@ -241,8 +241,8 @@ protected: LLImageProviderInterface() {}; virtual ~LLImageProviderInterface() {}; public: - virtual LLPointer getUIImage(const std::string& name) = 0; - virtual LLPointer getUIImageByID(const LLUUID& id) = 0; + virtual LLPointer getUIImage(const std::string& name, S32 priority) = 0; + virtual LLPointer getUIImageByID(const LLUUID& id, S32 priority) = 0; virtual void cleanUp() = 0; }; -- cgit v1.2.3