Annotation of /trunk/indra/newview/llprogressview.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llprogressview.cpp | ||
| 3 : | * @brief LLProgressView class implementation | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | mjm | 137 | * Copyright (c) 2002-2010, Linden Research, Inc. |
| 8 : | mjm | 135 | * |
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at | ||
| 21 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | #include "llviewerprecompiledheaders.h" | ||
| 34 : | |||
| 35 : | #include "llprogressview.h" | ||
| 36 : | |||
| 37 : | #include "indra_constants.h" | ||
| 38 : | #include "llmath.h" | ||
| 39 : | #include "llgl.h" | ||
| 40 : | #include "llrender.h" | ||
| 41 : | #include "llui.h" | ||
| 42 : | #include "llfontgl.h" | ||
| 43 : | #include "llimagegl.h" | ||
| 44 : | #include "lltimer.h" | ||
| 45 : | #include "llglheaders.h" | ||
| 46 : | |||
| 47 : | #include "llagent.h" | ||
| 48 : | #include "llbutton.h" | ||
| 49 : | #include "llfocusmgr.h" | ||
| 50 : | #include "llprogressbar.h" | ||
| 51 : | #include "llstartup.h" | ||
| 52 : | #include "llversionviewer.h" | ||
| 53 : | #include "llviewercontrol.h" | ||
| 54 : | #include "llviewerimagelist.h" | ||
| 55 : | #include "llviewerwindow.h" | ||
| 56 : | #include "llappviewer.h" | ||
| 57 : | #include "llweb.h" | ||
| 58 : | #include "lluictrlfactory.h" | ||
| 59 : | |||
| 60 : | LLProgressView* LLProgressView::sInstance = NULL; | ||
| 61 : | |||
| 62 : | S32 gStartImageWidth = 1; | ||
| 63 : | S32 gStartImageHeight = 1; | ||
| 64 : | const F32 FADE_IN_TIME = 1.f; | ||
| 65 : | |||
| 66 : | const std::string ANIMATION_FILENAME = "Login Sequence "; | ||
| 67 : | const std::string ANIMATION_SUFFIX = ".jpg"; | ||
| 68 : | const F32 TOTAL_LOGIN_TIME = 10.f; // seconds, wild guess at time from GL context to actual world view | ||
| 69 : | S32 gLastStartAnimationFrame = 0; // human-style indexing, first image = 1 | ||
| 70 : | const S32 ANIMATION_FRAMES = 1; //13; | ||
| 71 : | |||
| 72 : | // XUI:translate | ||
| 73 : | LLProgressView::LLProgressView(const std::string& name, const LLRect &rect) | ||
| 74 : | : LLPanel(name, rect, FALSE), | ||
| 75 : | mPercentDone( 0.f ), | ||
| 76 : | mURLInMessage(false), | ||
| 77 : | mMouseDownInActiveArea( false ) | ||
| 78 : | { | ||
| 79 : | LLUICtrlFactory::getInstance()->buildPanel(this, "panel_progress.xml"); | ||
| 80 : | reshape(rect.getWidth(), rect.getHeight()); | ||
| 81 : | } | ||
| 82 : | |||
| 83 : | BOOL LLProgressView::postBuild() | ||
| 84 : | { | ||
| 85 : | mProgressBar = getChild<LLProgressBar>("login_progress_bar"); | ||
| 86 : | |||
| 87 : | mCancelBtn = getChild<LLButton>("cancel_btn"); | ||
| 88 : | mCancelBtn->setClickedCallback( LLProgressView::onCancelButtonClicked ); | ||
| 89 : | mFadeTimer.stop(); | ||
| 90 : | |||
| 91 : | getChild<LLTextBox>("title_text")->setText(LLStringExplicit(HIPPO_PRODUCT)); | ||
| 92 : | |||
| 93 : | getChild<LLTextBox>("message_text")->setClickedCallback(onClickMessage, this); | ||
| 94 : | |||
| 95 : | sInstance = this; | ||
| 96 : | return TRUE; | ||
| 97 : | } | ||
| 98 : | |||
| 99 : | |||
| 100 : | LLProgressView::~LLProgressView() | ||
| 101 : | { | ||
| 102 : | gFocusMgr.releaseFocusIfNeeded( this ); | ||
| 103 : | |||
| 104 : | sInstance = NULL; | ||
| 105 : | } | ||
| 106 : | |||
| 107 : | BOOL LLProgressView::handleHover(S32 x, S32 y, MASK mask) | ||
| 108 : | { | ||
| 109 : | if( childrenHandleHover( x, y, mask ) == NULL ) | ||
| 110 : | { | ||
| 111 : | gViewerWindow->setCursor(UI_CURSOR_WAIT); | ||
| 112 : | } | ||
| 113 : | return TRUE; | ||
| 114 : | } | ||
| 115 : | |||
| 116 : | |||
| 117 : | BOOL LLProgressView::handleKeyHere(KEY key, MASK mask) | ||
| 118 : | { | ||
| 119 : | // Suck up all keystokes except CTRL-Q. | ||
| 120 : | if( ('Q' == key) && (MASK_CONTROL == mask) ) | ||
| 121 : | { | ||
| 122 : | LLAppViewer::instance()->userQuit(); | ||
| 123 : | } | ||
| 124 : | return TRUE; | ||
| 125 : | } | ||
| 126 : | |||
| 127 : | void LLProgressView::setVisible(BOOL visible) | ||
| 128 : | { | ||
| 129 : | if (getVisible() && !visible) | ||
| 130 : | { | ||
| 131 : | mFadeTimer.start(); | ||
| 132 : | } | ||
| 133 : | else if (!getVisible() && visible) | ||
| 134 : | { | ||
| 135 : | gFocusMgr.setTopCtrl(this); | ||
| 136 : | setFocus(TRUE); | ||
| 137 : | mFadeTimer.stop(); | ||
| 138 : | mProgressTimer.start(); | ||
| 139 : | LLPanel::setVisible(visible); | ||
| 140 : | } | ||
| 141 : | } | ||
| 142 : | |||
| 143 : | |||
| 144 : | void LLProgressView::draw() | ||
| 145 : | { | ||
| 146 : | static LLTimer timer; | ||
| 147 : | |||
| 148 : | // Paint bitmap if we've got one | ||
| 149 : | glPushMatrix(); | ||
| 150 : | if (gStartImageGL) | ||
| 151 : | { | ||
| 152 : | LLGLSUIDefault gls_ui; | ||
| 153 : | gGL.getTexUnit(0)->bind(gStartImageGL); | ||
| 154 : | 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); | ||
| 155 : | F32 image_aspect = (F32)gStartImageWidth / (F32)gStartImageHeight; | ||
| 156 : | S32 width = getRect().getWidth(); | ||
| 157 : | S32 height = getRect().getHeight(); | ||
| 158 : | F32 view_aspect = (F32)width / (F32)height; | ||
| 159 : | // stretch image to maintain aspect ratio | ||
| 160 : | if (image_aspect > view_aspect) | ||
| 161 : | { | ||
| 162 : | glTranslatef(-0.5f * (image_aspect / view_aspect - 1.f) * width, 0.f, 0.f); | ||
| 163 : | glScalef(image_aspect / view_aspect, 1.f, 1.f); | ||
| 164 : | } | ||
| 165 : | else | ||
| 166 : | { | ||
| 167 : | glTranslatef(0.f, -0.5f * (view_aspect / image_aspect - 1.f) * height, 0.f); | ||
| 168 : | glScalef(1.f, view_aspect / image_aspect, 1.f); | ||
| 169 : | } | ||
| 170 : | gl_rect_2d_simple_tex( getRect().getWidth(), getRect().getHeight() ); | ||
| 171 : | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | ||
| 172 : | } | ||
| 173 : | else | ||
| 174 : | { | ||
| 175 : | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | ||
| 176 : | gGL.color4f(0.f, 0.f, 0.f, 1.f); | ||
| 177 : | gl_rect_2d(getRect()); | ||
| 178 : | } | ||
| 179 : | glPopMatrix(); | ||
| 180 : | |||
| 181 : | // Handle fade-in animation | ||
| 182 : | if (mFadeTimer.getStarted()) | ||
| 183 : | { | ||
| 184 : | LLPanel::draw(); | ||
| 185 : | if (mFadeTimer.getElapsedTimeF32() > FADE_IN_TIME) | ||
| 186 : | { | ||
| 187 : | gFocusMgr.removeTopCtrlWithoutCallback(this); | ||
| 188 : | LLPanel::setVisible(FALSE); | ||
| 189 : | gStartImageGL = NULL; | ||
| 190 : | } | ||
| 191 : | return; | ||
| 192 : | } | ||
| 193 : | |||
| 194 : | // draw children | ||
| 195 : | LLPanel::draw(); | ||
| 196 : | } | ||
| 197 : | |||
| 198 : | void LLProgressView::setText(const std::string& text) | ||
| 199 : | { | ||
| 200 : | getChild<LLTextBox>("progress_text")->setWrappedText(LLStringExplicit(text)); | ||
| 201 : | } | ||
| 202 : | |||
| 203 : | void LLProgressView::setPercent(const F32 percent) | ||
| 204 : | { | ||
| 205 : | mProgressBar->setPercent(percent); | ||
| 206 : | } | ||
| 207 : | |||
| 208 : | void LLProgressView::setMessage(const std::string& msg) | ||
| 209 : | { | ||
| 210 : | mMessage = msg; | ||
| 211 : | mURLInMessage = (mMessage.find( "https://" ) != std::string::npos || | ||
| 212 : | mMessage.find( "http://" ) != std::string::npos || | ||
| 213 : | mMessage.find( "ftp://" ) != std::string::npos); | ||
| 214 : | |||
| 215 : | getChild<LLTextBox>("message_text")->setWrappedText(LLStringExplicit(mMessage)); | ||
| 216 : | getChild<LLTextBox>("message_text")->setHoverActive(mURLInMessage); | ||
| 217 : | } | ||
| 218 : | |||
| 219 : | void LLProgressView::setCancelButtonVisible(BOOL b, const std::string& label) | ||
| 220 : | { | ||
| 221 : | mCancelBtn->setVisible( b ); | ||
| 222 : | mCancelBtn->setEnabled( b ); | ||
| 223 : | mCancelBtn->setLabelSelected(label); | ||
| 224 : | mCancelBtn->setLabelUnselected(label); | ||
| 225 : | } | ||
| 226 : | |||
| 227 : | // static | ||
| 228 : | void LLProgressView::onCancelButtonClicked(void*) | ||
| 229 : | { | ||
| 230 : | if (gAgent.getTeleportState() == LLAgent::TELEPORT_NONE) | ||
| 231 : | { | ||
| 232 : | LLAppViewer::instance()->requestQuit(); | ||
| 233 : | } | ||
| 234 : | else | ||
| 235 : | { | ||
| 236 : | gAgent.teleportCancel(); | ||
| 237 : | sInstance->mCancelBtn->setEnabled(FALSE); | ||
| 238 : | sInstance->setVisible(FALSE); | ||
| 239 : | } | ||
| 240 : | } | ||
| 241 : | |||
| 242 : | // static | ||
| 243 : | void LLProgressView::onClickMessage(void* data) | ||
| 244 : | { | ||
| 245 : | LLProgressView* viewp = (LLProgressView*)data; | ||
| 246 : | if ( viewp != NULL && ! viewp->mMessage.empty() ) | ||
| 247 : | { | ||
| 248 : | std::string url_to_open( "" ); | ||
| 249 : | |||
| 250 : | size_t start_pos; | ||
| 251 : | start_pos = viewp->mMessage.find( "https://" ); | ||
| 252 : | if (start_pos == std::string::npos) | ||
| 253 : | start_pos = viewp->mMessage.find( "http://" ); | ||
| 254 : | if (start_pos == std::string::npos) | ||
| 255 : | start_pos = viewp->mMessage.find( "ftp://" ); | ||
| 256 : | |||
| 257 : | if ( start_pos != std::string::npos ) | ||
| 258 : | { | ||
| 259 : | size_t end_pos = viewp->mMessage.find_first_of( " \n\r\t", start_pos ); | ||
| 260 : | if ( end_pos != std::string::npos ) | ||
| 261 : | url_to_open = viewp->mMessage.substr( start_pos, end_pos - start_pos ); | ||
| 262 : | else | ||
| 263 : | url_to_open = viewp->mMessage.substr( start_pos ); | ||
| 264 : | |||
| 265 : | LLWeb::loadURLExternal( url_to_open ); | ||
| 266 : | } | ||
| 267 : | } | ||
| 268 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

