diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llconsole.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 86 | ||||
-rw-r--r-- | indra/llui/llfloater.h | 7 | ||||
-rw-r--r-- | indra/llui/llfloaterreg.cpp | 28 | ||||
-rw-r--r-- | indra/llui/llfloaterreg.h | 2 | ||||
-rw-r--r-- | indra/llui/lllayoutstack.cpp | 5 | ||||
-rw-r--r-- | indra/llui/lllineeditor.cpp | 33 | ||||
-rw-r--r-- | indra/llui/lllineeditor.h | 3 | ||||
-rw-r--r-- | indra/llui/llpanel.cpp | 6 | ||||
-rw-r--r-- | indra/llui/llpanel.h | 5 | ||||
-rw-r--r-- | indra/llui/llspinctrl.cpp | 23 | ||||
-rw-r--r-- | indra/llui/llui.cpp | 21 | ||||
-rw-r--r-- | indra/llui/llui.h | 5 |
13 files changed, 158 insertions, 70 deletions
diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp index 04040200d0..161496b1f5 100644 --- a/indra/llui/llconsole.cpp +++ b/indra/llui/llconsole.cpp @@ -372,9 +372,7 @@ LLConsole::Paragraph::Paragraph (LLWString str, const LLColor4 &color, F32 add_t // static void LLConsole::updateClass() { - LLInstanceTrackerScopedGuard guard; - - for (instance_iter it = guard.beginInstances(); it != guard.endInstances(); ++it) + for (instance_iter it = beginInstances(); it != endInstances(); ++it) { it->update(); } diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index d19e33ea55..43a37d6dff 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -766,7 +766,6 @@ void LLFloater::closeFloater(bool app_quitting) void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent) { LLPanel::reshape(width, height, called_from_parent); - storeRectControl(); } void LLFloater::releaseFocus() @@ -968,6 +967,11 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user) const LLRect old_rect = getRect(); LLView::handleReshape(new_rect, by_user); + if (by_user) + { + storeRectControl(); + } + // if not minimized, adjust all snapped dependents to new shape if (!isMinimized()) { @@ -2048,7 +2052,6 @@ static LLDefaultChildRegistry::Register<LLFloaterView> r("floater_view"); LLFloaterView::LLFloaterView (const Params& p) : LLUICtrl (p), - mFocusCycleMode(FALSE), mMinimizePositionVOffset(0), mSnapOffsetBottom(0), @@ -2059,12 +2062,6 @@ LLFloaterView::LLFloaterView (const Params& p) // By default, adjust vertical. void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent) { - reshapeFloater(width, height, called_from_parent, ADJUST_VERTICAL_YES); -} - -// When reshaping this view, make the floaters follow their closest edge. -void LLFloaterView::reshapeFloater(S32 width, S32 height, BOOL called_from_parent, BOOL adjust_vertical) -{ S32 old_width = getRect().getWidth(); S32 old_height = getRect().getHeight(); @@ -2109,11 +2106,7 @@ void LLFloaterView::reshapeFloater(S32 width, S32 height, BOOL called_from_paren // "No vertical adjustment" usually means that the bottom of the view // has been pushed up or down. Hence we want the floaters to follow // the top. - if (!adjust_vertical) - { - follow_flags |= FOLLOWS_TOP; - } - else if (top_offset < bottom_offset) + if (top_offset < bottom_offset) { follow_flags |= FOLLOWS_TOP; } @@ -2847,7 +2840,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p) mAutoTile = p.auto_tile; mOpenCentered = p.open_centered; - if (p.save_rect) + if (p.save_rect && mRectControl.empty()) { mRectControl = "t"; // flag to build mRectControl name once mInstanceName is set } @@ -2885,13 +2878,54 @@ boost::signals2::connection LLFloater::setCloseCallback( const commit_signal_t:: } LLFastTimer::DeclareTimer POST_BUILD("Floater Post Build"); +static LLFastTimer::DeclareTimer FTM_EXTERNAL_FLOATER_LOAD("Load Extern Floater Reference"); bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::string& filename, LLXMLNodePtr output_node) { - Params params(LLUICtrlFactory::getDefaultParams<LLFloater>()); + Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>()); + Params params(default_params); + LLXUIParser parser; parser.readXUI(node, params, filename); // *TODO: Error checking + std::string xml_filename = params.filename; + + if (!xml_filename.empty()) + { + LLXMLNodePtr referenced_xml; + + if (output_node) + { + //if we are exporting, we want to export the current xml + //not the referenced xml + Params output_params; + parser.readXUI(node, output_params, LLUICtrlFactory::getInstance()->getCurFileName()); + setupParamsForExport(output_params, parent); + output_node->setName(node->getName()->mString); + parser.writeXUI(output_node, output_params, &default_params); + return TRUE; + } + + LLUICtrlFactory::instance().pushFileName(xml_filename); + + LLFastTimer _(FTM_EXTERNAL_FLOATER_LOAD); + if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml)) + { + llwarns << "Couldn't parse panel from: " << xml_filename << llendl; + + return FALSE; + } + + parser.readXUI(referenced_xml, params, LLUICtrlFactory::getInstance()->getCurFileName()); + + // add children using dimensions from referenced xml for consistent layout + setShape(params.rect); + LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance()); + + LLUICtrlFactory::instance().popFileName(); + } + + if (output_node) { Params output_params(params); @@ -2912,7 +2946,6 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str { params.rect.left.set(0); } - params.from_xui = true; applyXUILayout(params, parent); initFromParams(params); @@ -3054,3 +3087,24 @@ bool LLFloater::buildFromFile(const std::string& filename, LLXMLNodePtr output_n return res; } + +void LLFloater::stackWith(LLFloater& other) +{ + static LLUICachedControl<S32> floater_offset ("UIFloaterOffset", 16); + + LLRect next_rect; + if (other.getHost()) + { + next_rect = other.getHost()->getRect(); + } + else + { + next_rect = other.getRect(); + } + next_rect.translate(floater_offset, -floater_offset); + + next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, getRect().getWidth(), getRect().getHeight()); + + mRectControl.clear(); // don't save rect of stacked floaters + setShape(next_rect); +}
\ No newline at end of file diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 9aae1afc62..58c2d34253 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -265,6 +265,8 @@ public: virtual void setTornOff(bool torn_off) { mTornOff = torn_off; } + void stackWith(LLFloater& other); + // Return a closeable floater, if any, given the current focus. static LLFloater* getClosableFloaterFromFocus(); @@ -289,9 +291,6 @@ public: void updateTransparency(ETypeTransparency transparency_type); protected: - - void setRectControl(const std::string& rectname) { mRectControl = rectname; }; - virtual void applySavedVariables(); void applyRectControl(); @@ -455,8 +454,6 @@ protected: public: /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); - void reshapeFloater(S32 width, S32 height, BOOL called_from_parent, BOOL adjust_vertical); - /*virtual*/ void draw(); /*virtual*/ LLRect getSnapRect() const; /*virtual*/ void refresh(); diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index f5e6444287..1463d0bfbb 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -57,7 +57,7 @@ void LLFloaterReg::add(const std::string& name, const std::string& filename, con } //static -LLRect LLFloaterReg::getFloaterRect(const std::string& name) +LLFloater* LLFloaterReg::getLastFloaterInGroup(const std::string& name) { LLRect rect; const std::string& groupname = sGroupMap[name]; @@ -66,20 +66,10 @@ LLRect LLFloaterReg::getFloaterRect(const std::string& name) instance_list_t& list = sInstanceMap[groupname]; if (!list.empty()) { - static LLUICachedControl<S32> floater_offset ("UIFloaterOffset", 16); - LLFloater* last_floater = list.back(); - if (last_floater->getHost()) - { - rect = last_floater->getHost()->getRect(); - } - else - { - rect = last_floater->getRect(); - } - rect.translate(floater_offset, -floater_offset); + return list.back(); } } - return rect; + return NULL; } //static @@ -137,12 +127,12 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) res->applySavedVariables(); // Can't apply rect and dock state until setting instance name if (res->mAutoTile && !res->getHost() && index > 0) { - const LLRect& cur_rect = res->getRect(); - LLRect next_rect = getFloaterRect(groupname); - next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, cur_rect.getWidth(), cur_rect.getHeight()); - res->setRect(next_rect); - res->setRectControl(LLStringUtil::null); // don't save rect of tiled floaters - gFloaterView->adjustToFitScreen(res, true); + LLFloater* last_floater = getLastFloaterInGroup(groupname); + if (last_floater) + { + res->stackWith(*last_floater); + gFloaterView->adjustToFitScreen(res, true); + } } else { diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index 8414b92113..a2027a77a0 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -86,7 +86,7 @@ public: const std::string& groupname = LLStringUtil::null); // Helpers - static LLRect getFloaterRect(const std::string& name); + static LLFloater* getLastFloaterInGroup(const std::string& name); // Find / get (create) / remove / destroy static LLFloater* findInstance(const std::string& name, const LLSD& key = LLSD()); diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 6a91ec56e4..a59247ba09 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -713,10 +713,7 @@ void LLLayoutStack::createResizeBars() //static void LLLayoutStack::updateClass() { - LLInstanceTrackerScopedGuard guard; - for (LLLayoutStack::instance_iter it = guard.beginInstances(); - it != guard.endInstances(); - ++it) + for (instance_iter it = beginInstances(); it != endInstances(); ++it) { it->updateLayout(); } diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 123997e5e9..06fbc0f234 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -37,6 +37,7 @@ #include "llgl.h" #include "lltimer.h" +#include "llcalc.h" //#include "llclipboard.h" #include "llcontrol.h" #include "llbutton.h" @@ -133,6 +134,7 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p) mIgnoreTab( p.ignore_tab ), mDrawAsterixes( p.is_password ), mSelectAllonFocusReceived( p.select_on_focus ), + mSelectAllonCommit( TRUE ), mPassDelete(FALSE), mReadOnly(FALSE), mBgImage( p.background_image ), @@ -230,7 +232,10 @@ void LLLineEditor::onCommit() setControlValue(getValue()); LLUICtrl::onCommit(); - selectAll(); + + // Selection on commit needs to be turned off when evaluating maths + // expressions, to allow indication of the error position + if (mSelectAllonCommit) selectAll(); } // Returns TRUE if user changed value at all @@ -2072,6 +2077,32 @@ BOOL LLLineEditor::postvalidateFloat(const std::string &str) return success; } +BOOL LLLineEditor::evaluateFloat() +{ + bool success; + F32 result = 0.f; + std::string expr = getText(); + LLStringUtil::toUpper(expr); + + success = LLCalc::getInstance()->evalString(expr, result); + + if (!success) + { + // Move the cursor to near the error on failure + setCursor(LLCalc::getInstance()->getLastErrorPos()); + // *TODO: Translated error message indicating the type of error? Select error text? + } + else + { + // Replace the expression with the result + std::string result_str = llformat("%f",result); + setText(result_str); + selectAll(); + } + + return success; +} + void LLLineEditor::onMouseCaptureLost() { endSelection(); diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 4b77708590..583bde360a 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -221,6 +221,7 @@ public: void deleteSelection(); void setSelectAllonFocusReceived(BOOL b); + void setSelectAllonCommit(BOOL b) { mSelectAllonCommit = b; } typedef boost::function<void (LLLineEditor* caller, void* user_data)> callback_t; void setKeystrokeCallback(callback_t callback, void* user_data); @@ -241,6 +242,7 @@ public: static BOOL postvalidateFloat(const std::string &str); bool prevalidateInput(const LLWString& wstr); + BOOL evaluateFloat(); // line history support: void setEnableLineHistory( BOOL enabled ) { mHaveHistory = enabled; } // switches line history on or off @@ -340,6 +342,7 @@ protected: BOOL mDrawAsterixes; BOOL mSelectAllonFocusReceived; + BOOL mSelectAllonCommit; BOOL mPassDelete; BOOL mReadOnly; diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 775db6bc9d..e3193bc352 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -515,9 +515,6 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu if (!xml_filename.empty()) { - LLUICtrlFactory::instance().pushFileName(xml_filename); - - LLFastTimer timer(FTM_EXTERNAL_PANEL_LOAD); if (output_node) { //if we are exporting, we want to export the current xml @@ -530,6 +527,9 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu return TRUE; } + LLUICtrlFactory::instance().pushFileName(xml_filename); + + LLFastTimer timer(FTM_EXTERNAL_PANEL_LOAD); if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml)) { llwarns << "Couldn't parse panel from: " << xml_filename << llendl; diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 1b777ee1cb..790025cb2d 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -265,6 +265,9 @@ protected: std::string mHelpTopic; // the name of this panel's help topic to display in the Help Viewer typedef std::deque<const LLCallbackMap::map_t*> factory_stack_t; static factory_stack_t sFactoryStack; + + // for setting the xml filename when building panel in context dependent cases + std::string mXMLFilename; private: BOOL mBgVisible; // any background at all? @@ -283,8 +286,6 @@ private: typedef std::map<std::string, std::string> ui_string_map_t; ui_string_map_t mUIStrings; - // for setting the xml filename when building panel in context dependent cases - std::string mXMLFilename; }; // end class LLPanel diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp index 15a7438ec9..934879cdfd 100644 --- a/indra/llui/llspinctrl.cpp +++ b/indra/llui/llspinctrl.cpp @@ -44,7 +44,7 @@ #include "llresmgr.h" #include "lluictrlfactory.h" -const U32 MAX_STRING_LENGTH = 32; +const U32 MAX_STRING_LENGTH = 255; static LLDefaultChildRegistry::Register<LLSpinCtrl> r2("spinner"); @@ -124,14 +124,7 @@ LLSpinCtrl::LLSpinCtrl(const LLSpinCtrl::Params& p) params.max_length.bytes(MAX_STRING_LENGTH); params.commit_callback.function((boost::bind(&LLSpinCtrl::onEditorCommit, this, _2))); - if( mPrecision>0 )//should accept float numbers - { - params.prevalidate_callback(&LLTextValidate::validateFloat); - } - else //should accept int numbers - { - params.prevalidate_callback(&LLTextValidate::validateInt); - } + //*NOTE: allow entering of any chars for LLCalc, proper input will be evaluated on commit params.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM); mEditor = LLUICtrlFactory::create<LLLineEditor> (params); @@ -140,6 +133,7 @@ LLSpinCtrl::LLSpinCtrl(const LLSpinCtrl::Params& p) // than when it doesn't. Instead, if you always have to double click to select all the text, // it's easier to understand //mEditor->setSelectAllonFocusReceived(TRUE); + mEditor->setSelectAllonCommit(FALSE); addChild(mEditor); updateEditor(); @@ -304,9 +298,10 @@ void LLSpinCtrl::onEditorCommit( const LLSD& data ) { BOOL success = FALSE; - std::string text = mEditor->getText(); - if( LLLineEditor::postvalidateFloat( text ) ) + if( mEditor->evaluateFloat() ) { + std::string text = mEditor->getText(); + LLLocale locale(LLLocale::USER_LOCALE); F32 val = (F32) atof(text.c_str()); @@ -327,7 +322,11 @@ void LLSpinCtrl::onEditorCommit( const LLSD& data ) } updateEditor(); - if( !success ) + if( success ) + { + updateEditor(); + } + else { reportInvalidData(); } diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index bc2432f6f7..58ba9e05f5 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -95,7 +95,6 @@ static LLDefaultChildRegistry::Register<LLSearchEditor> register_search_editor(" // register other widgets which otherwise may not be linked in static LLDefaultChildRegistry::Register<LLLoadingIndicator> register_loading_indicator("loading_indicator"); - // // Functions // @@ -524,8 +523,15 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex if (solid_color) { - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); - gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA); + if (LLGLSLShader::sNoFixedFunction) + { + gSolidColorProgram.bind(); + } + else + { + gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); + gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA); + } } gGL.getTexUnit(0)->bind(image); @@ -699,7 +705,14 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex if (solid_color) { - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + else + { + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } } } diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 4e622033b3..7801a01ace 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -33,6 +33,7 @@ #include "llrect.h" #include "llcontrol.h" #include "llcoord.h" +#include "llglslshader.h" #include "llinitparam.h" #include "llregistry.h" #include "lluicolor.h" @@ -47,6 +48,7 @@ // for initparam specialization #include "llfontgl.h" + class LLColor4; class LLVector3; class LLVector2; @@ -484,4 +486,7 @@ namespace LLInitParam }; } +extern LLGLSLShader gSolidColorProgram; +extern LLGLSLShader gUIProgram; + #endif |