diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/llui/llbutton.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llbutton.h | 2 | ||||
-rw-r--r-- | indra/llui/llcheckboxctrl.cpp | 6 | ||||
-rw-r--r-- | indra/llui/llcombobox.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 2 | ||||
-rw-r--r-- | indra/llui/lllineeditor.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llmenugl.cpp | 12 | ||||
-rw-r--r-- | indra/llui/llmultisliderctrl.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llresmgr.cpp | 10 | ||||
-rw-r--r-- | indra/llui/llscrollbar.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llscrolllistctrl.cpp | 8 | ||||
-rw-r--r-- | indra/llui/llsliderctrl.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llspinctrl.cpp | 4 | ||||
-rw-r--r-- | indra/llui/lltabcontainer.cpp | 8 | ||||
-rw-r--r-- | indra/llui/lltextbox.cpp | 8 | ||||
-rw-r--r-- | indra/llui/lltexteditor.cpp | 88 | ||||
-rw-r--r-- | indra/llui/lltexteditor.h | 13 | ||||
-rw-r--r-- | indra/llui/lltextparser.cpp | 298 | ||||
-rw-r--r-- | indra/llui/lltextparser.h | 48 | ||||
-rw-r--r-- | indra/llui/lluictrlfactory.cpp | 6 | ||||
-rw-r--r-- | indra/llui/lluictrlfactory.h | 2 | ||||
-rw-r--r-- | indra/llui/llview.cpp | 39 |
23 files changed, 505 insertions, 67 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 8ae0137a5e..32118e8a69 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -64,6 +64,7 @@ set(llui_SOURCE_FILES lltabcontainervertical.cpp lltextbox.cpp lltexteditor.cpp + lltextparser.cpp llui.cpp lluictrl.cpp lluictrlfactory.cpp @@ -119,6 +120,7 @@ set(llui_HEADER_FILES lltabcontainervertical.h lltextbox.h lltexteditor.h + lltextparser.h lluiconstants.h lluictrlfactory.h lluictrl.h diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 309919b874..2c2c1c25d8 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -188,7 +188,7 @@ LLButton::LLButton(const std::string& name, const LLRect& rect, void LLButton::init(void (*click_callback)(void*), void *callback_data, const LLFontGL* font, const std::string& control_name) { - mGLFont = ( font ? font : LLFontGL::sSansSerif); + mGLFont = ( font ? font : LLFontGL::getFontSansSerif()); // Hack to make sure there is space for at least one character if (getRect().getWidth() - (mRightHPad + mLeftHPad) < mGLFont->getWidth(std::string(" "))) diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 285c55e633..724b77541a 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -164,7 +164,7 @@ public: void setDisabledLabelColor( const LLColor4& c ) { mDisabledLabelColor = c; } void setFont(const LLFontGL *font) - { mGLFont = ( font ? font : LLFontGL::sSansSerif); } + { mGLFont = ( font ? font : LLFontGL::getFontSansSerif()); } void setScaleImage(BOOL scale) { mScaleImage = scale; } BOOL getScaleImage() const { return mScaleImage; } diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp index f351d3a7f2..eda9467d87 100644 --- a/indra/llui/llcheckboxctrl.cpp +++ b/indra/llui/llcheckboxctrl.cpp @@ -73,7 +73,7 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const std::string& name, const LLRect& rect, } else { - mFont = LLFontGL::sSansSerifSmall; + mFont = LLFontGL::getFontSansSerifSmall(); } // must be big enough to hold all children @@ -123,7 +123,7 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const std::string& name, const LLRect& rect, inactive_false_id = "UIImgRadioInactiveUUID"; mButton = new LLButton(std::string("Radio control button"), btn_rect, active_false_id, active_true_id, control_which, - &LLCheckBoxCtrl::onButtonPress, this, LLFontGL::sSansSerif ); + &LLCheckBoxCtrl::onButtonPress, this, LLFontGL::getFontSansSerif() ); mButton->setDisabledImages( inactive_false_id, inactive_true_id ); mButton->setHoverGlowStrength(0.35f); } @@ -135,7 +135,7 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const std::string& name, const LLRect& rect, inactive_false_id = "UIImgCheckboxInactiveUUID"; mButton = new LLButton(std::string("Checkbox control button"), btn_rect, active_false_id, active_true_id, control_which, - &LLCheckBoxCtrl::onButtonPress, this, LLFontGL::sSansSerif ); + &LLCheckBoxCtrl::onButtonPress, this, LLFontGL::getFontSansSerif() ); mButton->setDisabledImages( inactive_false_id, inactive_true_id ); mButton->setHoverGlowStrength(0.35f); } diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index fd17a16a37..28a05c13f5 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -89,7 +89,7 @@ LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std:: mButton->setScaleImage(TRUE); mButton->setMouseDownCallback(onButtonDown); - mButton->setFont(LLFontGL::sSansSerifSmall); + mButton->setFont(LLFontGL::getFontSansSerifSmall()); mButton->setFollows(FOLLOWS_LEFT | FOLLOWS_BOTTOM | FOLLOWS_RIGHT); mButton->setHAlign( LLFontGL::LEFT ); mButton->setRightHPad(2); @@ -517,7 +517,7 @@ void LLComboBox::updateLayout() mTextEntry = new LLLineEditor(std::string("combo_text_entry"), text_entry_rect, LLStringUtil::null, - LLFontGL::sSansSerifSmall, + LLFontGL::getFontSansSerifSmall(), mMaxChars, onTextCommit, onTextEntry, diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 3d92280828..94af1868be 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1703,7 +1703,7 @@ void LLFloater::buildButtons() LLStringUtil::null, sButtonCallbacks[i], this, - LLFontGL::sSansSerif); + LLFontGL::getFontSansSerif()); buttonp->setTabStop(FALSE); buttonp->setFollowsTop(); diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 609763ce15..6aa2aac48c 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -152,7 +152,7 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, } else { - mGLFont = LLFontGL::sSansSerifSmall; + mGLFont = LLFontGL::getFontSansSerifSmall(); } setFocusLostCallback(focus_lost_callback); diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 64649b664c..f2f2aae382 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -142,7 +142,7 @@ LLMenuItemGL::LLMenuItemGL( const std::string& name, const std::string& label, K mHighlight( FALSE ), mGotHover( FALSE ), mBriefItem( FALSE ), - mFont( LLFontGL::sSansSerif ), + mFont( LLFontGL::getFontSansSerif() ), mStyle(LLFontGL::NORMAL), mDrawTextDisabled( FALSE ) { @@ -2168,8 +2168,8 @@ void LLMenuGL::arrange( void ) U32 max_width = getTornOff() ? U32_MAX : menu_region_rect.getWidth(); U32 max_height = getTornOff() ? U32_MAX : menu_region_rect.getHeight(); // *FIX: create the item first and then ask for its dimensions? - S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::sSansSerif->getWidth( std::string("More") ); - S32 spillover_item_height = llround(LLFontGL::sSansSerif->getLineHeight()) + MENU_ITEM_PADDING; + S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::getFontSansSerif()->getWidth( std::string("More") ); + S32 spillover_item_height = llround(LLFontGL::getFontSansSerif()->getLineHeight()) + MENU_ITEM_PADDING; if (mHorizontalLayout) { @@ -3495,7 +3495,7 @@ void LLPieMenu::drawBackground(LLMenuItemGL* itemp, LLColor4& color) BOOL LLPieMenu::append(LLMenuItemGL *item) { item->setBriefItem(TRUE); - item->setFont( LLFontGL::sSansSerifSmall ); + item->setFont( LLFontGL::getFontSansSerifSmall() ); return LLMenuGL::append(item); } @@ -3503,7 +3503,7 @@ BOOL LLPieMenu::append(LLMenuItemGL *item) BOOL LLPieMenu::appendSeparator(const std::string &separator_name) { LLMenuItemGL* separator = new LLMenuItemBlankGL(); - separator->setFont( LLFontGL::sSansSerifSmall ); + separator->setFont( LLFontGL::getFontSansSerifSmall() ); return append( separator ); } @@ -3517,7 +3517,7 @@ BOOL LLPieMenu::appendPieMenu(LLPieMenu *menu) LLPieMenuBranch *item; item = new LLPieMenuBranch(menu->getName(), menu->getLabel(), menu); getParent()->addChild(item->getBranch()); - item->setFont( LLFontGL::sSansSerifSmall ); + item->setFont( LLFontGL::getFontSansSerifSmall() ); return append( item ); } diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp index bbbd138e26..8bcf9f9b76 100644 --- a/indra/llui/llmultisliderctrl.cpp +++ b/indra/llui/llmultisliderctrl.cpp @@ -544,7 +544,7 @@ LLView* LLMultiSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFa // HACK: Font might not be specified. if (!font) { - font = LLFontGL::sSansSerifSmall; + font = LLFontGL::getFontSansSerifSmall(); } S32 label_width = 0; diff --git a/indra/llui/llresmgr.cpp b/indra/llui/llresmgr.cpp index b751c171f6..32d3d1f752 100644 --- a/indra/llui/llresmgr.cpp +++ b/indra/llui/llresmgr.cpp @@ -55,11 +55,11 @@ LLResMgr::LLResMgr() { mUSAFonts[i] = NULL; } - mUSAFonts[ LLFONT_OCRA ] = LLFontGL::sMonospace; - mUSAFonts[ LLFONT_SANSSERIF ] = LLFontGL::sSansSerif; - mUSAFonts[ LLFONT_SANSSERIF_SMALL ] = LLFontGL::sSansSerifSmall; - mUSAFonts[ LLFONT_SANSSERIF_BIG ] = LLFontGL::sSansSerifBig; - mUSAFonts[ LLFONT_SMALL ] = LLFontGL::sMonospace; + mUSAFonts[ LLFONT_OCRA ] = LLFontGL::getFontMonospace(); + mUSAFonts[ LLFONT_SANSSERIF ] = LLFontGL::getFontSansSerif(); + mUSAFonts[ LLFONT_SANSSERIF_SMALL ] = LLFontGL::getFontSansSerifSmall(); + mUSAFonts[ LLFONT_SANSSERIF_BIG ] = LLFontGL::getFontSansSerifBig(); + mUSAFonts[ LLFONT_SMALL ] = LLFontGL::getFontMonospace(); /* // USA Strings for( i=0; i<LLSTR_COUNT; i++ ) diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index 3972c01831..65086d833d 100644 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -114,7 +114,7 @@ LLScrollbar::LLScrollbar( LLButton* line_up_btn = new LLButton(std::string("Line Up"), line_up_rect, line_up_img, line_up_selected_img, LLStringUtil::null, - &LLScrollbar::onLineUpBtnPressed, this, LLFontGL::sSansSerif ); + &LLScrollbar::onLineUpBtnPressed, this, LLFontGL::getFontSansSerif() ); if( LLScrollbar::VERTICAL == mOrientation ) { line_up_btn->setFollowsRight(); @@ -134,7 +134,7 @@ LLScrollbar::LLScrollbar( LLButton* line_down_btn = new LLButton(std::string("Line Down"), line_down_rect, line_down_img, line_down_selected_img, LLStringUtil::null, - &LLScrollbar::onLineDownBtnPressed, this, LLFontGL::sSansSerif ); + &LLScrollbar::onLineDownBtnPressed, this, LLFontGL::getFontSansSerif() ); line_down_btn->setFollowsRight(); line_down_btn->setFollowsBottom(); line_down_btn->setHeldDownCallback( &LLScrollbar::onLineDownBtnPressed ); diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 45ee78507e..7b6c125eb1 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -957,14 +957,14 @@ void LLScrollListCtrl::calcColumnWidths() column->setWidth(new_width); // update max content width for this column, by looking at all items - column->mMaxContentWidth = column->mHeader ? LLFontGL::sSansSerifSmall->getWidth(column->mLabel) + mColumnPadding + HEADING_TEXT_PADDING : 0; + column->mMaxContentWidth = column->mHeader ? LLFontGL::getFontSansSerifSmall()->getWidth(column->mLabel) + mColumnPadding + HEADING_TEXT_PADDING : 0; item_list::iterator iter; for (iter = mItemList.begin(); iter != mItemList.end(); iter++) { LLScrollListCell* cellp = (*iter)->getColumn(column->mIndex); if (!cellp) continue; - column->mMaxContentWidth = llmax(LLFontGL::sSansSerifSmall->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth); + column->mMaxContentWidth = llmax(LLFontGL::getFontSansSerifSmall()->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth); } max_item_width += column->mMaxContentWidth; @@ -3711,8 +3711,8 @@ void LLColumnHeader::showList() descending_string = mDescendingText.getString(); } - S32 text_width = LLFontGL::sSansSerifSmall->getWidth(ascending_string); - text_width = llmax(text_width, LLFontGL::sSansSerifSmall->getWidth(descending_string)) + 10; + 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); diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp index f603fc5119..31baddd7cc 100644 --- a/indra/llui/llsliderctrl.cpp +++ b/indra/llui/llsliderctrl.cpp @@ -464,7 +464,7 @@ LLView* LLSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory // HACK: Font might not be specified. if (!font) { - font = LLFontGL::sSansSerifSmall; + font = LLFontGL::getFontSansSerifSmall(); } S32 label_width = 0; diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp index b0a52a1ed3..c54a2cd140 100644 --- a/indra/llui/llspinctrl.cpp +++ b/indra/llui/llspinctrl.cpp @@ -99,7 +99,7 @@ LLSpinCtrl::LLSpinCtrl( const std::string& name, const LLRect& rect, const std:: out_id, in_id, LLStringUtil::null, - &LLSpinCtrl::onUpBtn, this, LLFontGL::sSansSerif ); + &LLSpinCtrl::onUpBtn, this, LLFontGL::getFontSansSerif() ); mUpBtn->setFollowsLeft(); mUpBtn->setFollowsBottom(); mUpBtn->setHeldDownCallback( &LLSpinCtrl::onUpBtn ); @@ -113,7 +113,7 @@ LLSpinCtrl::LLSpinCtrl( const std::string& name, const LLRect& rect, const std:: out_id, in_id, LLStringUtil::null, - &LLSpinCtrl::onDownBtn, this, LLFontGL::sSansSerif ); + &LLSpinCtrl::onDownBtn, this, LLFontGL::getFontSansSerif() ); mDownBtn->setFollowsLeft(); mDownBtn->setFollowsBottom(); mDownBtn->setHeldDownCallback( &LLSpinCtrl::onDownBtn ); diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index e3ebd0057d..f4169488d4 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -1658,14 +1658,14 @@ void LLTabContainer::initButtons() in_id = "UIImgBtnJumpLeftInUUID"; mJumpPrevArrowBtn = new LLButton(std::string("Jump Left Arrow"), jump_left_arrow_btn_rect, out_id, in_id, LLStringUtil::null, - &LLTabContainer::onJumpFirstBtn, this, LLFontGL::sSansSerif ); + &LLTabContainer::onJumpFirstBtn, this, LLFontGL::getFontSansSerif() ); mJumpPrevArrowBtn->setFollowsLeft(); out_id = "UIImgBtnScrollLeftOutUUID"; in_id = "UIImgBtnScrollLeftInUUID"; mPrevArrowBtn = new LLButton(std::string("Left Arrow"), left_arrow_btn_rect, out_id, in_id, LLStringUtil::null, - &LLTabContainer::onPrevBtn, this, LLFontGL::sSansSerif ); + &LLTabContainer::onPrevBtn, this, LLFontGL::getFontSansSerif() ); mPrevArrowBtn->setHeldDownCallback(onPrevBtnHeld); mPrevArrowBtn->setFollowsLeft(); @@ -1674,7 +1674,7 @@ void LLTabContainer::initButtons() mJumpNextArrowBtn = new LLButton(std::string("Jump Right Arrow"), jump_right_arrow_btn_rect, out_id, in_id, LLStringUtil::null, &LLTabContainer::onJumpLastBtn, this, - LLFontGL::sSansSerif); + LLFontGL::getFontSansSerif()); mJumpNextArrowBtn->setFollowsRight(); out_id = "UIImgBtnScrollRightOutUUID"; @@ -1682,7 +1682,7 @@ void LLTabContainer::initButtons() mNextArrowBtn = new LLButton(std::string("Right Arrow"), right_arrow_btn_rect, out_id, in_id, LLStringUtil::null, &LLTabContainer::onNextBtn, this, - LLFontGL::sSansSerif); + LLFontGL::getFontSansSerif()); mNextArrowBtn->setFollowsRight(); if( getTabPosition() == TOP ) diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index ccaafab14d..2348ef314c 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -41,7 +41,7 @@ static LLRegisterWidget<LLTextBox> r("text"); LLTextBox::LLTextBox(const std::string& name, const LLRect& rect, const std::string& text, const LLFontGL* font, BOOL mouse_opaque) : LLUICtrl(name, rect, mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP ), - mFontGL(font ? font : LLFontGL::sSansSerifSmall) + mFontGL(font ? font : LLFontGL::getFontSansSerifSmall()) { initDefaults(); setText( text ); @@ -51,7 +51,7 @@ LLTextBox::LLTextBox(const std::string& name, const LLRect& rect, const std::str LLTextBox::LLTextBox(const std::string& name, const std::string& text, F32 max_width, const LLFontGL* font, BOOL mouse_opaque) : LLUICtrl(name, LLRect(0, 0, 1, 1), mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP), - mFontGL(font ? font : LLFontGL::sSansSerifSmall) + mFontGL(font ? font : LLFontGL::getFontSansSerifSmall()) { initDefaults(); setWrappedText(text, max_width); @@ -61,7 +61,7 @@ LLTextBox::LLTextBox(const std::string& name, const std::string& text, F32 max_w LLTextBox::LLTextBox(const std::string& name_and_label, const LLRect& rect) : LLUICtrl(name_and_label, rect, TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP), - mFontGL(LLFontGL::sSansSerifSmall) + mFontGL(LLFontGL::getFontSansSerifSmall()) { initDefaults(); setText( name_and_label ); @@ -431,7 +431,7 @@ LLView* LLTextBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *f std::string font_style; if (node->getAttributeString("font-style", font_style)) { - text_box->mFontStyle = LLFontGL::getStyleFromString(font_style); + text_box->mFontStyle |= LLFontGL::getStyleFromString(font_style); } BOOL mouse_opaque = text_box->getMouseOpaque(); diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index a626a7a1bc..7928887d4b 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -57,6 +57,7 @@ #include "llcontrol.h" #include "llimagegl.h" #include "llwindow.h" +#include "lltextparser.h" #include <queue> // @@ -300,7 +301,7 @@ LLTextEditor::LLTextEditor( } else { - mGLFont = LLFontGL::sSansSerif; + mGLFont = LLFontGL::getFontSansSerif(); } updateTextRect(); @@ -383,7 +384,7 @@ void LLTextEditor::updateLineStartList(S32 startpos) { updateSegments(); - bindEmbeddedChars( const_cast<LLFontGL*>(mGLFont) ); + bindEmbeddedChars(mGLFont); S32 seg_num = mSegments.size(); S32 seg_idx = 0; @@ -461,7 +462,7 @@ void LLTextEditor::updateLineStartList(S32 startpos) } } - unbindEmbeddedChars(const_cast<LLFontGL*>(mGLFont)); + unbindEmbeddedChars(mGLFont); mScrollbar->setDocSize( getLineCount() ); @@ -852,13 +853,13 @@ S32 LLTextEditor::getCursorPosFromLocalCoord( S32 local_x, S32 local_y, BOOL rou if (mAllowEmbeddedItems) { // Figure out which character we're nearest to. - bindEmbeddedChars(const_cast<LLFontGL*>(mGLFont)); + bindEmbeddedChars(mGLFont); pos = mGLFont->charFromPixelOffset(mWText.c_str(), line_start, (F32)(local_x - mTextRect.mLeft), (F32)(mTextRect.getWidth()), line_len, round, TRUE); - unbindEmbeddedChars(const_cast<LLFontGL*>(mGLFont)); + unbindEmbeddedChars(mGLFont); } else { @@ -2931,7 +2932,7 @@ void LLTextEditor::drawText() // draw the line numbers if( mShowLineNumbers && !cur_line_is_continuation) { - const LLFontGL *num_font = LLFontGL::sMonospace; + const LLFontGL *num_font = LLFontGL::getFontMonospace(); F32 y_top = text_y + ((F32)llround(num_font->getLineHeight()) / 2); const LLWString ltext = utf8str_to_wstring(llformat("%*d", UI_TEXTEDITOR_LINE_NUMBER_DIGITS, cur_line_num )); BOOL is_cur_line = getCurrentLine() == cur_line_num; @@ -3116,7 +3117,7 @@ void LLTextEditor::draw() { LLLocalClipRect clip(LLRect(0, getRect().getHeight(), getRect().getWidth() - (mScrollbar->getVisible() ? SCROLLBAR_SIZE : 0), 0)); - bindEmbeddedChars( const_cast<LLFontGL*>(mGLFont) ); + bindEmbeddedChars(mGLFont); drawBackground(); drawSelectionBackground(); @@ -3124,7 +3125,7 @@ void LLTextEditor::draw() drawText(); drawCursor(); - unbindEmbeddedChars( const_cast<LLFontGL*>(mGLFont) ); + unbindEmbeddedChars(mGLFont); //RN: the decision was made to always show the orange border for keyboard focus but do not put an insertion caret // when in readonly mode @@ -3245,7 +3246,7 @@ void LLTextEditor::changePage( S32 delta ) void LLTextEditor::changeLine( S32 delta ) { - bindEmbeddedChars( const_cast<LLFontGL*>(mGLFont) ); + bindEmbeddedChars(mGLFont); S32 line, offset; getLineAndOffset( mCursorPos, &line, &offset ); @@ -3272,7 +3273,7 @@ void LLTextEditor::changeLine( S32 delta ) } else { - unbindEmbeddedChars( const_cast<LLFontGL*>(mGLFont) ); + unbindEmbeddedChars(mGLFont); return; } @@ -3297,7 +3298,7 @@ void LLTextEditor::changeLine( S32 delta ) // put desired position into remember-buffer after setCursorPos() mDesiredXPixel = desired_x_pixel; - unbindEmbeddedChars( const_cast<LLFontGL*>(mGLFont) ); + unbindEmbeddedChars(mGLFont); } BOOL LLTextEditor::isScrolledToTop() @@ -3519,9 +3520,16 @@ void LLTextEditor::appendColoredText(const std::string &new_text, const LLColor4 &color, const std::string& font_name) { + LLColor4 lcolor=color; + if (mParseHighlights) + { + LLTextParser* highlight = LLTextParser::getInstance(); + highlight->parseFullLineHighlights(new_text, &lcolor); + } + LLStyleSP style(new LLStyle); style->setVisible(true); - style->setColor(color); + style->setColor(lcolor); style->setFontName(font_name); appendStyledText(new_text, allow_undo, prepend_newline, style); } @@ -3529,8 +3537,9 @@ void LLTextEditor::appendColoredText(const std::string &new_text, void LLTextEditor::appendStyledText(const std::string &new_text, bool allow_undo, bool prepend_newline, - const LLStyleSP stylep) + LLStyleSP stylep) { + S32 part = (S32)LLTextParser::WHOLE; if(mParseHTML) { @@ -3547,27 +3556,73 @@ void LLTextEditor::appendStyledText(const std::string &new_text, } html->mUnderline = TRUE; - if (start > 0) appendText(text.substr(0,start),allow_undo, prepend_newline, stylep); + if (start > 0) + { + if (part == (S32)LLTextParser::WHOLE || + part == (S32)LLTextParser::START) + { + part = (S32)LLTextParser::START; + } + else + { + part = (S32)LLTextParser::MIDDLE; + } + std::string subtext=text.substr(0,start); + appendHighlightedText(subtext,allow_undo, prepend_newline, part, stylep); + } + html->setLinkHREF(text.substr(start,end-start)); appendText(text.substr(start, end-start),allow_undo, prepend_newline, html); if (end < (S32)text.length()) { text = text.substr(end,text.length() - end); end=0; + part=(S32)LLTextParser::END; } else { break; } } - if (end < (S32)text.length()) appendText(text,allow_undo, prepend_newline, stylep); + if (part != (S32)LLTextParser::WHOLE) part=(S32)LLTextParser::END; + if (end < (S32)text.length()) appendHighlightedText(text,allow_undo, prepend_newline, part, stylep); } else { - appendText(new_text, allow_undo, prepend_newline, stylep); + appendHighlightedText(new_text, allow_undo, prepend_newline, part, stylep); } } +void LLTextEditor::appendHighlightedText(const std::string &new_text, + bool allow_undo, + bool prepend_newline, + S32 highlight_part, + LLStyleSP stylep) +{ + if (mParseHighlights) + { + LLTextParser* highlight = LLTextParser::getInstance(); + + if (highlight && stylep) + { + LLSD pieces = highlight->parsePartialLineHighlights(new_text, stylep->getColor(), highlight_part); + bool lprepend=prepend_newline; + for (S32 i=0;i<pieces.size();i++) + { + LLSD color_llsd = pieces[i]["color"]; + LLColor4 lcolor; + lcolor.setValue(color_llsd); + LLStyleSP lstylep(new LLStyle(*stylep)); + lstylep->setColor(lcolor); + if (i != 0 && (pieces.size() > 1) ) lprepend=FALSE; + appendText((std::string)pieces[i]["text"], allow_undo, lprepend, lstylep); + } + return; + } + } + appendText(new_text, allow_undo, prepend_newline, stylep); +} + // Appends new text to end of document void LLTextEditor::appendText(const std::string &new_text, bool allow_undo, bool prepend_newline, const LLStyleSP stylep) @@ -4275,7 +4330,6 @@ S32 LLTextEditor::findHTMLToken(const std::string &line, S32 pos, BOOL reverse) } else { - for (int index=pos; index<(S32)line.length(); index++) { char c = line[index]; diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 72f673463e..56825e7bfe 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -76,6 +76,7 @@ public: static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory); void setTextEditorParameters(LLXMLNodePtr node); void setParseHTML(BOOL parsing) {mParseHTML=parsing;} + void setParseHighlights(BOOL parsing) {mParseHighlights=parsing;} // mousehandler overrides virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); @@ -149,8 +150,11 @@ public: // if styled text starts a line, you need to prepend a newline. void appendStyledText(const std::string &new_text, bool allow_undo, bool prepend_newline, - const LLStyleSP stylep = NULL); - + LLStyleSP stylep = NULL); + void appendHighlightedText(const std::string &new_text, bool allow_undo, + bool prepend_newline, S32 highlight_part, + LLStyleSP stylep); + // Removes text from the end of document // Does not change highlight or cursor position. void removeTextFromEnd(S32 num_chars); @@ -313,8 +317,8 @@ protected: virtual BOOL handleMouseUpOverSegment(S32 x, S32 y, MASK mask); virtual llwchar pasteEmbeddedItem(llwchar ext_char) { return ext_char; } - virtual void bindEmbeddedChars(LLFontGL* font) const {} - virtual void unbindEmbeddedChars(LLFontGL* font) const {} + virtual void bindEmbeddedChars(const LLFontGL* font) const {} + virtual void unbindEmbeddedChars(const LLFontGL* font) const {} S32 findHTMLToken(const std::string &line, S32 pos, BOOL reverse) const; BOOL findHTML(const std::string &line, S32 *begin, S32 *end) const; @@ -402,6 +406,7 @@ protected: S32 mLastSelectionY; BOOL mParseHTML; + BOOL mParseHighlights; std::string mHTML; typedef std::vector<LLTextSegment *> segment_list_t; diff --git a/indra/llui/lltextparser.cpp b/indra/llui/lltextparser.cpp new file mode 100644 index 0000000000..cc3fcd4d84 --- /dev/null +++ b/indra/llui/lltextparser.cpp @@ -0,0 +1,298 @@ +/** + * @file lltexteditor.cpp + * @brief LLTextEditor base class + * + * $LicenseInfo:firstyear=2001&license=viewergpl$ + * + * Copyright (c) 2001-2007, 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://secondlife.com/developers/opensource/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://secondlife.com/developers/opensource/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$ + */ + +#include "linden_common.h" + +#include "llsd.h" +#include "llsdserialize.h" +#include "llerror.h" +#include "lluuid.h" +#include "llstring.h" +#include "message.h" +#include "llmath.h" +#include "v4color.h" +#include "audioengine.h" +#include "llwindow.h" +#include "lldir.h" + +#include "lltextparser.h" +//#include "lltexttospeech.h" + +// Routines used for parsing text for TextParsers and html + +LLTextParser* LLTextParser::sInstance = NULL; + +// +// Constants +// +const F32 SOUND_GAIN = 1.0f; + +// +// Member Functions +// + +LLTextParser::~LLTextParser() +{ + sInstance=NULL; +} + +// static +LLTextParser* LLTextParser::getInstance() +{ + if (!sInstance) + { + sInstance = new LLTextParser(); + sInstance->loadFromDisk(); + } + return sInstance; +} + +void LLTextParser::triggerAlerts(LLUUID agent_id, LLVector3d position, std::string text, LLWindow* viewer_window) +{ +// bool spoken=FALSE; + for (S32 i=0;i<mHighlights.size();i++) + { + if (findPattern(text,mHighlights[i]) >= 0 ) + { + if(gAudiop) + { + if ((std::string)mHighlights[i]["sound_lluuid"] != LLUUID::null.asString()) + { + gAudiop->triggerSound(mHighlights[i]["sound_lluuid"].asUUID(), agent_id, SOUND_GAIN, LLAudioEngine::AUDIO_TYPE_UI, position); + } +/* + if (!spoken) + { + LLTextToSpeech* text_to_speech = NULL; + text_to_speech = LLTextToSpeech::getInstance(); + spoken = text_to_speech->speak((LLString)mHighlights[i]["voice"],text); + } + */ + } + if (mHighlights[i]["flash"]) + { + if (viewer_window && viewer_window->getMinimized()) + { + viewer_window->flashIcon(5.f); + } + } + } + } +} + +S32 LLTextParser::findPattern(const std::string &text, LLSD highlight) +{ + if (!highlight.has("pattern")) return -1; + + std::string pattern=std::string(highlight["pattern"]); + std::string ltext=text; + + if (!(bool)highlight["case_sensitive"]) + { + ltext = utf8str_tolower(text); + pattern= utf8str_tolower(pattern); + } + + S32 found=std::string::npos; + + switch ((S32)highlight["condition"]) + { + case CONTAINS: + found = ltext.find(pattern); + break; + case MATCHES: + found = (! ltext.compare(pattern) ? 0 : std::string::npos); + break; + case STARTS_WITH: + found = (! ltext.find(pattern) ? 0 : std::string::npos); + break; + case ENDS_WITH: + S32 pos = ltext.rfind(pattern); + if (pos >= 0 && (ltext.length()-pattern.length()==pos)) found = pos; + break; + } + return found; +} + +LLSD LLTextParser::parsePartialLineHighlights(const std::string &text, const LLColor4 &color, S32 part, S32 index) +{ + //evil recursive string atomizer. + LLSD ret_llsd, start_llsd, middle_llsd, end_llsd; + + for (S32 i=index;i<mHighlights.size();i++) + { + S32 condition = mHighlights[i]["condition"]; + if ((S32)mHighlights[i]["highlight"]==PART && condition!=MATCHES) + { + if ( (condition==STARTS_WITH && part==START) || + (condition==ENDS_WITH && part==END) || + condition==CONTAINS || part==WHOLE ) + { + S32 start = findPattern(text,mHighlights[i]); + if (start >= 0 ) + { + S32 end = std::string(mHighlights[i]["pattern"]).length(); + S32 len = text.length(); + S32 newpart; + if (start==0) + { + start_llsd[0]["text"] =text.substr(0,end); + start_llsd[0]["color"]=mHighlights[i]["color"]; + + if (end < len) + { + if (part==END || part==WHOLE) newpart=END; else newpart=MIDDLE; + end_llsd=parsePartialLineHighlights(text.substr( end ),color,newpart,i); + } + } + else + { + if (part==START || part==WHOLE) newpart=START; else newpart=MIDDLE; + + start_llsd=parsePartialLineHighlights(text.substr(0,start),color,newpart,i+1); + + if (end < len) + { + middle_llsd[0]["text"] =text.substr(start,end); + middle_llsd[0]["color"]=mHighlights[i]["color"]; + + if (part==END || part==WHOLE) newpart=END; else newpart=MIDDLE; + + end_llsd=parsePartialLineHighlights(text.substr( (start+end) ),color,newpart,i); + } + else + { + end_llsd[0]["text"] =text.substr(start,end); + end_llsd[0]["color"]=mHighlights[i]["color"]; + } + } + + S32 retcount=0; + + //FIXME These loops should be wrapped into a subroutine. + for (LLSD::array_iterator iter = start_llsd.beginArray(); + iter != start_llsd.endArray();++iter) + { + LLSD highlight = *iter; + ret_llsd[retcount++]=highlight; + } + + for (LLSD::array_iterator iter = middle_llsd.beginArray(); + iter != middle_llsd.endArray();++iter) + { + LLSD highlight = *iter; + ret_llsd[retcount++]=highlight; + } + + for (LLSD::array_iterator iter = end_llsd.beginArray(); + iter != end_llsd.endArray();++iter) + { + LLSD highlight = *iter; + ret_llsd[retcount++]=highlight; + } + + return ret_llsd; + } + } + } + } + + //No patterns found. Just send back what was passed in. + ret_llsd[0]["text"] =text; + LLSD color_sd = color.getValue(); + ret_llsd[0]["color"]=color_sd; + return ret_llsd; +} + +bool LLTextParser::parseFullLineHighlights(const std::string &text, LLColor4 *color) +{ + for (S32 i=0;i<mHighlights.size();i++) + { + if ((S32)mHighlights[i]["highlight"]==ALL || (S32)mHighlights[i]["condition"]==MATCHES) + { + if (findPattern(text,mHighlights[i]) >= 0 ) + { + LLSD color_llsd = mHighlights[i]["color"]; + color->setValue(color_llsd); + return TRUE; + } + } + } + return FALSE; //No matches found. +} + +std::string LLTextParser::getFileName() +{ + std::string path=gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, ""); + + if (!path.empty()) + { + path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "highlights.xml"); + } + return path; +} + +LLSD LLTextParser::loadFromDisk() +{ + std::string filename=getFileName(); + if (filename.empty()) + { + llwarns << "LLTextParser::loadFromDisk() no valid user directory." << llendl; + } + else + { + llifstream file; + file.open(filename.c_str()); + if (file.is_open()) + { + LLSDSerialize::fromXML(mHighlights, file); + } + file.close(); + } + + return mHighlights; +} + +bool LLTextParser::saveToDisk(LLSD highlights) +{ + mHighlights=highlights; + std::string filename=getFileName(); + if (filename.empty()) + { + llwarns << "LLTextParser::saveToDisk() no valid user directory." << llendl; + return FALSE; + } + llofstream file; + file.open(filename.c_str()); + LLSDSerialize::toPrettyXML(mHighlights, file); + file.close(); + return TRUE; +} diff --git a/indra/llui/lltextparser.h b/indra/llui/lltextparser.h new file mode 100644 index 0000000000..f6099b8f65 --- /dev/null +++ b/indra/llui/lltextparser.h @@ -0,0 +1,48 @@ +/** + * @file llTextParser.h + * @brief GUI for user-defined highlights + * + * Copyright (c) 2002-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +#ifndef LL_LLTEXTPARSER_H +#define LL_LLTEXTPARSER_H + +#include <vector> +#include "linden_common.h" + +#include "lltextparser.h" + +class LLSD; +class LLUUID; +class LLVector3d; +class LLColor4; + +class LLTextParser +{ +public: + enum ConditionType { CONTAINS, MATCHES, STARTS_WITH, ENDS_WITH }; + enum HighlightType { PART, ALL }; + enum HighlightPosition { WHOLE, START, MIDDLE, END }; + enum DialogAction { ACTION_NONE, ACTION_CLOSE, ACTION_ADD, ACTION_COPY, ACTION_UPDATE }; + + static LLTextParser* getInstance(); + LLTextParser(){}; + ~LLTextParser(); + + S32 findPattern(const std::string &text, LLSD highlight); + LLSD parsePartialLineHighlights(const std::string &text,const LLColor4 &color,S32 part=WHOLE, S32 index=0); + bool parseFullLineHighlights(const std::string &text, LLColor4 *color); + void triggerAlerts(LLUUID agent_id, LLVector3d position, std::string text, LLWindow* viewer_window); + + std::string getFileName(); + LLSD loadFromDisk(); + bool saveToDisk(LLSD highlights); +public: + LLSD mHighlights; +private: + static LLTextParser* sInstance; +}; + +#endif diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index 1d37061ae8..983cc53f69 100644 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -149,7 +149,11 @@ void LLUICtrlFactory::setupPaths() } } - +// static +const std::vector<std::string>& LLUICtrlFactory::getXUIPaths() +{ + return sXUIPaths; +} //----------------------------------------------------------------------------- // getLayeredXMLNode() diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index b5b1af0371..5e7c24efc0 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -78,6 +78,8 @@ public: static bool getLayeredXMLNode(const std::string &filename, LLXMLNodePtr& root); + static const std::vector<std::string>& getXUIPaths(); + private: bool getLayeredXMLNodeImpl(const std::string &filename, LLXMLNodePtr& root); diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index d59155398f..a3db076b17 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -709,9 +709,11 @@ BOOL LLView::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_s LLView* viewp = *child_it; S32 local_x = x - viewp->mRect.mLeft; S32 local_y = y - viewp->mRect.mBottom; + // Allow tooltips for disabled views so we can explain to the user why + // the view is disabled. JC if( viewp->pointInView(local_x, local_y) && viewp->getVisible() - && viewp->getEnabled() + // && viewp->getEnabled() && viewp->handleToolTip(local_x, local_y, msg, sticky_rect_screen )) { // child provided a tooltip, just return @@ -1290,6 +1292,8 @@ void LLView::draw() { drawDebugRect(); } + + gGL.getTexUnit(0)->disable(); } //Draw a box for debugging. @@ -1344,7 +1348,7 @@ void LLView::drawDebugRect() y = debug_rect.getHeight()/2; std::string debug_text = llformat("%s (%d x %d)", getName().c_str(), debug_rect.getWidth(), debug_rect.getHeight()); - LLFontGL::sSansSerifSmall->renderUTF8(debug_text, 0, (F32)x, (F32)y, border_color, + LLFontGL::getFontSansSerifSmall()->renderUTF8(debug_text, 0, (F32)x, (F32)y, border_color, LLFontGL::HCENTER, LLFontGL::BASELINE, LLFontGL::NORMAL, S32_MAX, S32_MAX, NULL, FALSE); } @@ -2607,19 +2611,40 @@ void LLView::parseFollowsFlags(LLXMLNodePtr node) } } - // static LLFontGL* LLView::selectFont(LLXMLNodePtr node) { - LLFontGL* gl_font = NULL; - + std::string font_name, font_size, font_style; + U8 style = 0; + if (node->hasAttribute("font")) { - std::string font_name; node->getAttributeString("font", font_name); + } + + if (node->hasAttribute("font_size")) + { + node->getAttributeString("font_size", font_size); + } - gl_font = LLFontGL::fontFromName(font_name); + if (node->hasAttribute("font_style")) + { + node->getAttributeString("font_style", font_style); + style = LLFontGL::getStyleFromString(font_style); + } + + if (node->hasAttribute("font-style")) + { + node->getAttributeString("font-style", font_style); + style = LLFontGL::getStyleFromString(font_style); } + + if (font_name.empty()) + return NULL; + + LLFontDescriptor desc(font_name, font_size, style); + LLFontGL* gl_font = LLFontGL::getFont(desc); + return gl_font; } |