diff options
author | Melinda Green <melinda@lindenlab.com> | 2008-12-15 21:21:19 +0000 |
---|---|---|
committer | Melinda Green <melinda@lindenlab.com> | 2008-12-15 21:21:19 +0000 |
commit | e1d8dac25a93db837c780428a23f81cbf9109270 (patch) | |
tree | a0bcaec0cec1ba6b3ce813764650eada61fcde4f /indra/newview/llprogressview.cpp | |
parent | 9c0dbb123376608e464fcd8d1a2e288e01d78a3f (diff) |
svn merge -r105329:105903 svn+ssh://svn/svn/linden/branches/featurettes/featurettes-batch4-merge
Resolving QAR-1051 Merge featurettes batch #4
Diffstat (limited to 'indra/newview/llprogressview.cpp')
-rw-r--r-- | indra/newview/llprogressview.cpp | 265 |
1 files changed, 53 insertions, 212 deletions
diff --git a/indra/newview/llprogressview.cpp b/indra/newview/llprogressview.cpp index c79022a98f..897596ea42 100644 --- a/indra/newview/llprogressview.cpp +++ b/indra/newview/llprogressview.cpp @@ -46,12 +46,14 @@ #include "llagent.h" #include "llbutton.h" #include "llfocusmgr.h" +#include "llprogressbar.h" #include "llstartup.h" #include "llviewercontrol.h" #include "llviewerimagelist.h" #include "llviewerwindow.h" #include "llappviewer.h" #include "llweb.h" +#include "lluictrlfactory.h" LLProgressView* LLProgressView::sInstance = NULL; @@ -69,28 +71,28 @@ const S32 ANIMATION_FRAMES = 1; //13; LLProgressView::LLProgressView(const std::string& name, const LLRect &rect) : LLPanel(name, rect, FALSE), mPercentDone( 0.f ), + mURLInMessage(false), mMouseDownInActiveArea( false ) { - const S32 CANCEL_BTN_WIDTH = 70; - const S32 CANCEL_BTN_OFFSET = 16; - LLRect r; - r.setOriginAndSize( - getRect().getWidth() - CANCEL_BTN_OFFSET - CANCEL_BTN_WIDTH, CANCEL_BTN_OFFSET, - CANCEL_BTN_WIDTH, BTN_HEIGHT ); - - mCancelBtn = new LLButton(std::string("Quit"), - r, - std::string(""), - LLProgressView::onCancelButtonClicked, - NULL ); - mCancelBtn->setFollows( FOLLOWS_RIGHT | FOLLOWS_BOTTOM ); - addChild( mCancelBtn ); + LLUICtrlFactory::getInstance()->buildPanel(this, "panel_progress.xml"); + reshape(rect.getWidth(), rect.getHeight()); +} + +BOOL LLProgressView::postBuild() +{ + mProgressBar = getChild<LLProgressBar>("login_progress_bar"); + + mCancelBtn = getChild<LLButton>("cancel_btn"); + mCancelBtn->setClickedCallback( LLProgressView::onCancelButtonClicked ); mFadeTimer.stop(); - setVisible(FALSE); - mOutlineRect.set( 0, 0, 0, 0 ); + getChild<LLTextBox>("title_text")->setText(LLStringExplicit(LLAppViewer::instance()->getSecondLifeTitle())); + + getChild<LLTextBox>("message_text")->setClickedCallback(onClickMessage); + getChild<LLTextBox>("message_text")->setCallbackUserData(this); sInstance = this; + return TRUE; } @@ -101,59 +103,11 @@ LLProgressView::~LLProgressView() sInstance = NULL; } -BOOL LLProgressView::handleMouseDown(S32 x, S32 y, MASK mask) -{ - if ( mOutlineRect.pointInRect( x, y ) ) - { - mMouseDownInActiveArea = TRUE; - return TRUE; - }; - - return LLPanel::handleMouseDown(x, y, mask); -} - -BOOL LLProgressView::handleMouseUp(S32 x, S32 y, MASK mask) -{ - if ( mOutlineRect.pointInRect( x, y ) ) - { - if ( mMouseDownInActiveArea ) - { - if ( ! mMessage.empty() ) - { - std::string url_to_open( "" ); - - size_t start_pos = mMessage.find( "http://" ); - if ( start_pos != std::string::npos ) - { - size_t end_pos = mMessage.find_first_of( " \n\r\t", start_pos ); - if ( end_pos != std::string::npos ) - url_to_open = mMessage.substr( start_pos, end_pos - start_pos ); - else - url_to_open = mMessage.substr( start_pos ); - - LLWeb::loadURLExternal( url_to_open ); - }; - }; - return TRUE; - }; - }; - - return LLPanel::handleMouseUp(x, y, mask); -} - BOOL LLProgressView::handleHover(S32 x, S32 y, MASK mask) { if( childrenHandleHover( x, y, mask ) == NULL ) { - lldebugst(LLERR_USER_INPUT) << "hover handled by LLProgressView" << llendl; - if ( mOutlineRect.pointInRect( x, y ) ) - { - gViewerWindow->setCursor(UI_CURSOR_ARROW); - } - else - { - gViewerWindow->setCursor(UI_CURSOR_WAIT); - } + gViewerWindow->setCursor(UI_CURSOR_WAIT); } return TRUE; } @@ -181,7 +135,7 @@ void LLProgressView::setVisible(BOOL visible) setFocus(TRUE); mFadeTimer.stop(); mProgressTimer.start(); - LLView::setVisible(visible); + LLPanel::setVisible(visible); } } @@ -190,19 +144,6 @@ void LLProgressView::draw() { static LLTimer timer; - if (gNoRender) - { - return; - } - - // Make sure the progress view always fills the entire window. - S32 width = gViewerWindow->getWindowWidth(); - S32 height = gViewerWindow->getWindowHeight(); - if( (width != getRect().getWidth()) || (height != getRect().getHeight()) ) - { - reshape( width, height ); - } - // Paint bitmap if we've got one glPushMatrix(); if (gStartImageGL) @@ -211,6 +152,8 @@ void LLProgressView::draw() gGL.getTexUnit(0)->bind(gStartImageGL); gGL.color4f(1.f, 1.f, 1.f, mFadeTimer.getStarted() ? clamp_rescale(mFadeTimer.getElapsedTimeF32(), 0.f, FADE_IN_TIME, 1.f, 0.f) : 1.f); F32 image_aspect = (F32)gStartImageWidth / (F32)gStartImageHeight; + S32 width = getRect().getWidth(); + S32 height = getRect().getHeight(); F32 view_aspect = (F32)width / (F32)height; // stretch image to maintain aspect ratio if (image_aspect > view_aspect) @@ -237,161 +180,37 @@ void LLProgressView::draw() // Handle fade-in animation if (mFadeTimer.getStarted()) { - LLView::draw(); + LLPanel::draw(); if (mFadeTimer.getElapsedTimeF32() > FADE_IN_TIME) { gFocusMgr.removeTopCtrlWithoutCallback(this); - LLView::setVisible(FALSE); + LLPanel::setVisible(FALSE); gStartImageGL = NULL; } return; } - S32 line_x = getRect().getWidth() / 2; - S32 line_one_y = getRect().getHeight() / 2 + 64; - const S32 LINE_SPACING = 25; - S32 line_two_y = line_one_y - LINE_SPACING; - const LLFontGL* font = LLFontGL::sSansSerif; - - LLUIImagePtr shadow_imagep = LLUI::getUIImage("rounded_square_soft.tga"); - LLUIImagePtr bar_fg_imagep = LLUI::getUIImage("progressbar_fill.tga"); - LLUIImagePtr bar_bg_imagep = LLUI::getUIImage("progressbar_track.tga"); - LLUIImagePtr bar_imagep = LLUI::getUIImage("rounded_square.tga"); - - LLColor4 background_color = gColors.getColor("LoginProgressBarBgColor"); - - F32 alpha = 0.5f + 0.5f*0.5f*(1.f + (F32)sin(3.f*timer.getElapsedTimeF32())); - // background_color.mV[3] = background_color.mV[3]*alpha; - - std::string top_line = LLAppViewer::instance()->getSecondLifeTitle(); - - S32 bar_bottom = line_two_y - 30; - S32 bar_height = 18; - S32 bar_width = getRect().getWidth() * 2 / 3; - S32 bar_left = (getRect().getWidth() / 2) - (bar_width / 2); - - // translucent outline box - S32 background_box_left = ( ( ( getRect().getWidth() / 2 ) - ( bar_width / 2 ) ) / 4 ) * 3; - S32 background_box_top = ( getRect().getHeight() / 2 ) + LINE_SPACING * 5; - S32 background_box_right = getRect().getWidth() - background_box_left; - S32 background_box_bottom = ( getRect().getHeight() / 2 ) - LINE_SPACING * 5; - S32 background_box_width = background_box_right - background_box_left + 1; - S32 background_box_height = background_box_top - background_box_bottom + 1; - -// shadow_imagep->draw( background_box_left + 2, -// background_box_bottom - 2, -// background_box_width, -// background_box_height, -// gColors.getColor( "LoginProgressBoxShadowColor" ) ); -// bar_outline_imagep->draw( background_box_left, -// background_box_bottom, -// background_box_width, -// background_box_height, -// gColors.getColor("LoginProgressBoxBorderColor") ); - - bar_imagep->draw( background_box_left + 1, - background_box_bottom + 1, - background_box_width - 2, - background_box_height - 2, - gColors.getColor("LoginProgressBoxCenterColor") ); - - // we'll need this later for catching a click if it looks like it contains a link - if ( mMessage.find( "http://" ) != std::string::npos ) - mOutlineRect.set( background_box_left, background_box_top, background_box_right, background_box_bottom ); - else - mOutlineRect.set( 0, 0, 0, 0 ); - - // draw loading bar - font->renderUTF8(top_line, 0, - line_x, line_one_y, - //LLColor4::white, - gColors.getColor("LoginProgressBoxTextColor"), - LLFontGL::HCENTER, LLFontGL::BASELINE, - LLFontGL::DROP_SHADOW); - font->renderUTF8(mText, 0, - line_x, line_two_y, - //LLColor4::white, - gColors.getColor("LoginProgressBoxTextColor"), - LLFontGL::HCENTER, LLFontGL::BASELINE, - LLFontGL::DROP_SHADOW); - -// shadow_imagep->draw( -// bar_left + 2, -// bar_bottom - 2, -// bar_width, -// bar_height, -// gColors.getColor("LoginProgressBoxShadowColor")); - -// bar_imagep->draw( -// bar_left, -// bar_bottom, -// bar_width, -// bar_height, -// LLColor4(0.7f, 0.7f, 0.8f, 1.0f)); - - bar_bg_imagep->draw( - bar_left + 2, - bar_bottom + 2, - bar_width - 4, - bar_height - 4, - background_color); - - LLColor4 bar_color = gColors.getColor("LoginProgressBarFgColor"); - bar_color.mV[3] = alpha; - bar_fg_imagep->draw( - bar_left + 2, - bar_bottom + 2, - llround((bar_width - 4) * (mPercentDone / 100.f)), - bar_height - 4, - bar_color); - - S32 line_three_y = line_two_y - LINE_SPACING * 3; - - // draw the message if there is one - if(!mMessage.empty()) - { - LLColor4 text_message_color = gColors.getColor("LoginProgressBoxTextColor"); - LLWString wmessage = utf8str_to_wstring(mMessage); - const F32 MAX_PIXELS = 640.0f; - S32 chars_left = wmessage.length(); - S32 chars_this_time = 0; - S32 msgidx = 0; - while(chars_left > 0) - { - chars_this_time = font->maxDrawableChars(wmessage.substr(msgidx).c_str(), - MAX_PIXELS, - MAX_STRING - 1, - TRUE); - LLWString wbuffer = wmessage.substr(msgidx, chars_this_time); - font->render(wbuffer, 0, - (F32)line_x, (F32)line_three_y, - //LLColor4::white, - gColors.getColor("LoginProgressBoxTextColor"), - LLFontGL::HCENTER, LLFontGL::BASELINE, - LLFontGL::DROP_SHADOW); - msgidx += chars_this_time; - chars_left -= chars_this_time; - line_three_y -= LINE_SPACING; - } - } - // draw children - LLView::draw(); + LLPanel::draw(); } void LLProgressView::setText(const std::string& text) { - mText = text; + getChild<LLTextBox>("progress_text")->setWrappedText(LLStringExplicit(text)); } void LLProgressView::setPercent(const F32 percent) { - mPercentDone = llclamp(percent, 0.f, 100.f); + mProgressBar->setPercent(percent); } void LLProgressView::setMessage(const std::string& msg) { mMessage = msg; + mURLInMessage = mMessage.find( "http://" ) != std::string::npos; + + getChild<LLTextBox>("message_text")->setWrappedText(LLStringExplicit(mMessage)); + getChild<LLTextBox>("message_text")->setHoverActive(mURLInMessage); } void LLProgressView::setCancelButtonVisible(BOOL b, const std::string& label) @@ -416,3 +235,25 @@ void LLProgressView::onCancelButtonClicked(void*) sInstance->setVisible(FALSE); } } + +// static +void LLProgressView::onClickMessage(void* data) +{ + LLProgressView* viewp = (LLProgressView*)data; + if ( ! viewp->mMessage.empty() ) + { + std::string url_to_open( "" ); + + size_t start_pos = viewp->mMessage.find( "http://" ); + if ( start_pos != std::string::npos ) + { + size_t end_pos = viewp->mMessage.find_first_of( " \n\r\t", start_pos ); + if ( end_pos != std::string::npos ) + url_to_open = viewp->mMessage.substr( start_pos, end_pos - start_pos ); + else + url_to_open = viewp->mMessage.substr( start_pos ); + + LLWeb::loadURLExternal( url_to_open ); + } + } +} |