From 58ee415c4972c37256cbd23e2c96cc5f644944d1 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 24 Nov 2009 11:39:22 -0800 Subject: Fixed line editor right padding to work when left padding also assigned Eliminated UILineEditorHPad and added 2 px of padding to all custom line editors. EXT-1735 Show parcel property icons Review with Leyla pending --- indra/llui/lllineeditor.cpp | 51 +++++++++++----------- indra/llui/lllineeditor.h | 4 +- indra/newview/app_settings/settings.xml | 11 ----- indra/newview/lllocationinputctrl.cpp | 4 +- indra/newview/lllocationinputctrl.h | 6 ++- .../skins/default/xui/en/alert_line_editor.xml | 2 +- .../default/xui/en/floater_test_line_editor.xml | 30 ++++++++++++- .../skins/default/xui/en/panel_main_inventory.xml | 2 +- .../skins/default/xui/en/widgets/filter_editor.xml | 2 +- .../skins/default/xui/en/widgets/line_editor.xml | 1 + .../default/xui/en/widgets/location_input.xml | 5 ++- .../default/xui/en/widgets/search_combo_box.xml | 2 +- .../skins/default/xui/en/widgets/search_editor.xml | 2 +- 13 files changed, 72 insertions(+), 50 deletions(-) diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index bd5734312a..af1f8752c9 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -125,8 +125,8 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p) mScrollHPos( 0 ), mTextPadLeft(p.text_pad_left), mTextPadRight(p.text_pad_right), - mMinHPixels(0), // computed in updateTextPadding() below - mMaxHPixels(0), // computed in updateTextPadding() below + mTextLeftEdge(0), // computed in updateTextPadding() below + mTextRightEdge(0), // computed in updateTextPadding() below mCommitOnFocusLost( p.commit_on_focus_lost ), mRevertOnEsc( p.revert_on_esc ), mKeystrokeCallback( p.keystroke_callback() ), @@ -338,9 +338,8 @@ void LLLineEditor::setTextPadding(S32 left, S32 right) void LLLineEditor::updateTextPadding() { - static LLUICachedControl line_editor_hpad ("UILineEditorHPad", 0); - mMinHPixels = line_editor_hpad + llclamp(mTextPadLeft, 0, getRect().getWidth());; - mMaxHPixels = getRect().getWidth() - mMinHPixels - llclamp(mTextPadRight, 0, getRect().getWidth()); + mTextLeftEdge = llclamp(mTextPadLeft, 0, getRect().getWidth());; + mTextRightEdge = getRect().getWidth() - llclamp(mTextPadRight, 0, getRect().getWidth()); } @@ -406,8 +405,8 @@ void LLLineEditor::setCursorAtLocalPos( S32 local_mouse_x ) mScrollHPos + mGLFont->charFromPixelOffset( wtext, mScrollHPos, - (F32)(local_mouse_x - mMinHPixels), - (F32)(mMaxHPixels - mMinHPixels + 1)); // min-max range is inclusive + (F32)(local_mouse_x - mTextLeftEdge), + (F32)(mTextRightEdge - mTextLeftEdge + 1)); // min-max range is inclusive setCursor(cursor_pos); } @@ -417,11 +416,11 @@ void LLLineEditor::setCursor( S32 pos ) mCursorPos = llclamp( pos, 0, mText.length()); S32 pixels_after_scroll = findPixelNearestPos(); - if( pixels_after_scroll > mMaxHPixels ) + if( pixels_after_scroll > mTextRightEdge ) { S32 width_chars_to_left = mGLFont->getWidth(mText.getWString().c_str(), 0, mScrollHPos); - S32 last_visible_char = mGLFont->maxDrawableChars(mText.getWString().c_str(), llmax(0.f, (F32)(mMaxHPixels - mMinHPixels + width_chars_to_left))); - S32 min_scroll = mGLFont->firstDrawableChar(mText.getWString().c_str(), (F32)(mMaxHPixels - mMinHPixels), mText.length(), getCursor()); + S32 last_visible_char = mGLFont->maxDrawableChars(mText.getWString().c_str(), llmax(0.f, (F32)(mTextRightEdge - mTextLeftEdge + width_chars_to_left))); + S32 min_scroll = mGLFont->firstDrawableChar(mText.getWString().c_str(), (F32)(mTextRightEdge - mTextLeftEdge), mText.length(), getCursor()); if (old_cursor_pos == last_visible_char) { mScrollHPos = llmin(mText.length(), llmax(min_scroll, mScrollHPos + SCROLL_INCREMENT_ADD)); @@ -682,17 +681,17 @@ BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask) S32 increment = llround(mScrollTimer.getElapsedTimeF32() / AUTO_SCROLL_TIME); mScrollTimer.reset(); mScrollTimer.setTimerExpirySec(AUTO_SCROLL_TIME); - if( (x < mMinHPixels) && (mScrollHPos > 0 ) ) + if( (x < mTextLeftEdge) && (mScrollHPos > 0 ) ) { // Scroll to the left mScrollHPos = llclamp(mScrollHPos - increment, 0, mText.length()); } else - if( (x > mMaxHPixels) && (mCursorPos < (S32)mText.length()) ) + if( (x > mTextRightEdge) && (mCursorPos < (S32)mText.length()) ) { // If scrolling one pixel would make a difference... S32 pixels_after_scrolling_one_char = findPixelNearestPos(1); - if( pixels_after_scrolling_one_char >= mMaxHPixels ) + if( pixels_after_scrolling_one_char >= mTextRightEdge ) { // ...scroll to the right mScrollHPos = llclamp(mScrollHPos + increment, 0, mText.length()); @@ -1671,7 +1670,7 @@ void LLLineEditor::draw() } S32 rendered_text = 0; - F32 rendered_pixels_right = (F32)mMinHPixels; + F32 rendered_pixels_right = (F32)mTextLeftEdge; F32 text_bottom = (F32)background.mBottom + (F32)lineeditor_v_pad; if( (gFocusMgr.getKeyboardFocus() == this) && hasSelection() ) @@ -1700,17 +1699,17 @@ void LLLineEditor::draw() 0, LLFontGL::NO_SHADOW, select_left - mScrollHPos, - mMaxHPixels - llround(rendered_pixels_right), + mTextRightEdge - llround(rendered_pixels_right), &rendered_pixels_right); } - if( (rendered_pixels_right < (F32)mMaxHPixels) && (rendered_text < text_len) ) + if( (rendered_pixels_right < (F32)mTextRightEdge) && (rendered_text < text_len) ) { LLColor4 color = mHighlightColor; color.setAlpha(alpha); // selected middle S32 width = mGLFont->getWidth(mText.getWString().c_str(), mScrollHPos + rendered_text, select_right - mScrollHPos - rendered_text); - width = llmin(width, mMaxHPixels - llround(rendered_pixels_right)); + width = llmin(width, mTextRightEdge - llround(rendered_pixels_right)); gl_rect_2d(llround(rendered_pixels_right), cursor_top, llround(rendered_pixels_right)+width, cursor_bottom, color); LLColor4 tmp_color( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], alpha ); @@ -1722,11 +1721,11 @@ void LLLineEditor::draw() 0, LLFontGL::NO_SHADOW, select_right - mScrollHPos - rendered_text, - mMaxHPixels - llround(rendered_pixels_right), + mTextRightEdge - llround(rendered_pixels_right), &rendered_pixels_right); } - if( (rendered_pixels_right < (F32)mMaxHPixels) && (rendered_text < text_len) ) + if( (rendered_pixels_right < (F32)mTextRightEdge) && (rendered_text < text_len) ) { // unselected, right side mGLFont->render( @@ -1737,7 +1736,7 @@ void LLLineEditor::draw() 0, LLFontGL::NO_SHADOW, S32_MAX, - mMaxHPixels - llround(rendered_pixels_right), + mTextRightEdge - llround(rendered_pixels_right), &rendered_pixels_right); } } @@ -1751,7 +1750,7 @@ void LLLineEditor::draw() 0, LLFontGL::NO_SHADOW, S32_MAX, - mMaxHPixels - llround(rendered_pixels_right), + mTextRightEdge - llround(rendered_pixels_right), &rendered_pixels_right); } #if 1 // for when we're ready for image art. @@ -1809,14 +1808,14 @@ void LLLineEditor::draw() if (0 == mText.length() && mReadOnly) { mGLFont->render(mLabel.getWString(), 0, - mMinHPixels, (F32)text_bottom, + mTextLeftEdge, (F32)text_bottom, label_color, LLFontGL::LEFT, LLFontGL::BOTTOM, 0, LLFontGL::NO_SHADOW, S32_MAX, - mMaxHPixels - llround(rendered_pixels_right), + mTextRightEdge - llround(rendered_pixels_right), &rendered_pixels_right, FALSE); } @@ -1834,14 +1833,14 @@ void LLLineEditor::draw() if (0 == mText.length()) { mGLFont->render(mLabel.getWString(), 0, - mMinHPixels, (F32)text_bottom, + mTextLeftEdge, (F32)text_bottom, label_color, LLFontGL::LEFT, LLFontGL::BOTTOM, 0, LLFontGL::NO_SHADOW, S32_MAX, - mMaxHPixels - llround(rendered_pixels_right), + mTextRightEdge - llround(rendered_pixels_right), &rendered_pixels_right, FALSE); } // Draw children (border) @@ -1859,7 +1858,7 @@ void LLLineEditor::draw() S32 LLLineEditor::findPixelNearestPos(const S32 cursor_offset) const { S32 dpos = getCursor() - mScrollHPos + cursor_offset; - S32 result = mGLFont->getWidth(mText.getWString().c_str(), mScrollHPos, dpos) + mMinHPixels; + S32 result = mGLFont->getWidth(mText.getWString().c_str(), mScrollHPos, dpos) + mTextLeftEdge; return result; } diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 4c4b00094d..b96220e020 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -303,8 +303,8 @@ protected: LLFrameTimer mScrollTimer; S32 mTextPadLeft; // Used to reserve space before the beginning of the text for children. S32 mTextPadRight; // Used to reserve space after the end of the text for children. - S32 mMinHPixels; - S32 mMaxHPixels; + S32 mTextLeftEdge; // Pixels, cached left edge of text based on left padding and width + S32 mTextRightEdge; // Pixels, cached right edge of text based on right padding and width BOOL mCommitOnFocusLost; BOOL mRevertOnEsc; diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 075aee46c7..b0f782622c 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9251,17 +9251,6 @@ Value 2 - UILineEditorHPad - - Comment - UI Line Editor Horizontal Pad - Persist - 1 - Type - S32 - Value - 2 - UILineEditorVPad Comment diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 6b28edf0b6..a57aea5734 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -158,6 +158,7 @@ LLLocationInputCtrl::Params::Params() add_landmark_image_disabled("add_landmark_image_disabled"), add_landmark_image_hover("add_landmark_image_hover"), add_landmark_image_selected("add_landmark_image_selected"), + add_landmark_hpad("add_landmark_hpad", 0), icon_hpad("icon_hpad", 0), add_landmark_button("add_landmark_button"), info_button("info_button"), @@ -174,6 +175,7 @@ LLLocationInputCtrl::Params::Params() LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) : LLComboBox(p), mIconHPad(p.icon_hpad), + mAddLandmarkHPad(p.add_landmark_hpad), mInfoBtn(NULL), mLocationContextMenu(NULL), mAddLandmarkBtn(NULL), @@ -608,7 +610,7 @@ void LLLocationInputCtrl::refreshLocation() void LLLocationInputCtrl::refreshParcelIcons() { // Our "cursor" moving right to left - S32 x = mAddLandmarkBtn->getRect().mLeft - mIconHPad; + S32 x = mAddLandmarkBtn->getRect().mLeft - mAddLandmarkHPad; static LLUICachedControl show_properties("NavBarShowParcelProperties", false); if (show_properties) diff --git a/indra/newview/lllocationinputctrl.h b/indra/newview/lllocationinputctrl.h index 3bd23e80a9..608176290e 100644 --- a/indra/newview/lllocationinputctrl.h +++ b/indra/newview/lllocationinputctrl.h @@ -65,7 +65,8 @@ public: add_landmark_image_disabled, add_landmark_image_hover, add_landmark_image_selected; - Optional icon_hpad; + Optional icon_hpad, + add_landmark_hpad; Optional add_landmark_button, info_button; Optional voice_icon, @@ -139,7 +140,8 @@ private: LLMenuGL* mLocationContextMenu; LLButton* mAddLandmarkBtn; LLButton* mInfoBtn; - S32 mIconHPad; + S32 mIconHPad; // pad between all icons + S32 mAddLandmarkHPad; // pad to left of landmark star enum EParcelIcon { diff --git a/indra/newview/skins/default/xui/en/alert_line_editor.xml b/indra/newview/skins/default/xui/en/alert_line_editor.xml index ab708adb06..97991153d8 100644 --- a/indra/newview/skins/default/xui/en/alert_line_editor.xml +++ b/indra/newview/skins/default/xui/en/alert_line_editor.xml @@ -7,5 +7,5 @@ ignore_tab="true" max_length="254" text_pad_right="0" - text_pad_left="0" + text_pad_left="2" mouse_opaque="true"/> diff --git a/indra/newview/skins/default/xui/en/floater_test_line_editor.xml b/indra/newview/skins/default/xui/en/floater_test_line_editor.xml index 0531b52e5a..fe6ec91709 100644 --- a/indra/newview/skins/default/xui/en/floater_test_line_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_test_line_editor.xml @@ -2,7 +2,7 @@ Disabled red-text line editor + + 25 px left text padding + + + 75 px right text padding + + + 25 px left 75 px right text padding + diff --git a/indra/newview/skins/default/xui/en/widgets/search_editor.xml b/indra/newview/skins/default/xui/en/widgets/search_editor.xml index 9a79243b03..f644a710b2 100644 --- a/indra/newview/skins/default/xui/en/widgets/search_editor.xml +++ b/indra/newview/skins/default/xui/en/widgets/search_editor.xml @@ -2,7 +2,7 @@