void LLOverlayBar::layoutButtons() { LLView* state_buttons_panel = getChildView("state_buttons"); if (state_buttons_panel->getVisible()) { LLViewQuery query; LLWidgetTypeFilter<LLButton> widget_filter; query.addPreFilter(LLEnabledFilter::getInstance()); query.addPreFilter(&widget_filter); child_list_t button_list = query(state_buttons_panel); const S32 MAX_BAR_WIDTH = 600; S32 bar_width = llclamp(state_buttons_panel->getRect().getWidth(), 0, MAX_BAR_WIDTH); // calculate button widths const S32 MAX_BUTTON_WIDTH = 150; S32 segment_width = llclamp(lltrunc((F32)(bar_width) / (F32)button_list.size()), 0, MAX_BUTTON_WIDTH); S32 btn_width = segment_width - gSavedSettings.getS32("StatusBarPad"); // Evenly space all buttons, starting from left S32 left = 0; S32 bottom = 1; for (child_list_reverse_iter_t child_iter = button_list.rbegin(); child_iter != button_list.rend(); ++child_iter) { LLView *view = *child_iter; LLRect r = view->getRect(); r.setOriginAndSize(left, bottom, btn_width, r.getHeight()); view->setRect(r); left += segment_width; } } }
void LLControlGroup::setRect(const std::string& name, const LLRect &val) { LLControlVariable* control = getControl(name); if (control && control->isType(TYPE_RECT)) { control->set(val.getValue()); if(mChangeCallback) mChangeCallback(name,llformat("[%f,%f,%f,%f]",val.mBottom,val.mLeft,val.mRight,val.mTop)); } else { CONTROL_ERRS << "Invalid rect control " << name << llendl; } }
//static LLRect LLFloaterReg::getFloaterRect(const std::string& name) { LLRect rect; const std::string& groupname = sGroupMap[name]; if (!groupname.empty()) { instance_list_t& list = sInstanceMap[groupname]; if (!list.empty()) { static LLUICachedControl<S32> floater_offset ("UIFloaterOffset", 16); LLFloater* last_floater = list.back(); if (last_floater->getHost()) { rect = last_floater->getHost()->getRect(); } else { rect = last_floater->getRect(); } rect.translate(floater_offset, -floater_offset); } } return rect; }
// assumes GL state is set for 2D void LLColorSwatchCtrl::draw() { mBorder->setKeyboardFocusHighlight(hasFocus()); // Draw border LLRect border( 0, getRect().getHeight(), getRect().getWidth(), BTN_HEIGHT_SMALL ); gl_rect_2d( border, mBorderColor, FALSE ); LLRect interior = border; interior.stretch( -1 ); // Check state if ( mValid ) { // Draw the color swatch gl_rect_2d_checkerboard( interior ); gl_rect_2d(interior, mColor, TRUE); LLColor4 opaque_color = mColor; opaque_color.mV[VALPHA] = 1.f; if (mAlphaGradientImage.notNull()) { gGL.pushMatrix(); { mAlphaGradientImage->draw(interior, opaque_color); } gGL.popMatrix(); } } else { if (!mFallbackImageName.empty()) { LLPointer<LLViewerImage> fallback_image = gImageList.getImageFromFile(mFallbackImageName); if( fallback_image->getComponents() == 4 ) { gl_rect_2d_checkerboard( interior ); } gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), fallback_image); fallback_image->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) ); } else { // Draw grey and an X gl_rect_2d(interior, LLColor4::grey, TRUE); gl_draw_x(interior, LLColor4::black); } } LLUICtrl::draw(); }
void LLAccordionCtrlTab::drawChild(const LLRect& root_rect,LLView* child) { if (child && child->getVisible() && child->getRect().isValid()) { LLRect screen_rect; localRectToScreen(child->getRect(),&screen_rect); if ( root_rect.overlaps(screen_rect) && LLUI::sDirtyRect.overlaps(screen_rect)) { glMatrixMode(GL_MODELVIEW); LLUI::pushMatrix(); { LLUI::translate((F32)child->getRect().mLeft, (F32)child->getRect().mBottom, 0.f); child->draw(); } LLUI::popMatrix(); } } }
void object::test<8>() { // // test the set() method // LLRect rect; rect.set(10, 90, 70, 10); ensure_equals("set() rectf left", rect.mLeft, 10); ensure_equals("set() rectf top", rect.mTop, 90); ensure_equals("set() rectf right", rect.mRight, 70); ensure_equals("set() rectf bottom", rect.mBottom, 10); ensure_equals("set() rectf width", rect.getWidth(), 60); ensure_equals("set() rectf height", rect.getHeight(), 80); ensure_equals("set() rectf centerx", rect.getCenterX(), 40); ensure_equals("set() rectf centery", rect.getCenterY(), 50); }
S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, const LLRect& rect, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars, F32* right_x, BOOL use_embedded, BOOL use_ellipses) const { F32 x = rect.mLeft; F32 y = 0.f; switch(valign) { case TOP: y = rect.mTop; break; case VCENTER: y = rect.getCenterY(); break; case BASELINE: case BOTTOM: y = rect.mBottom; break; default: y = rect.mBottom; break; } return render(wstr, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, rect.getWidth(), right_x, use_embedded, use_ellipses); }
void LLAccordionCtrlTab::reshape(S32 width, S32 height, BOOL called_from_parent /* = TRUE */) { LLRect headerRect; headerRect.setLeftTopAndSize( 0,height,width,HEADER_HEIGHT); mHeader->setRect(headerRect); mHeader->reshape(headerRect.getWidth(), headerRect.getHeight()); if(!mDisplayChildren) return; LLRect childRect; childRect.setLeftTopAndSize( getPaddingLeft(), height - getHeaderHeight() - getPaddingTop(), width - getPaddingLeft() - getPaddingRight(), height - getHeaderHeight() - getPaddingTop() - getPaddingBottom() ); adjustContainerPanel(childRect); }
void LLPanelClassifiedInfo::stretchSnapshot() { // *NOTE dzaporozhan // Could be moved to LLTextureCtrl LLViewerFetchedTexture* texture = mSnapshotCtrl->getTexture(); if(!texture) { return; } if(0 == texture->getOriginalWidth() || 0 == texture->getOriginalHeight()) { // looks like texture is not loaded yet return; } LLRect rc = mSnapshotRect; // *HACK dzaporozhan // LLTextureCtrl uses BTN_HEIGHT_SMALL as bottom for texture which causes // drawn texture to be smaller than expected. (see LLTextureCtrl::draw()) // Lets increase texture height to force texture look as expected. rc.mBottom -= BTN_HEIGHT_SMALL; F32 t_width = texture->getFullWidth(); F32 t_height = texture->getFullHeight(); F32 ratio = llmin<F32>( (rc.getWidth() / t_width), (rc.getHeight() / t_height) ); t_width *= ratio; t_height *= ratio; rc.setCenterAndSize(rc.getCenterX(), rc.getCenterY(), llfloor(t_width), llfloor(t_height)); mSnapshotCtrl->setShape(rc); mSnapshotStreched = true; }
// Paint the display! void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, bool tiling) { LLFastTimer t(FTM_RENDER); if (gWindowResized) { //skip render on frames where window has been resized gGL.flush(); glClear(GL_COLOR_BUFFER_BIT); gViewerWindow->getWindow()->swapBuffers(); LLPipeline::refreshCachedSettings(); gPipeline.resizeScreenTexture(); gResizeScreenTexture = FALSE; gWindowResized = FALSE; return; } //Nope /*if (LLPipeline::sRenderDeferred) { //hack to make sky show up in deferred snapshots for_snapshot = FALSE; }*/ if (LLPipeline::sRenderFrameTest) { send_agent_pause(); } gSnapshot = for_snapshot; LLGLSDefault gls_default; LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE, GL_LEQUAL); LLVertexBuffer::unbind(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); stop_glerror(); gPipeline.disableLights(); //reset vertex buffers if needed gPipeline.doResetVertexBuffers(); stop_glerror(); // Don't draw if the window is hidden or minimized. // In fact, must explicitly check the minimized state before drawing. // Attempting to draw into a minimized window causes a GL error. JC if ( !gViewerWindow->getActive() || !gViewerWindow->getWindow()->getVisible() || gViewerWindow->getWindow()->getMinimized() ) { // Clean up memory the pools may have allocated if (rebuild) { gFrameStats.start(LLFrameStats::REBUILD); stop_glerror(); gPipeline.rebuildPools(); stop_glerror(); } stop_glerror(); gViewerWindow->returnEmptyPicks(); stop_glerror(); return; } gViewerWindow->checkSettings(); if(gWindowResized) //Singu Note: gViewerWindow->checkSettings() can call LLViewerWindow::reshape(). If it has then skip this frame. { return; } { LLFastTimer ftm(FTM_PICK); LLAppViewer::instance()->pingMainloopTimeout("Display:Pick"); gViewerWindow->performPick(); } LLAppViewer::instance()->pingMainloopTimeout("Display:CheckStates"); LLGLState::checkStates(); LLGLState::checkTextureChannels(); ////////////////////////////////////////////////////////// // // Logic for forcing window updates if we're in drone mode. // if (gNoRender) { #if LL_WINDOWS static F32 last_update_time = 0.f; if ((gFrameTimeSeconds - last_update_time) > 1.f) { InvalidateRect((HWND)gViewerWindow->getPlatformWindow(), NULL, FALSE); last_update_time = gFrameTimeSeconds; } #elif LL_DARWIN // MBW -- Do something clever here. #endif // Not actually rendering, don't bother. return; } // // Bail out if we're in the startup state and don't want to try to // render the world. // if (LLStartUp::getStartupState() < STATE_STARTED) { LLAppViewer::instance()->pingMainloopTimeout("Display:Startup"); display_startup(); return; } //LLGLState::verify(FALSE); ///////////////////////////////////////////////// // // Update GL Texture statistics (used for discard logic?) // LLAppViewer::instance()->pingMainloopTimeout("Display:TextureStats"); gFrameStats.start(LLFrameStats::UPDATE_TEX_STATS); stop_glerror(); LLImageGL::updateStats(gFrameTimeSeconds); LLVOAvatar::sRenderName = gSavedSettings.getS32("RenderName"); LLVOAvatar::sRenderGroupTitles = !gSavedSettings.getBOOL("RenderHideGroupTitleAll"); gPipeline.mBackfaceCull = TRUE; gFrameCount++; gRecentFrameCount++; if (gFocusMgr.getAppHasFocus()) { gForegroundFrameCount++; } ////////////////////////////////////////////////////////// // // Display start screen if we're teleporting, and skip render // if (gTeleportDisplay) { LLAppViewer::instance()->pingMainloopTimeout("Display:Teleport"); const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived. S32 attach_count = 0; if (isAgentAvatarValid()) { attach_count = gAgentAvatarp->getAttachmentCount(); } F32 teleport_save_time = TELEPORT_EXPIRY + TELEPORT_EXPIRY_PER_ATTACHMENT * attach_count; F32 teleport_elapsed = gTeleportDisplayTimer.getElapsedTimeF32(); F32 teleport_percent = teleport_elapsed * (100.f / teleport_save_time); if( (gAgent.getTeleportState() != LLAgent::TELEPORT_START) && (teleport_percent > 100.f) ) { // Give up. Don't keep the UI locked forever. gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); gAgent.setTeleportMessage(std::string()); } static const LLCachedControl<bool> hide_tp_screen("AscentDisableTeleportScreens",false); const std::string& message = gAgent.getTeleportMessage(); switch( gAgent.getTeleportState() ) { case LLAgent::TELEPORT_PENDING: gTeleportDisplayTimer.reset(); if(!hide_tp_screen) gViewerWindow->setShowProgress(TRUE); gViewerWindow->setProgressPercent(llmin(teleport_percent, 0.0f)); gAgent.setTeleportMessage(LLAgent::sTeleportProgressMessages["pending"]); gViewerWindow->setProgressString(LLAgent::sTeleportProgressMessages["pending"]); break; case LLAgent::TELEPORT_START: // Transition to REQUESTED. Viewer has sent some kind // of TeleportRequest to the source simulator gTeleportDisplayTimer.reset(); if(!hide_tp_screen) gViewerWindow->setShowProgress(TRUE); gViewerWindow->setProgressPercent(llmin(teleport_percent, 0.0f)); gAgent.setTeleportState( LLAgent::TELEPORT_REQUESTED ); gAgent.setTeleportMessage( LLAgent::sTeleportProgressMessages["requesting"]); gViewerWindow->setProgressString(LLAgent::sTeleportProgressMessages["requesting"]); break; case LLAgent::TELEPORT_REQUESTED: // Waiting for source simulator to respond gViewerWindow->setProgressPercent( llmin(teleport_percent, 37.5f) ); gViewerWindow->setProgressString(message); break; case LLAgent::TELEPORT_MOVING: // Viewer has received destination location from source simulator gViewerWindow->setProgressPercent( llmin(teleport_percent, 75.f) ); gViewerWindow->setProgressString(message); break; case LLAgent::TELEPORT_START_ARRIVAL: // Transition to ARRIVING. Viewer has received avatar update, etc., from destination simulator gTeleportArrivalTimer.reset(); gViewerWindow->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")); gViewerWindow->setProgressPercent(75.f); gAgent.setTeleportState( LLAgent::TELEPORT_ARRIVING ); gAgent.setTeleportMessage( LLAgent::sTeleportProgressMessages["arriving"]); gTextureList.mForceResetTextureStats = TRUE; if(!hide_tp_screen) gAgentCamera.resetView(TRUE, TRUE); break; case LLAgent::TELEPORT_ARRIVING: // Make the user wait while content "pre-caches" { F32 arrival_fraction = (gTeleportArrivalTimer.getElapsedTimeF32() / TELEPORT_ARRIVAL_DELAY); if( arrival_fraction > 1.f || hide_tp_screen) { arrival_fraction = 1.f; LLFirstUse::useTeleport(); gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); } gViewerWindow->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")); gViewerWindow->setProgressPercent( arrival_fraction * 25.f + 75.f); gViewerWindow->setProgressString(message); } break; case LLAgent::TELEPORT_LOCAL: // Short delay when teleporting in the same sim (progress screen active but not shown - did not // fall-through from TELEPORT_START) { // <edit> // is this really needed.... I say no. //if( gTeleportDisplayTimer.getElapsedTimeF32() > TELEPORT_LOCAL_DELAY ) // </edit> { LLFirstUse::useTeleport(); gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); } } break; case LLAgent::TELEPORT_NONE: // No teleport in progress gViewerWindow->setShowProgress(FALSE); gTeleportDisplay = FALSE; gTeleportArrivalTimer.reset(); break; default: break; } } else if(LLAppViewer::instance()->logoutRequestSent()) { LLAppViewer::instance()->pingMainloopTimeout("Display:Logout"); F32 percent_done = gLogoutTimer.getElapsedTimeF32() * 100.f / gLogoutMaxTime; if (percent_done > 100.f) { percent_done = 100.f; } if( LLApp::isExiting() ) { percent_done = 100.f; } gViewerWindow->setProgressPercent( percent_done ); } else if (gRestoreGL) { LLAppViewer::instance()->pingMainloopTimeout("Display:RestoreGL"); F32 percent_done = gRestoreGLTimer.getElapsedTimeF32() * 100.f / RESTORE_GL_TIME; if( percent_done > 100.f ) { gViewerWindow->setShowProgress(FALSE); gRestoreGL = FALSE; } else { if( LLApp::isExiting() ) { percent_done = 100.f; } gViewerWindow->setProgressPercent( percent_done ); } } // Progressively increase draw distance after TP when required. if (gSavedDrawDistance > 0.0f && gAgent.getTeleportState() == LLAgent::TELEPORT_NONE) { if (gTeleportArrivalTimer.getElapsedTimeF32() >= (F32)gSavedSettings.getU32("SpeedRezInterval")) { gTeleportArrivalTimer.reset(); F32 current = gSavedSettings.getF32("RenderFarClip"); if (gSavedDrawDistance > current) { current *= 2.0; if (current > gSavedDrawDistance) { current = gSavedDrawDistance; } gSavedSettings.setF32("RenderFarClip", current); } if (current >= gSavedDrawDistance) { gSavedDrawDistance = 0.0f; gSavedSettings.setF32("SavedRenderFarClip", 0.0f); } } } ////////////////////////// // // Prepare for the next frame // ///////////////////////////// // // Update the camera // // LLAppViewer::instance()->pingMainloopTimeout("Display:Camera"); LLViewerCamera::getInstance()->setZoomParameters(zoom_factor, subfield); LLViewerCamera::getInstance()->setNear(MIN_NEAR_PLANE); ////////////////////////// // // clear the next buffer // (must follow dynamic texture writing since that uses the frame buffer) // if (gDisconnected) { LLAppViewer::instance()->pingMainloopTimeout("Display:Disconnected"); render_ui(); } ////////////////////////// // // Set rendering options // // LLAppViewer::instance()->pingMainloopTimeout("Display:RenderSetup"); stop_glerror(); /////////////////////////////////////// // // Slam lighting parameters back to our defaults. // Note that these are not the same as GL defaults... stop_glerror(); gGL.setAmbientLightColor(LLColor4::white); stop_glerror(); ///////////////////////////////////// // // Render // // Actually push all of our triangles to the screen. // // do render-to-texture stuff here if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES)) { LLAppViewer::instance()->pingMainloopTimeout("Display:DynamicTextures"); LLFastTimer t(FTM_UPDATE_TEXTURES); if (LLViewerDynamicTexture::updateAllInstances()) { gGL.setColorMask(true, true); glClear(GL_DEPTH_BUFFER_BIT); } } gViewerWindow->setup3DViewport(); gPipeline.resetFrameStats(); // Reset per-frame statistics. if (!gDisconnected) { LLAppViewer::instance()->pingMainloopTimeout("Display:Update"); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) { //don't draw hud objects in this frame gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); } if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD_PARTICLES)) { //don't draw hud particles in this frame gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD_PARTICLES); } //upkeep gl name pools LLGLNamePool::upkeepPools(); stop_glerror(); display_update_camera(tiling); stop_glerror(); // *TODO: merge these two methods LLHUDManager::getInstance()->updateEffects(); LLHUDObject::updateAll(); stop_glerror(); if(!tiling) { gFrameStats.start(LLFrameStats::UPDATE_GEOM); const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds; // 50 ms/second update time gPipeline.createObjects(max_geom_update_time); gPipeline.processPartitionQ(); gPipeline.updateGeom(max_geom_update_time); stop_glerror(); gPipeline.updateGL(); stop_glerror(); } gFrameStats.start(LLFrameStats::UPDATE_CULL); S32 water_clip = 0; if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT) > 1) && (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WATER) || gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_VOIDWATER))) { if (LLViewerCamera::getInstance()->cameraUnderWater()) { water_clip = -1; } else { water_clip = 1; } } LLAppViewer::instance()->pingMainloopTimeout("Display:Cull"); //Increment drawable frame counter LLDrawable::incrementVisible(); LLSpatialGroup::sNoDelete = TRUE; LLTexUnit::sWhiteTexture = LLViewerFetchedTexture::sWhiteImagep->getTexName(); /*if (LLPipeline::sUseOcclusion && LLPipeline::sRenderDeferred) { //force occlusion on for all render types if doing deferred render LLPipeline::sUseOcclusion = 3; }*/ S32 occlusion = LLPipeline::sUseOcclusion; if (gDepthDirty) { //depth buffer is invalid, don't overwrite occlusion state LLPipeline::sUseOcclusion = llmin(occlusion, 1); } gDepthDirty = FALSE; LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); static LLCullResult result; LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; gPipeline.updateCull(*LLViewerCamera::getInstance(), result, water_clip); stop_glerror(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); BOOL to_texture = gPipeline.canUseVertexShaders() && LLPipeline::sRenderGlow; LLAppViewer::instance()->pingMainloopTimeout("Display:Swap"); { if (gResizeScreenTexture) { gResizeScreenTexture = FALSE; gPipeline.resizeScreenTexture(); } gGL.setColorMask(true, true); glClearColor(0,0,0,0); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); if (!for_snapshot || LLPipeline::sRenderDeferred) { if (gFrameCount > 1) { //for some reason, ATI 4800 series will error out if you //try to generate a shadow before the first frame is through gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); } LLVertexBuffer::unbind(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); const LLMatrix4a saved_proj = glh_get_current_projection(); const LLMatrix4a saved_mod = glh_get_current_modelview(); glViewport(0,0,512,512); LLVOAvatar::updateFreezeCounter() ; if(!LLPipeline::sMemAllocationThrottled) { LLVOAvatar::updateImpostors(); } glh_set_current_projection(saved_proj); glh_set_current_modelview(saved_mod); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.loadMatrix(saved_proj); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.loadMatrix(saved_mod); gViewerWindow->setup3DViewport(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); } glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } LLGLState::checkStates(); LLGLState::checkClientArrays(); //if (!for_snapshot) { LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery"); gPipeline.generateWaterReflection(*LLViewerCamera::getInstance()); gPipeline.renderPhysicsDisplay(); } LLGLState::checkStates(); LLGLState::checkClientArrays(); ////////////////////////////////////// // // Update images, using the image stats generated during object update/culling // // Can put objects onto the retextured list. // // Doing this here gives hardware occlusion queries extra time to complete LLAppViewer::instance()->pingMainloopTimeout("Display:UpdateImages"); LLError::LLCallStacks::clear() ; llpushcallstacks ; gFrameStats.start(LLFrameStats::IMAGE_UPDATE); { LLFastTimer t(FTM_IMAGE_UPDATE); { LLFastTimer t(FTM_IMAGE_UPDATE_CLASS); LLViewerTexture::updateClass(LLViewerCamera::getInstance()->getVelocityStat()->getMean(), LLViewerCamera::getInstance()->getAngularVelocityStat()->getMean()); } { LLFastTimer t(FTM_IMAGE_UPDATE_BUMP); gBumpImageList.updateImages(); // must be called before gTextureList version so that it's textures are thrown out first. } { LLFastTimer t(FTM_IMAGE_UPDATE_LIST); F32 max_image_decode_time = 0.050f*gFrameIntervalSeconds; // 50 ms/second decode time max_image_decode_time = llclamp(max_image_decode_time, 0.002f, 0.005f ); // min 2ms/frame, max 5ms/frame) gTextureList.updateImages(max_image_decode_time); } /*{ LLFastTimer t(FTM_IMAGE_UPDATE_DELETE); //remove dead textures from GL LLImageGL::deleteDeadTextures(); stop_glerror(); }*/ } llpushcallstacks ; LLGLState::checkStates(); LLGLState::checkClientArrays(); /////////////////////////////////// // // StateSort // // Responsible for taking visible objects, and adding them to the appropriate draw orders. // In the case of alpha objects, z-sorts them first. // Also creates special lists for outlines and selected face rendering. // LLAppViewer::instance()->pingMainloopTimeout("Display:StateSort"); { LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; gFrameStats.start(LLFrameStats::STATE_SORT); gPipeline.stateSort(*LLViewerCamera::getInstance(), result); stop_glerror(); if (rebuild) { ////////////////////////////////////// // // rebuildPools // // gFrameStats.start(LLFrameStats::REBUILD); gPipeline.rebuildPools(); stop_glerror(); } } LLGLState::checkStates(); LLGLState::checkClientArrays(); LLPipeline::sUseOcclusion = occlusion; { LLAppViewer::instance()->pingMainloopTimeout("Display:Sky"); LLFastTimer t(FTM_UPDATE_SKY); gSky.updateSky(); } // if(gUseWireframe) // [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.1.3b) | Modified: RLVa-1.1.3b if ( (gUseWireframe) && ((!rlv_handler_t::isEnabled()) || (!gRlvAttachmentLocks.hasLockedHUD())) ) // [/RLVa:KB] { glClearColor(0.5f, 0.5f, 0.5f, 0.f); glClear(GL_COLOR_BUFFER_BIT); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderStart"); //// render frontmost floater opaque for occlusion culling purposes //LLFloater* frontmost_floaterp = gFloaterView->getFrontmost(); //// assumes frontmost floater with focus is opaque //if (frontmost_floaterp && gFocusMgr.childHasKeyboardFocus(frontmost_floaterp)) //{ // gGL.matrixMode(LLRender::MM_MODELVIEW); // gGL.pushMatrix(); // { // gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); // gGL.loadIdentity(); // LLRect floater_rect = frontmost_floaterp->calcScreenRect(); // // deflate by one pixel so rounding errors don't occlude outside of floater extents // floater_rect.stretch(-1); // LLRectf floater_3d_rect((F32)floater_rect.mLeft / (F32)gViewerWindow->getWindowWidthScaled(), // (F32)floater_rect.mTop / (F32)gViewerWindow->getWindowHeightScaled(), // (F32)floater_rect.mRight / (F32)gViewerWindow->getWindowWidthScaled(), // (F32)floater_rect.mBottom / (F32)gViewerWindow->getWindowHeightScaled()); // floater_3d_rect.translate(-0.5f, -0.5f); // gGL.translatef(0.f, 0.f, -LLViewerCamera::getInstance()->getNear()); // gGL.scalef(LLViewerCamera::getInstance()->getNear() * LLViewerCamera::getInstance()->getAspect() / sinf(LLViewerCamera::getInstance()->getView()), LLViewerCamera::getInstance()->getNear() / sinf(LLViewerCamera::getInstance()->getView()), 1.f); // gGL.color4fv(LLColor4::white.mV); // gGL.begin(LLVertexBuffer::QUADS); // { // gGL.vertex3f(floater_3d_rect.mLeft, floater_3d_rect.mBottom, 0.f); // gGL.vertex3f(floater_3d_rect.mLeft, floater_3d_rect.mTop, 0.f); // gGL.vertex3f(floater_3d_rect.mRight, floater_3d_rect.mTop, 0.f); // gGL.vertex3f(floater_3d_rect.mRight, floater_3d_rect.mBottom, 0.f); // } // gGL.end(); // glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // } // gGL.popMatrix(); //} LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; LLGLState::checkStates(); LLGLState::checkClientArrays(); stop_glerror(); if (to_texture) { gGL.setColorMask(true, true); if (LLPipeline::sRenderDeferred) { gPipeline.mDeferredScreen.bindTarget(); glClearColor(1,0,1,1); gPipeline.mDeferredScreen.clear(); } else { gPipeline.mScreen.bindTarget(); if (LLPipeline::sUnderWaterRender && !gPipeline.canUseWindLightShaders()) { const LLColor4 &col = LLDrawPoolWater::sWaterFogColor; glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); } gPipeline.mScreen.clear(); } gGL.setColorMask(true, false); } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderGeom"); if (!(LLAppViewer::instance()->logoutRequestSent() && LLAppViewer::instance()->hasSavedFinalSnapshot()) && !gRestoreGL) { LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; static LLCachedControl<bool> render_ui_occlusion("RenderUIOcclusion", false); if(render_ui_occlusion && LLGLSLShader::sNoFixedFunction) { LLFloater* floaterp = gFloaterView->getFrontmost(); if(floaterp && floaterp->getVisible() && floaterp->isBackgroundVisible() && floaterp->isBackgroundOpaque()) { LLGLDepthTest depth(GL_TRUE, GL_TRUE); gGL.setColorMask(false, false); gOcclusionProgram.bind(); LLRect rect = floaterp->calcScreenRect(); rect.stretch(-1); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.loadIdentity(); gGL.ortho(0.0f, gViewerWindow->getWindowWidth(), 0.0f, gViewerWindow->getWindowHeight(), 0.f, 1.0f); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); gGL.loadIdentity(); gGL.color4fv( LLColor4::white.mV ); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.begin( LLRender::QUADS ); gGL.vertex3f(rect.mLeft, rect.mTop,0.f); gGL.vertex3f(rect.mLeft, rect.mBottom,0.f); gGL.vertex3f(rect.mRight, rect.mBottom,0.f); gGL.vertex3f(rect.mRight, rect.mTop,0.f); gGL.end(); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.popMatrix(); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); gOcclusionProgram.unbind(); } } static LLCachedControl<bool> render_depth_pre_pass("RenderDepthPrePass", false); if (render_depth_pre_pass && LLGLSLShader::sNoFixedFunction) { LLGLDepthTest depth(GL_TRUE, GL_TRUE); LLGLEnable cull_face(GL_CULL_FACE); gGL.setColorMask(false, false); U32 types[] = { LLRenderPass::PASS_SIMPLE, LLRenderPass::PASS_FULLBRIGHT, LLRenderPass::PASS_SHINY }; U32 num_types = LL_ARRAY_SIZE(types); gOcclusionProgram.bind(); for (U32 i = 0; i < num_types; i++) { gPipeline.renderObjects(types[i], LLVertexBuffer::MAP_VERTEX, FALSE); } gOcclusionProgram.unbind(); } gGL.setColorMask(true, false); if (LLPipeline::sRenderDeferred) { gPipeline.renderGeomDeferred(*LLViewerCamera::getInstance()); } else { gPipeline.renderGeom(*LLViewerCamera::getInstance(), TRUE); } gGL.setColorMask(true, true); //store this frame's modelview matrix for use //when rendering next frame's occlusion queries gGLPreviousModelView = gGLLastModelView; gGLLastModelView = gGLModelView; gGLLastProjection = gGLProjection; stop_glerror(); } //Reversed this. disabling a texunit sets its index as current.. randomly breaking LLRender::matrixMode(U32 mode). Make sure unit0 is the 'current' unit. for (S32 i = gGLManager.mNumTextureImageUnits-1; i >= 0; --i) { //dummy cleanup of any currently bound textures if (gGL.getTexUnit((U32)i)->getCurrType() != LLTexUnit::TT_NONE) { gGL.getTexUnit((U32)i)->unbind(gGL.getTexUnit((U32)i)->getCurrType()); gGL.getTexUnit((U32)i)->disable(); } } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderFlush"); if (to_texture) { if (LLPipeline::sRenderDeferred) { gPipeline.mDeferredScreen.flush(); if(gPipeline.mDeferredScreen.getFBO()) { LLRenderTarget::copyContentsToFramebuffer(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); } } else { gPipeline.mScreen.flush(); if(gPipeline.mScreen.getFBO()) { LLRenderTarget::copyContentsToFramebuffer(gPipeline.mScreen, 0, 0, gPipeline.mScreen.getWidth(), gPipeline.mScreen.getHeight(), 0, 0, gPipeline.mScreen.getWidth(), gPipeline.mScreen.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); } } } //gGL.flush(); if (LLPipeline::sRenderDeferred) { gPipeline.renderDeferredLighting(); } LLPipeline::sUnderWaterRender = FALSE; LLAppViewer::instance()->pingMainloopTimeout("Display:RenderUI"); if (!for_snapshot || LLPipeline::sRenderDeferred) { LLFastTimer t(FTM_RENDER_UI); gFrameStats.start(LLFrameStats::RENDER_UI); render_ui(); } LLSpatialGroup::sNoDelete = FALSE; gPipeline.clearReferences(); gPipeline.rebuildGroups(); } LLAppViewer::instance()->pingMainloopTimeout("Display:FrameStats"); gFrameStats.start(LLFrameStats::MISC_END); stop_glerror(); if (LLPipeline::sRenderFrameTest) { send_agent_resume(); LLPipeline::sRenderFrameTest = FALSE; } display_stats(); LLAppViewer::instance()->pingMainloopTimeout("Display:Done"); gShiftFrame = false; }
void LLPreviewTexture::draw() { updateDimensions(); LLPreview::draw(); if (!isMinimized()) { LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); const LLRect& border = mClientRect; LLRect interior = mClientRect; interior.stretch( -PREVIEW_BORDER_WIDTH ); // ...border gl_rect_2d( border, LLColor4(0.f, 0.f, 0.f, 1.f)); gl_rect_2d_checkerboard( interior ); if ( mImage.notNull() ) { // Draw the texture glColor3f( 1.f, 1.f, 1.f ); gl_draw_scaled_image(interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mImage); // Pump the texture priority F32 pixel_area = mLoadingFullImage ? (F32)MAX_IMAGE_AREA : (F32)(interior.getWidth() * interior.getHeight() ); mImage->addTextureStats( pixel_area ); if(pixel_area > 0.f) { //boost the previewed image priority to the highest to make it to get loaded first. mImage->setAdditionalDecodePriority(1.0f) ; } std::string assetid(mImageID.asString()); if (mIsCopyable) childSetText("uuid", assetid); if (uploaderkey.isNull()&&(mImage->mDecodedComment.find("a")!=mImage->mDecodedComment.end())) { uploaderkey = LLUUID(mImage->mDecodedComment["a"]); childSetText("uploader", mImage->mDecodedComment["a"]); gCacheName->get(uploaderkey, FALSE, callbackLoadAvatarName); } if (color.empty()&&(mImage->mDecodedComment.find("c")!=mImage->mDecodedComment.end())) { color = mImage->mDecodedComment["c"]; } if (time.empty()&&(mImage->mDecodedComment.find("z")!=mImage->mDecodedComment.end())) { time=mImage->mDecodedComment["z"]; std::string year = time.substr(0,4); std::string month = time.substr(4,2); std::string day = time.substr(6,2); std::string hour = time.substr(8,2); std::string minute = time.substr(10,2); std::string second = time.substr(12,2); time = llformat("%s/%s/%s - %s:%s:%s",year.c_str(),month.c_str(),day.c_str(),hour.c_str(),minute.c_str(),second.c_str()); childSetText("uploadtime", time); } // Don't bother decoding more than we can display, unless // we're loading the full image. if (!mLoadingFullImage) { S32 int_width = interior.getWidth(); S32 int_height = interior.getHeight(); mImage->setKnownDrawSize(int_width, int_height); } else { // Don't use this feature mImage->setKnownDrawSize(0, 0); } if( mLoadingFullImage ) { // *TODO: Translate LLFontGL::getFontSansSerif()->renderUTF8(std::string("Receiving:"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::DROP_SHADOW); F32 data_progress = mImage->mDownloadProgress; // Draw the progress bar. const S32 BAR_HEIGHT = 12; const S32 BAR_LEFT_PAD = 80; S32 left = interior.mLeft + 4 + BAR_LEFT_PAD; S32 bar_width = getRect().getWidth() - left - RESIZE_HANDLE_WIDTH - 2; S32 top = interior.mBottom + 4 + BAR_HEIGHT; S32 right = left + bar_width; S32 bottom = top - BAR_HEIGHT; LLColor4 background_color(0.f, 0.f, 0.f, 0.75f); LLColor4 decoded_color(0.f, 1.f, 0.f, 1.0f); LLColor4 downloaded_color(0.f, 0.5f, 0.f, 1.0f); gl_rect_2d(left, top, right, bottom, background_color); if (data_progress > 0.0f) { // Downloaded bytes right = left + llfloor(data_progress * (F32)bar_width); if (right > left) { gl_rect_2d(left, top, right, bottom, downloaded_color); } } } else if( !mSavedFileTimer.hasExpired() ) { // *TODO: Translate LLFontGL::getFontSansSerif()->renderUTF8(std::string("File Saved"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::DROP_SHADOW); } } } }
//--------------------------------------------------------------------------- // Public methods //--------------------------------------------------------------------------- LLPanelLogin::LLPanelLogin(const LLRect &rect, void (*callback)(S32 option, void* user_data), void *cb_data) : LLPanel(std::string("panel_login"), LLRect(0,600,800,0), FALSE), // not bordered mLogoImage(), mCallback(callback), mCallbackData(cb_data), mHtmlAvailable( TRUE ) { setFocusRoot(TRUE); setBackgroundVisible(FALSE); setBackgroundOpaque(TRUE); // instance management if (LLPanelLogin::sInstance) { llwarns << "Duplicate instance of login view deleted" << llendl; delete LLPanelLogin::sInstance; // Don't leave bad pointer in gFocusMgr gFocusMgr.setDefaultKeyboardFocus(NULL); } LLPanelLogin::sInstance = this; // add to front so we are the bottom-most child gViewerWindow->getRootView()->addChildAtEnd(this); // Logo mLogoImage = LLUI::getUIImage("startup_logo.j2c"); LLUICtrlFactory::getInstance()->buildPanel(this, "panel_login.xml"); #if USE_VIEWER_AUTH //leave room for the login menu bar setRect(LLRect(0, rect.getHeight()-18, rect.getWidth(), 0)); #endif reshape(rect.getWidth(), rect.getHeight()); #if !USE_VIEWER_AUTH LLComboBox* name_combo = sInstance->getChild<LLComboBox>("name_combo"); name_combo->setCommitCallback(onSelectLoginEntry); name_combo->setFocusLostCallback(onLoginComboLostFocus); name_combo->setPrevalidate(LLLineEditor::prevalidatePrintableNotPipe); name_combo->setSuppressTentative(true); name_combo->setSuppressAutoComplete(true); childSetCommitCallback("remember_name_check", onNameCheckChanged); childSetCommitCallback("password_edit", mungePassword); childSetKeystrokeCallback("password_edit", onPassKey, this); childSetUserData("password_edit", this); // change z sort of clickable text to be behind buttons sendChildToBack(getChildView("channel_text")); sendChildToBack(getChildView("forgot_password_text")); LLLineEditor* edit = getChild<LLLineEditor>("password_edit"); if (edit) edit->setDrawAsterixes(TRUE); //OGPX : This keeps the uris in a history file //OGPX TODO: should this be inside an OGP only check? LLComboBox* regioncombo = getChild<LLComboBox>("regionuri_edit"); regioncombo->setAllowTextEntry(TRUE, 256, FALSE); std::string current_regionuri = gSavedSettings.getString("CmdLineRegionURI"); // iterate on uri list adding to combobox (couldn't figure out how to add them all in one call) // ... and also append the command line value we might have gotten to the URLHistory LLSD regionuri_history = LLURLHistory::getURLHistory("regionuri"); LLSD::array_iterator iter_history = regionuri_history.beginArray(); LLSD::array_iterator iter_end = regionuri_history.endArray(); for (; iter_history != iter_end; ++iter_history) { regioncombo->addSimpleElement((*iter_history).asString()); } if ( LLURLHistory::appendToURLCollection("regionuri",current_regionuri)) { // since we are in login, another read of urlhistory file is going to happen // so we need to persist the new value we just added (or maybe we should do it in startup.cpp?) // since URL history only populated on create of sInstance, add to combo list directly regioncombo->addSimpleElement(current_regionuri); } // select which is displayed if we have a current URL. regioncombo->setSelectedByValue(LLSD(current_regionuri),TRUE); //llinfos << " url history: " << LLSDOStreamer<LLSDXMLFormatter>(LLURLHistory::getURLHistory("regionuri")) << llendl; LLComboBox* combo = getChild<LLComboBox>("start_location_combo"); combo->setAllowTextEntry(TRUE, 128, FALSE); // The XML file loads the combo with the following labels: // 0 - "My Home" // 1 - "My Last Location" // 2 - "<Type region name>" BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation"); std::string sim_string = LLURLSimString::sInstance.mSimString; if (!sim_string.empty()) { // Replace "<Type region name>" with this region name combo->remove(2); combo->add( sim_string ); combo->setTextEntry(sim_string); combo->setCurrentByIndex( 2 ); } else if (login_last) { combo->setCurrentByIndex( 1 ); } else { combo->setCurrentByIndex( 0 ); } combo->setCommitCallback( &set_start_location ); childSetAction("connect_btn", onClickConnect, this); setDefaultBtn("connect_btn"); // childSetAction("quit_btn", onClickQuit, this); childSetAction("grids_btn", onClickGrids, this); childSetCommitCallback("grids_combo", onSelectGrid, this); std::string channel = LL_CHANNEL; std::string version = llformat("%d.%d.%d (%d)", LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VIEWER_BUILD ); LLTextBox* channel_text = getChild<LLTextBox>("channel_text"); channel_text->setTextArg("[CHANNEL]", channel); // though not displayed channel_text->setTextArg("[VERSION]", version); channel_text->setClickedCallback(onClickVersion); channel_text->setCallbackUserData(this); LLTextBox* forgot_password_text = getChild<LLTextBox>("forgot_password_text"); forgot_password_text->setClickedCallback(onClickForgotPassword); LLTextBox* create_new_account_text = getChild<LLTextBox>("create_new_account_text"); create_new_account_text->setClickedCallback(onClickNewAccount); #endif // get the web browser control LLMediaCtrl* web_browser = getChild<LLMediaCtrl>("login_html"); web_browser->addObserver(this); // Need to handle login secondlife:///app/ URLs web_browser->setTrusted( true ); // don't make it a tab stop until SL-27594 is fixed web_browser->setTabStop(FALSE); // web_browser->navigateToLocalPage( "loading", "loading.html" ); // make links open in external browser web_browser->setOpenInExternalBrowser( true ); // force the size to be correct (XML doesn't seem to be sufficient to do this) (with some padding so the other login screen doesn't show through) LLRect htmlRect = getRect(); #if USE_VIEWER_AUTH htmlRect.setCenterAndSize( getRect().getCenterX() - 2, getRect().getCenterY(), getRect().getWidth() + 6, getRect().getHeight()); #else htmlRect.setCenterAndSize( getRect().getCenterX() - 2, getRect().getCenterY() + 40, getRect().getWidth() + 6, getRect().getHeight() - 78 ); #endif web_browser->setRect( htmlRect ); web_browser->reshape( htmlRect.getWidth(), htmlRect.getHeight(), TRUE ); reshape( getRect().getWidth(), getRect().getHeight(), 1 ); updateGridCombo(); childSetVisible("create_new_account_text", !gHippoGridManager->getConnectedGrid()->getRegisterUrl().empty()); childSetVisible("forgot_password_text", !gHippoGridManager->getConnectedGrid()->getPasswordUrl().empty()); loadLoginPage(); #if !USE_VIEWER_AUTH // Initialize visibility (and don't force visibility - use prefs) refreshLocation( false ); #endif }
void LLFloaterBuyLandUI::updateCovenantInfo() { LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion(); if(!region) return; U8 sim_access = region->getSimAccess(); std::string rating = LLViewerRegion::accessToString(sim_access); LLTextBox* region_name = getChild<LLTextBox>("region_name_text"); if (region_name) { std::string region_name_txt = region->getName() + " ("+rating +")"; region_name->setText(region_name_txt); LLIconCtrl* rating_icon = getChild<LLIconCtrl>("rating_icon"); LLRect rect = rating_icon->getRect(); S32 region_name_width = llmin(region_name->getRect().getWidth(), region_name->getTextBoundingRect().getWidth()); S32 icon_left_pad = region_name->getRect().mLeft + region_name_width + ICON_PAD; region_name->setToolTip(region_name->getText()); rating_icon->setRect(rect.setOriginAndSize(icon_left_pad, rect.mBottom, rect.getWidth(), rect.getHeight())); switch(sim_access) { case SIM_ACCESS_PG: rating_icon->setValue(getString("icon_PG")); break; case SIM_ACCESS_ADULT: rating_icon->setValue(getString("icon_R")); break; default: rating_icon->setValue(getString("icon_M")); } } LLTextBox* region_type = getChild<LLTextBox>("region_type_text"); if (region_type) { region_type->setText(region->getLocalizedSimProductName()); region_type->setToolTip(region->getLocalizedSimProductName()); } LLTextBox* resellable_clause = getChild<LLTextBox>("resellable_clause"); if (resellable_clause) { if (region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL) { resellable_clause->setText(getString("can_not_resell")); } else { resellable_clause->setText(getString("can_resell")); } } LLTextBox* changeable_clause = getChild<LLTextBox>("changeable_clause"); if (changeable_clause) { if (region->getRegionFlags() & REGION_FLAGS_ALLOW_PARCEL_CHANGES) { changeable_clause->setText(getString("can_change")); } else { changeable_clause->setText(getString("can_not_change")); } } LLCheckBoxCtrl* check = getChild<LLCheckBoxCtrl>("agree_covenant"); if(check) { check->set(false); check->setEnabled(true); check->setCommitCallback(onChangeAgreeCovenant, this); } LLTextBox* box = getChild<LLTextBox>("covenant_text"); if(box) { box->setVisible(FALSE); } // send EstateCovenantInfo message LLMessageSystem *msg = gMessageSystem; msg->newMessage("EstateCovenantRequest"); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID()); msg->sendReliable(region->getHost()); }
BOOL LLFloaterColorPicker::handleHover ( S32 x, S32 y, MASK mask ) { // if we're the front most window if ( isFrontmost () ) { // mouse was pressed within region if ( getMouseDownInHueRegion() || getMouseDownInLumRegion()) { S32 clamped_x, clamped_y; if (getMouseDownInHueRegion()) { clamped_x = llclamp(x, mRGBViewerImageLeft, mRGBViewerImageLeft + mRGBViewerImageWidth); clamped_y = llclamp(y, mRGBViewerImageTop - mRGBViewerImageHeight, mRGBViewerImageTop); } else { clamped_x = llclamp(x, mLumRegionLeft, mLumRegionLeft + mLumRegionWidth); clamped_y = llclamp(y, mLumRegionTop - mLumRegionHeight, mLumRegionTop); } // update the stored RGB/HSL values using the mouse position - returns TRUE if RGB was updated if ( updateRgbHslFromPoint ( clamped_x, clamped_y ) ) { // update text entry fields updateTextEntry (); // RN: apparently changing color when dragging generates too much traffic and results in sporadic updates //// commit changed color to swatch subject //// REVIEW: this gets sent each time a color changes - is this okay ? //if (mApplyImmediateCheck->get()) //{ // LLColorSwatchCtrl::onColorChanged ( getSwatch () ); //} } } highlightEntry = -1; if ( mMouseDownInSwatch ) { getWindow()->setCursor ( UI_CURSOR_ARROWDRAG ); // if cursor if over a palette entry LLRect paletteRect ( mPaletteRegionLeft, mPaletteRegionTop, mPaletteRegionLeft + mPaletteRegionWidth, mPaletteRegionTop - mPaletteRegionHeight ); if ( paletteRect.pointInRect ( x, y ) ) { // find row/column in palette S32 xOffset = ( ( x - mPaletteRegionLeft ) * numPaletteColumns ) / mPaletteRegionWidth; S32 yOffset = ( ( mPaletteRegionTop - y - 1 ) * numPaletteRows ) / mPaletteRegionHeight; // calculate the entry 0..n-1 to highlight and set variable to next draw() picks it up highlightEntry = xOffset + yOffset * numPaletteColumns; } return TRUE; } } // dispatch to base class for the rest of things return LLFloater::handleHover ( x, y, mask ); }
void LLDockControl::moveDockable() { // calculate new dockable position LLRect dockRect = mDockWidget->calcScreenRect(); LLRect rootRect; mGetAllowedRectCallback(rootRect); bool use_tongue = false; LLDockableFloater* dockable_floater = dynamic_cast<LLDockableFloater*> (mDockableFloater); if (dockable_floater != NULL) { use_tongue = dockable_floater->getUseTongue(); } LLRect dockableRect = mDockableFloater->calcScreenRect(); S32 x = 0; S32 y = 0; LLRect dockParentRect; switch (mDockAt) { case LEFT: x = dockRect.mLeft - dockableRect.getWidth(); y = dockRect.getCenterY() + dockableRect.getHeight() / 2; if (use_tongue) { x -= mDockTongue->getWidth(); } mDockTongueX = dockableRect.mRight; mDockTongueY = dockableRect.getCenterY() - mDockTongue->getHeight() / 2; break; case RIGHT: x = dockRect.mRight; y = dockRect.getCenterY() + dockableRect.getHeight() / 2; if (use_tongue) { x += mDockTongue->getWidth(); } mDockTongueX = dockRect.mRight; mDockTongueY = dockableRect.getCenterY() - mDockTongue->getHeight() / 2; break; case TOP: x = dockRect.getCenterX() - dockableRect.getWidth() / 2; y = dockRect.mTop + dockableRect.getHeight(); // unique docking used with dock tongue, so add tongue height to the Y coordinate if (use_tongue) { y += mDockTongue->getHeight(); if ( y > rootRect.mTop) { y = rootRect.mTop; } } // check is dockable inside root view rect if (x < rootRect.mLeft) { x = rootRect.mLeft; } if (x + dockableRect.getWidth() > rootRect.mRight) { x = rootRect.mRight - dockableRect.getWidth(); } // calculate dock tongue position dockParentRect = mDockWidget->getParent()->calcScreenRect(); if (dockRect.getCenterX() < dockParentRect.mLeft) { mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2; } else if (dockRect.getCenterX() > dockParentRect.mRight) { mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;; } else { mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2; } mDockTongueY = dockRect.mTop; break; case BOTTOM: x = dockRect.getCenterX() - dockableRect.getWidth() / 2; y = dockRect.mBottom; // unique docking used with dock tongue, so add tongue height to the Y coordinate if (use_tongue) { y -= mDockTongue->getHeight(); } // check is dockable inside root view rect if (x < rootRect.mLeft) { x = rootRect.mLeft; } if (x + dockableRect.getWidth() > rootRect.mRight) { x = rootRect.mRight - dockableRect.getWidth(); } // calculate dock tongue position dockParentRect = mDockWidget->getParent()->calcScreenRect(); if (dockRect.getCenterX() < dockParentRect.mLeft) { mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2; } else if (dockRect.getCenterX() > dockParentRect.mRight) { mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;; } else { mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2; } mDockTongueY = dockRect.mBottom - mDockTongue->getHeight(); break; } S32 max_available_height = rootRect.getHeight() - (rootRect.mBottom - mDockTongueY) - mDockTongue->getHeight(); // A floater should be shrunk so it doesn't cover a part of its docking tongue and // there is a space between a dockable floater and a control to which it is docked. if (use_tongue && dockableRect.getHeight() >= max_available_height) { dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(), max_available_height); mDockableFloater->reshape(dockableRect.getWidth(), dockableRect.getHeight()); } else { // move dockable dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(), dockableRect.getHeight()); } LLRect localDocableParentRect; mDockableFloater->getParent()->screenRectToLocal(dockableRect, &localDocableParentRect); mDockableFloater->setRect(localDocableParentRect); mDockableFloater->screenPointToLocal(mDockTongueX, mDockTongueY, &mDockTongueX, &mDockTongueY); }
LLDebugView::LLDebugView(const std::string& name, const LLRect &rect) : LLView(name, rect, FALSE) { LLRect r; r.set(10, rect.getHeight() - 100, rect.getWidth()/2, 100); mDebugConsolep = new LLConsole("debug console", 20, r, -1, 0.f ); mDebugConsolep->setFollowsBottom(); mDebugConsolep->setFollowsLeft(); mDebugConsolep->setVisible( FALSE ); addChild(mDebugConsolep); r.set(150 - 25, rect.getHeight() - 50, rect.getWidth()/2 - 25, rect.getHeight() - 450); mFrameStatView = new LLFrameStatView("frame stat", r); mFrameStatView->setFollowsTop(); mFrameStatView->setFollowsLeft(); mFrameStatView->setVisible(FALSE); // start invisible addChild(mFrameStatView); r.set(25, rect.getHeight() - 50, (S32) (gViewerWindow->getVirtualWindowRect().getWidth() * 0.75f), (S32) (gViewerWindow->getVirtualWindowRect().getHeight() * 0.75f)); mFastTimerView = new LLFastTimerView("fast timers", r); mFastTimerView->setFollowsTop(); mFastTimerView->setFollowsLeft(); mFastTimerView->setVisible(FALSE); // start invisible addChild(mFastTimerView); r.set(25, rect.getHeight() - 50, rect.getWidth()/2, rect.getHeight() - 450); mMemoryView = new LLMemoryView("memory", r); mMemoryView->setFollowsTop(); mMemoryView->setFollowsLeft(); mMemoryView->setVisible(FALSE); // start invisible addChild(mMemoryView); r.set(150, rect.getHeight() - 50, 820, 100); gTextureView = new LLTextureView("gTextureView", r); gTextureView->setRect(r); gTextureView->setFollowsBottom(); gTextureView->setFollowsLeft(); addChild(gTextureView); //gTextureView->reshape(r.getWidth(), r.getHeight(), TRUE); const S32 VELOCITY_LEFT = 10; // 370; const S32 VELOCITY_WIDTH = 500; const S32 VELOCITY_TOP = 140; const S32 VELOCITY_HEIGHT = 45; r.setLeftTopAndSize( VELOCITY_LEFT, VELOCITY_TOP, VELOCITY_WIDTH, VELOCITY_HEIGHT ); gVelocityBar = new LLVelocityBar("Velocity Bar", r); gVelocityBar->setFollowsBottom(); gVelocityBar->setFollowsLeft(); addChild(gVelocityBar); }
//--------------------------------------------------------------------------- // Public methods //--------------------------------------------------------------------------- LLPanelLogin::LLPanelLogin(const LLRect &rect, BOOL show_server, void (*callback)(S32 option, void* user_data), void *cb_data) : LLPanel(std::string("panel_login"), LLRect(0,600,800,0), FALSE), // not bordered mLogoImage(), mCallback(callback), mCallbackData(cb_data), mHtmlAvailable( TRUE ) { setFocusRoot(TRUE); setBackgroundVisible(FALSE); setBackgroundOpaque(TRUE); // instance management if (LLPanelLogin::sInstance) { llwarns << "Duplicate instance of login view deleted" << llendl; delete LLPanelLogin::sInstance; // Don't leave bad pointer in gFocusMgr gFocusMgr.setDefaultKeyboardFocus(NULL); } LLPanelLogin::sInstance = this; // add to front so we are the bottom-most child gViewerWindow->getRootView()->addChildAtEnd(this); // Logo mLogoImage = LLUI::getUIImage("startup_logo.j2c"); LLUICtrlFactory::getInstance()->buildPanel(this, "panel_login.xml"); #if USE_VIEWER_AUTH //leave room for the login menu bar setRect(LLRect(0, rect.getHeight()-18, rect.getWidth(), 0)); #endif reshape(rect.getWidth(), rect.getHeight()); #if !USE_VIEWER_AUTH childSetPrevalidate("first_name_edit", LLLineEditor::prevalidatePrintableNoSpace); childSetPrevalidate("last_name_edit", LLLineEditor::prevalidatePrintableNoSpace); childSetCommitCallback("password_edit", mungePassword); childSetKeystrokeCallback("password_edit", onPassKey, this); childSetUserData("password_edit", this); // change z sort of clickable text to be behind buttons sendChildToBack(getChildView("channel_text")); sendChildToBack(getChildView("forgot_password_text")); LLLineEditor* edit = getChild<LLLineEditor>("password_edit"); if (edit) edit->setDrawAsterixes(TRUE); LLComboBox* combo = getChild<LLComboBox>("start_location_combo"); combo->setAllowTextEntry(TRUE, 128, FALSE); // The XML file loads the combo with the following labels: // 0 - "My Home" // 1 - "My Last Location" // 2 - "<Type region name>" BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation"); std::string sim_string = LLURLSimString::sInstance.mSimString; if (!sim_string.empty()) { // Replace "<Type region name>" with this region name combo->remove(2); combo->add( sim_string ); combo->setTextEntry(sim_string); combo->setCurrentByIndex( 2 ); } else if (login_last) { combo->setCurrentByIndex( 1 ); } else { combo->setCurrentByIndex( 0 ); } LLComboBox* server_choice_combo = sInstance->getChild<LLComboBox>("server_combo"); server_choice_combo->setCommitCallback(onSelectServer); //server_choice_combo->setFocusLostCallback(onServerComboLostFocus); childSetAction("connect_btn", onClickConnect, this); childSetAction("grid_btn", onClickGrid, this); setDefaultBtn("connect_btn"); // childSetAction("quit_btn", onClickQuit, this); std::string imp_channel = gSavedSettings.getString("VersionChannelName"); std::string imp_version = llformat("%d.%d.%d %s", ViewerVersion::getImpMajorVersion(), ViewerVersion::getImpMinorVersion(), ViewerVersion::getImpPatchVersion(), ViewerVersion::getImpTestVersion().c_str() ); std::string ll_channel = ViewerVersion::getLLViewerName(); std::string ll_version = llformat("%d.%d.%d (%d)", ViewerVersion::getLLMajorVersion(), ViewerVersion::getLLMinorVersion(), ViewerVersion::getLLPatchVersion(), ViewerVersion::getLLBuildVersion() ); LLTextBox* channel_text = getChild<LLTextBox>("channel_text"); channel_text->setTextArg("[CHANNEL]", imp_channel); channel_text->setTextArg("[VERSION]", imp_version); channel_text->setTextArg("[ALT_CHANNEL]", ll_channel); channel_text->setTextArg("[ALT_VERSION]", ll_version); channel_text->setClickedCallback(onClickVersion); channel_text->setCallbackUserData(this); LLTextBox* forgot_password_text = getChild<LLTextBox>("forgot_password_text"); forgot_password_text->setClickedCallback(onClickForgotPassword); LLTextBox* create_new_account_text = getChild<LLTextBox>("create_new_account_text"); create_new_account_text->setClickedCallback(onClickNewAccount); #endif // get the web browser control LLWebBrowserCtrl* web_browser = getChild<LLWebBrowserCtrl>("login_html"); // Need to handle login secondlife:///app/ URLs web_browser->setTrusted( true ); // observe browser events web_browser->addObserver( this ); // don't make it a tab stop until SL-27594 is fixed web_browser->setTabStop(FALSE); web_browser->navigateToLocalPage( "loading", "loading.html" ); // make links open in external browser web_browser->setOpenInExternalBrowser( true ); // force the size to be correct (XML doesn't seem to be sufficient to do this) (with some padding so the other login screen doesn't show through) LLRect htmlRect = getRect(); #if USE_VIEWER_AUTH htmlRect.setCenterAndSize( getRect().getCenterX() - 2, getRect().getCenterY(), getRect().getWidth() + 6, getRect().getHeight()); #else htmlRect.setCenterAndSize( getRect().getCenterX() - 2, getRect().getCenterY() + 40, getRect().getWidth() + 6, getRect().getHeight() - 78 ); #endif web_browser->setRect( htmlRect ); web_browser->reshape( htmlRect.getWidth(), htmlRect.getHeight(), TRUE ); reshape( getRect().getWidth(), getRect().getHeight(), 1 ); // kick off a request to grab the url manually gResponsePtr = LLIamHereLogin::build( this ); std::string login_page = gSavedSettings.getString("LoginPage"); if (login_page.empty()) { login_page = getString( "real_url" ); } LLHTTPClient::head( login_page, gResponsePtr ); #if !USE_VIEWER_AUTH // Initialize visibility (and don't force visibility - use prefs) refreshLocation( false ); #endif LLFirstUse::useLoginScreen(); }
void LLTracker::drawMarker(const LLVector3d& pos_global, const LLColor4& color) { // get position LLVector3 pos_local = gAgent.getPosAgentFromGlobal(pos_global); // check in frustum LLCoordGL screen; S32 x = 0; S32 y = 0; const BOOL CLAMP = TRUE; if (LLViewerCamera::getInstance()->projectPosAgentToScreen(pos_local, screen, CLAMP) || LLViewerCamera::getInstance()->projectPosAgentToScreenEdge(pos_local, screen) ) { gHUDView->screenPointToLocal(screen.mX, screen.mY, &x, &y); // the center of the rendered position of the arrow obeys // the following rules: // (1) it lies on an ellipse centered on the target position // (2) it lies on the line between the target and the window center // (3) right now the radii of the ellipse are fixed, but eventually // they will be a function of the target text // // from those rules we can compute the position of the // lower left corner of the image LLRect rect = gHUDView->getRect(); S32 x_center = lltrunc(0.5f * (F32)rect.getWidth()); S32 y_center = lltrunc(0.5f * (F32)rect.getHeight()); x = x - x_center; // x and y relative to center y = y - y_center; F32 dist = sqrt((F32)(x*x + y*y)); S32 half_arrow_size = lltrunc(0.5f * HUD_ARROW_SIZE); if (dist > 0.f) { const F32 ARROW_ELLIPSE_RADIUS_X = 2 * HUD_ARROW_SIZE; const F32 ARROW_ELLIPSE_RADIUS_Y = HUD_ARROW_SIZE; // compute where the arrow should be F32 x_target = (F32)(x + x_center) - (ARROW_ELLIPSE_RADIUS_X * ((F32)x / dist) ); F32 y_target = (F32)(y + y_center) - (ARROW_ELLIPSE_RADIUS_Y * ((F32)y / dist) ); // keep the arrow within the window F32 x_clamped = llclamp( x_target, (F32)half_arrow_size, (F32)(rect.getWidth() - half_arrow_size)); F32 y_clamped = llclamp( y_target, (F32)half_arrow_size, (F32)(rect.getHeight() - half_arrow_size)); F32 slope = (F32)(y) / (F32)(x); F32 window_ratio = (F32)(rect.getHeight() - HUD_ARROW_SIZE) / (F32)(rect.getWidth() - HUD_ARROW_SIZE); // if the arrow has been clamped on one axis // then we need to compute the other axis if (llabs(slope) > window_ratio) { if (y_clamped != (F32)y_target) { // clamp by y x_clamped = (y_clamped - (F32)y_center) / slope + (F32)x_center; } } else if (x_clamped != (F32)x_target) { // clamp by x y_clamped = (x_clamped - (F32)x_center) * slope + (F32)y_center; } mHUDArrowCenterX = lltrunc(x_clamped); mHUDArrowCenterY = lltrunc(y_clamped); } else { // recycle the old values x = mHUDArrowCenterX - x_center; y = mHUDArrowCenterY - y_center; } F32 angle = atan2( (F32)y, (F32)x ); gl_draw_scaled_rotated_image(mHUDArrowCenterX - half_arrow_size, mHUDArrowCenterY - half_arrow_size, HUD_ARROW_SIZE, HUD_ARROW_SIZE, RAD_TO_DEG * angle, LLWorldMapView::sTrackArrowImage->getImage(), color); } }
void LLMediaCtrl::draw() { if ( gRestoreGL == 1 ) { LLRect r = getRect(); reshape( r.getWidth(), r.getHeight(), FALSE ); return; } // NOTE: optimization needed here - probably only need to do this once // unless tearoffs change the parent which they probably do. const LLUICtrl* ptr = findRootMostFocusRoot(); if ( ptr && ptr->hasFocus() ) { setFrequentUpdates( true ); } else { setFrequentUpdates( false ); }; // alpha off for this LLGLSUIDefault gls_ui; LLGLDisable gls_alphaTest( GL_ALPHA_TEST ); bool draw_media = false; LLPluginClassMedia* media_plugin = NULL; LLViewerMediaTexture* media_texture = NULL; if(mMediaSource && mMediaSource->hasMedia()) { media_plugin = mMediaSource->getMediaPlugin(); if(media_plugin && (media_plugin->textureValid())) { media_texture = LLViewerTextureManager::findMediaTexture(mMediaTextureID); if(media_texture) { draw_media = true; } } } bool background_visible = isBackgroundVisible(); bool background_opaque = isBackgroundOpaque(); if(draw_media) { gGL.pushUIMatrix(); { mMediaSource->setPageZoomFactor( LLUI::getScaleFactor().mV[ VX ] ); // scale texture to fit the space using texture coords gGL.getTexUnit(0)->bind(media_texture); LLColor4 media_color = LLColor4::white; gGL.color4fv( media_color.mV ); F32 max_u = ( F32 )media_plugin->getWidth() / ( F32 )media_plugin->getTextureWidth(); F32 max_v = ( F32 )media_plugin->getHeight() / ( F32 )media_plugin->getTextureHeight(); LLRect r = getRect(); S32 width, height; S32 x_offset = 0; S32 y_offset = 0; if(mStretchToFill) { if(mMaintainAspectRatio) { F32 media_aspect = (F32)(media_plugin->getWidth()) / (F32)(media_plugin->getHeight()); F32 view_aspect = (F32)(r.getWidth()) / (F32)(r.getHeight()); if(media_aspect > view_aspect) { // max width, adjusted height width = r.getWidth(); height = llmin(llmax(ll_round(width / media_aspect), 0), r.getHeight()); } else { // max height, adjusted width height = r.getHeight(); width = llmin(llmax(ll_round(height * media_aspect), 0), r.getWidth()); } } else { width = r.getWidth(); height = r.getHeight(); } } else { width = llmin(media_plugin->getWidth(), r.getWidth()); height = llmin(media_plugin->getHeight(), r.getHeight()); } x_offset = (r.getWidth() - width) / 2; y_offset = (r.getHeight() - height) / 2; /*if (mIgnoreUIScale) { x_offset = ll_round((F32)x_offset * LLUI::getScaleFactor().mV[VX]); y_offset = ll_round((F32)y_offset * LLUI::getScaleFactor().mV[VY]); width = ll_round((F32)width * LLUI::getScaleFactor().mV[VX]); height = ll_round((F32)height * LLUI::getScaleFactor().mV[VY]); }*/ // draw the browser gGL.setSceneBlendType(LLRender::BT_REPLACE); gGL.begin( LLRender::QUADS ); if (! media_plugin->getTextureCoordsOpenGL()) { // render using web browser reported width and height, instead of trying to invert GL scale gGL.texCoord2f( max_u, 0.f ); gGL.vertex2i( x_offset + width, y_offset + height ); gGL.texCoord2f( 0.f, 0.f ); gGL.vertex2i( x_offset, y_offset + height ); gGL.texCoord2f( 0.f, max_v ); gGL.vertex2i( x_offset, y_offset ); gGL.texCoord2f( max_u, max_v ); gGL.vertex2i( x_offset + width, y_offset ); } else { // render using web browser reported width and height, instead of trying to invert GL scale gGL.texCoord2f( max_u, max_v ); gGL.vertex2i( x_offset + width, y_offset + height ); gGL.texCoord2f( 0.f, max_v ); gGL.vertex2i( x_offset, y_offset + height ); gGL.texCoord2f( 0.f, 0.f ); gGL.vertex2i( x_offset, y_offset ); gGL.texCoord2f( max_u, 0.f ); gGL.vertex2i( x_offset + width, y_offset ); } gGL.end(); gGL.setSceneBlendType(LLRender::BT_ALPHA); } gGL.popUIMatrix(); } else { // Setting these will make LLPanel::draw draw the opaque background color. setBackgroundVisible(true); setBackgroundOpaque(true); } // highlight if keyboard focus here. (TODO: this needs some work) if ( mBorder && mBorder->getVisible() ) mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus( this ) ); LLPanel::draw(); // Restore the previous values setBackgroundVisible(background_visible); setBackgroundOpaque(background_opaque); }
LLView* LLSpinCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { std::string name("spinner"); node->getAttributeString("name", name); std::string label; node->getAttributeString("label", label); LLRect rect; createRect(node, rect, parent, LLRect()); LLFontGL* font = LLView::selectFont(node); F32 initial_value = 0.f; node->getAttributeF32("initial_val", initial_value); F32 min_value = 0.f; node->getAttributeF32("min_val", min_value); F32 max_value = 1.f; node->getAttributeF32("max_val", max_value); F32 increment = 0.1f; node->getAttributeF32("increment", increment); U32 precision = 3; node->getAttributeU32("decimal_digits", precision); S32 label_width = llmin(40, rect.getWidth() - 40); node->getAttributeS32("label_width", label_width); BOOL allow_text_entry = TRUE; node->getAttributeBOOL("allow_text_entry", allow_text_entry); LLUICtrlCallback callback = NULL; if(label.empty()) { label.assign( node->getValue() ); } LLSpinCtrl* spinner = new LLSpinCtrl(name, rect, label, font, callback, NULL, initial_value, min_value, max_value, increment, LLStringUtil::null, label_width); spinner->setPrecision(precision); spinner->initFromXML(node, parent); spinner->setAllowEdit(allow_text_entry); return spinner; }
void LLPreviewTexture::draw() { updateDimensions(); LLPreview::draw(); if (!isMinimized()) { LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); const LLRect& border = mClientRect; LLRect interior = mClientRect; interior.stretch( -PREVIEW_BORDER_WIDTH ); // ...border gl_rect_2d( border, LLColor4(0.f, 0.f, 0.f, 1.f)); gl_rect_2d_checkerboard( interior ); if ( mImage.notNull() ) { // Automatically bring up SaveAs dialog if we opened this to save the texture. if (mPreviewToSave) { mPreviewToSave = FALSE; saveAs(); } // Draw the texture gGL.diffuseColor3f( 1.f, 1.f, 1.f ); gl_draw_scaled_image(interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mImage); // Pump the texture priority F32 pixel_area = mLoadingFullImage ? (F32)MAX_IMAGE_AREA : (F32)(interior.getWidth() * interior.getHeight() ); mImage->addTextureStats( pixel_area ); // Don't bother decoding more than we can display, unless // we're loading the full image. if (!mLoadingFullImage) { S32 int_width = interior.getWidth(); S32 int_height = interior.getHeight(); mImage->setKnownDrawSize(int_width, int_height); } else { // Don't use this feature mImage->setKnownDrawSize(0, 0); } if( mLoadingFullImage ) { LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("Receiving"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW); F32 data_progress = mImage->getDownloadProgress() ; // Draw the progress bar. const S32 BAR_HEIGHT = 12; const S32 BAR_LEFT_PAD = 80; S32 left = interior.mLeft + 4 + BAR_LEFT_PAD; S32 bar_width = getRect().getWidth() - left - RESIZE_HANDLE_WIDTH - 2; S32 top = interior.mBottom + 4 + BAR_HEIGHT; S32 right = left + bar_width; S32 bottom = top - BAR_HEIGHT; LLColor4 background_color(0.f, 0.f, 0.f, 0.75f); LLColor4 decoded_color(0.f, 1.f, 0.f, 1.0f); LLColor4 downloaded_color(0.f, 0.5f, 0.f, 1.0f); gl_rect_2d(left, top, right, bottom, background_color); if (data_progress > 0.0f) { // Downloaded bytes right = left + llfloor(data_progress * (F32)bar_width); if (right > left) { gl_rect_2d(left, top, right, bottom, downloaded_color); } } } else if( !mSavedFileTimer.hasExpired() ) { LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("FileSaved"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW); } } } }
// Default constructor LLPreviewNotecard::LLPreviewNotecard(const std::string& name, const LLRect& rect, const std::string& title, const LLUUID& item_id, const LLUUID& object_id, const LLUUID& asset_id, BOOL show_keep_discard, LLPointer<LLViewerInventoryItem> inv_item) : LLPreview(name, rect, title, item_id, object_id, TRUE, PREVIEW_MIN_WIDTH, PREVIEW_MIN_HEIGHT, inv_item), mAssetID( asset_id ), mNotecardItemID(item_id), mObjectID(object_id) { LLRect curRect = rect; if (show_keep_discard) { LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard_keep_discard.xml"); childSetAction("Keep",onKeepBtn,this); childSetAction("Discard",onDiscardBtn,this); } else { LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard.xml"); // <edit> childSetAction("Get Items", onClickGetItems, this); // </edit> if( mAssetID.isNull() ) { const LLInventoryItem* item = getItem(); if( item ) { mAssetID = item->getAssetUUID(); } } } if (hasChild("Save", true)) childSetAction("Save",onClickSave,this); // only assert shape if not hosted in a multifloater if (!getHost()) { reshape(curRect.getWidth(), curRect.getHeight(), TRUE); setRect(curRect); } if (LLUICtrl* ctrl = findChild<LLUICtrl>("lock")) ctrl->setVisible(false); if (hasChild("desc", true)) { childSetCommitCallback("desc", LLPreview::onText, this); if (const LLInventoryItem* item = getItem()) childSetText("desc", item->getDescription()); childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe); } setTitle(title); LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor"); if (editor) { editor->setWordWrap(TRUE); editor->setSourceID(item_id); editor->setHandleEditKeysDirectly(TRUE); } initMenu(); gAgentCamera.changeCameraToDefault(); }
//static void LLFloaterSettingsDebug::onCommitSettings(LLUICtrl* ctrl, void* user_data) { LLFloaterSettingsDebug* floaterp = (LLFloaterSettingsDebug*)user_data; LLComboBox* settings_combo = floaterp->getChild<LLComboBox>("settings_combo"); LLControlVariable* controlp = (LLControlVariable*)settings_combo->getCurrentUserdata(); LLVector3 vector; LLVector3d vectord; LLRect rect; LLColor4 col4; LLColor3 col3; LLColor4U col4U; LLColor4 color_with_alpha; switch(controlp->type()) { case TYPE_U32: controlp->set(floaterp->childGetValue("val_spinner_1")); break; case TYPE_S32: controlp->set(floaterp->childGetValue("val_spinner_1")); break; case TYPE_F32: controlp->set(LLSD(floaterp->childGetValue("val_spinner_1").asReal())); break; case TYPE_BOOLEAN: controlp->set(floaterp->childGetValue("boolean_combo")); break; case TYPE_STRING: controlp->set(LLSD(floaterp->childGetValue("val_text").asString())); break; case TYPE_VEC3: vector.mV[VX] = (F32)floaterp->childGetValue("val_spinner_1").asReal(); vector.mV[VY] = (F32)floaterp->childGetValue("val_spinner_2").asReal(); vector.mV[VZ] = (F32)floaterp->childGetValue("val_spinner_3").asReal(); controlp->set(vector.getValue()); break; case TYPE_VEC3D: vectord.mdV[VX] = floaterp->childGetValue("val_spinner_1").asReal(); vectord.mdV[VY] = floaterp->childGetValue("val_spinner_2").asReal(); vectord.mdV[VZ] = floaterp->childGetValue("val_spinner_3").asReal(); controlp->set(vectord.getValue()); break; case TYPE_RECT: rect.mLeft = floaterp->childGetValue("val_spinner_1").asInteger(); rect.mRight = floaterp->childGetValue("val_spinner_2").asInteger(); rect.mBottom = floaterp->childGetValue("val_spinner_3").asInteger(); rect.mTop = floaterp->childGetValue("val_spinner_4").asInteger(); controlp->set(rect.getValue()); break; case TYPE_COL4: col3.setValue(floaterp->childGetValue("color_swatch")); col4 = LLColor4(col3, (F32)floaterp->childGetValue("val_spinner_4").asReal()); controlp->set(col4.getValue()); break; case TYPE_COL3: controlp->set(floaterp->childGetValue("color_swatch")); //col3.mV[VRED] = (F32)floaterp->childGetValue("val_spinner_1").asC(); //col3.mV[VGREEN] = (F32)floaterp->childGetValue("val_spinner_2").asReal(); //col3.mV[VBLUE] = (F32)floaterp->childGetValue("val_spinner_3").asReal(); //controlp->set(col3.getValue()); break; case TYPE_COL4U: col3.setValue(floaterp->childGetValue("color_swatch")); col4U.setVecScaleClamp(col3); col4U.mV[VALPHA] = floaterp->childGetValue("val_spinner_4").asInteger(); controlp->set(col4U.getValue()); break; default: break; } }
void LLScrollContainer::updateScroll() { if (!mScrolledView) { return; } static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0); LLRect doc_rect = mScrolledView->getRect(); S32 doc_width = doc_rect.getWidth(); S32 doc_height = doc_rect.getHeight(); S32 visible_width = 0; S32 visible_height = 0; BOOL show_v_scrollbar = FALSE; BOOL show_h_scrollbar = FALSE; calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar ); S32 border_width = getBorderWidth(); if( show_v_scrollbar ) { if( doc_rect.mTop < getRect().getHeight() - border_width ) { mScrolledView->translate( 0, getRect().getHeight() - border_width - doc_rect.mTop ); } scrollVertical( mScrollbar[VERTICAL]->getDocPos() ); mScrollbar[VERTICAL]->setVisible( TRUE ); S32 v_scrollbar_height = visible_height; if( !show_h_scrollbar && mReserveScrollCorner ) { v_scrollbar_height -= scrollbar_size; } mScrollbar[VERTICAL]->reshape( scrollbar_size, v_scrollbar_height, TRUE ); // Make room for the horizontal scrollbar (or not) S32 v_scrollbar_offset = 0; if( show_h_scrollbar || mReserveScrollCorner ) { v_scrollbar_offset = scrollbar_size; } LLRect r = mScrollbar[VERTICAL]->getRect(); r.translate( 0, mInnerRect.mBottom - r.mBottom + v_scrollbar_offset ); mScrollbar[VERTICAL]->setRect( r ); } else { mScrolledView->translate( 0, getRect().getHeight() - border_width - doc_rect.mTop ); mScrollbar[VERTICAL]->setVisible( FALSE ); mScrollbar[VERTICAL]->setDocPos( 0 ); } if( show_h_scrollbar ) { if( doc_rect.mLeft > border_width ) { mScrolledView->translate( border_width - doc_rect.mLeft, 0 ); mScrollbar[HORIZONTAL]->setDocPos( 0 ); } else { scrollHorizontal( mScrollbar[HORIZONTAL]->getDocPos() ); } mScrollbar[HORIZONTAL]->setVisible( TRUE ); S32 h_scrollbar_width = visible_width; if( !show_v_scrollbar && mReserveScrollCorner ) { h_scrollbar_width -= scrollbar_size; } mScrollbar[HORIZONTAL]->reshape( h_scrollbar_width, scrollbar_size, TRUE ); } else { mScrolledView->translate( border_width - doc_rect.mLeft, 0 ); mScrollbar[HORIZONTAL]->setVisible( FALSE ); mScrollbar[HORIZONTAL]->setDocPos( 0 ); } mScrollbar[HORIZONTAL]->setDocSize( doc_width ); mScrollbar[HORIZONTAL]->setPageSize( visible_width ); mScrollbar[VERTICAL]->setDocSize( doc_height ); mScrollbar[VERTICAL]->setPageSize( visible_height ); } // end updateScroll
// we've switched controls, or doing per-frame update, so update spinners, etc. void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) { LLSpinCtrl* spinner1 = getChild<LLSpinCtrl>("val_spinner_1"); LLSpinCtrl* spinner2 = getChild<LLSpinCtrl>("val_spinner_2"); LLSpinCtrl* spinner3 = getChild<LLSpinCtrl>("val_spinner_3"); LLSpinCtrl* spinner4 = getChild<LLSpinCtrl>("val_spinner_4"); LLColorSwatchCtrl* color_swatch = getChild<LLColorSwatchCtrl>("color_swatch"); if (!spinner1 || !spinner2 || !spinner3 || !spinner4 || !color_swatch) { llwarns << "Could not find all desired controls by name" << llendl; return; } spinner1->setVisible(FALSE); spinner2->setVisible(FALSE); spinner3->setVisible(FALSE); spinner4->setVisible(FALSE); color_swatch->setVisible(FALSE); childSetVisible("val_text", FALSE); mComment->setText(LLStringUtil::null); if (controlp) { eControlType type = controlp->type(); //hide combo box only for non booleans, otherwise this will result in the combo box closing every frame childSetVisible("boolean_combo", type == TYPE_BOOLEAN); mComment->setText(controlp->getComment()); spinner1->setMaxValue(F32_MAX); spinner2->setMaxValue(F32_MAX); spinner3->setMaxValue(F32_MAX); spinner4->setMaxValue(F32_MAX); spinner1->setMinValue(-F32_MAX); spinner2->setMinValue(-F32_MAX); spinner3->setMinValue(-F32_MAX); spinner4->setMinValue(-F32_MAX); if (!spinner1->hasFocus()) { spinner1->setIncrement(0.1f); } if (!spinner2->hasFocus()) { spinner2->setIncrement(0.1f); } if (!spinner3->hasFocus()) { spinner3->setIncrement(0.1f); } if (!spinner4->hasFocus()) { spinner4->setIncrement(0.1f); } LLSD sd = controlp->get(); switch(type) { case TYPE_U32: spinner1->setVisible(TRUE); spinner1->setLabel(std::string("value")); // Debug, don't translate if (!spinner1->hasFocus()) { spinner1->setValue(sd); spinner1->setMinValue((F32)U32_MIN); spinner1->setMaxValue((F32)U32_MAX); spinner1->setIncrement(1.f); spinner1->setPrecision(0); } break; case TYPE_S32: spinner1->setVisible(TRUE); spinner1->setLabel(std::string("value")); // Debug, don't translate if (!spinner1->hasFocus()) { spinner1->setValue(sd); spinner1->setMinValue((F32)S32_MIN); spinner1->setMaxValue((F32)S32_MAX); spinner1->setIncrement(1.f); spinner1->setPrecision(0); } break; case TYPE_F32: spinner1->setVisible(TRUE); spinner1->setLabel(std::string("value")); // Debug, don't translate if (!spinner1->hasFocus()) { spinner1->setPrecision(3); spinner1->setValue(sd); } break; case TYPE_BOOLEAN: if (!childHasFocus("boolean_combo")) { if (sd.asBoolean()) { childSetValue("boolean_combo", LLSD("true")); } else { childSetValue("boolean_combo", LLSD("")); } } break; case TYPE_STRING: childSetVisible("val_text", TRUE); if (!childHasFocus("val_text")) { childSetValue("val_text", sd); } break; case TYPE_VEC3: { LLVector3 v; v.setValue(sd); spinner1->setVisible(TRUE); spinner1->setLabel(std::string("X")); spinner2->setVisible(TRUE); spinner2->setLabel(std::string("Y")); spinner3->setVisible(TRUE); spinner3->setLabel(std::string("Z")); if (!spinner1->hasFocus()) { spinner1->setPrecision(3); spinner1->setValue(v[VX]); } if (!spinner2->hasFocus()) { spinner2->setPrecision(3); spinner2->setValue(v[VY]); } if (!spinner3->hasFocus()) { spinner3->setPrecision(3); spinner3->setValue(v[VZ]); } break; } case TYPE_VEC3D: { LLVector3d v; v.setValue(sd); spinner1->setVisible(TRUE); spinner1->setLabel(std::string("X")); spinner2->setVisible(TRUE); spinner2->setLabel(std::string("Y")); spinner3->setVisible(TRUE); spinner3->setLabel(std::string("Z")); if (!spinner1->hasFocus()) { spinner1->setPrecision(3); spinner1->setValue(v[VX]); } if (!spinner2->hasFocus()) { spinner2->setPrecision(3); spinner2->setValue(v[VY]); } if (!spinner3->hasFocus()) { spinner3->setPrecision(3); spinner3->setValue(v[VZ]); } break; } case TYPE_RECT: { LLRect r; r.setValue(sd); spinner1->setVisible(TRUE); spinner1->setLabel(std::string("Left")); spinner2->setVisible(TRUE); spinner2->setLabel(std::string("Right")); spinner3->setVisible(TRUE); spinner3->setLabel(std::string("Bottom")); spinner4->setVisible(TRUE); spinner4->setLabel(std::string("Top")); if (!spinner1->hasFocus()) { spinner1->setPrecision(0); spinner1->setValue(r.mLeft); } if (!spinner2->hasFocus()) { spinner2->setPrecision(0); spinner2->setValue(r.mRight); } if (!spinner3->hasFocus()) { spinner3->setPrecision(0); spinner3->setValue(r.mBottom); } if (!spinner4->hasFocus()) { spinner4->setPrecision(0); spinner4->setValue(r.mTop); } spinner1->setMinValue((F32)S32_MIN); spinner1->setMaxValue((F32)S32_MAX); spinner1->setIncrement(1.f); spinner2->setMinValue((F32)S32_MIN); spinner2->setMaxValue((F32)S32_MAX); spinner2->setIncrement(1.f); spinner3->setMinValue((F32)S32_MIN); spinner3->setMaxValue((F32)S32_MAX); spinner3->setIncrement(1.f); spinner4->setMinValue((F32)S32_MIN); spinner4->setMaxValue((F32)S32_MAX); spinner4->setIncrement(1.f); break; } case TYPE_COL4: { LLColor4 clr; clr.setValue(sd); color_swatch->setVisible(TRUE); // only set if changed so color picker doesn't update if(clr != LLColor4(color_swatch->getValue())) { color_swatch->set(LLColor4(sd), TRUE, FALSE); } spinner4->setVisible(TRUE); spinner4->setLabel(std::string("Alpha")); if (!spinner4->hasFocus()) { spinner4->setPrecision(3); spinner4->setMinValue(0.0); spinner4->setMaxValue(1.f); spinner4->setValue(clr.mV[VALPHA]); } break; } case TYPE_COL3: { LLColor3 clr; clr.setValue(sd); color_swatch->setVisible(TRUE); color_swatch->setValue(sd); break; } case TYPE_COL4U: { LLColor4U clr; clr.setValue(sd); color_swatch->setVisible(TRUE); if(LLColor4(clr) != LLColor4(color_swatch->getValue())) { color_swatch->set(LLColor4(clr), TRUE, FALSE); } spinner4->setVisible(TRUE); spinner4->setLabel(std::string("Alpha")); if(!spinner4->hasFocus()) { spinner4->setPrecision(0); spinner4->setValue(clr.mV[VALPHA]); } spinner4->setMinValue(0); spinner4->setMaxValue(255); spinner4->setIncrement(1.f); break; } default: mComment->setText(std::string("unknown")); break; } } }
// rect is in document coordinates, constraint is in display coordinates relative to content window rect void LLScrollContainer::scrollToShowRect(const LLRect& rect, const LLRect& constraint) { if (!mScrolledView) { llwarns << "LLScrollContainer::scrollToShowRect with no view!" << llendl; return; } LLRect content_window_rect = getContentWindowRect(); // get document rect LLRect scrolled_rect = mScrolledView->getRect(); // shrink target rect to fit within constraint region, biasing towards top left LLRect rect_to_constrain = rect; rect_to_constrain.mBottom = llmax(rect_to_constrain.mBottom, rect_to_constrain.mTop - constraint.getHeight()); rect_to_constrain.mRight = llmin(rect_to_constrain.mRight, rect_to_constrain.mLeft + constraint.getWidth()); // calculate allowable positions for scroller window in document coordinates LLRect allowable_scroll_rect(rect_to_constrain.mRight - constraint.mRight, rect_to_constrain.mBottom - constraint.mBottom, rect_to_constrain.mLeft - constraint.mLeft, rect_to_constrain.mTop - constraint.mTop); // translate from allowable region for lower left corner to upper left corner allowable_scroll_rect.translate(0, content_window_rect.getHeight()); S32 vert_pos = llclamp(mScrollbar[VERTICAL]->getDocPos(), mScrollbar[VERTICAL]->getDocSize() - allowable_scroll_rect.mTop, // min vertical scroll mScrollbar[VERTICAL]->getDocSize() - allowable_scroll_rect.mBottom); // max vertical scroll mScrollbar[VERTICAL]->setDocSize( scrolled_rect.getHeight() ); mScrollbar[VERTICAL]->setPageSize( content_window_rect.getHeight() ); mScrollbar[VERTICAL]->setDocPos( vert_pos ); S32 horizontal_pos = llclamp(mScrollbar[HORIZONTAL]->getDocPos(), allowable_scroll_rect.mLeft, allowable_scroll_rect.mRight); mScrollbar[HORIZONTAL]->setDocSize( scrolled_rect.getWidth() ); mScrollbar[HORIZONTAL]->setPageSize( content_window_rect.getWidth() ); mScrollbar[HORIZONTAL]->setDocPos( horizontal_pos ); // propagate scroll to document updateScroll(); // In case we are in accordion tab notify parent to show selected rectangle LLRect screen_rc; localRectToScreen(rect_to_constrain, &screen_rc); notifyParent(LLSD().with("scrollToShowRect",screen_rc.getValue())); }
BOOL LLFloaterColorPicker::handleMouseDown ( S32 x, S32 y, MASK mask ) { // make it the frontmost gFloaterView->bringToFront(this); // rect containing RGB area LLRect rgbAreaRect ( mRGBViewerImageLeft, mRGBViewerImageTop, mRGBViewerImageLeft + mRGBViewerImageWidth, mRGBViewerImageTop - mRGBViewerImageHeight ); if ( rgbAreaRect.pointInRect ( x, y ) ) { gFocusMgr.setMouseCapture(this); // mouse button down setMouseDownInHueRegion ( TRUE ); // update all values based on initial click updateRgbHslFromPoint ( x, y ); // required by base class return TRUE; } // rect containing RGB area LLRect lumAreaRect ( mLumRegionLeft, mLumRegionTop, mLumRegionLeft + mLumRegionWidth + mLumMarkerSize, mLumRegionTop - mLumRegionHeight ); if ( lumAreaRect.pointInRect ( x, y ) ) { gFocusMgr.setMouseCapture(this); // mouse button down setMouseDownInLumRegion ( TRUE ); // required by base class return TRUE; } // rect containing swatch area LLRect swatchRect ( mSwatchRegionLeft, mSwatchRegionTop, mSwatchRegionLeft + mSwatchRegionWidth, mSwatchRegionTop - mSwatchRegionHeight ); setMouseDownInSwatch( FALSE ); if ( swatchRect.pointInRect ( x, y ) ) { setMouseDownInSwatch( TRUE ); // required - dont drag windows here. return TRUE; } // rect containing palette area LLRect paletteRect ( mPaletteRegionLeft, mPaletteRegionTop, mPaletteRegionLeft + mPaletteRegionWidth, mPaletteRegionTop - mPaletteRegionHeight ); if ( paletteRect.pointInRect ( x, y ) ) { // release keyboard focus so we can change text values if (gFocusMgr.childHasKeyboardFocus(this)) { mSelectBtn->setFocus(TRUE); } // calculate which palette index we selected S32 c = ( ( x - mPaletteRegionLeft ) * numPaletteColumns ) / mPaletteRegionWidth; S32 r = ( ( y - ( mPaletteRegionTop - mPaletteRegionHeight ) ) * numPaletteRows ) / mPaletteRegionHeight; U32 index = ( numPaletteRows - r - 1 ) * numPaletteColumns + c; if ( index <= mPalette.size () ) { LLColor4 selected = *mPalette [ index ]; setCurRgb ( selected [ 0 ], selected [ 1 ], selected [ 2 ] ); if (mApplyImmediateCheck->get()) { LLColorSwatchCtrl::onColorChanged ( getSwatch (), LLColorSwatchCtrl::COLOR_CHANGE ); } updateTextEntry (); } return TRUE; } // dispatch to base class for the rest of things return LLFloater::handleMouseDown ( x, y, mask ); }
// static void LLFloaterPay::processPayPriceReply(LLMessageSystem* msg, void **userdata) { LLFloaterPay* self = (LLFloaterPay*)userdata; if (self) { S32 price; LLUUID target; msg->getUUIDFast(_PREHASH_ObjectData,_PREHASH_ObjectID,target); if (target != self->mTargetUUID) { // This is a message for a different object's pay info return; } msg->getS32Fast(_PREHASH_ObjectData,_PREHASH_DefaultPayPrice,price); if (PAY_PRICE_HIDE == price) { self->childSetVisible("amount", FALSE); self->childSetVisible("pay btn", FALSE); self->childSetVisible("amount text", FALSE); } else if (PAY_PRICE_DEFAULT == price) { self->childSetVisible("amount", TRUE); self->childSetVisible("pay btn", TRUE); self->childSetVisible("amount text", TRUE); } else { // PAY_PRICE_HIDE and PAY_PRICE_DEFAULT are negative values // So we take the absolute value here after we have checked for those cases self->childSetVisible("amount", TRUE); self->childSetVisible("pay btn", TRUE); self->childSetEnabled("pay btn", TRUE); self->childSetVisible("amount text", TRUE); self->childSetText("amount", llformat("%d", llabs(price))); } S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_ButtonData); S32 i = 0; if (num_blocks > MAX_PAY_BUTTONS) num_blocks = MAX_PAY_BUTTONS; S32 max_pay_amount = 0; S32 padding_required = 0; for (i=0;i<num_blocks;++i) { S32 pay_button; msg->getS32Fast(_PREHASH_ButtonData,_PREHASH_PayButton,pay_button,i); if (pay_button > 0) { std::string button_str = "L$"; button_str += LLResMgr::getInstance()->getMonetaryString( pay_button ); self->mQuickPayButton[i]->setLabelSelected(button_str); self->mQuickPayButton[i]->setLabelUnselected(button_str); self->mQuickPayButton[i]->setVisible(TRUE); self->mQuickPayInfo[i]->mAmount = pay_button; self->childSetVisible("fastpay text",TRUE); if ( pay_button > max_pay_amount ) { max_pay_amount = pay_button; } } else { self->mQuickPayButton[i]->setVisible(FALSE); } } // build a string containing the maximum value and calc nerw button width from it. std::string balance_str = "L$"; balance_str += LLResMgr::getInstance()->getMonetaryString( max_pay_amount ); const LLFontGL* font = LLFontGL::getFontSansSerif(); S32 new_button_width = font->getWidth( std::string(balance_str)); new_button_width += ( 12 + 12 ); // padding // dialong is sized for 2 digit pay amounts - larger pay values need to be scaled const S32 threshold = 100000; if ( max_pay_amount >= threshold ) { S32 num_digits_threshold = (S32)log10((double)threshold) + 1; S32 num_digits_max = (S32)log10((double)max_pay_amount) + 1; // calculate the extra width required by 2 buttons with max amount and some commas padding_required = ( num_digits_max - num_digits_threshold + ( num_digits_max / 3 ) ) * font->getWidth( std::string("0") ); }; // change in button width S32 button_delta = new_button_width - FASTPAY_BUTTON_WIDTH; if ( button_delta < 0 ) button_delta = 0; // now we know the maximum amount, we can resize all the buttons to be for (i=0;i<num_blocks;++i) { LLRect r; r = self->mQuickPayButton[i]->getRect(); // RHS button colum needs to move further because LHS changed too if ( i % 2 ) { r.setCenterAndSize( r.getCenterX() + ( button_delta * 3 ) / 2 , r.getCenterY(), r.getWidth() + button_delta, r.getHeight() ); } else { r.setCenterAndSize( r.getCenterX() + button_delta / 2, r.getCenterY(), r.getWidth() + button_delta, r.getHeight() ); } self->mQuickPayButton[i]->setRect( r ); } for (i=num_blocks;i<MAX_PAY_BUTTONS;++i) { self->mQuickPayButton[i]->setVisible(FALSE); } self->reshape( self->getRect().getWidth() + padding_required, self->getRect().getHeight(), FALSE ); } msg->setHandlerFunc("PayPriceReply",NULL,NULL); }
////////////////////////////////////////////////////////////////////////////// // reverts state once mouse button is released BOOL LLFloaterColorPicker::handleMouseUp ( S32 x, S32 y, MASK mask ) { getWindow()->setCursor ( UI_CURSOR_ARROW ); if (getMouseDownInHueRegion() || getMouseDownInLumRegion()) { if (mApplyImmediateCheck->get()) { LLColorSwatchCtrl::onColorChanged ( getSwatch (), LLColorSwatchCtrl::COLOR_CHANGE ); } } // rect containing palette area LLRect paletteRect ( mPaletteRegionLeft, mPaletteRegionTop, mPaletteRegionLeft + mPaletteRegionWidth, mPaletteRegionTop - mPaletteRegionHeight ); if ( paletteRect.pointInRect ( x, y ) ) { if ( mMouseDownInSwatch ) { S32 curEntry = 0; for ( S32 row = 0; row < numPaletteRows; ++row ) { for ( S32 column = 0; column < numPaletteColumns; ++column ) { S32 left = mPaletteRegionLeft + ( mPaletteRegionWidth * column ) / numPaletteColumns; S32 top = mPaletteRegionTop - ( mPaletteRegionHeight * row ) / numPaletteRows; S32 right = ( mPaletteRegionLeft + ( mPaletteRegionWidth * ( column + 1 ) ) / numPaletteColumns ); S32 bottom = ( mPaletteRegionTop - ( mPaletteRegionHeight * ( row + 1 ) ) / numPaletteRows ); // rect is flipped vertically when testing here LLRect dropRect ( left, top, right, bottom ); if ( dropRect.pointInRect ( x, y ) ) { if ( mPalette [ curEntry ] ) { delete mPalette [ curEntry ]; mPalette [ curEntry ] = new LLColor4 ( getCurR (), getCurG (), getCurB (), 1.0f ); // save off color std::ostringstream codec; codec << "ColorPaletteEntry" << std::setfill ( '0' ) << std::setw ( 2 ) << curEntry + 1; const std::string s ( codec.str () ); LLUIColorTable::instance().setColor(s, *mPalette [ curEntry ] ); } } ++curEntry; } } } } // mouse button not down anymore setMouseDownInHueRegion ( FALSE ); setMouseDownInLumRegion ( FALSE ); // mouse button not down in color swatch anymore mMouseDownInSwatch = false; if (hasMouseCapture()) { gFocusMgr.setMouseCapture(NULL); } // dispatch to base class for the rest of things return LLFloater::handleMouseUp ( x, y, mask ); }
//////////////////////////////////////////////////////////////////////////////// // inherited from LLViewerMediaObserver //virtual void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) { switch(event) { case MEDIA_EVENT_CONTENT_UPDATED: { // LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CONTENT_UPDATED " << LL_ENDL; }; break; case MEDIA_EVENT_TIME_DURATION_UPDATED: { // LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_TIME_DURATION_UPDATED, time is " << self->getCurrentTime() << " of " << self->getDuration() << LL_ENDL; }; break; case MEDIA_EVENT_SIZE_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_SIZE_CHANGED " << LL_ENDL; LLRect r = getRect(); reshape( r.getWidth(), r.getHeight(), FALSE ); }; break; case MEDIA_EVENT_CURSOR_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CURSOR_CHANGED, new cursor is " << self->getCursorName() << LL_ENDL; } break; case MEDIA_EVENT_NAVIGATE_BEGIN: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAVIGATE_BEGIN, url is " << self->getNavigateURI() << LL_ENDL; hideNotification(); }; break; case MEDIA_EVENT_NAVIGATE_COMPLETE: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAVIGATE_COMPLETE, result string is: " << self->getNavigateResultString() << LL_ENDL; if(mHidingInitialLoad) { mHidingInitialLoad = false; } }; break; case MEDIA_EVENT_PROGRESS_UPDATED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PROGRESS_UPDATED, loading at " << self->getProgressPercent() << "%" << LL_ENDL; }; break; case MEDIA_EVENT_STATUS_TEXT_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_STATUS_TEXT_CHANGED, new status text is: " << self->getStatusText() << LL_ENDL; }; break; case MEDIA_EVENT_LOCATION_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_LOCATION_CHANGED, new uri is: " << self->getLocation() << LL_ENDL; mCurrentNavUrl = self->getLocation(); }; break; case MEDIA_EVENT_NAVIGATE_ERROR_PAGE: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAVIGATE_ERROR_PAGE" << LL_ENDL; if ( mErrorPageURL.length() > 0 ) { navigateTo(mErrorPageURL, "text/html"); }; }; break; case MEDIA_EVENT_CLICK_LINK_HREF: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CLICK_LINK_HREF, target is \"" << self->getClickTarget() << "\", uri is " << self->getClickURL() << LL_ENDL; // retrieve the event parameters std::string url = self->getClickURL(); std::string target = self->getClickTarget(); std::string uuid = self->getClickUUID(); LLNotification::Params notify_params("PopupAttempt"); notify_params.payload = LLSD().with("target", target).with("url", url).with("uuid", uuid).with("media_id", mMediaTextureID); notify_params.functor(boost::bind(&LLMediaCtrl::onPopup, this, _1, _2)); if (mTrusted) { LLNotifications::instance().forceResponse(notify_params, 0); } else { LLNotifications::instance().add(notify_params); } break; }; case MEDIA_EVENT_CLICK_LINK_NOFOLLOW: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CLICK_LINK_NOFOLLOW, uri is " << self->getClickURL() << LL_ENDL; }; break; case MEDIA_EVENT_PLUGIN_FAILED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PLUGIN_FAILED" << LL_ENDL; }; break; case MEDIA_EVENT_PLUGIN_FAILED_LAUNCH: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PLUGIN_FAILED_LAUNCH" << LL_ENDL; }; break; case MEDIA_EVENT_NAME_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAME_CHANGED" << LL_ENDL; }; break; case MEDIA_EVENT_CLOSE_REQUEST: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CLOSE_REQUEST" << LL_ENDL; } break; case MEDIA_EVENT_PICK_FILE_REQUEST: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PICK_FILE_REQUEST" << LL_ENDL; } break; case MEDIA_EVENT_GEOMETRY_CHANGE: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_GEOMETRY_CHANGE, uuid is " << self->getClickUUID() << LL_ENDL; } break; case MEDIA_EVENT_AUTH_REQUEST: { LLNotification::Params auth_request_params("AuthRequest"); // pass in host name and realm for site (may be zero length but will always exist) LLSD args; LLURL raw_url( self->getAuthURL().c_str() ); args["HOST_NAME"] = raw_url.getAuthority(); args["REALM"] = self->getAuthRealm(); auth_request_params.substitutions = args; auth_request_params.payload = LLSD().with("media_id", mMediaTextureID); auth_request_params.functor(boost::bind(&LLViewerMedia::onAuthSubmit, _1, _2)); LLNotifications::instance().add(auth_request_params); }; break; case MEDIA_EVENT_LINK_HOVERED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_LINK_HOVERED, hover text is: " << self->getHoverText() << LL_ENDL; mHoverTextChanged = true; }; break; case MEDIA_EVENT_DEBUG_MESSAGE: { LL_INFOS("media") << self->getDebugMessageText() << LL_ENDL; }; break; default: { LL_WARNS("Media") << "Media event: unknown event type" << LL_ENDL; }; }; // chain all events to any potential observers of this object. emitEvent(self, event); }