void LLChatEntry::expandText() { S32 line_count = mSingleLineMode ? 1 : mExpandLinesCount; // <FS:Ansariel> Store result of getVisibleLines - it calls reflow //int visible_lines_count = llabs(getVisibleLines(true).first - getVisibleLines(true).second); std::pair<BOOL, BOOL> visible_lines = getVisibleLines(true); int visible_lines_count = llabs(visible_lines.first - visible_lines.second); // </FS:Ansariel> bool can_changed = getLineCount() <= line_count || line_count < mPrevExpandedLineCount ; mPrevExpandedLineCount = line_count; // true if pasted text has more lines than expand height limit and expand limit is not reached yet bool text_pasted = (getLineCount() > line_count) && (visible_lines_count < line_count); if (mIsExpandable && (can_changed || text_pasted || mSingleLineMode) && getLineCount() != mPrevLinesCount) { int lines_height = 0; if (text_pasted) { // text is pasted and now mLineInfoList.size() > mExpandLineCounts and mLineInfoList is not empty, // so lines_height is the sum of the last 'expanded_line_count' lines height lines_height = (mLineInfoList.end() - line_count)->mRect.mTop - mLineInfoList.back().mRect.mBottom; } else { lines_height = mLineInfoList.begin()->mRect.mTop - mLineInfoList.back().mRect.mBottom; } int height = mVPad * 2 + lines_height; LLRect doc_rect = getRect(); doc_rect.setOriginAndSize(doc_rect.mLeft, doc_rect.mBottom, doc_rect.getWidth(), height); setShape(doc_rect); mPrevLinesCount = getLineCount(); if (mTextExpandedSignal) { (*mTextExpandedSignal)(this, LLSD() ); } needsReflow(); } }
void LLTextBox::onUrlLabelUpdated(const std::string &url, const std::string &label) { needsReflow(); }
// virtual BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) { BOOL handled = FALSE; LLToolDragAndDrop::ESource source = LLToolDragAndDrop::getInstance()->getSource(); if (LLToolDragAndDrop::SOURCE_NOTECARD == source) { // We currently do not handle dragging items from one notecard to another // since items in a notecard must be in Inventory to be verified. See DEV-2891. return FALSE; } if (getEnabled() && acceptsTextInput()) { switch( cargo_type ) { case DAD_CALLINGCARD: case DAD_TEXTURE: case DAD_SOUND: case DAD_LANDMARK: case DAD_SCRIPT: case DAD_CLOTHING: case DAD_OBJECT: case DAD_NOTECARD: case DAD_BODYPART: case DAD_ANIMATION: case DAD_GESTURE: case DAD_MESH: { LLInventoryItem *item = (LLInventoryItem *)cargo_data; if( item && allowsEmbeddedItems() ) { U32 mask_next = item->getPermissions().getMaskNextOwner(); if((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) { if( drop ) { deselect(); S32 old_cursor = mCursorPos; setCursorAtLocalPos( x, y, TRUE ); S32 insert_pos = mCursorPos; setCursorPos(old_cursor); BOOL inserted = insertEmbeddedItem( insert_pos, item ); if( inserted && (old_cursor > mCursorPos) ) { setCursorPos(mCursorPos + 1); } needsReflow(); } *accept = ACCEPT_YES_COPY_MULTI; } else { *accept = ACCEPT_NO; if (tooltip_msg.empty()) { // *TODO: Translate tooltip_msg.assign("Only items with unrestricted\n" "'next owner' permissions \n" "can be attached to notecards."); } } } else { *accept = ACCEPT_NO; } break; } default: *accept = ACCEPT_NO; break; } } else { // Not enabled *accept = ACCEPT_NO; } handled = TRUE; LL_DEBUGS("UserInput") << "dragAndDrop handled by LLViewerTextEditor " << getName() << LL_ENDL; return handled; }
BOOL LLChatEntry::handleSpecialKey(const KEY key, const MASK mask) { BOOL handled = FALSE; LLTextEditor::handleSpecialKey(key, mask); switch(key) { case KEY_RETURN: if (MASK_NONE == mask) { needsReflow(); } // <FS:Ansariel> FIRE-12537: CTRL-UP discards current input mCurrentInput = ""; break; case KEY_UP: if (mHasHistory && MASK_CONTROL == mask) { if (!mLineHistory.empty() && mCurrentHistoryLine > mLineHistory.begin()) { // <FS:Ansariel> FIRE-12537: CTRL-UP discards current input if (mCurrentHistoryLine == mLineHistory.end()) { mCurrentInput = getText(); } // </FS:Ansariel> setText(*(--mCurrentHistoryLine)); endOfDoc(); } else { LLUI::reportBadKeystroke(); } handled = TRUE; } break; case KEY_DOWN: if (mHasHistory && MASK_CONTROL == mask) { if (!mLineHistory.empty() && mCurrentHistoryLine < (mLineHistory.end() - 1) ) { setText(*(++mCurrentHistoryLine)); endOfDoc(); } else if (!mLineHistory.empty() && mCurrentHistoryLine == (mLineHistory.end() - 1) ) { mCurrentHistoryLine++; // <FS:Ansariel> FIRE-12537: CTRL-UP discards current input //std::string empty(""); //setText(empty); setText(mCurrentInput); // </FS:Ansariel> needsReflow(); endOfDoc(); } else { LLUI::reportBadKeystroke(); } handled = TRUE; } break; default: break; } return handled; }