From 2d19b297a98d8be87c487f6b93e098dce9ca908c Mon Sep 17 00:00:00 2001 From: Paul ProductEngine Date: Fri, 13 May 2011 18:23:11 +0300 Subject: STORM-1202 FIXED Time spin control Implemented time spin control which is like spin control, but shows and allows to edit time string in "hh:mm PM/AM" format. Implemented according to the WLRS spec. --- indra/llui/CMakeLists.txt | 2 + indra/llui/lllineeditor.cpp | 106 +++++++++--- indra/llui/lllineeditor.h | 4 + indra/llui/lltextvalidate.cpp | 33 ++++ indra/llui/lltextvalidate.h | 1 + indra/llui/lltimectrl.cpp | 390 ++++++++++++++++++++++++++++++++++++++++++ indra/llui/lltimectrl.h | 125 ++++++++++++++ 7 files changed, 640 insertions(+), 21 deletions(-) create mode 100644 indra/llui/lltimectrl.cpp create mode 100644 indra/llui/lltimectrl.h (limited to 'indra/llui') diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 33ab2e93b5..72329c70fe 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -93,6 +93,7 @@ set(llui_SOURCE_FILES lltextparser.cpp lltextutil.cpp lltextvalidate.cpp + lltimectrl.cpp lltransutil.cpp lltoggleablemenu.cpp lltooltip.cpp @@ -191,6 +192,7 @@ set(llui_HEADER_FILES lltextparser.h lltextutil.h lltextvalidate.h + lltimectrl.h lltoggleablemenu.h lltooltip.h lltransutil.h diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index d99ee5a545..66c607e988 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -81,6 +81,7 @@ LLLineEditor::Params::Params() : max_length(""), keystroke_callback("keystroke_callback"), prevalidate_callback("prevalidate_callback"), + prevalidate_input_callback("prevalidate_input_callback"), background_image("background_image"), background_image_disabled("background_image_disabled"), background_image_focused("background_image_focused"), @@ -173,6 +174,7 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p) updateTextPadding(); setCursor(mText.length()); + setPrevalidate(p.prevalidate_input_callback()); setPrevalidate(p.prevalidate_callback()); LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile @@ -401,23 +403,16 @@ void LLLineEditor::setText(const LLStringExplicit &new_text) // Picks a new cursor position based on the actual screen size of text being drawn. void LLLineEditor::setCursorAtLocalPos( S32 local_mouse_x ) { - const llwchar* wtext = mText.getWString().c_str(); - LLWString asterix_text; - if (mDrawAsterixes) - { - for (S32 i = 0; i < mText.length(); i++) - { - asterix_text += utf8str_to_wstring(PASSWORD_ASTERISK); - } - wtext = asterix_text.c_str(); - } + S32 cursor_pos = calcCursorPos(local_mouse_x); + + S32 left_pos = llmin( mSelectionStart, cursor_pos ); + S32 selection_length = llabs( mSelectionStart - cursor_pos ); + const LLWString& text = mText.getWString(); + const LLWString& substr = text.substr(left_pos, selection_length); + + if (mPrevalidateInputFunc && mIsSelecting && !mPrevalidateInputFunc(substr)) + return; - S32 cursor_pos = - mScrollHPos + - mGLFont->charFromPixelOffset( - wtext, mScrollHPos, - (F32)(local_mouse_x - mTextLeftEdge), - (F32)(mTextRightEdge - mTextLeftEdge + 1)); // min-max range is inclusive setCursor(cursor_pos); } @@ -501,6 +496,9 @@ BOOL LLLineEditor::canSelectAll() const void LLLineEditor::selectAll() { + if (mPrevalidateInputFunc && !mPrevalidateInputFunc(mText.getWString())) + return; + mSelectionStart = mText.length(); mSelectionEnd = 0; setCursor(mSelectionEnd); @@ -586,6 +584,9 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) if (mask & MASK_SHIFT) { + // assume we're starting a drag select + mIsSelecting = TRUE; + // Handle selection extension S32 old_cursor_pos = getCursor(); setCursorAtLocalPos(x); @@ -620,8 +621,6 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) mSelectionStart = old_cursor_pos; mSelectionEnd = getCursor(); } - // assume we're starting a drag select - mIsSelecting = TRUE; } else { @@ -792,6 +791,9 @@ void LLLineEditor::removeChar() { if( getCursor() > 0 ) { + if (mPrevalidateInputFunc && !mPrevalidateInputFunc(mText.getWString().substr(getCursor()-1, 1))) + return; + mText.erase(getCursor() - 1, 1); setCursor(getCursor() - 1); @@ -812,6 +814,9 @@ void LLLineEditor::addChar(const llwchar uni_char) } else if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode()) { + if (mPrevalidateInputFunc && !mPrevalidateInputFunc(mText.getWString().substr(getCursor(), 1))) + return; + mText.erase(getCursor(), 1); } @@ -860,6 +865,13 @@ void LLLineEditor::extendSelection( S32 new_cursor_pos ) startSelection(); } + S32 left_pos = llmin( mSelectionStart, new_cursor_pos ); + S32 selection_length = llabs( mSelectionStart - new_cursor_pos ); + const LLWString& selection = mText.getWString(); + + if ( mPrevalidateInputFunc && !mPrevalidateInputFunc(selection.substr(left_pos, selection_length))) + return; + setCursor(new_cursor_pos); mSelectionEnd = getCursor(); } @@ -992,6 +1004,10 @@ void LLLineEditor::deleteSelection() { S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 selection_length = llabs( mSelectionStart - mSelectionEnd ); + const LLWString& selection = mText.getWString(); + + if ( mPrevalidateInputFunc && !mPrevalidateInputFunc(selection.substr(left_pos, selection_length))) + return; mText.erase(left_pos, selection_length); deselect(); @@ -1009,12 +1025,16 @@ void LLLineEditor::cut() { if( canCut() ) { + S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); + S32 length = llabs( mSelectionStart - mSelectionEnd ); + const LLWString& selection = mText.getWString(); + + if ( mPrevalidateInputFunc && !mPrevalidateInputFunc(selection.substr(left_pos, length))) + return; + // Prepare for possible rollback LLLineEditorRollback rollback( this ); - - S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); - S32 length = llabs( mSelectionStart - mSelectionEnd ); gClipboard.copyFromSubstring( mText.getWString(), left_pos, length ); deleteSelection(); @@ -1094,6 +1114,9 @@ void LLLineEditor::pasteHelper(bool is_primary) if (!paste.empty()) { + if ( mPrevalidateInputFunc && !mPrevalidateInputFunc(paste) ) + return; + // Prepare for possible rollback LLLineEditorRollback rollback(this); @@ -1441,6 +1464,11 @@ BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char) LLLineEditorRollback rollback( this ); + LLWString u_char; + u_char.assign(1, uni_char); + if (mPrevalidateInputFunc && !mPrevalidateInputFunc(u_char)) + return handled; + addChar(uni_char); mKeystrokeTimer.reset(); @@ -1492,6 +1520,15 @@ void LLLineEditor::doDelete() } else if ( getCursor() < mText.length()) { + const LLWString& selection = mText.getWString(); + + if ( mPrevalidateInputFunc && !mPrevalidateInputFunc(selection.substr(getCursor(), 1))) + { + if( mKeystrokeCallback ) + mKeystrokeCallback( this ); + + return; + } setCursor(getCursor() + 1); removeChar(); } @@ -1839,6 +1876,27 @@ S32 LLLineEditor::findPixelNearestPos(const S32 cursor_offset) const return result; } +S32 LLLineEditor::calcCursorPos(S32 mouse_x) +{ + const llwchar* wtext = mText.getWString().c_str(); + LLWString asterix_text; + if (mDrawAsterixes) + { + for (S32 i = 0; i < mText.length(); i++) + { + asterix_text += utf8str_to_wstring(PASSWORD_ASTERISK); + } + wtext = asterix_text.c_str(); + } + + S32 cur_pos = mScrollHPos + + mGLFont->charFromPixelOffset( + wtext, mScrollHPos, + (F32)(mouse_x - mTextLeftEdge), + (F32)(mTextRightEdge - mTextLeftEdge + 1)); // min-max range is inclusive + + return cur_pos; +} //virtual void LLLineEditor::clear() { @@ -1932,6 +1990,12 @@ void LLLineEditor::setPrevalidate(LLTextValidate::validate_func_t func) updateAllowingLanguageInput(); } +void LLLineEditor::setPrevalidateInputText(LLTextValidate::validate_func_t func) +{ + mPrevalidateInputFunc = func; + updateAllowingLanguageInput(); +} + // static BOOL LLLineEditor::postvalidateFloat(const std::string &str) { diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 7b5fa218f2..1e29fd0dbf 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -75,6 +75,7 @@ public: Optional keystroke_callback; Optional prevalidate_callback; + Optional prevalidate_input_callback; Optional border; @@ -231,6 +232,7 @@ public: // Prevalidation controls which keystrokes can affect the editor void setPrevalidate( LLTextValidate::validate_func_t func ); + void setPrevalidateInputText( LLTextValidate::validate_func_t func ); static BOOL postvalidateFloat(const std::string &str); // line history support: @@ -250,6 +252,7 @@ private: void addChar(const llwchar c); void setCursorAtLocalPos(S32 local_mouse_x); S32 findPixelNearestPos(S32 cursor_offset = 0) const; + S32 calcCursorPos(S32 mouse_x); BOOL handleSpecialKey(KEY key, MASK mask); BOOL handleSelectionKey(KEY key, MASK mask); BOOL handleControlKey(KEY key, MASK mask); @@ -311,6 +314,7 @@ protected: S32 mLastSelectionEnd; LLTextValidate::validate_func_t mPrevalidateFunc; + LLTextValidate::validate_func_t mPrevalidateInputFunc; LLFrameTimer mKeystrokeTimer; LLTimer mTripleClickTimer; diff --git a/indra/llui/lltextvalidate.cpp b/indra/llui/lltextvalidate.cpp index 4b9faa0560..234e600ccd 100644 --- a/indra/llui/lltextvalidate.cpp +++ b/indra/llui/lltextvalidate.cpp @@ -188,6 +188,39 @@ namespace LLTextValidate return success; } + bool validateNonNegativeS32NoSpace(const LLWString &str) + { + LLLocale locale(LLLocale::USER_LOCALE); + + LLWString test_str = str; + S32 len = test_str.length(); + bool success = TRUE; + if(0 < len) + { + if('-' == test_str[0]) + { + success = FALSE; + } + S32 i = 0; + while(success && (i < len)) + { + if(!LLStringOps::isDigit(test_str[i]) || LLStringOps::isSpace(test_str[i++])) + { + success = FALSE; + } + } + } + if (success) + { + S32 val = strtol(wstring_to_utf8str(test_str).c_str(), NULL, 10); + if (val < 0) + { + success = FALSE; + } + } + return success; + } + bool validateAlphaNum(const LLWString &str) { LLLocale locale(LLLocale::USER_LOCALE); diff --git a/indra/llui/lltextvalidate.h b/indra/llui/lltextvalidate.h index 84644be30c..5c830d7db3 100644 --- a/indra/llui/lltextvalidate.h +++ b/indra/llui/lltextvalidate.h @@ -46,6 +46,7 @@ namespace LLTextValidate bool validateInt(const LLWString &str ); bool validatePositiveS32(const LLWString &str); bool validateNonNegativeS32(const LLWString &str); + bool validateNonNegativeS32NoSpace(const LLWString &str); bool validateAlphaNum(const LLWString &str ); bool validateAlphaNumSpace(const LLWString &str ); bool validateASCIIPrintableNoPipe(const LLWString &str); diff --git a/indra/llui/lltimectrl.cpp b/indra/llui/lltimectrl.cpp new file mode 100644 index 0000000000..33e8db432f --- /dev/null +++ b/indra/llui/lltimectrl.cpp @@ -0,0 +1,390 @@ +/** + * @file lltimectrl.cpp + * @brief LLTimeCtrl base class + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "lltimectrl.h" + +#include "llui.h" +#include "lluiconstants.h" + +#include "llbutton.h" +#include "llfontgl.h" +#include "lllineeditor.h" +#include "llkeyboard.h" +#include "llstring.h" +#include "lltextbox.h" +#include "lluictrlfactory.h" + +static LLDefaultChildRegistry::Register time_r("time"); + +const U32 AMPM_LEN = 3; +const U32 MINUTES_MIN = 0; +const U32 MINUTES_MAX = 59; +const U32 HOURS_MIN = 1; +const U32 HOURS_MAX = 12; + +LLTimeCtrl::Params::Params() +: label_width("label_width"), + allow_text_entry("allow_text_entry", true), + text_enabled_color("text_enabled_color"), + text_disabled_color("text_disabled_color"), + up_button("up_button"), + down_button("down_button") +{} + +LLTimeCtrl::LLTimeCtrl(const LLTimeCtrl::Params& p) +: LLUICtrl(p), + mLabelBox(NULL), + mTextEnabledColor(p.text_enabled_color()), + mTextDisabledColor(p.text_disabled_color()), + mHours(HOURS_MIN), + mMinutes(MINUTES_MIN) +{ + static LLUICachedControl spinctrl_spacing ("UISpinctrlSpacing", 0); + static LLUICachedControl spinctrl_btn_width ("UISpinctrlBtnWidth", 0); + static LLUICachedControl spinctrl_btn_height ("UISpinctrlBtnHeight", 0); + S32 centered_top = getRect().getHeight(); + S32 centered_bottom = getRect().getHeight() - 2 * spinctrl_btn_height; + S32 label_width = llclamp(p.label_width(), 0, llmax(0, getRect().getWidth() - 40)); + S32 editor_left = label_width + spinctrl_spacing; + + //================= Label =================// + if( !p.label().empty() ) + { + LLRect label_rect( 0, centered_top, label_width, centered_bottom ); + LLTextBox::Params params; + params.name("TimeCtrl Label"); + params.rect(label_rect); + params.initial_value(p.label()); + if (p.font.isProvided()) + { + params.font(p.font); + } + mLabelBox = LLUICtrlFactory::create (params); + addChild(mLabelBox); + + editor_left = label_rect.mRight + spinctrl_spacing; + } + + S32 editor_right = getRect().getWidth() - spinctrl_btn_width - spinctrl_spacing; + + //================= Editor ================// + LLRect editor_rect( editor_left, centered_top, editor_right, centered_bottom ); + LLLineEditor::Params params; + params.name("SpinCtrl Editor"); + params.rect(editor_rect); + if (p.font.isProvided()) + { + params.font(p.font); + } + + params.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM); + params.max_length.chars(8); + params.keystroke_callback(boost::bind(&LLTimeCtrl::onTextEntry, this, _1)); + mEditor = LLUICtrlFactory::create (params); + mEditor->setPrevalidateInputText(LLTextValidate::validateNonNegativeS32NoSpace); + mEditor->setPrevalidate(boost::bind(&LLTimeCtrl::isTimeStringValid, this, _1)); + mEditor->setText(LLStringExplicit("0:00 AM")); + addChild(mEditor); + + //================= Spin Buttons ==========// + LLButton::Params up_button_params(p.up_button); + up_button_params.rect = LLRect(editor_right + 1, getRect().getHeight(), editor_right + spinctrl_btn_width, getRect().getHeight() - spinctrl_btn_height); + + up_button_params.click_callback.function(boost::bind(&LLTimeCtrl::onUpBtn, this)); + up_button_params.mouse_held_callback.function(boost::bind(&LLTimeCtrl::onUpBtn, this)); + mUpBtn = LLUICtrlFactory::create(up_button_params); + addChild(mUpBtn); + + LLButton::Params down_button_params(p.down_button); + down_button_params.rect = LLRect(editor_right + 1, getRect().getHeight() - spinctrl_btn_height, editor_right + spinctrl_btn_width, getRect().getHeight() - 2 * spinctrl_btn_height); + down_button_params.click_callback.function(boost::bind(&LLTimeCtrl::onDownBtn, this)); + down_button_params.mouse_held_callback.function(boost::bind(&LLTimeCtrl::onDownBtn, this)); + mDownBtn = LLUICtrlFactory::create(down_button_params); + addChild(mDownBtn); + + setUseBoundingRect( TRUE ); +} + +BOOL LLTimeCtrl::handleKeyHere(KEY key, MASK mask) +{ + if (mEditor->hasFocus()) + { + if(key == KEY_UP) + { + onUpBtn(); + return TRUE; + } + if(key == KEY_DOWN) + { + onDownBtn(); + return TRUE; + } + } + return FALSE; +} + +void LLTimeCtrl::onUpBtn() +{ + switch(getEditingPart()) + { + case HOURS: + increaseHours(); + break; + case MINUTES: + increaseMinutes(); + break; + case DAYPART: + switchDayPeriod(); + break; + default: + break; + } + + buildTimeString(); + mEditor->setText(mTimeString); +} + +void LLTimeCtrl::onDownBtn() +{ + switch(getEditingPart()) + { + case HOURS: + decreaseHours(); + break; + case MINUTES: + decreaseMinutes(); + break; + case DAYPART: + switchDayPeriod(); + break; + default: + break; + } + + buildTimeString(); + mEditor->setText(mTimeString); +} + +void LLTimeCtrl::onFocusLost() +{ + buildTimeString(); + mEditor->setText(mTimeString); + + LLUICtrl::onFocusLost(); +} + +void LLTimeCtrl::onTextEntry(LLLineEditor* line_editor) +{ + LLWString time_str = line_editor->getWText(); + switch(getEditingPart()) + { + case HOURS: + validateHours(getHoursWString(time_str)); + break; + case MINUTES: + validateMinutes(getMinutesWString(time_str)); + break; + default: + break; + } +} + +bool LLTimeCtrl::isTimeStringValid(const LLWString &wstr) +{ + if (!isHoursStringValid(getHoursWString(wstr)) || !isMinutesStringValid(getMinutesWString(wstr)) || !isPMAMStringValid(wstr)) + return false; + + return true; +} + +bool LLTimeCtrl::isHoursStringValid(const LLWString& wstr) +{ + U32 hours; + if ((!LLWStringUtil::convertToU32(wstr, hours) || (hours <= HOURS_MAX)) && wstr.length() < 3) + return true; + + return false; +} + +bool LLTimeCtrl::isMinutesStringValid(const LLWString& wstr) +{ + U32 minutes; + if (!LLWStringUtil::convertToU32(wstr, minutes) || (minutes <= MINUTES_MAX) && wstr.length() < 3) + return true; + + return false; +} + +void LLTimeCtrl::validateHours(const LLWString& wstr) +{ + U32 hours; + if (LLWStringUtil::convertToU32(wstr, hours) && (hours >= HOURS_MIN) && (hours <= HOURS_MAX)) + { + mHours = hours; + } + else + { + mHours = HOURS_MIN; + } +} + +void LLTimeCtrl::validateMinutes(const LLWString& wstr) +{ + U32 minutes; + if (LLWStringUtil::convertToU32(wstr, minutes) && (minutes >= MINUTES_MIN) && (minutes <= MINUTES_MAX)) + { + mMinutes = minutes; + } + else + { + mMinutes = MINUTES_MIN; + } +} + +bool LLTimeCtrl::isPMAMStringValid(const LLWString &wstr) +{ + S32 len = wstr.length(); + + bool valid = (wstr[--len] == 'M') && (wstr[--len] == 'P' || wstr[len] == 'A'); + + return valid; +} + +LLWString LLTimeCtrl::getHoursWString(const LLWString& wstr) +{ + size_t colon_index = wstr.find_first_of(':'); + LLWString hours_str = wstr.substr(0, colon_index); + + return hours_str; +} + +LLWString LLTimeCtrl::getMinutesWString(const LLWString& wstr) +{ + size_t colon_index = wstr.find_first_of(':'); + ++colon_index; + + int minutes_len = wstr.length() - colon_index - AMPM_LEN; + LLWString minutes_str = wstr.substr(colon_index, minutes_len); + + return minutes_str; +} + +void LLTimeCtrl::increaseMinutes() +{ + if (++mMinutes > MINUTES_MAX) + { + mMinutes = MINUTES_MIN; + } +} + +void LLTimeCtrl::increaseHours() +{ + if (++mHours > HOURS_MAX) + { + mHours = HOURS_MIN; + } +} + +void LLTimeCtrl::decreaseMinutes() +{ + if (mMinutes-- == MINUTES_MIN) + { + mMinutes = MINUTES_MAX; + } +} + +void LLTimeCtrl::decreaseHours() +{ + if (mHours-- == HOURS_MIN) + { + mHours = HOURS_MAX; + switchDayPeriod(); + } +} + +void LLTimeCtrl::switchDayPeriod() +{ + switch (mCurrentDayPeriod) + { + case AM: + mCurrentDayPeriod = PM; + break; + case PM: + mCurrentDayPeriod = AM; + break; + } +} + +void LLTimeCtrl::buildTimeString() +{ + std::stringstream time_buf; + time_buf << mHours << ":"; + + if (mMinutes < 10) + { + time_buf << "0"; + } + + time_buf << mMinutes; + time_buf << " "; + + switch (mCurrentDayPeriod) + { + case AM: + time_buf << "AM"; + break; + case PM: + time_buf << "PM"; + break; + } + + mTimeString = time_buf.str(); +} + +LLTimeCtrl::EEditingPart LLTimeCtrl::getEditingPart() +{ + S32 cur_pos = mEditor->getCursor(); + LLWString time_str = mEditor->getWText(); + + size_t colon_index = time_str.find_first_of(':'); + + if (cur_pos <= colon_index) + { + return HOURS; + } + else if (cur_pos > colon_index && cur_pos <= (time_str.length() - AMPM_LEN)) + { + return MINUTES; + } + else if (cur_pos > (time_str.length() - AMPM_LEN)) + { + return DAYPART; + } + + return NONE; +} diff --git a/indra/llui/lltimectrl.h b/indra/llui/lltimectrl.h new file mode 100644 index 0000000000..81d4477da4 --- /dev/null +++ b/indra/llui/lltimectrl.h @@ -0,0 +1,125 @@ +/** + * @file lltimectrl.h + * @brief Time control + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LLTIMECTRL_H_ +#define LLTIMECTRL_H_ + +#include "stdtypes.h" +#include "llbutton.h" +#include "v4color.h" +#include "llrect.h" + +class LLLineEditor; + +class LLTimeCtrl +: public LLUICtrl +{ +public: + struct Params : public LLInitParam::Block + { + Optional label_width; + Optional allow_text_entry; + + Optional text_enabled_color; + Optional text_disabled_color; + + Optional up_button; + Optional down_button; + + Params(); + }; +protected: + LLTimeCtrl(const Params&); + friend class LLUICtrlFactory; + + U32 getHours() const { return mHours; } + U32 getMinutes() const { return mMinutes; } + +private: + + enum EDayPeriod + { + AM, + PM + }; + + enum EEditingPart + { + HOURS, + MINUTES, + DAYPART, + NONE + }; + + virtual void onFocusLost(); + virtual BOOL handleKeyHere(KEY key, MASK mask); + + void onUpBtn(); + void onDownBtn(); + + void onTextEntry(LLLineEditor* line_editor); + + void validateHours(const LLWString& wstr); + void validateMinutes(const LLWString& wstr); + bool isTimeStringValid(const LLWString& wstr); + + bool isPMAMStringValid(const LLWString& wstr); + bool isHoursStringValid(const LLWString& wstr); + bool isMinutesStringValid(const LLWString& wstr); + + LLWString getHoursWString(const LLWString& wstr); + LLWString getMinutesWString(const LLWString& wstr); + + void increaseMinutes(); + void increaseHours(); + + void decreaseMinutes(); + void decreaseHours(); + + void switchDayPeriod(); + + void buildTimeString(); + + EEditingPart getEditingPart(); + + class LLTextBox* mLabelBox; + + class LLLineEditor* mEditor; + LLUIColor mTextEnabledColor; + LLUIColor mTextDisabledColor; + + class LLButton* mUpBtn; + class LLButton* mDownBtn; + + U32 mHours; + U32 mMinutes; + EDayPeriod mCurrentDayPeriod; + + std::string mTimeString; + + BOOL mAllowEdit; +}; +#endif /* LLTIMECTRL_H_ */ -- cgit v1.2.3 From 5daeefd35e1e105f403f99184ad866e8823767d4 Mon Sep 17 00:00:00 2001 From: Paul ProductEngine Date: Mon, 16 May 2011 17:59:05 +0300 Subject: STORM-1202 Code cleanup for LLLineEditor - Removed code duplication - Renamed prevalidateInputText to prevalidateInput --- indra/llui/lllineeditor.cpp | 65 +++++++++++++++++++++++++++------------------ indra/llui/lllineeditor.h | 8 +++++- indra/llui/lltimectrl.cpp | 2 +- 3 files changed, 47 insertions(+), 28 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 66c607e988..2527a608bf 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -174,7 +174,7 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p) updateTextPadding(); setCursor(mText.length()); - setPrevalidate(p.prevalidate_input_callback()); + setPrevalidateInput(p.prevalidate_input_callback()); setPrevalidate(p.prevalidate_callback()); LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile @@ -406,11 +406,10 @@ void LLLineEditor::setCursorAtLocalPos( S32 local_mouse_x ) S32 cursor_pos = calcCursorPos(local_mouse_x); S32 left_pos = llmin( mSelectionStart, cursor_pos ); - S32 selection_length = llabs( mSelectionStart - cursor_pos ); - const LLWString& text = mText.getWString(); - const LLWString& substr = text.substr(left_pos, selection_length); + S32 length = llabs( mSelectionStart - cursor_pos ); + const LLWString& substr = mText.getWString().substr(left_pos, length); - if (mPrevalidateInputFunc && mIsSelecting && !mPrevalidateInputFunc(substr)) + if (mIsSelecting && !prevalidateInput(substr)) return; setCursor(cursor_pos); @@ -496,8 +495,10 @@ BOOL LLLineEditor::canSelectAll() const void LLLineEditor::selectAll() { - if (mPrevalidateInputFunc && !mPrevalidateInputFunc(mText.getWString())) + if (!prevalidateInput(mText.getWString())) + { return; + } mSelectionStart = mText.length(); mSelectionEnd = 0; @@ -791,7 +792,7 @@ void LLLineEditor::removeChar() { if( getCursor() > 0 ) { - if (mPrevalidateInputFunc && !mPrevalidateInputFunc(mText.getWString().substr(getCursor()-1, 1))) + if (!prevalidateInput(mText.getWString().substr(getCursor()-1, 1))) return; mText.erase(getCursor() - 1, 1); @@ -814,7 +815,7 @@ void LLLineEditor::addChar(const llwchar uni_char) } else if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode()) { - if (mPrevalidateInputFunc && !mPrevalidateInputFunc(mText.getWString().substr(getCursor(), 1))) + if (!prevalidateInput(mText.getWString().substr(getCursor(), 1))) return; mText.erase(getCursor(), 1); @@ -867,9 +868,9 @@ void LLLineEditor::extendSelection( S32 new_cursor_pos ) S32 left_pos = llmin( mSelectionStart, new_cursor_pos ); S32 selection_length = llabs( mSelectionStart - new_cursor_pos ); - const LLWString& selection = mText.getWString(); + const LLWString& selection = mText.getWString().substr(left_pos, selection_length); - if ( mPrevalidateInputFunc && !mPrevalidateInputFunc(selection.substr(left_pos, selection_length))) + if (!prevalidateInput(selection)) return; setCursor(new_cursor_pos); @@ -1002,11 +1003,11 @@ void LLLineEditor::deleteSelection() { if( !mReadOnly && hasSelection() ) { - S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); - S32 selection_length = llabs( mSelectionStart - mSelectionEnd ); - const LLWString& selection = mText.getWString(); + S32 left_pos, selection_length; + getSelectionRange(&left_pos, &selection_length); + const LLWString& selection = mText.getWString().substr(left_pos, selection_length); - if ( mPrevalidateInputFunc && !mPrevalidateInputFunc(selection.substr(left_pos, selection_length))) + if (!prevalidateInput(selection)) return; mText.erase(left_pos, selection_length); @@ -1025,11 +1026,11 @@ void LLLineEditor::cut() { if( canCut() ) { - S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); - S32 length = llabs( mSelectionStart - mSelectionEnd ); - const LLWString& selection = mText.getWString(); + S32 left_pos, length; + getSelectionRange(&left_pos, &length); + const LLWString& selection = mText.getWString().substr(left_pos, length); - if ( mPrevalidateInputFunc && !mPrevalidateInputFunc(selection.substr(left_pos, length))) + if (!prevalidateInput(selection)) return; // Prepare for possible rollback @@ -1114,7 +1115,7 @@ void LLLineEditor::pasteHelper(bool is_primary) if (!paste.empty()) { - if ( mPrevalidateInputFunc && !mPrevalidateInputFunc(paste) ) + if (!prevalidateInput(paste)) return; // Prepare for possible rollback @@ -1464,10 +1465,12 @@ BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char) LLLineEditorRollback rollback( this ); - LLWString u_char; - u_char.assign(1, uni_char); - if (mPrevalidateInputFunc && !mPrevalidateInputFunc(u_char)) - return handled; + { + LLWString u_char; + u_char.assign(1, uni_char); + if (!prevalidateInput(u_char)) + return handled; + } addChar(uni_char); @@ -1520,9 +1523,9 @@ void LLLineEditor::doDelete() } else if ( getCursor() < mText.length()) { - const LLWString& selection = mText.getWString(); + const LLWString& text_to_delete = mText.getWString().substr(getCursor(), 1); - if ( mPrevalidateInputFunc && !mPrevalidateInputFunc(selection.substr(getCursor(), 1))) + if (!prevalidateInput(text_to_delete)) { if( mKeystrokeCallback ) mKeystrokeCallback( this ); @@ -1990,12 +1993,22 @@ void LLLineEditor::setPrevalidate(LLTextValidate::validate_func_t func) updateAllowingLanguageInput(); } -void LLLineEditor::setPrevalidateInputText(LLTextValidate::validate_func_t func) +void LLLineEditor::setPrevalidateInput(LLTextValidate::validate_func_t func) { mPrevalidateInputFunc = func; updateAllowingLanguageInput(); } +bool LLLineEditor::prevalidateInput(const LLWString& wstr) +{ + if (mPrevalidateInputFunc && !mPrevalidateInputFunc(wstr)) + { + return false; + } + + return true; +} + // static BOOL LLLineEditor::postvalidateFloat(const std::string &str) { diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 1e29fd0dbf..1588f59b46 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -232,9 +232,15 @@ public: // Prevalidation controls which keystrokes can affect the editor void setPrevalidate( LLTextValidate::validate_func_t func ); - void setPrevalidateInputText( LLTextValidate::validate_func_t func ); + // This method sets callback that prevents from: + // - deleting, selecting, typing, cutting, pasting characters that are not valid. + // Also callback that this method sets differs from setPrevalidate in a way that it validates just inputed + // symbols, before existing text is modified, but setPrevalidate validates line after it was modified. + void setPrevalidateInput(LLTextValidate::validate_func_t func); static BOOL postvalidateFloat(const std::string &str); + bool prevalidateInput(const LLWString& wstr); + // line history support: void setEnableLineHistory( BOOL enabled ) { mHaveHistory = enabled; } // switches line history on or off void updateHistory(); // stores current line in history diff --git a/indra/llui/lltimectrl.cpp b/indra/llui/lltimectrl.cpp index 33e8db432f..08d24a29a8 100644 --- a/indra/llui/lltimectrl.cpp +++ b/indra/llui/lltimectrl.cpp @@ -106,7 +106,7 @@ LLTimeCtrl::LLTimeCtrl(const LLTimeCtrl::Params& p) params.max_length.chars(8); params.keystroke_callback(boost::bind(&LLTimeCtrl::onTextEntry, this, _1)); mEditor = LLUICtrlFactory::create (params); - mEditor->setPrevalidateInputText(LLTextValidate::validateNonNegativeS32NoSpace); + mEditor->setPrevalidateInput(LLTextValidate::validateNonNegativeS32NoSpace); mEditor->setPrevalidate(boost::bind(&LLTimeCtrl::isTimeStringValid, this, _1)); mEditor->setText(LLStringExplicit("0:00 AM")); addChild(mEditor); -- cgit v1.2.3 From 03dca7cb7e578d20ec07298cecc47e0ae67aaaf5 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Tue, 17 May 2011 16:38:51 -0700 Subject: fixing llaccordian crash with multiple child panels --- indra/llui/llaccordionctrltab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp index 9e4849c58b..6afe276379 100644 --- a/indra/llui/llaccordionctrltab.cpp +++ b/indra/llui/llaccordionctrltab.cpp @@ -1022,7 +1022,7 @@ void LLAccordionCtrlTab::updateLayout ( const LLRect& child_rect ) S32 panel_width = child_rect.getWidth(); static LLUICachedControl scrollbar_size ("UIScrollbarSize", 0); - if(mScrollbar->getVisible() != false) + if(mScrollbar && mScrollbar->getVisible() != false) { panel_top+=mScrollbar->getDocPos(); panel_width-=scrollbar_size; -- cgit v1.2.3 From a9d7ee879216857fd61b36c70ffea257021c869a Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Wed, 18 May 2011 16:07:36 +0300 Subject: STORM-1202 ADDITIONAL_FIX Fixing Windows build. --- indra/llui/lltimectrl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltimectrl.cpp b/indra/llui/lltimectrl.cpp index 08d24a29a8..4b49c45006 100644 --- a/indra/llui/lltimectrl.cpp +++ b/indra/llui/lltimectrl.cpp @@ -371,17 +371,17 @@ LLTimeCtrl::EEditingPart LLTimeCtrl::getEditingPart() S32 cur_pos = mEditor->getCursor(); LLWString time_str = mEditor->getWText(); - size_t colon_index = time_str.find_first_of(':'); + S32 colon_index = time_str.find_first_of(':'); if (cur_pos <= colon_index) { return HOURS; } - else if (cur_pos > colon_index && cur_pos <= (time_str.length() - AMPM_LEN)) + else if (cur_pos > colon_index && cur_pos <= (S32)(time_str.length() - AMPM_LEN)) { return MINUTES; } - else if (cur_pos > (time_str.length() - AMPM_LEN)) + else if (cur_pos > (S32)(time_str.length() - AMPM_LEN)) { return DAYPART; } -- cgit v1.2.3 From f02d6e7095d526bc7abc75cc796dc4f07c9b18c7 Mon Sep 17 00:00:00 2001 From: Paul ProductEngine Date: Wed, 18 May 2011 21:07:06 +0300 Subject: STORM-1202 ADDITIONAL_FIX Workaround for another Windows build issue. --- indra/llui/lltimectrl.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltimectrl.cpp b/indra/llui/lltimectrl.cpp index 4b49c45006..a77842a392 100644 --- a/indra/llui/lltimectrl.cpp +++ b/indra/llui/lltimectrl.cpp @@ -225,7 +225,8 @@ bool LLTimeCtrl::isTimeStringValid(const LLWString &wstr) bool LLTimeCtrl::isHoursStringValid(const LLWString& wstr) { U32 hours; - if ((!LLWStringUtil::convertToU32(wstr, hours) || (hours <= HOURS_MAX)) && wstr.length() < 3) + std::string utf8time = wstring_to_utf8str(wstr); + if ((!LLStringUtil::convertToU32(utf8time, hours) || (hours <= HOURS_MAX)) && wstr.length() < 3) return true; return false; @@ -234,7 +235,8 @@ bool LLTimeCtrl::isHoursStringValid(const LLWString& wstr) bool LLTimeCtrl::isMinutesStringValid(const LLWString& wstr) { U32 minutes; - if (!LLWStringUtil::convertToU32(wstr, minutes) || (minutes <= MINUTES_MAX) && wstr.length() < 3) + std::string utf8time = wstring_to_utf8str(wstr); + if (!LLStringUtil::convertToU32(utf8time, minutes) || (minutes <= MINUTES_MAX) && wstr.length() < 3) return true; return false; @@ -243,7 +245,8 @@ bool LLTimeCtrl::isMinutesStringValid(const LLWString& wstr) void LLTimeCtrl::validateHours(const LLWString& wstr) { U32 hours; - if (LLWStringUtil::convertToU32(wstr, hours) && (hours >= HOURS_MIN) && (hours <= HOURS_MAX)) + std::string utf8time = wstring_to_utf8str(wstr); + if (LLStringUtil::convertToU32(utf8time, hours) && (hours >= HOURS_MIN) && (hours <= HOURS_MAX)) { mHours = hours; } @@ -256,7 +259,8 @@ void LLTimeCtrl::validateHours(const LLWString& wstr) void LLTimeCtrl::validateMinutes(const LLWString& wstr) { U32 minutes; - if (LLWStringUtil::convertToU32(wstr, minutes) && (minutes >= MINUTES_MIN) && (minutes <= MINUTES_MAX)) + std::string utf8time = wstring_to_utf8str(wstr); + if (LLStringUtil::convertToU32(utf8time, minutes) && (minutes >= MINUTES_MIN) && (minutes <= MINUTES_MAX)) { mMinutes = minutes; } -- cgit v1.2.3 From 406195e4f20e0bea341c8a7a979b56a8259b8536 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 24 May 2011 09:38:49 -0700 Subject: Added badges version 0.1 to buttons. Reviewed by Richard --- indra/llui/CMakeLists.txt | 2 + indra/llui/llbadge.cpp | 263 ++++++++++++++++++++++++++++++++++++++++++++++ indra/llui/llbadge.h | 152 +++++++++++++++++++++++++++ indra/llui/llbutton.cpp | 94 ++++++++++++++++- indra/llui/llbutton.h | 12 ++- 5 files changed, 517 insertions(+), 6 deletions(-) create mode 100644 indra/llui/llbadge.cpp create mode 100644 indra/llui/llbadge.h (limited to 'indra/llui') diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 33ab2e93b5..fb585e062c 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -28,6 +28,7 @@ include_directories( set(llui_SOURCE_FILES llaccordionctrl.cpp llaccordionctrltab.cpp + llbadge.cpp llbutton.cpp llcheckboxctrl.cpp llclipboard.cpp @@ -119,6 +120,7 @@ set(llui_HEADER_FILES llaccordionctrl.h llaccordionctrltab.h + llbadge.h llbutton.h llcallbackmap.h llcheckboxctrl.h diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp new file mode 100644 index 0000000000..ea934aa93b --- /dev/null +++ b/indra/llui/llbadge.cpp @@ -0,0 +1,263 @@ +/** + * @file llbadge.cpp + * @brief Implementation for badges + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#define LLBADGE_CPP +#include "llbadge.h" + +#include "lluictrlfactory.h" + + +static LLDefaultChildRegistry::Register r("badge"); + +// Compiler optimization, generate extern template +template class LLBadge* LLView::getChild(const std::string& name, BOOL recurse) const; + + +LLBadge::Params::Params() + : image("image") + , image_color("image_color") + , label("label") + , label_color("label_color") + , location("location", LLRelPos::TOP_LEFT) + , location_percent_hcenter("location_percent_hcenter") + , location_percent_vcenter("location_percent_vcenter") + , padding_horiz("padding_horiz") + , padding_vert("padding_vert") +{ + // We set a name here so the name isn't necessary in any xml files that use badges + name = "badge"; +} + +bool LLBadge::Params::equals(const Params& a) const +{ + bool comp = true; + + // skip owner in comparison on purpose + + comp &= (image() == a.image()); + comp &= (image_color() == a.image_color()); + comp &= (label() == a.label()); + comp &= (label_color() == a.label_color()); + comp &= (location() == a.location()); + comp &= (location_percent_hcenter() == a.location_percent_hcenter()); + comp &= (location_percent_vcenter() == a.location_percent_vcenter()); + comp &= (padding_horiz() == a.padding_horiz()); + comp &= (padding_vert() == a.padding_vert()); + + return comp; +} + +LLBadge::LLBadge(const LLBadge::Params& p) + : LLUICtrl(p) + , mOwner(p.owner) + , mGLFont(p.font) + , mImage(p.image) + , mImageColor(p.image_color) + , mLabel(p.label) + , mLabelColor(p.label_color) + , mLocation(p.location) + , mLocationPercentHCenter(0.5f) + , mLocationPercentVCenter(0.5f) + , mPaddingHoriz(p.padding_horiz) + , mPaddingVert(p.padding_vert) +{ + if (mImage.isNull()) + { + llwarns << "Badge: " << getName() << " with no image!" << llendl; + } + + // + // The following logic is to set the mLocationPercentHCenter and mLocationPercentVCenter + // based on the Location enum and our horizontal and vertical location percentages. The + // draw code then uses this on the owner rectangle to compute the screen location for + // the badge. + // + + if (!LLRelPos::IsCenter(mLocation)) + { + F32 h_center = p.location_percent_hcenter * 0.01f; + F32 v_center = p.location_percent_vcenter * 0.01f; + + if (LLRelPos::IsRight(mLocation)) + { + mLocationPercentHCenter = 0.5f * (1.0f + h_center); + } + else if (LLRelPos::IsLeft(mLocation)) + { + mLocationPercentHCenter = 0.5f * (1.0f - h_center); + } + + if (LLRelPos::IsTop(mLocation)) + { + mLocationPercentVCenter = 0.5f * (1.0f + v_center); + } + else if (LLRelPos::IsBottom(mLocation)) + { + mLocationPercentVCenter = 0.5f * (1.0f - v_center); + } + } +} + +LLBadge::~LLBadge() +{ +} + +void LLBadge::setLabel(const LLStringExplicit& label) +{ + mLabel = label; +} + +// +// This is a fallback function to render a rectangle for badges without a valid image +// +void renderBadgeBackground(F32 centerX, F32 centerY, F32 width, F32 height, const LLColor4U &color) +{ + gGL.pushUIMatrix(); + gGL.loadUIIdentity(); + gGL.setSceneBlendType(LLRender::BT_REPLACE); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + gGL.color4ubv(color.mV); + gGL.texCoord2i(0, 0); + + F32 x = LLFontGL::sCurOrigin.mX + centerX - width * 0.5f; + F32 y = LLFontGL::sCurOrigin.mY + centerY - height * 0.5f; + + LLRectf screen_rect(llround(x), + llround(y), + llround(x) + width, + llround(y) + height); + + LLVector3 vertices[4]; + vertices[0] = LLVector3(screen_rect.mRight, screen_rect.mTop, 1.0f); + vertices[1] = LLVector3(screen_rect.mLeft, screen_rect.mTop, 1.0f); + vertices[2] = LLVector3(screen_rect.mLeft, screen_rect.mBottom, 1.0f); + vertices[3] = LLVector3(screen_rect.mRight, screen_rect.mBottom, 1.0f); + + gGL.begin(LLRender::QUADS); + { + gGL.vertexBatchPreTransformed(vertices, 4); + } + gGL.end(); + + gGL.popUIMatrix(); +} + + +// virtual +void LLBadge::draw() +{ + if (!mLabel.empty()) + { + LLUICtrl* owner_ctrl = mOwner.get(); + + if (owner_ctrl) + { + // + // Calculate badge position based on owner + // + + LLRect owner_rect; + owner_ctrl->localRectToOtherView(owner_ctrl->getLocalRect(), & owner_rect, this); + + F32 badge_center_x = owner_rect.mLeft + owner_rect.getWidth() * mLocationPercentHCenter; + F32 badge_center_y = owner_rect.mBottom + owner_rect.getHeight() * mLocationPercentVCenter; + + // + // Calculate badge size based on label text + // + + LLWString badge_label_wstring = mLabel; + + S32 badge_label_begin_offset = 0; + S32 badge_char_length = S32_MAX; + S32 badge_pixel_length = S32_MAX; + F32 *right_position_out = NULL; + BOOL do_not_use_ellipses = false; + + F32 badge_width = (2.0f * mPaddingHoriz) + + mGLFont->getWidthF32(badge_label_wstring.c_str(), badge_label_begin_offset, badge_char_length); + + F32 badge_height = (2.0f * mPaddingVert) + mGLFont->getLineHeight(); + + // + // Draw button image, if available. + // Otherwise draw basic rectangular button. + // + + F32 alpha = getDrawContext().mAlpha; + + if (!mImage.isNull()) + { + F32 badge_x = badge_center_x - badge_width * 0.5f; + F32 badge_y = badge_center_y - badge_height * 0.5f; + + mImage->drawSolid(badge_x, badge_y, badge_width, badge_height, mImageColor % alpha); + } + else + { + lldebugs << "No image for badge " << getName() << " on owner " << owner_ctrl->getName() << llendl; + + renderBadgeBackground(badge_center_x, badge_center_y, + badge_width, badge_height, + mImageColor % alpha); + } + + // + // Draw the label + // + + mGLFont->render(badge_label_wstring, badge_label_begin_offset, + badge_center_x, badge_center_y, + mLabelColor % alpha, + LLFontGL::HCENTER, LLFontGL::VCENTER, // centered around the position + LLFontGL::NORMAL, // normal text (not bold, italics, etc.) + LLFontGL::DROP_SHADOW_SOFT, + badge_char_length, badge_pixel_length, + right_position_out, do_not_use_ellipses); + } + } +} + + +namespace LLInitParam +{ + void TypeValues::declareValues() + { + declare("bottom", LLRelPos::BOTTOM); + declare("bottom_left", LLRelPos::BOTTOM_LEFT); + declare("bottom_right", LLRelPos::BOTTOM_RIGHT); + declare("center", LLRelPos::CENTER); + declare("left", LLRelPos::LEFT); + declare("right", LLRelPos::RIGHT); + declare("top", LLRelPos::TOP); + declare("top_left", LLRelPos::TOP_LEFT); + declare("top_right", LLRelPos::TOP_RIGHT); + } +} + + +// eof diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h new file mode 100644 index 0000000000..c2e0a763b2 --- /dev/null +++ b/indra/llui/llbadge.h @@ -0,0 +1,152 @@ +/** + * @file llbadge.h + * @brief Header for badges + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLBADGE_H +#define LL_LLBADGE_H + +#include + +#include "lluicolor.h" +#include "lluictrl.h" +#include "llstring.h" +#include "lluiimage.h" + +// +// Declarations +// + +class LLUICtrlFactory; +class LLFontGL; + +// +// Relative Position Alignment +// + +namespace LLRelPos +{ + enum Location + { + CENTER = 0, + + LEFT = (1 << 0), + RIGHT = (1 << 1), + + TOP = (1 << 2), + BOTTOM = (1 << 3), + + BOTTOM_LEFT = (BOTTOM | LEFT), + BOTTOM_RIGHT = (BOTTOM | RIGHT), + + TOP_LEFT = (TOP | LEFT), + TOP_RIGHT = (TOP | RIGHT), + }; + + inline bool IsBottom(Location relPos) { return (relPos & BOTTOM) == BOTTOM; } + inline bool IsCenter(Location relPos) { return (relPos == CENTER); } + inline bool IsLeft(Location relPos) { return (relPos & LEFT) == LEFT; } + inline bool IsRight(Location relPos) { return (relPos & RIGHT) == RIGHT; } + inline bool IsTop(Location relPos) { return (relPos & TOP) == TOP; } +} + +// NOTE: This needs to occur before Optional declaration for proper compilation. +namespace LLInitParam +{ + template<> + struct TypeValues : public TypeValuesHelper + { + static void declareValues(); + }; +} + +// +// Classes +// + +class LLBadge +: public LLUICtrl +{ +public: + struct Params + : public LLInitParam::Block + { + Optional< LLHandle > owner; // Mandatory in code but not in xml + + Optional< LLUIImage* > image; + Optional< LLUIColor > image_color; + + Optional< std::string > label; + Optional< LLUIColor > label_color; + + Optional< LLRelPos::Location > location; + Optional< U32 > location_percent_hcenter; + Optional< U32 > location_percent_vcenter; + + Optional< F32 > padding_horiz; + Optional< F32 > padding_vert; + + Params(); + + bool equals(const Params&) const; + }; + +protected: + friend class LLUICtrlFactory; + LLBadge(const Params& p); + +public: + + ~LLBadge(); + + virtual void draw(); + + const std::string getLabel() const { return wstring_to_utf8str(mLabel); } + void setLabel( const LLStringExplicit& label); + +private: + const LLFontGL* mGLFont; + + LLPointer< LLUIImage > mImage; + LLUIColor mImageColor; + + LLUIString mLabel; + LLUIColor mLabelColor; + + LLRelPos::Location mLocation; + F32 mLocationPercentHCenter; + F32 mLocationPercentVCenter; + + LLHandle< LLUICtrl > mOwner; + + F32 mPaddingHoriz; + F32 mPaddingVert; +}; + +// Build time optimization, generate once in .cpp file +#ifndef LLBADGE_CPP +extern template class LLBadge* LLView::getChild(const std::string& name, BOOL recurse) const; +#endif + +#endif // LL_LLBADGE_H diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 45ceaff696..a63281b3c1 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -56,6 +56,9 @@ static LLDefaultChildRegistry::Register r("button"); template class LLButton* LLView::getChild( const std::string& name, BOOL recurse) const; + + + // globals loaded from settings.xml S32 LLBUTTON_H_PAD = 0; S32 BTN_HEIGHT_SMALL= 0; @@ -99,7 +102,8 @@ LLButton::Params::Params() scale_image("scale_image", true), hover_glow_amount("hover_glow_amount"), commit_on_return("commit_on_return", true), - use_draw_context_alpha("use_draw_context_alpha", true) + use_draw_context_alpha("use_draw_context_alpha", true), + badge("badge") { addSynonym(is_toggle, "toggle"); held_down_delay.seconds = 0.5f; @@ -160,8 +164,8 @@ LLButton::LLButton(const LLButton::Params& p) mMouseDownSignal(NULL), mMouseUpSignal(NULL), mHeldDownSignal(NULL), - mUseDrawContextAlpha(p.use_draw_context_alpha) - + mUseDrawContextAlpha(p.use_draw_context_alpha), + mBadge(NULL) { static LLUICachedControl llbutton_orig_h_pad ("UIButtonOrigHPad", 0); static Params default_params(LLUICtrlFactory::getDefaultParams()); @@ -244,6 +248,17 @@ LLButton::LLButton(const LLButton::Params& p) { setHeldDownCallback(initCommitCallback(p.mouse_held_callback)); } + + // Only create a badge here if a non-default one was provided. + if (p.badge.isProvided()) + { + if (!p.badge().equals(LLUICtrlFactory::getDefaultParams())) + { + LLBadge::Params badge_params(p.badge()); + badge_params.owner = getUICtrlHandle(); + mBadge = LLUICtrlFactory::create(badge_params); + } + } } LLButton::~LLButton() @@ -327,6 +342,13 @@ boost::signals2::connection LLButton::setHeldDownCallback( button_callback_t cb, BOOL LLButton::postBuild() { autoResize(); + + // Attach the badge to the appropriate parent panel + if (mBadge) + { + addBadgeToParentPanel(); + } + return TRUE; } BOOL LLButton::handleUnicodeCharHere(llwchar uni_char) @@ -867,7 +889,7 @@ void LLButton::draw() S32_MAX, text_width, NULL, mUseEllipses); } - + LLUICtrl::draw(); } @@ -1063,6 +1085,70 @@ void LLButton::setImageOverlay(const LLUUID& image_id, LLFontGL::HAlign alignmen } } +void LLButton::addBadgeToParentPanel() +{ + if (mBadge) + { + // Find the appropriate parent panel for the badge + + LLPanel * parentPanel = NULL; + LLUICtrl * parent = getParentUICtrl(); + + while (parent) + { + parentPanel = dynamic_cast(parent); + + if (parentPanel != NULL) + { + break; + } + + parent = parent->getParentUICtrl(); + } + + if (parentPanel) + { + parentPanel->addChild(mBadge); + } + else + { + llwarns << "Unable to find parent panel for badge " << mBadge->getName() << " on button " << getName() << llendl; + } + } + else + { + llwarns << "Unable to add NULL badge to button " << getName() << llendl; + } +} + +void LLButton::setBadgeLabel(const LLStringExplicit& label) +{ + if (mBadge == NULL) + { + LLBadge::Params badge_params(LLUICtrlFactory::getDefaultParams()); + badge_params.owner = getUICtrlHandle(); + mBadge = LLUICtrlFactory::create(badge_params); + + addBadgeToParentPanel(); + } + + if (mBadge) + { + mBadge->setLabel(label); + + // + // Push the badge to the front so it renders last + // + + LLUICtrl * parent = mBadge->getParentUICtrl(); + + if (parent) + { + parent->sendChildToFront(mBadge); + } + } +} + void LLButton::onMouseCaptureLost() { resetMouseDownTimer(); diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 0cfc393e05..232ab81e0d 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -27,6 +27,8 @@ #ifndef LL_LLBUTTON_H #define LL_LLBUTTON_H +#include "lluuid.h" +#include "llbadge.h" #include "llcontrol.h" #include "lluictrl.h" #include "v4color.h" @@ -52,8 +54,6 @@ S32 round_up(S32 grid, S32 value); class LLUICtrlFactory; -class LLUIImage; -class LLUUID; // // Classes @@ -126,6 +126,8 @@ public: Optional held_down_delay; Optional use_draw_context_alpha; + + Optional badge; Params(); }; @@ -249,6 +251,8 @@ public: void setImageDisabledSelected(LLPointer image); void setImageFlash(LLPointer image); void setImagePressed(LLPointer image); + + void setBadgeLabel(const LLStringExplicit& label); void setCommitOnReturn(BOOL commit) { mCommitOnReturn = commit; } BOOL getCommitOnReturn() const { return mCommitOnReturn; } @@ -267,6 +271,8 @@ protected: LLPointer getImageUnselected() const { return mImageUnselected; } LLPointer getImageSelected() const { return mImageSelected; } + void addBadgeToParentPanel(); + LLFrameTimer mMouseDownTimer; private: @@ -357,6 +363,8 @@ private: bool mForcePressedState; LLFrameTimer mFlashingTimer; + + LLBadge* mBadge; }; // Build time optimization, generate once in .cpp file -- cgit v1.2.3 From 33e4a2c7b1ab3a06f1adb5edd9850523c897ea77 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 25 May 2011 10:39:34 -0700 Subject: Updated Marketplace Inbox & Outbox panel to maintain size when one is expanded vs the other --- indra/llui/lllayoutstack.cpp | 18 +++++++++--------- indra/llui/lllayoutstack.h | 4 ++++ 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 9b6830a816..8a92796942 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -78,20 +78,20 @@ LLLayoutPanel::~LLLayoutPanel() delete mResizeBar; mResizeBar = NULL; } - + F32 LLLayoutPanel::getCollapseFactor(LLLayoutStack::ELayoutOrientation orientation) { if (orientation == LLLayoutStack::HORIZONTAL) { F32 collapse_amt = - clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, (F32)mMinDim / (F32)llmax(1, getRect().getWidth())); + clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, (F32)mMinDim / (F32)llmax(1, getRect().getWidth())); return mVisibleAmt * collapse_amt; } else { - F32 collapse_amt = + F32 collapse_amt = clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, llmin(1.f, (F32)mMinDim / (F32)llmax(1, getRect().getHeight()))); - return mVisibleAmt * collapse_amt; + return mVisibleAmt * collapse_amt; } } @@ -182,14 +182,14 @@ BOOL LLLayoutStack::postBuild() } bool LLLayoutStack::addChild(LLView* child, S32 tab_group) - { +{ LLLayoutPanel* panelp = dynamic_cast(child); - if (panelp) - { + if (panelp) + { mPanels.push_back(panelp); - } + } return LLView::addChild(child, tab_group); - } +} S32 LLLayoutStack::getDefaultHeight(S32 cur_height) diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 4ac8ef0ee9..2fc2cf3eb4 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -177,6 +177,10 @@ public: ~LLLayoutPanel(); void initFromParams(const Params& p); + + S32 getMinDim() const { return mMinDim; } + S32 getMaxDim() const { return mMaxDim; } + void setMinDim(S32 value) { mMinDim = value; } void setMaxDim(S32 value) { mMaxDim = value; } -- cgit v1.2.3 From 657e434fd59139436e8b97e5ecd01ca686e82269 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 30 May 2011 22:34:56 +0300 Subject: STORM-1253 WIP New day cycle editor. Done: * Creating new local day cycles. * Editing existing local day cycles. * Deleting day cycles. To do: * Editing region day cycle, dealing with skies in region scope. * Handle teleport while editing a day cycle. * Update UI when a day cycle or sky preset gets deleted. * Make the time ctrl increase/decrease consistently. --- indra/llui/lltimectrl.cpp | 86 +++++++++++++++++++++++++++++++++++++++++------ indra/llui/lltimectrl.h | 21 +++++++----- 2 files changed, 88 insertions(+), 19 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltimectrl.cpp b/indra/llui/lltimectrl.cpp index a77842a392..ce376f001d 100644 --- a/indra/llui/lltimectrl.cpp +++ b/indra/llui/lltimectrl.cpp @@ -108,7 +108,7 @@ LLTimeCtrl::LLTimeCtrl(const LLTimeCtrl::Params& p) mEditor = LLUICtrlFactory::create (params); mEditor->setPrevalidateInput(LLTextValidate::validateNonNegativeS32NoSpace); mEditor->setPrevalidate(boost::bind(&LLTimeCtrl::isTimeStringValid, this, _1)); - mEditor->setText(LLStringExplicit("0:00 AM")); + mEditor->setText(LLStringExplicit("12:00 AM")); addChild(mEditor); //================= Spin Buttons ==========// @@ -130,6 +130,66 @@ LLTimeCtrl::LLTimeCtrl(const LLTimeCtrl::Params& p) setUseBoundingRect( TRUE ); } +F32 LLTimeCtrl::getTime24() const +{ + return getHours24() + getMinutes() / 60.0f; +} + +U32 LLTimeCtrl::getHours24() const +{ + U32 h = mHours; + + if (h == 12) + { + h = 0; + } + + if (mCurrentDayPeriod == PM) + { + h += 12; + } + + return h; +} + +U32 LLTimeCtrl::getMinutes() const +{ + return mMinutes; +} + +void LLTimeCtrl::setTime24(F32 time) +{ + time = llclamp(time, 0.0f, 23.99f); // fix out of range values + + U32 h = time; + U32 m = llround((time - h) * 60); // fixes values like 4.99999 + + // fix rounding error + if (m == 60) + { + m = 0; + ++h; + } + + mCurrentDayPeriod = (h >= 12 ? PM : AM); + + if (h >= 12) + { + h -= 12; + } + + if (h == 0) + { + h = 12; + } + + + mHours = h; + mMinutes = m; + + updateText(); +} + BOOL LLTimeCtrl::handleKeyHere(KEY key, MASK mask) { if (mEditor->hasFocus()) @@ -144,6 +204,11 @@ BOOL LLTimeCtrl::handleKeyHere(KEY key, MASK mask) onDownBtn(); return TRUE; } + if (key == KEY_RETURN) + { + onCommit(); + return TRUE; + } } return FALSE; } @@ -165,8 +230,8 @@ void LLTimeCtrl::onUpBtn() break; } - buildTimeString(); - mEditor->setText(mTimeString); + updateText(); + onCommit(); } void LLTimeCtrl::onDownBtn() @@ -186,15 +251,14 @@ void LLTimeCtrl::onDownBtn() break; } - buildTimeString(); - mEditor->setText(mTimeString); + updateText(); + onCommit(); } void LLTimeCtrl::onFocusLost() { - buildTimeString(); - mEditor->setText(mTimeString); - + updateText(); + onCommit(); LLUICtrl::onFocusLost(); } @@ -300,6 +364,7 @@ LLWString LLTimeCtrl::getMinutesWString(const LLWString& wstr) void LLTimeCtrl::increaseMinutes() { + // *TODO: snap to 5 min if (++mMinutes > MINUTES_MAX) { mMinutes = MINUTES_MIN; @@ -316,6 +381,7 @@ void LLTimeCtrl::increaseHours() void LLTimeCtrl::decreaseMinutes() { + // *TODO: snap to 5 min if (mMinutes-- == MINUTES_MIN) { mMinutes = MINUTES_MAX; @@ -344,7 +410,7 @@ void LLTimeCtrl::switchDayPeriod() } } -void LLTimeCtrl::buildTimeString() +void LLTimeCtrl::updateText() { std::stringstream time_buf; time_buf << mHours << ":"; @@ -367,7 +433,7 @@ void LLTimeCtrl::buildTimeString() break; } - mTimeString = time_buf.str(); + mEditor->setText(time_buf.str()); } LLTimeCtrl::EEditingPart LLTimeCtrl::getEditingPart() diff --git a/indra/llui/lltimectrl.h b/indra/llui/lltimectrl.h index 81d4477da4..aebc5b6eab 100644 --- a/indra/llui/lltimectrl.h +++ b/indra/llui/lltimectrl.h @@ -37,6 +37,7 @@ class LLLineEditor; class LLTimeCtrl : public LLUICtrl { + LOG_CLASS(LLTimeCtrl); public: struct Params : public LLInitParam::Block { @@ -51,13 +52,17 @@ public: Params(); }; + + F32 getTime24() const; // 0.0 - 24.0 + U32 getHours24() const; // 0 - 23 + U32 getMinutes() const; // 0 - 59 + + void setTime24(F32 time); // 0.0 - 23.98(3) + protected: LLTimeCtrl(const Params&); friend class LLUICtrlFactory; - U32 getHours() const { return mHours; } - U32 getMinutes() const { return mMinutes; } - private: enum EDayPeriod @@ -101,7 +106,7 @@ private: void switchDayPeriod(); - void buildTimeString(); + void updateText(); EEditingPart getEditingPart(); @@ -114,11 +119,9 @@ private: class LLButton* mUpBtn; class LLButton* mDownBtn; - U32 mHours; - U32 mMinutes; - EDayPeriod mCurrentDayPeriod; - - std::string mTimeString; + U32 mHours; // 1 - 12 + U32 mMinutes; // 0 - 59 + EDayPeriod mCurrentDayPeriod; // AM/PM BOOL mAllowEdit; }; -- cgit v1.2.3 From 345a72f47996f9e3ccd7cb1a28060250339be3c8 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 30 May 2011 23:20:04 +0300 Subject: STORM-1253 WIP Fixed a compiler warning. --- indra/llui/lltimectrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/lltimectrl.cpp b/indra/llui/lltimectrl.cpp index ce376f001d..88b11d6c0f 100644 --- a/indra/llui/lltimectrl.cpp +++ b/indra/llui/lltimectrl.cpp @@ -161,7 +161,7 @@ void LLTimeCtrl::setTime24(F32 time) { time = llclamp(time, 0.0f, 23.99f); // fix out of range values - U32 h = time; + U32 h = (U32) time; U32 m = llround((time - h) * 60); // fixes values like 4.99999 // fix rounding error -- cgit v1.2.3 From af1b7a4ac87f81b56fe1ff49d29c6bd7c3bffa9c Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Wed, 1 Jun 2011 16:53:19 +0300 Subject: STORM-1253 WIP Time control: the up/down buttons now work consistently across the whole day; time values are snapped to 5 minutes. --- indra/llui/lltimectrl.cpp | 292 +++++++++++++++++++++------------------------- indra/llui/lltimectrl.h | 29 ++--- 2 files changed, 148 insertions(+), 173 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lltimectrl.cpp b/indra/llui/lltimectrl.cpp index 88b11d6c0f..9ea1e8815e 100644 --- a/indra/llui/lltimectrl.cpp +++ b/indra/llui/lltimectrl.cpp @@ -46,9 +46,13 @@ const U32 MINUTES_MIN = 0; const U32 MINUTES_MAX = 59; const U32 HOURS_MIN = 1; const U32 HOURS_MAX = 12; +const U32 MINUTES_PER_HOUR = 60; +const U32 MINUTES_PER_DAY = 24 * MINUTES_PER_HOUR; + LLTimeCtrl::Params::Params() : label_width("label_width"), + snap_to("snap_to"), allow_text_entry("allow_text_entry", true), text_enabled_color("text_enabled_color"), text_disabled_color("text_disabled_color"), @@ -61,8 +65,8 @@ LLTimeCtrl::LLTimeCtrl(const LLTimeCtrl::Params& p) mLabelBox(NULL), mTextEnabledColor(p.text_enabled_color()), mTextDisabledColor(p.text_disabled_color()), - mHours(HOURS_MIN), - mMinutes(MINUTES_MIN) + mTime(0), + mSnapToMin(5) { static LLUICachedControl spinctrl_spacing ("UISpinctrlSpacing", 0); static LLUICachedControl spinctrl_btn_width ("UISpinctrlBtnWidth", 0); @@ -132,60 +136,24 @@ LLTimeCtrl::LLTimeCtrl(const LLTimeCtrl::Params& p) F32 LLTimeCtrl::getTime24() const { - return getHours24() + getMinutes() / 60.0f; + // 0.0 - 23.99; + return mTime / 60.0f; } U32 LLTimeCtrl::getHours24() const { - U32 h = mHours; - - if (h == 12) - { - h = 0; - } - - if (mCurrentDayPeriod == PM) - { - h += 12; - } - - return h; + return (U32) getTime24(); } U32 LLTimeCtrl::getMinutes() const { - return mMinutes; + return mTime % MINUTES_PER_HOUR; } void LLTimeCtrl::setTime24(F32 time) { time = llclamp(time, 0.0f, 23.99f); // fix out of range values - - U32 h = (U32) time; - U32 m = llround((time - h) * 60); // fixes values like 4.99999 - - // fix rounding error - if (m == 60) - { - m = 0; - ++h; - } - - mCurrentDayPeriod = (h >= 12 ? PM : AM); - - if (h >= 12) - { - h -= 12; - } - - if (h == 0) - { - h = 12; - } - - - mHours = h; - mMinutes = m; + mTime = llround(time * MINUTES_PER_HOUR); // fixes values like 4.99999 updateText(); } @@ -264,197 +232,201 @@ void LLTimeCtrl::onFocusLost() void LLTimeCtrl::onTextEntry(LLLineEditor* line_editor) { - LLWString time_str = line_editor->getWText(); - switch(getEditingPart()) + std::string time_str = line_editor->getText(); + U32 h12 = parseHours(getHoursString(time_str)); + U32 m = parseMinutes(getMinutesString(time_str)); + bool pm = parseAMPM(getAMPMString(time_str)); + + if (h12 == 12) { - case HOURS: - validateHours(getHoursWString(time_str)); - break; - case MINUTES: - validateMinutes(getMinutesWString(time_str)); - break; - default: - break; + h12 = 0; } + + U32 h24 = pm ? h12 + 12 : h12; + + mTime = h24 * MINUTES_PER_HOUR + m; } bool LLTimeCtrl::isTimeStringValid(const LLWString &wstr) { - if (!isHoursStringValid(getHoursWString(wstr)) || !isMinutesStringValid(getMinutesWString(wstr)) || !isPMAMStringValid(wstr)) - return false; + std::string str = wstring_to_utf8str(wstr); - return true; + return isHoursStringValid(getHoursString(str)) && + isMinutesStringValid(getMinutesString(str)) && + isPMAMStringValid(getAMPMString(str)); } -bool LLTimeCtrl::isHoursStringValid(const LLWString& wstr) +void LLTimeCtrl::increaseMinutes() { - U32 hours; - std::string utf8time = wstring_to_utf8str(wstr); - if ((!LLStringUtil::convertToU32(utf8time, hours) || (hours <= HOURS_MAX)) && wstr.length() < 3) - return true; + mTime = (mTime + mSnapToMin) % MINUTES_PER_DAY - (mTime % mSnapToMin); +} - return false; +void LLTimeCtrl::increaseHours() +{ + mTime = (mTime + MINUTES_PER_HOUR) % MINUTES_PER_DAY; } -bool LLTimeCtrl::isMinutesStringValid(const LLWString& wstr) +void LLTimeCtrl::decreaseMinutes() { - U32 minutes; - std::string utf8time = wstring_to_utf8str(wstr); - if (!LLStringUtil::convertToU32(utf8time, minutes) || (minutes <= MINUTES_MAX) && wstr.length() < 3) - return true; + if (mTime < mSnapToMin) + { + mTime = MINUTES_PER_DAY - mTime; + } - return false; + mTime -= (mTime % mSnapToMin) ? mTime % mSnapToMin : mSnapToMin; } -void LLTimeCtrl::validateHours(const LLWString& wstr) +void LLTimeCtrl::decreaseHours() { - U32 hours; - std::string utf8time = wstring_to_utf8str(wstr); - if (LLStringUtil::convertToU32(utf8time, hours) && (hours >= HOURS_MIN) && (hours <= HOURS_MAX)) + if (mTime < MINUTES_PER_HOUR) { - mHours = hours; + mTime = 23 * MINUTES_PER_HOUR + mTime; } else { - mHours = HOURS_MIN; + mTime -= MINUTES_PER_HOUR; } } -void LLTimeCtrl::validateMinutes(const LLWString& wstr) +bool LLTimeCtrl::isPM() const { - U32 minutes; - std::string utf8time = wstring_to_utf8str(wstr); - if (LLStringUtil::convertToU32(utf8time, minutes) && (minutes >= MINUTES_MIN) && (minutes <= MINUTES_MAX)) + return mTime >= (MINUTES_PER_DAY / 2); +} + +void LLTimeCtrl::switchDayPeriod() +{ + if (isPM()) { - mMinutes = minutes; + mTime -= MINUTES_PER_DAY / 2; } else { - mMinutes = MINUTES_MIN; + mTime += MINUTES_PER_DAY / 2; } } -bool LLTimeCtrl::isPMAMStringValid(const LLWString &wstr) +void LLTimeCtrl::updateText() +{ + U32 h24 = getHours24(); + U32 m = getMinutes(); + U32 h12 = h24 > 12 ? h24 - 12 : h24; + + if (h12 == 0) + h12 = 12; + + mEditor->setText(llformat("%d:%02d %s", h12, m, isPM() ? "PM":"AM")); +} + +LLTimeCtrl::EEditingPart LLTimeCtrl::getEditingPart() { - S32 len = wstr.length(); + S32 cur_pos = mEditor->getCursor(); + std::string time_str = mEditor->getText(); - bool valid = (wstr[--len] == 'M') && (wstr[--len] == 'P' || wstr[len] == 'A'); + S32 colon_index = time_str.find_first_of(':'); - return valid; + if (cur_pos <= colon_index) + { + return HOURS; + } + else if (cur_pos > colon_index && cur_pos <= (S32)(time_str.length() - AMPM_LEN)) + { + return MINUTES; + } + else if (cur_pos > (S32)(time_str.length() - AMPM_LEN)) + { + return DAYPART; + } + + return NONE; } -LLWString LLTimeCtrl::getHoursWString(const LLWString& wstr) +// static +std::string LLTimeCtrl::getHoursString(const std::string& str) { - size_t colon_index = wstr.find_first_of(':'); - LLWString hours_str = wstr.substr(0, colon_index); + size_t colon_index = str.find_first_of(':'); + std::string hours_str = str.substr(0, colon_index); return hours_str; } -LLWString LLTimeCtrl::getMinutesWString(const LLWString& wstr) +// static +std::string LLTimeCtrl::getMinutesString(const std::string& str) { - size_t colon_index = wstr.find_first_of(':'); + size_t colon_index = str.find_first_of(':'); ++colon_index; - int minutes_len = wstr.length() - colon_index - AMPM_LEN; - LLWString minutes_str = wstr.substr(colon_index, minutes_len); + int minutes_len = str.length() - colon_index - AMPM_LEN; + std::string minutes_str = str.substr(colon_index, minutes_len); return minutes_str; } -void LLTimeCtrl::increaseMinutes() +// static +std::string LLTimeCtrl::getAMPMString(const std::string& str) { - // *TODO: snap to 5 min - if (++mMinutes > MINUTES_MAX) - { - mMinutes = MINUTES_MIN; - } + return str.substr(str.size() - 2, 2); // returns last two characters } -void LLTimeCtrl::increaseHours() +// static +bool LLTimeCtrl::isHoursStringValid(const std::string& str) { - if (++mHours > HOURS_MAX) - { - mHours = HOURS_MIN; - } -} + U32 hours; + if ((!LLStringUtil::convertToU32(str, hours) || (hours <= HOURS_MAX)) && str.length() < 3) + return true; -void LLTimeCtrl::decreaseMinutes() -{ - // *TODO: snap to 5 min - if (mMinutes-- == MINUTES_MIN) - { - mMinutes = MINUTES_MAX; - } + return false; } -void LLTimeCtrl::decreaseHours() +// static +bool LLTimeCtrl::isMinutesStringValid(const std::string& str) { - if (mHours-- == HOURS_MIN) - { - mHours = HOURS_MAX; - switchDayPeriod(); - } + U32 minutes; + if (!LLStringUtil::convertToU32(str, minutes) || (minutes <= MINUTES_MAX) && str.length() < 3) + return true; + + return false; } -void LLTimeCtrl::switchDayPeriod() +// static +bool LLTimeCtrl::isPMAMStringValid(const std::string& str) { - switch (mCurrentDayPeriod) - { - case AM: - mCurrentDayPeriod = PM; - break; - case PM: - mCurrentDayPeriod = AM; - break; - } + S32 len = str.length(); + + bool valid = (str[--len] == 'M') && (str[--len] == 'P' || str[len] == 'A'); + + return valid; } -void LLTimeCtrl::updateText() +// static +U32 LLTimeCtrl::parseHours(const std::string& str) { - std::stringstream time_buf; - time_buf << mHours << ":"; - - if (mMinutes < 10) + U32 hours; + if (LLStringUtil::convertToU32(str, hours) && (hours >= HOURS_MIN) && (hours <= HOURS_MAX)) { - time_buf << "0"; + return hours; } - - time_buf << mMinutes; - time_buf << " "; - - switch (mCurrentDayPeriod) + else { - case AM: - time_buf << "AM"; - break; - case PM: - time_buf << "PM"; - break; + return HOURS_MIN; } - - mEditor->setText(time_buf.str()); } -LLTimeCtrl::EEditingPart LLTimeCtrl::getEditingPart() +// static +U32 LLTimeCtrl::parseMinutes(const std::string& str) { - S32 cur_pos = mEditor->getCursor(); - LLWString time_str = mEditor->getWText(); - - S32 colon_index = time_str.find_first_of(':'); - - if (cur_pos <= colon_index) - { - return HOURS; - } - else if (cur_pos > colon_index && cur_pos <= (S32)(time_str.length() - AMPM_LEN)) + U32 minutes; + if (LLStringUtil::convertToU32(str, minutes) && (minutes >= MINUTES_MIN) && (minutes <= MINUTES_MAX)) { - return MINUTES; + return minutes; } - else if (cur_pos > (S32)(time_str.length() - AMPM_LEN)) + else { - return DAYPART; + return MINUTES_MIN; } +} - return NONE; +// static +bool LLTimeCtrl::parseAMPM(const std::string& str) +{ + return str == "PM"; } diff --git a/indra/llui/lltimectrl.h b/indra/llui/lltimectrl.h index aebc5b6eab..b5f268c76a 100644 --- a/indra/llui/lltimectrl.h +++ b/indra/llui/lltimectrl.h @@ -42,6 +42,7 @@ public: struct Params : public LLInitParam::Block { Optional label_width; + Optional snap_to; Optional allow_text_entry; Optional text_enabled_color; @@ -84,32 +85,35 @@ private: void onUpBtn(); void onDownBtn(); - void onTextEntry(LLLineEditor* line_editor); - void validateHours(const LLWString& wstr); - void validateMinutes(const LLWString& wstr); bool isTimeStringValid(const LLWString& wstr); - bool isPMAMStringValid(const LLWString& wstr); - bool isHoursStringValid(const LLWString& wstr); - bool isMinutesStringValid(const LLWString& wstr); - - LLWString getHoursWString(const LLWString& wstr); - LLWString getMinutesWString(const LLWString& wstr); - void increaseMinutes(); void increaseHours(); void decreaseMinutes(); void decreaseHours(); + bool isPM() const; void switchDayPeriod(); void updateText(); EEditingPart getEditingPart(); + static std::string getHoursString(const std::string& str); + static std::string getMinutesString(const std::string& str); + static std::string getAMPMString(const std::string& str); + + static bool isHoursStringValid(const std::string& str); + static bool isMinutesStringValid(const std::string& str); + static bool isPMAMStringValid(const std::string& str); + + static U32 parseHours(const std::string& str); + static U32 parseMinutes(const std::string& str); + static bool parseAMPM(const std::string& str); + class LLTextBox* mLabelBox; class LLLineEditor* mEditor; @@ -119,9 +123,8 @@ private: class LLButton* mUpBtn; class LLButton* mDownBtn; - U32 mHours; // 1 - 12 - U32 mMinutes; // 0 - 59 - EDayPeriod mCurrentDayPeriod; // AM/PM + U32 mTime; // minutes since midnight: 0 - 1439 + U32 mSnapToMin; // interval in minutes to snap to BOOL mAllowEdit; }; -- cgit v1.2.3 From 17d862fdf2529a5b64a9a6909fe9eda22ab1057b Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Fri, 3 Jun 2011 18:28:51 +0300 Subject: STORM-1253 WIP Fixed track colors in the day cycle editor. - Selected key now visually differs from others. - Disabled triangle becomes more transparent. --- indra/llui/llmultislider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index f744e9db41..9052bc7d1d 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -511,7 +511,7 @@ void LLMultiSlider::draw() mIt->second.mTop + extra_triangle_height, mIt->second.mLeft + mIt->second.getWidth() / 2, mIt->second.mBottom - extra_triangle_height, - mTriangleColor.get(), TRUE); + mTriangleColor.get() % opacity, TRUE); } } else if (!thumb_imagep) -- cgit v1.2.3 From 98bcd9e2efe4cc0dc5e51da09c6f18424b9d9144 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 6 Jun 2011 17:00:59 -0700 Subject: EXP-859 FIX -- Save setting for last time inbox expanded EXP-841 PROGRESS -- Create outbox sync button with basic enable/disable logic and animation EXP-866 PROGRESS -- Create inbox observer to dynamically update inbox item count and badge value EXP-872 PROGRESS -- Hide inbox and outbox unless applicable Inbox expansion time is now saved as setting variable "LastInventoryInboxExpand". New outbox sync button art. Observers for items and categories are now implemented in the LLSidepanelInventory but the exact method of use is still to be determined. Functions are in place to show and hide the inbox and outbox panels but the logic around the decision is TBD. The resize bar for the inbox/outbox is now disabled when both inbox and outbox are collapsed. Reviewed by Leyla. --- indra/llui/llloadingindicator.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/llloadingindicator.h b/indra/llui/llloadingindicator.h index 4c47cc267c..7c44478848 100644 --- a/indra/llui/llloadingindicator.h +++ b/indra/llui/llloadingindicator.h @@ -86,6 +86,8 @@ public: */ void start(); + void reset() { mCurImageIdx = 0; } + private: LLLoadingIndicator(const Params&); void initFromParams(const Params&); -- cgit v1.2.3 From 1aed9849285b574346087eb5ac7e0c8038fa21fe Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 7 Jun 2011 13:57:19 -0700 Subject: EXP-865 PROGRESS -- Modify LLBadge to allow it to hang off of non-buttons Added the following for increased LLBadge functionality: * Panels now choose whether or not they accept buttons as children, which they do by default. * UI controls now shuffle controls with "requests_front" to the front of their children list at postBuild time. * Badges are set to "requests_front" by default * Badges now accept border image and color attributes Reviewed by Callum --- indra/llui/llbadge.cpp | 11 +++++++++++ indra/llui/llbadge.h | 6 ++++++ indra/llui/llbutton.cpp | 2 +- indra/llui/llbutton.h | 2 +- indra/llui/llpanel.cpp | 8 ++++++-- indra/llui/llpanel.h | 5 +++++ indra/llui/lluictrl.cpp | 36 +++++++++++++++++++++++++++++++++++- indra/llui/lluictrl.h | 8 ++++++-- 8 files changed, 71 insertions(+), 7 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index ea934aa93b..e4c64e327e 100644 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -38,6 +38,8 @@ template class LLBadge* LLView::getChild(const std::string& name, LLBadge::Params::Params() : image("image") + , border_image("border_image") + , border_color("border_color") , image_color("image_color") , label("label") , label_color("label_color") @@ -57,6 +59,8 @@ bool LLBadge::Params::equals(const Params& a) const // skip owner in comparison on purpose + comp &= (border_image() == a.border_image()); + comp &= (border_color() == a.border_color()); comp &= (image() == a.image()); comp &= (image_color() == a.image_color()); comp &= (label() == a.label()); @@ -73,6 +77,8 @@ bool LLBadge::Params::equals(const Params& a) const LLBadge::LLBadge(const LLBadge::Params& p) : LLUICtrl(p) , mOwner(p.owner) + , mBorderImage(p.border_image) + , mBorderColor(p.border_color) , mGLFont(p.font) , mImage(p.image) , mImageColor(p.image_color) @@ -216,6 +222,11 @@ void LLBadge::draw() F32 badge_y = badge_center_y - badge_height * 0.5f; mImage->drawSolid(badge_x, badge_y, badge_width, badge_height, mImageColor % alpha); + + if (!mBorderImage.isNull()) + { + mBorderImage->drawSolid(badge_x, badge_y, badge_width, badge_height, mBorderColor % alpha); + } } else { diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h index c2e0a763b2..05a76af42c 100644 --- a/indra/llui/llbadge.h +++ b/indra/llui/llbadge.h @@ -94,6 +94,9 @@ public: { Optional< LLHandle > owner; // Mandatory in code but not in xml + Optional< LLUIImage* > border_image; + Optional< LLUIColor > border_color; + Optional< LLUIImage* > image; Optional< LLUIColor > image_color; @@ -126,6 +129,9 @@ public: void setLabel( const LLStringExplicit& label); private: + LLPointer< LLUIImage > mBorderImage; + LLUIColor mBorderColor; + const LLFontGL* mGLFont; LLPointer< LLUIImage > mImage; diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index a63281b3c1..c841933a5f 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -1098,7 +1098,7 @@ void LLButton::addBadgeToParentPanel() { parentPanel = dynamic_cast(parent); - if (parentPanel != NULL) + if (parentPanel && parentPanel->acceptsBadge()) { break; } diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 232ab81e0d..07f0395719 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -125,7 +125,7 @@ public: Optional hover_glow_amount; Optional held_down_delay; - Optional use_draw_context_alpha; + Optional use_draw_context_alpha; Optional badge; diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index b2383106a8..1dcdd79efa 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -87,7 +87,8 @@ LLPanel::Params::Params() filename("filename"), class_name("class"), help_topic("help_topic"), - visible_callback("visible_callback") + visible_callback("visible_callback"), + accepts_badge("accepts_badge") { name = "panel"; addSynonym(background_visible, "bg_visible"); @@ -113,7 +114,8 @@ LLPanel::LLPanel(const LLPanel::Params& p) mCommitCallbackRegistrar(false), mEnableCallbackRegistrar(false), mXMLFilename(p.filename), - mVisibleSignal(NULL) + mVisibleSignal(NULL), + mAcceptsBadge(p.accepts_badge) // *NOTE: Be sure to also change LLPanel::initFromParams(). We have too // many classes derived from LLPanel to retrofit them all to pass in params. { @@ -485,6 +487,8 @@ void LLPanel::initFromParams(const LLPanel::Params& p) mBgAlphaImage = p.bg_alpha_image(); mBgOpaqueImageOverlay = p.bg_opaque_image_overlay; mBgAlphaImageOverlay = p.bg_alpha_image_overlay; + + mAcceptsBadge = p.accepts_badge; } static LLFastTimer::DeclareTimer FTM_PANEL_SETUP("Panel Setup"); diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 7bbbeaf709..67674fab7e 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -89,6 +89,8 @@ public: Multiple strings; Optional visible_callback; + + Optional accepts_badge; Params(); }; @@ -250,6 +252,8 @@ public: boost::signals2::connection setVisibleCallback( const commit_signal_t::slot_type& cb ); + bool acceptsBadge() const { return mAcceptsBadge; } + protected: // Override to set not found list LLButton* getDefaultButton() { return mDefaultBtn; } @@ -264,6 +268,7 @@ protected: static factory_stack_t sFactoryStack; private: + bool mAcceptsBadge; BOOL mBgVisible; // any background at all? BOOL mBgOpaque; // use opaque color or image LLUIColor mBgOpaqueColor; diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 0a06b5e74f..d58df5801b 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -68,6 +68,7 @@ LLUICtrl::ControlVisibility::ControlVisibility() LLUICtrl::Params::Params() : tab_stop("tab_stop", true), chrome("chrome", false), + requests_front("requests_front", false), label("label"), initial_value("value"), init_callback("init_callback"), @@ -96,9 +97,10 @@ const LLUICtrl::Params& LLUICtrl::getDefaultParams() LLUICtrl::LLUICtrl(const LLUICtrl::Params& p, const LLViewModelPtr& viewmodel) : LLView(p), - mTentative(FALSE), mIsChrome(FALSE), + mRequestsFront(p.requests_front), mTabStop(FALSE), + mTentative(FALSE), mViewModel(viewmodel), mControlVariable(NULL), mEnabledControlVariable(NULL), @@ -123,6 +125,8 @@ void LLUICtrl::initFromParams(const Params& p) { LLView::initFromParams(p); + mRequestsFront = p.requests_front; + setIsChrome(p.chrome); setControlName(p.control_name); if(p.enabled_controls.isProvided()) @@ -403,6 +407,36 @@ LLViewModel* LLUICtrl::getViewModel() const return mViewModel; } +//virtual +BOOL LLUICtrl::postBuild() +{ + // + // Find all of the children that want to be in front and move them to the front + // + + if (getChildCount() > 0) + { + std::vector childrenToMoveToFront; + + for (LLView::child_list_const_iter_t child_it = beginChild(); child_it != endChild(); ++child_it) + { + LLUICtrl* uictrl = dynamic_cast(*child_it); + + if (uictrl && uictrl->mRequestsFront) + { + childrenToMoveToFront.push_back(uictrl); + } + } + + for (std::vector::iterator it = childrenToMoveToFront.begin(); it != childrenToMoveToFront.end(); ++it) + { + sendChildToFront(*it); + } + } + + return LLView::postBuild(); +} + bool LLUICtrl::setControlValue(const LLSD& value) { if (mControlVariable) diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index b37e9f6b1b..09bed9b958 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -94,7 +94,8 @@ public: { Optional label; Optional tab_stop, - chrome; + chrome, + requests_front; Optional initial_value; Optional init_callback, @@ -143,6 +144,8 @@ protected: virtual LLViewModel* getViewModel() const; // We shouldn't ever need to set this directly //virtual void setViewModel(const LLViewModelPtr&); + + virtual BOOL postBuild(); public: // LLView interface @@ -301,8 +304,9 @@ protected: private: - BOOL mTabStop; BOOL mIsChrome; + BOOL mRequestsFront; + BOOL mTabStop; BOOL mTentative; LLRootHandle mUICtrlHandle; -- cgit v1.2.3 From 888b39c283e53fd128778e70e231bcb6053de4b8 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 8 Jun 2011 13:14:15 -0700 Subject: EXP-865 PROGRESS -- Modify LLBadge to allow it to hang off of non-buttons Moved LLBadge use from LLButton into a separate LLBadgeOwner class. LLButton now derives from LLBadgeOwner which handles the bulk of the badge management. --- indra/llui/CMakeLists.txt | 2 + indra/llui/llbadgeowner.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++++ indra/llui/llbadgeowner.h | 58 ++++++++++++++++++++++ indra/llui/llbutton.cpp | 87 +++------------------------------ indra/llui/llbutton.h | 10 +--- 5 files changed, 185 insertions(+), 88 deletions(-) create mode 100644 indra/llui/llbadgeowner.cpp create mode 100644 indra/llui/llbadgeowner.h (limited to 'indra/llui') diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index fb585e062c..e9283788bd 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -29,6 +29,7 @@ set(llui_SOURCE_FILES llaccordionctrl.cpp llaccordionctrltab.cpp llbadge.cpp + llbadgeowner.cpp llbutton.cpp llcheckboxctrl.cpp llclipboard.cpp @@ -121,6 +122,7 @@ set(llui_HEADER_FILES llaccordionctrl.h llaccordionctrltab.h llbadge.h + llbadgeowner.h llbutton.h llcallbackmap.h llcheckboxctrl.h diff --git a/indra/llui/llbadgeowner.cpp b/indra/llui/llbadgeowner.cpp new file mode 100644 index 0000000000..c77cf21ae0 --- /dev/null +++ b/indra/llui/llbadgeowner.cpp @@ -0,0 +1,116 @@ +/** + * @file llbadgeowner.cpp + * @brief Class to manage badges attached to a UI control + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llbadgeowner.h" +#include "llpanel.h" + +// +// Classes +// + +LLBadgeOwner::LLBadgeOwner(LLHandle ctrlHandle) + : mBadge(NULL) + , mBadgeOwnerCtrl(ctrlHandle) +{ +} + +void LLBadgeOwner::initBadgeParams(const LLBadge::Params& p) +{ + if (!p.equals(LLUICtrlFactory::getDefaultParams())) + { + mBadge = createBadge(p); + } +} + +void LLBadgeOwner::setBadgeLabel(const LLStringExplicit& label) +{ + if (mBadge == NULL) + { + mBadge = createBadge(LLUICtrlFactory::getDefaultParams()); + + addBadgeToParentPanel(); + } + + if (mBadge) + { + mBadge->setLabel(label); + + // + // Push the badge to the front so it renders on top + // + + LLUICtrl * parent = mBadge->getParentUICtrl(); + + if (parent) + { + parent->sendChildToFront(mBadge); + } + } +} + +void LLBadgeOwner::addBadgeToParentPanel() +{ + if (mBadge && mBadgeOwnerCtrl.get()) + { + // Find the appropriate parent panel for the badge + + LLUICtrl * owner_ctrl = mBadgeOwnerCtrl.get(); + LLUICtrl * parent = owner_ctrl->getParentUICtrl(); + + LLPanel * parentPanel = NULL; + + while (parent) + { + parentPanel = dynamic_cast(parent); + + if (parentPanel && parentPanel->acceptsBadge()) + { + break; + } + + parent = parent->getParentUICtrl(); + } + + if (parentPanel) + { + parentPanel->addChild(mBadge); + } + else + { + llwarns << "Unable to find parent panel for badge " << mBadge->getName() << " on ui control " << owner_ctrl->getName() << llendl; + } + } +} + +LLBadge* LLBadgeOwner::createBadge(const LLBadge::Params& p) +{ + LLBadge::Params badge_params(p); + badge_params.owner = mBadgeOwnerCtrl; + + return LLUICtrlFactory::create(badge_params); +} diff --git a/indra/llui/llbadgeowner.h b/indra/llui/llbadgeowner.h new file mode 100644 index 0000000000..7b2bbe01fd --- /dev/null +++ b/indra/llui/llbadgeowner.h @@ -0,0 +1,58 @@ +/** + * @file llbadgeowner.h + * @brief Header for badge owners + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLBADGEOWNER_H +#define LL_LLBADGEOWNER_H + +#include "llbadge.h" +#include "lluictrl.h" + +// +// Classes +// + +class LLBadgeOwner +{ +public: + + LLBadgeOwner(LLHandle ctrlHandle); + + void initBadgeParams(const LLBadge::Params& p); + void addBadgeToParentPanel(); + + void setBadgeLabel(const LLStringExplicit& label); + +private: + + LLBadge* createBadge(const LLBadge::Params& p); + +private: + + LLBadge* mBadge; + LLHandle mBadgeOwnerCtrl; +}; + +#endif // LL_LLBADGEOWNER_H diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index c841933a5f..ecad38894c 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -113,6 +113,7 @@ LLButton::Params::Params() LLButton::LLButton(const LLButton::Params& p) : LLUICtrl(p), + LLBadgeOwner(getUICtrlHandle()), mMouseDownFrame(0), mMouseHeldDownCount(0), mBorderEnabled( FALSE ), @@ -164,8 +165,7 @@ LLButton::LLButton(const LLButton::Params& p) mMouseDownSignal(NULL), mMouseUpSignal(NULL), mHeldDownSignal(NULL), - mUseDrawContextAlpha(p.use_draw_context_alpha), - mBadge(NULL) + mUseDrawContextAlpha(p.use_draw_context_alpha) { static LLUICachedControl llbutton_orig_h_pad ("UIButtonOrigHPad", 0); static Params default_params(LLUICtrlFactory::getDefaultParams()); @@ -248,16 +248,10 @@ LLButton::LLButton(const LLButton::Params& p) { setHeldDownCallback(initCommitCallback(p.mouse_held_callback)); } - - // Only create a badge here if a non-default one was provided. + if (p.badge.isProvided()) { - if (!p.badge().equals(LLUICtrlFactory::getDefaultParams())) - { - LLBadge::Params badge_params(p.badge()); - badge_params.owner = getUICtrlHandle(); - mBadge = LLUICtrlFactory::create(badge_params); - } + LLBadgeOwner::initBadgeParams(p.badge()); } } @@ -343,14 +337,11 @@ BOOL LLButton::postBuild() { autoResize(); - // Attach the badge to the appropriate parent panel - if (mBadge) - { - addBadgeToParentPanel(); - } + addBadgeToParentPanel(); - return TRUE; + return LLUICtrl::postBuild(); } + BOOL LLButton::handleUnicodeCharHere(llwchar uni_char) { BOOL handled = FALSE; @@ -1085,70 +1076,6 @@ void LLButton::setImageOverlay(const LLUUID& image_id, LLFontGL::HAlign alignmen } } -void LLButton::addBadgeToParentPanel() -{ - if (mBadge) - { - // Find the appropriate parent panel for the badge - - LLPanel * parentPanel = NULL; - LLUICtrl * parent = getParentUICtrl(); - - while (parent) - { - parentPanel = dynamic_cast(parent); - - if (parentPanel && parentPanel->acceptsBadge()) - { - break; - } - - parent = parent->getParentUICtrl(); - } - - if (parentPanel) - { - parentPanel->addChild(mBadge); - } - else - { - llwarns << "Unable to find parent panel for badge " << mBadge->getName() << " on button " << getName() << llendl; - } - } - else - { - llwarns << "Unable to add NULL badge to button " << getName() << llendl; - } -} - -void LLButton::setBadgeLabel(const LLStringExplicit& label) -{ - if (mBadge == NULL) - { - LLBadge::Params badge_params(LLUICtrlFactory::getDefaultParams()); - badge_params.owner = getUICtrlHandle(); - mBadge = LLUICtrlFactory::create(badge_params); - - addBadgeToParentPanel(); - } - - if (mBadge) - { - mBadge->setLabel(label); - - // - // Push the badge to the front so it renders last - // - - LLUICtrl * parent = mBadge->getParentUICtrl(); - - if (parent) - { - parent->sendChildToFront(mBadge); - } - } -} - void LLButton::onMouseCaptureLost() { resetMouseDownTimer(); diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 07f0395719..5880a0e1f2 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -28,7 +28,7 @@ #define LL_LLBUTTON_H #include "lluuid.h" -#include "llbadge.h" +#include "llbadgeowner.h" #include "llcontrol.h" #include "lluictrl.h" #include "v4color.h" @@ -60,7 +60,7 @@ class LLUICtrlFactory; // class LLButton -: public LLUICtrl +: public LLUICtrl, public LLBadgeOwner { public: struct Params @@ -252,8 +252,6 @@ public: void setImageFlash(LLPointer image); void setImagePressed(LLPointer image); - void setBadgeLabel(const LLStringExplicit& label); - void setCommitOnReturn(BOOL commit) { mCommitOnReturn = commit; } BOOL getCommitOnReturn() const { return mCommitOnReturn; } @@ -271,8 +269,6 @@ protected: LLPointer getImageUnselected() const { return mImageUnselected; } LLPointer getImageSelected() const { return mImageSelected; } - void addBadgeToParentPanel(); - LLFrameTimer mMouseDownTimer; private: @@ -363,8 +359,6 @@ private: bool mForcePressedState; LLFrameTimer mFlashingTimer; - - LLBadge* mBadge; }; // Build time optimization, generate once in .cpp file -- cgit v1.2.3 From 86470d3889436017264a69d57fb2060a591955f4 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 8 Jun 2011 15:46:34 -0700 Subject: Fixed to allow param blocks to exceed 64k, even though the size makes me wince. Modified viewer window to not create a navigation bar on exit if one doesn't yet exist. Reviewed by Richard. --- indra/llui/tests/llurlmatch_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp index e09ef33d49..3cd61e574e 100644 --- a/indra/llui/tests/llurlmatch_test.cpp +++ b/indra/llui/tests/llurlmatch_test.cpp @@ -95,7 +95,7 @@ namespace LLInitParam { const U8* my_addr = reinterpret_cast(this); const U8* block_addr = reinterpret_cast(enclosing_block); - mEnclosingBlockOffset = (U16)(my_addr - block_addr); + mEnclosingBlockOffset = 0x7FFFffff & ((U32)(my_addr - block_addr)); } bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation){ return true; } -- cgit v1.2.3 From def85f2778d9b69bc3fb0e89c1cef854a1c01886 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 9 Jun 2011 12:12:28 -0700 Subject: EXP-865 FIX -- Modify LLBadge to allow it to hang off of non-buttons LLBadgeOwner now only depends on LLView instead of LLUICtrl Sidebar Tab Buttons now can support badges Reviewed by Leyla --- indra/llui/llbadge.cpp | 8 ++++---- indra/llui/llbadge.h | 5 +++-- indra/llui/llbadgeowner.cpp | 30 +++++++++++++++--------------- indra/llui/llbadgeowner.h | 6 +++--- indra/llui/llbutton.cpp | 2 +- 5 files changed, 26 insertions(+), 25 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index e4c64e327e..53db226b20 100644 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -178,16 +178,16 @@ void LLBadge::draw() { if (!mLabel.empty()) { - LLUICtrl* owner_ctrl = mOwner.get(); + LLView* owner_view = mOwner.get(); - if (owner_ctrl) + if (owner_view) { // // Calculate badge position based on owner // LLRect owner_rect; - owner_ctrl->localRectToOtherView(owner_ctrl->getLocalRect(), & owner_rect, this); + owner_view->localRectToOtherView(owner_view->getLocalRect(), & owner_rect, this); F32 badge_center_x = owner_rect.mLeft + owner_rect.getWidth() * mLocationPercentHCenter; F32 badge_center_y = owner_rect.mBottom + owner_rect.getHeight() * mLocationPercentVCenter; @@ -230,7 +230,7 @@ void LLBadge::draw() } else { - lldebugs << "No image for badge " << getName() << " on owner " << owner_ctrl->getName() << llendl; + lldebugs << "No image for badge " << getName() << " on owner " << owner_view->getName() << llendl; renderBadgeBackground(badge_center_x, badge_center_y, badge_width, badge_height, diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h index 05a76af42c..0f923ef01b 100644 --- a/indra/llui/llbadge.h +++ b/indra/llui/llbadge.h @@ -33,6 +33,7 @@ #include "lluictrl.h" #include "llstring.h" #include "lluiimage.h" +#include "llview.h" // // Declarations @@ -92,7 +93,7 @@ public: struct Params : public LLInitParam::Block { - Optional< LLHandle > owner; // Mandatory in code but not in xml + Optional< LLHandle > owner; // Mandatory in code but not in xml Optional< LLUIImage* > border_image; Optional< LLUIColor > border_color; @@ -144,7 +145,7 @@ private: F32 mLocationPercentHCenter; F32 mLocationPercentVCenter; - LLHandle< LLUICtrl > mOwner; + LLHandle< LLView > mOwner; F32 mPaddingHoriz; F32 mPaddingVert; diff --git a/indra/llui/llbadgeowner.cpp b/indra/llui/llbadgeowner.cpp index c77cf21ae0..11f1463b9b 100644 --- a/indra/llui/llbadgeowner.cpp +++ b/indra/llui/llbadgeowner.cpp @@ -33,9 +33,9 @@ // Classes // -LLBadgeOwner::LLBadgeOwner(LLHandle ctrlHandle) +LLBadgeOwner::LLBadgeOwner(LLHandle< LLView > viewHandle) : mBadge(NULL) - , mBadgeOwnerCtrl(ctrlHandle) + , mBadgeOwnerView(viewHandle) { } @@ -64,7 +64,7 @@ void LLBadgeOwner::setBadgeLabel(const LLStringExplicit& label) // Push the badge to the front so it renders on top // - LLUICtrl * parent = mBadge->getParentUICtrl(); + LLView * parent = mBadge->getParent(); if (parent) { @@ -75,34 +75,34 @@ void LLBadgeOwner::setBadgeLabel(const LLStringExplicit& label) void LLBadgeOwner::addBadgeToParentPanel() { - if (mBadge && mBadgeOwnerCtrl.get()) + LLView * owner_view = mBadgeOwnerView.get(); + + if (mBadge && owner_view) { // Find the appropriate parent panel for the badge - LLUICtrl * owner_ctrl = mBadgeOwnerCtrl.get(); - LLUICtrl * parent = owner_ctrl->getParentUICtrl(); - - LLPanel * parentPanel = NULL; + LLView * parent = owner_view->getParent(); + LLPanel * parent_panel = NULL; while (parent) { - parentPanel = dynamic_cast(parent); + parent_panel = dynamic_cast(parent); - if (parentPanel && parentPanel->acceptsBadge()) + if (parent_panel && parent_panel->acceptsBadge()) { break; } - parent = parent->getParentUICtrl(); + parent = parent->getParent(); } - if (parentPanel) + if (parent_panel) { - parentPanel->addChild(mBadge); + parent_panel->addChild(mBadge); } else { - llwarns << "Unable to find parent panel for badge " << mBadge->getName() << " on ui control " << owner_ctrl->getName() << llendl; + llwarns << "Unable to find parent panel for badge " << mBadge->getName() << " on " << owner_view->getName() << llendl; } } } @@ -110,7 +110,7 @@ void LLBadgeOwner::addBadgeToParentPanel() LLBadge* LLBadgeOwner::createBadge(const LLBadge::Params& p) { LLBadge::Params badge_params(p); - badge_params.owner = mBadgeOwnerCtrl; + badge_params.owner = mBadgeOwnerView; return LLUICtrlFactory::create(badge_params); } diff --git a/indra/llui/llbadgeowner.h b/indra/llui/llbadgeowner.h index 7b2bbe01fd..456ef90c13 100644 --- a/indra/llui/llbadgeowner.h +++ b/indra/llui/llbadgeowner.h @@ -28,7 +28,7 @@ #define LL_LLBADGEOWNER_H #include "llbadge.h" -#include "lluictrl.h" +#include "llview.h" // // Classes @@ -38,7 +38,7 @@ class LLBadgeOwner { public: - LLBadgeOwner(LLHandle ctrlHandle); + LLBadgeOwner(LLHandle< LLView > viewHandle); void initBadgeParams(const LLBadge::Params& p); void addBadgeToParentPanel(); @@ -52,7 +52,7 @@ private: private: LLBadge* mBadge; - LLHandle mBadgeOwnerCtrl; + LLHandle< LLView > mBadgeOwnerView; }; #endif // LL_LLBADGEOWNER_H diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 907dc31721..637024e513 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -110,7 +110,7 @@ LLButton::Params::Params() LLButton::LLButton(const LLButton::Params& p) : LLUICtrl(p), - LLBadgeOwner(getUICtrlHandle()), + LLBadgeOwner(LLView::getHandle()), mMouseDownFrame(0), mMouseHeldDownCount(0), mBorderEnabled( FALSE ), -- cgit v1.2.3 From 3eeb14ee0abb5720e010d94eba52db09fa32237e Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Fri, 10 Jun 2011 16:20:30 -0700 Subject: EXP-856 FIX -- Inbox item count reflected as badge on inventory button * Modified badges to be parented to their owners if their owners have no parents * Modified side tray tab panels to create badges on side tab buttons when the xml specifies a badge. * Modified inbox to drive the badge value of the sidebar_inventory button. * Updated inbox and outbox sizes so scroll bars function as expected * Updated inventory_panel.xml to allow scroll tag to specify scroll bar properties, instead of just having them hardcoded. Reviewed by Richard --- indra/llui/llbadgeowner.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbadgeowner.cpp b/indra/llui/llbadgeowner.cpp index 11f1463b9b..3d63fc7f60 100644 --- a/indra/llui/llbadgeowner.cpp +++ b/indra/llui/llbadgeowner.cpp @@ -79,26 +79,28 @@ void LLBadgeOwner::addBadgeToParentPanel() if (mBadge && owner_view) { - // Find the appropriate parent panel for the badge + // Badge parent is badge owner by default + LLView * badge_parent = owner_view; + // Find the appropriate parent for the badge LLView * parent = owner_view->getParent(); - LLPanel * parent_panel = NULL; while (parent) { - parent_panel = dynamic_cast(parent); + LLPanel * parent_panel = dynamic_cast(parent); if (parent_panel && parent_panel->acceptsBadge()) { + badge_parent = parent; break; } parent = parent->getParent(); } - if (parent_panel) + if (badge_parent) { - parent_panel->addChild(mBadge); + badge_parent->addChild(mBadge); } else { -- cgit v1.2.3 From 64f978dc81cf6b3dad42fc5f1cf3896208efc8ac Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Thu, 16 Jun 2011 16:39:30 -0700 Subject: EXP-891 Right click on Inbox or Outbox toggles up down arrow but has no action --- indra/llui/llbutton.cpp | 57 +++++++++++++++++++++++++++---------------------- indra/llui/llbutton.h | 4 ++++ 2 files changed, 36 insertions(+), 25 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 637024e513..7b015bd576 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -100,7 +100,8 @@ LLButton::Params::Params() hover_glow_amount("hover_glow_amount"), commit_on_return("commit_on_return", true), use_draw_context_alpha("use_draw_context_alpha", true), - badge("badge") + badge("badge"), + handle_right_mouse("handle_right_mouse") { addSynonym(is_toggle, "toggle"); held_down_delay.seconds = 0.5f; @@ -162,7 +163,8 @@ LLButton::LLButton(const LLButton::Params& p) mMouseDownSignal(NULL), mMouseUpSignal(NULL), mHeldDownSignal(NULL), - mUseDrawContextAlpha(p.use_draw_context_alpha) + mUseDrawContextAlpha(p.use_draw_context_alpha), + mHandleRightMouse(p.handle_right_mouse) { static LLUICachedControl llbutton_orig_h_pad ("UIButtonOrigHPad", 0); static Params default_params(LLUICtrlFactory::getDefaultParams()); @@ -457,7 +459,7 @@ BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask) BOOL LLButton::handleRightMouseDown(S32 x, S32 y, MASK mask) { - if (!childrenHandleRightMouseDown(x, y, mask)) + if (mHandleRightMouse && !childrenHandleRightMouseDown(x, y, mask)) { // Route future Mouse messages here preemptively. (Release on mouse up.) gFocusMgr.setMouseCapture( this ); @@ -470,37 +472,42 @@ BOOL LLButton::handleRightMouseDown(S32 x, S32 y, MASK mask) // if (pointInView(x, y)) // { // } + // send the mouse down signal + LLUICtrl::handleRightMouseDown(x,y,mask); + // *TODO: Return result of LLUICtrl call above? Should defer to base class + // but this might change the mouse handling of existing buttons in a bad way + // if they are not mouse opaque. } - // send the mouse down signal - LLUICtrl::handleRightMouseDown(x,y,mask); - // *TODO: Return result of LLUICtrl call above? Should defer to base class - // but this might change the mouse handling of existing buttons in a bad way - // if they are not mouse opaque. + return TRUE; } BOOL LLButton::handleRightMouseUp(S32 x, S32 y, MASK mask) { - // We only handle the click if the click both started and ended within us - if( hasMouseCapture() ) + if (mHandleRightMouse) { - // Always release the mouse - gFocusMgr.setMouseCapture( NULL ); + // We only handle the click if the click both started and ended within us + if( hasMouseCapture() ) + { + // Always release the mouse + gFocusMgr.setMouseCapture( NULL ); -// if (pointInView(x, y)) -// { -// mRightMouseUpSignal(this, x,y,mask); -// } - } - else - { - childrenHandleRightMouseUp(x, y, mask); + // if (pointInView(x, y)) + // { + // mRightMouseUpSignal(this, x,y,mask); + // } + } + else + { + childrenHandleRightMouseUp(x, y, mask); + } + + // send the mouse up signal + LLUICtrl::handleRightMouseUp(x,y,mask); + // *TODO: Return result of LLUICtrl call above? Should defer to base class + // but this might change the mouse handling of existing buttons in a bad way. + // if they are not mouse opaque. } - // send the mouse up signal - LLUICtrl::handleRightMouseUp(x,y,mask); - // *TODO: Return result of LLUICtrl call above? Should defer to base class - // but this might change the mouse handling of existing buttons in a bad way. - // if they are not mouse opaque. return TRUE; } diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 5880a0e1f2..5968916006 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -129,6 +129,8 @@ public: Optional badge; + Optional handle_right_mouse; + Params(); }; @@ -359,6 +361,8 @@ private: bool mForcePressedState; LLFrameTimer mFlashingTimer; + + bool mHandleRightMouse; }; // Build time optimization, generate once in .cpp file -- cgit v1.2.3 From 4267014b146798cabe96568b2091c6bb2dd2b294 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 22 Jun 2011 17:35:25 -0400 Subject: EXP-890 FIX -- Resizing inbox or outbox to minimum size while open does not show present items when hte box is next opened EXP-897 FIX -- Black box shown in UI when shrinking Inbox down in size * Layout panel now supports "expanded_min_dim" parameter which allows a different min size to be specified when the layout panel is collapsed vs expanded. * Inbox and Outbox expanded_min_dim attributes are now set to be larger than min dim so they can not be collapsed all the way when they are expanded. --- indra/llui/lllayoutstack.cpp | 97 +++++++++++++++++++++++--------------------- indra/llui/lllayoutstack.h | 34 ++++++++++++---- 2 files changed, 77 insertions(+), 54 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 8a92796942..d87ee428aa 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -49,6 +49,8 @@ void LLLayoutStack::OrientationNames::declareValues() // LLLayoutPanel::LLLayoutPanel(const Params& p) : LLPanel(p), + mExpandedMinDimSpecified(false), + mExpandedMinDim(p.min_dim), mMinDim(p.min_dim), mMaxDim(p.max_dim), mAutoResize(p.auto_resize), @@ -58,6 +60,13 @@ LLLayoutPanel::LLLayoutPanel(const Params& p) mVisibleAmt(1.f), // default to fully visible mResizeBar(NULL) { + // Set the expanded min dim if it is provided, otherwise it gets the p.min_dim value + if (p.expanded_min_dim.isProvided()) + { + mExpandedMinDimSpecified = true; + mExpandedMinDim = p.expanded_min_dim(); + } + // panels initialized as hidden should not start out partially visible if (!getVisible()) { @@ -84,13 +93,13 @@ F32 LLLayoutPanel::getCollapseFactor(LLLayoutStack::ELayoutOrientation orientati if (orientation == LLLayoutStack::HORIZONTAL) { F32 collapse_amt = - clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, (F32)mMinDim / (F32)llmax(1, getRect().getWidth())); + clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, getRelevantMinDim() / (F32)llmax(1, getRect().getWidth())); return mVisibleAmt * collapse_amt; } else { F32 collapse_amt = - clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, llmin(1.f, (F32)mMinDim / (F32)llmax(1, getRect().getHeight()))); + clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, llmin(1.f, getRelevantMinDim() / (F32)llmax(1, getRect().getHeight()))); return mVisibleAmt * collapse_amt; } } @@ -281,9 +290,9 @@ bool LLLayoutStack::getPanelMinSize(const std::string& panel_name, S32* min_dimp { LLLayoutPanel* panel = findEmbeddedPanelByName(panel_name); - if (panel) + if (panel && min_dimp) { - if (min_dimp) *min_dimp = panel->mMinDim; + *min_dimp = panel->getRelevantMinDim(); } return NULL != panel; @@ -316,7 +325,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) e_panel_list_t::iterator panel_it; for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { - LLPanel* panelp = (*panel_it); + LLLayoutPanel* panelp = (*panel_it); if (panelp->getVisible()) { if (mAnimate) @@ -366,9 +375,9 @@ void LLLayoutStack::updateLayout(BOOL force_resize) if (mOrientation == HORIZONTAL) { // enforce minimize size constraint by default - if (panelp->getRect().getWidth() < (*panel_it)->mMinDim) + if (panelp->getRect().getWidth() < (*panel_it)->getRelevantMinDim()) { - panelp->reshape((*panel_it)->mMinDim, panelp->getRect().getHeight()); + panelp->reshape((*panel_it)->getRelevantMinDim(), panelp->getRect().getHeight()); } total_width += llround(panelp->getRect().getWidth() * (*panel_it)->getCollapseFactor(mOrientation)); // want n-1 panel gaps for n panels @@ -380,9 +389,9 @@ void LLLayoutStack::updateLayout(BOOL force_resize) else //VERTICAL { // enforce minimize size constraint by default - if (panelp->getRect().getHeight() < (*panel_it)->mMinDim) + if (panelp->getRect().getHeight() < (*panel_it)->getRelevantMinDim()) { - panelp->reshape(panelp->getRect().getWidth(), (*panel_it)->mMinDim); + panelp->reshape(panelp->getRect().getWidth(), (*panel_it)->getRelevantMinDim()); } total_height += llround(panelp->getRect().getHeight() * (*panel_it)->getCollapseFactor(mOrientation)); if (panel_it != mPanels.begin()) @@ -409,28 +418,20 @@ void LLLayoutStack::updateLayout(BOOL force_resize) || (!(*panel_it)->mAutoResize && !force_resize)) { - if (mOrientation == HORIZONTAL) - { - shrink_headroom_total += (*panel_it)->getRect().getWidth() - (*panel_it)->mMinDim; - } - else //VERTICAL - { - shrink_headroom_total += (*panel_it)->getRect().getHeight() - (*panel_it)->mMinDim; - } + S32 relevant_dimension = (mOrientation == HORIZONTAL) ? (*panel_it)->getRect().getWidth() : (*panel_it)->getRect().getHeight(); + F32 relevant_min = ((*panel_it)->mCollapsed ? (*panel_it)->getRelevantMinDim() : (*panel_it)->mExpandedMinDim); + + shrink_headroom_total += relevant_dimension - relevant_min; } else { num_resizable_panels++; - if (mOrientation == HORIZONTAL) - { - shrink_headroom_available += (*panel_it)->getRect().getWidth() - (*panel_it)->mMinDim; - shrink_headroom_total += (*panel_it)->getRect().getWidth() - (*panel_it)->mMinDim; - } - else //VERTICAL - { - shrink_headroom_available += (*panel_it)->getRect().getHeight() - (*panel_it)->mMinDim; - shrink_headroom_total += (*panel_it)->getRect().getHeight() - (*panel_it)->mMinDim; - } + + S32 relevant_dimension = (mOrientation == HORIZONTAL) ? (*panel_it)->getRect().getWidth() : (*panel_it)->getRect().getHeight(); + F32 relevant_min = ((*panel_it)->mCollapsed ? (*panel_it)->getRelevantMinDim() : (*panel_it)->mExpandedMinDim); + + shrink_headroom_available += relevant_dimension - relevant_min; + shrink_headroom_total += relevant_dimension - relevant_min; } } @@ -452,27 +453,28 @@ void LLLayoutStack::updateLayout(BOOL force_resize) for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { - LLPanel* panelp = (*panel_it); + LLLayoutPanel* panelp = (*panel_it); S32 cur_width = panelp->getRect().getWidth(); S32 cur_height = panelp->getRect().getHeight(); S32 new_width = cur_width; - S32 new_height = cur_height; + S32 new_height = cur_height; + S32 relevant_min = (S32) panelp->getRelevantMinDim(); if (mOrientation == HORIZONTAL) { - new_width = llmax((*panel_it)->mMinDim, new_width); + new_width = llmax(relevant_min, new_width); } else { - new_height = llmax((*panel_it)->mMinDim, new_height); + new_height = llmax(relevant_min, new_height); } S32 delta_size = 0; // if panel can automatically resize (not animating, and resize flag set)... - if ((*panel_it)->getCollapseFactor(mOrientation) == 1.f - && (force_resize || (*panel_it)->mAutoResize) - && !(*panel_it)->mResizeBar->hasMouseCapture()) + if (panelp->getCollapseFactor(mOrientation) == 1.f + && (force_resize || panelp->mAutoResize) + && !panelp->mResizeBar->hasMouseCapture()) { if (mOrientation == HORIZONTAL) { @@ -481,8 +483,8 @@ void LLLayoutStack::updateLayout(BOOL force_resize) { // shrink proportionally to amount over minimum // so we can do this in one pass - delta_size = (shrink_headroom_available > 0) ? llround((F32)pixels_to_distribute * ((F32)(cur_width - (*panel_it)->mMinDim) / (F32)shrink_headroom_available)) : 0; - shrink_headroom_available -= (cur_width - (*panel_it)->mMinDim); + delta_size = (shrink_headroom_available > 0) ? llround((F32)pixels_to_distribute * ((F32)(cur_width - panelp->getRelevantMinDim()) / (F32)shrink_headroom_available)) : 0; + shrink_headroom_available -= (cur_width - relevant_min); } else { @@ -491,7 +493,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) num_resizable_panels--; } pixels_to_distribute -= delta_size; - new_width = llmax((*panel_it)->mMinDim, cur_width + delta_size); + new_width = llmax(relevant_min, cur_width + delta_size); } else { @@ -504,8 +506,8 @@ void LLLayoutStack::updateLayout(BOOL force_resize) { // shrink proportionally to amount over minimum // so we can do this in one pass - delta_size = (shrink_headroom_available > 0) ? llround((F32)pixels_to_distribute * ((F32)(cur_height - (*panel_it)->mMinDim) / (F32)shrink_headroom_available)) : 0; - shrink_headroom_available -= (cur_height - (*panel_it)->mMinDim); + delta_size = (shrink_headroom_available > 0) ? llround((F32)pixels_to_distribute * ((F32)(cur_height - relevant_min) / (F32)shrink_headroom_available)) : 0; + shrink_headroom_available -= (cur_height - relevant_min); } else { @@ -513,7 +515,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) num_resizable_panels--; } pixels_to_distribute -= delta_size; - new_height = llmax((*panel_it)->mMinDim, cur_height + delta_size); + new_height = llmax(relevant_min, cur_height + delta_size); } else { @@ -566,19 +568,20 @@ void LLLayoutStack::updateLayout(BOOL force_resize) LLLayoutPanel* last_resizeable_panel = NULL; for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { - LLPanel* panelp = (*panel_it); + LLLayoutPanel* panelp = (*panel_it); + F32 relevant_min = panelp->getRelevantMinDim(); if (mOrientation == HORIZONTAL) { (*panel_it)->mResizeBar->setResizeLimits( - (*panel_it)->mMinDim, - (*panel_it)->mMinDim + shrink_headroom_total); + relevant_min, + relevant_min + shrink_headroom_total); } else //VERTICAL { (*panel_it)->mResizeBar->setResizeLimits( - (*panel_it)->mMinDim, - (*panel_it)->mMinDim + shrink_headroom_total); + relevant_min, + relevant_min + shrink_headroom_total); } // toggle resize bars based on panel visibility, resizability, etc @@ -658,7 +661,7 @@ void LLLayoutStack::calcMinExtents() { if (mOrientation == HORIZONTAL) { - mMinWidth += (*panel_it)->mMinDim; + mMinWidth += (*panel_it)->getRelevantMinDim(); if (panel_it != mPanels.begin()) { mMinWidth += mPanelSpacing; @@ -666,7 +669,7 @@ void LLLayoutStack::calcMinExtents() } else //VERTICAL { - mMinHeight += (*panel_it)->mMinDim; + mMinHeight += (*panel_it)->getRelevantMinDim(); if (panel_it != mPanels.begin()) { mMinHeight += mPanelSpacing; diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 2fc2cf3eb4..d8ef0aeaca 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -30,10 +30,10 @@ #include "llpanel.h" -class LLPanel; class LLLayoutPanel; + class LLLayoutStack : public LLView, public LLInstanceTracker { public: @@ -149,6 +149,7 @@ private: F32 mCloseTimeConstant; }; // end class LLLayoutStack + class LLLayoutPanel : public LLPanel { friend class LLLayoutStack; @@ -156,13 +157,15 @@ friend class LLUICtrlFactory; public: struct Params : public LLInitParam::Block { - Optional min_dim, + Optional expanded_min_dim, + min_dim, max_dim; Optional user_resize, auto_resize; Params() - : min_dim("min_dim", 0), + : expanded_min_dim("expanded_min_dim", 0), + min_dim("min_dim", 0), max_dim("max_dim", 0), user_resize("user_resize", true), auto_resize("auto_resize", true) @@ -179,17 +182,34 @@ public: void initFromParams(const Params& p); S32 getMinDim() const { return mMinDim; } - S32 getMaxDim() const { return mMaxDim; } + void setMinDim(S32 value) { mMinDim = value; if (!mExpandedMinDimSpecified) mExpandedMinDim = value; } - void setMinDim(S32 value) { mMinDim = value; } + S32 getMaxDim() const { return mMaxDim; } void setMaxDim(S32 value) { mMaxDim = value; } -protected: - LLLayoutPanel(const Params& p) ; + S32 getExpandedMinDim() const { return mExpandedMinDim; } + void setExpandedMinDim(S32 value) { mExpandedMinDim = value; mExpandedMinDimSpecified = true; } + + S32 getRelevantMinDim() const + { + S32 min_dim = mMinDim; + + if (!mCollapsed) + { + min_dim = mExpandedMinDim; + } + + return min_dim; + } +protected: + LLLayoutPanel(const Params& p); F32 getCollapseFactor(LLLayoutStack::ELayoutOrientation orientation); + bool mExpandedMinDimSpecified; + S32 mExpandedMinDim; + S32 mMinDim; S32 mMaxDim; BOOL mAutoResize; -- cgit v1.2.3 From 4ebf8e3abc365f79b41008de8fd6509c46ea44bd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 23 Jun 2011 12:02:59 -0700 Subject: fix for gcc build --- indra/llui/lllayoutstack.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index d87ee428aa..c34acd3db6 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -419,7 +419,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) && !force_resize)) { S32 relevant_dimension = (mOrientation == HORIZONTAL) ? (*panel_it)->getRect().getWidth() : (*panel_it)->getRect().getHeight(); - F32 relevant_min = ((*panel_it)->mCollapsed ? (*panel_it)->getRelevantMinDim() : (*panel_it)->mExpandedMinDim); + S32 relevant_min = llround((*panel_it)->mCollapsed ? (*panel_it)->getRelevantMinDim() : (*panel_it)->mExpandedMinDim); shrink_headroom_total += relevant_dimension - relevant_min; } @@ -428,7 +428,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) num_resizable_panels++; S32 relevant_dimension = (mOrientation == HORIZONTAL) ? (*panel_it)->getRect().getWidth() : (*panel_it)->getRect().getHeight(); - F32 relevant_min = ((*panel_it)->mCollapsed ? (*panel_it)->getRelevantMinDim() : (*panel_it)->mExpandedMinDim); + S32 relevant_min = llround((*panel_it)->mCollapsed ? (*panel_it)->getRelevantMinDim() : (*panel_it)->mExpandedMinDim); shrink_headroom_available += relevant_dimension - relevant_min; shrink_headroom_total += relevant_dimension - relevant_min; -- cgit v1.2.3 From 842b6d2d142abcaa11a825a96537b0ceaef33e24 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 23 Jun 2011 16:34:54 -0400 Subject: Build fix after merge. --- indra/llui/lllayoutstack.cpp | 47 +++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index c34acd3db6..7e0c5542ea 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -332,16 +332,16 @@ void LLLayoutStack::updateLayout(BOOL force_resize) { if (!mAnimatedThisFrame) { - (*panel_it)->mVisibleAmt = lerp((*panel_it)->mVisibleAmt, 1.f, LLCriticalDamp::getInterpolant(mOpenTimeConstant)); - if ((*panel_it)->mVisibleAmt > 0.99f) + panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 1.f, LLCriticalDamp::getInterpolant(mOpenTimeConstant)); + if (panelp->mVisibleAmt > 0.99f) { - (*panel_it)->mVisibleAmt = 1.f; + panelp->mVisibleAmt = 1.f; } } } else { - (*panel_it)->mVisibleAmt = 1.f; + panelp->mVisibleAmt = 1.f; } } else // not visible @@ -350,36 +350,36 @@ void LLLayoutStack::updateLayout(BOOL force_resize) { if (!mAnimatedThisFrame) { - (*panel_it)->mVisibleAmt = lerp((*panel_it)->mVisibleAmt, 0.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); - if ((*panel_it)->mVisibleAmt < 0.001f) + panelp->mVisibleAmt = lerp(panelp->mVisibleAmt, 0.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); + if (panelp->mVisibleAmt < 0.001f) { - (*panel_it)->mVisibleAmt = 0.f; + panelp->mVisibleAmt = 0.f; } } } else { - (*panel_it)->mVisibleAmt = 0.f; + panelp->mVisibleAmt = 0.f; } } - if ((*panel_it)->mCollapsed) + if (panelp->mCollapsed) { - (*panel_it)->mCollapseAmt = lerp((*panel_it)->mCollapseAmt, 1.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); + panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, 1.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); } else { - (*panel_it)->mCollapseAmt = lerp((*panel_it)->mCollapseAmt, 0.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); + panelp->mCollapseAmt = lerp(panelp->mCollapseAmt, 0.f, LLCriticalDamp::getInterpolant(mCloseTimeConstant)); } if (mOrientation == HORIZONTAL) { // enforce minimize size constraint by default - if (panelp->getRect().getWidth() < (*panel_it)->getRelevantMinDim()) + if (panelp->getRect().getWidth() < panelp->getRelevantMinDim()) { - panelp->reshape((*panel_it)->getRelevantMinDim(), panelp->getRect().getHeight()); + panelp->reshape(panelp->getRelevantMinDim(), panelp->getRect().getHeight()); } - total_width += llround(panelp->getRect().getWidth() * (*panel_it)->getCollapseFactor(mOrientation)); + total_width += llround(panelp->getRect().getWidth() * panelp->getCollapseFactor(mOrientation)); // want n-1 panel gaps for n panels if (panel_it != mPanels.begin()) { @@ -389,11 +389,11 @@ void LLLayoutStack::updateLayout(BOOL force_resize) else //VERTICAL { // enforce minimize size constraint by default - if (panelp->getRect().getHeight() < (*panel_it)->getRelevantMinDim()) + if (panelp->getRect().getHeight() < panelp->getRelevantMinDim()) { - panelp->reshape(panelp->getRect().getWidth(), (*panel_it)->getRelevantMinDim()); + panelp->reshape(panelp->getRect().getWidth(), panelp->getRelevantMinDim()); } - total_height += llround(panelp->getRect().getHeight() * (*panel_it)->getCollapseFactor(mOrientation)); + total_height += llround(panelp->getRect().getHeight() * panelp->getCollapseFactor(mOrientation)); if (panel_it != mPanels.begin()) { total_height += mPanelSpacing; @@ -412,23 +412,20 @@ void LLLayoutStack::updateLayout(BOOL force_resize) continue; } + S32 relevant_dimension = (mOrientation == HORIZONTAL) ? (*panel_it)->getRect().getWidth() : (*panel_it)->getRect().getHeight(); + S32 relevant_min = (*panel_it)->getRelevantMinDim(); + // if currently resizing a panel or the panel is flagged as not automatically resizing // only track total available headroom, but don't use it for automatic resize logic if ((*panel_it)->mResizeBar->hasMouseCapture() || (!(*panel_it)->mAutoResize && !force_resize)) { - S32 relevant_dimension = (mOrientation == HORIZONTAL) ? (*panel_it)->getRect().getWidth() : (*panel_it)->getRect().getHeight(); - S32 relevant_min = llround((*panel_it)->mCollapsed ? (*panel_it)->getRelevantMinDim() : (*panel_it)->mExpandedMinDim); - shrink_headroom_total += relevant_dimension - relevant_min; } else { num_resizable_panels++; - - S32 relevant_dimension = (mOrientation == HORIZONTAL) ? (*panel_it)->getRect().getWidth() : (*panel_it)->getRect().getHeight(); - S32 relevant_min = llround((*panel_it)->mCollapsed ? (*panel_it)->getRelevantMinDim() : (*panel_it)->mExpandedMinDim); shrink_headroom_available += relevant_dimension - relevant_min; shrink_headroom_total += relevant_dimension - relevant_min; @@ -483,7 +480,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) { // shrink proportionally to amount over minimum // so we can do this in one pass - delta_size = (shrink_headroom_available > 0) ? llround((F32)pixels_to_distribute * ((F32)(cur_width - panelp->getRelevantMinDim()) / (F32)shrink_headroom_available)) : 0; + delta_size = (shrink_headroom_available > 0) ? llround((F32)pixels_to_distribute * ((F32)(cur_width - relevant_min) / (F32)shrink_headroom_available)) : 0; shrink_headroom_available -= (cur_width - relevant_min); } else @@ -691,7 +688,7 @@ void LLLayoutStack::createResizeBars() LLResizeBar::Params resize_params; resize_params.name("resize"); resize_params.resizing_view(lp); - resize_params.min_size(lp->mMinDim); + resize_params.min_size(lp->getRelevantMinDim()); resize_params.side(side); resize_params.snapping_enabled(false); LLResizeBar* resize_bar = LLUICtrlFactory::create(resize_params); -- cgit v1.2.3 From c6d9a6b8321807523926fe7055b0b80572d29f44 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 23 Jun 2011 15:35:23 -0700 Subject: another gcc fix --- indra/llui/lllayoutstack.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 7e0c5542ea..6a91ec56e4 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -93,13 +93,13 @@ F32 LLLayoutPanel::getCollapseFactor(LLLayoutStack::ELayoutOrientation orientati if (orientation == LLLayoutStack::HORIZONTAL) { F32 collapse_amt = - clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, getRelevantMinDim() / (F32)llmax(1, getRect().getWidth())); + clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, (F32)getRelevantMinDim() / (F32)llmax(1, getRect().getWidth())); return mVisibleAmt * collapse_amt; } else { F32 collapse_amt = - clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, llmin(1.f, getRelevantMinDim() / (F32)llmax(1, getRect().getHeight()))); + clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, llmin(1.f, (F32)getRelevantMinDim() / (F32)llmax(1, getRect().getHeight()))); return mVisibleAmt * collapse_amt; } } @@ -456,7 +456,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) S32 cur_height = panelp->getRect().getHeight(); S32 new_width = cur_width; S32 new_height = cur_height; - S32 relevant_min = (S32) panelp->getRelevantMinDim(); + S32 relevant_min = panelp->getRelevantMinDim(); if (mOrientation == HORIZONTAL) { @@ -566,7 +566,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { LLLayoutPanel* panelp = (*panel_it); - F32 relevant_min = panelp->getRelevantMinDim(); + S32 relevant_min = panelp->getRelevantMinDim(); if (mOrientation == HORIZONTAL) { -- cgit v1.2.3 From f09cabd4b03a56b6ae9c9def483f96ae6bdbdc1f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 30 Jun 2011 16:15:10 -0700 Subject: EXP-970 FIX Group Roles > choose name causes other UI to become disabled --- indra/llui/llview.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 245126d178..8803d106ba 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -1299,15 +1299,7 @@ void LLView::drawChildren() { if (!mChildList.empty()) { - static const LLRect* rootRect = NULL; - - if (!mParentView) - { - rootRect = &mRect; - } - - LLRect screenRect; - + LLView* rootp = LLUI::getRootView(); ++sDepth; for (child_list_reverse_iter_t child_iter = mChildList.rbegin(); child_iter != mChildList.rend();) // ++child_iter) @@ -1317,9 +1309,8 @@ void LLView::drawChildren() if (viewp->getVisible() && viewp->getRect().isValid()) { - // Only draw views that are within the root view - localRectToScreen(viewp->getRect(),&screenRect); - if ( rootRect->overlaps(screenRect) && LLUI::sDirtyRect.overlaps(screenRect)) + LLRect screen_rect = viewp->calcScreenRect(); + if ( rootp->getLocalRect().overlaps(screen_rect) && LLUI::sDirtyRect.overlaps(screen_rect)) { LLUI::pushMatrix(); { -- cgit v1.2.3 From 2f21ec48a222662351c9f8e7243673eb6a31b457 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 5 Jul 2011 12:32:12 -0700 Subject: EXP-860 FIX -- Display NEW for items added to inbox * Added createFolderView, createFolderViewFolder and createFolderViewItem virtuals to LLInventoryPanel so these can be overridden by a derived class for custom display. * Added new LLInboxInventoryPanel class that overrides createFolderViewFolder with a LLInboxFolderViewFolder for custom display with NEW tags. * LLInboxFolderViewFolder NEW tag is tied to the mFresh variable that currently has no logic attached to it, meaning it remains off all the time. Reviewed by Richard. --- indra/llui/llbadgeowner.cpp | 8 ++++++++ indra/llui/llbadgeowner.h | 3 +++ 2 files changed, 11 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/llbadgeowner.cpp b/indra/llui/llbadgeowner.cpp index 3d63fc7f60..77f15567bf 100644 --- a/indra/llui/llbadgeowner.cpp +++ b/indra/llui/llbadgeowner.cpp @@ -73,6 +73,14 @@ void LLBadgeOwner::setBadgeLabel(const LLStringExplicit& label) } } +void LLBadgeOwner::setBadgeVisibility(bool visible) +{ + if (mBadge) + { + mBadge->setVisible(visible); + } +} + void LLBadgeOwner::addBadgeToParentPanel() { LLView * owner_view = mBadgeOwnerView.get(); diff --git a/indra/llui/llbadgeowner.h b/indra/llui/llbadgeowner.h index 456ef90c13..a2399189a5 100644 --- a/indra/llui/llbadgeowner.h +++ b/indra/llui/llbadgeowner.h @@ -42,8 +42,11 @@ public: void initBadgeParams(const LLBadge::Params& p); void addBadgeToParentPanel(); + + bool badgeHasParent() const { return (mBadge && mBadge->getParent()); } void setBadgeLabel(const LLStringExplicit& label); + void setBadgeVisibility(bool visible); private: -- cgit v1.2.3