BOOL LLAccordionCtrl::autoScroll (S32 x, S32 y) { static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0); bool scrolling = false; if( mScrollbar->getVisible() ) { LLRect rect_local( 0, getRect().getHeight(), getRect().getWidth() - scrollbar_size, 0 ); LLRect screen_local_extents; // clip rect against root view screenRectToLocal(getRootView()->getLocalRect(), &screen_local_extents); rect_local.intersectWith(screen_local_extents); // autoscroll region should take up no more than one third of visible scroller area S32 auto_scroll_region_height = llmin(rect_local.getHeight() / 3, 10); S32 auto_scroll_speed = llround(mAutoScrollRate * LLFrameTimer::getFrameDeltaTimeF32()); LLRect bottom_scroll_rect = screen_local_extents; bottom_scroll_rect.mTop = rect_local.mBottom + auto_scroll_region_height; if( bottom_scroll_rect.pointInRect( x, y ) && (mScrollbar->getDocPos() < mScrollbar->getDocPosMax()) ) { mScrollbar->setDocPos( mScrollbar->getDocPos() + auto_scroll_speed ); mAutoScrolling = true; scrolling = true; } LLRect top_scroll_rect = screen_local_extents; top_scroll_rect.mBottom = rect_local.mTop - auto_scroll_region_height; if( top_scroll_rect.pointInRect( x, y ) && (mScrollbar->getDocPos() > 0) ) { mScrollbar->setDocPos( mScrollbar->getDocPos() - auto_scroll_speed ); mAutoScrolling = true; scrolling = true; } } return scrolling; }
bool LLScrollContainer::autoScroll(S32 x, S32 y) { static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0); bool scrolling = false; if( mScrollbar[HORIZONTAL]->getVisible() || mScrollbar[VERTICAL]->getVisible() ) { LLRect screen_local_extents; screenRectToLocal(getRootView()->getLocalRect(), &screen_local_extents); LLRect inner_rect_local( 0, mInnerRect.getHeight(), mInnerRect.getWidth(), 0 ); if( mScrollbar[HORIZONTAL]->getVisible() ) { inner_rect_local.mBottom += scrollbar_size; } if( mScrollbar[VERTICAL]->getVisible() ) { inner_rect_local.mRight -= scrollbar_size; } // clip rect against root view inner_rect_local.intersectWith(screen_local_extents); S32 auto_scroll_speed = llround(mAutoScrollRate * LLFrameTimer::getFrameDeltaTimeF32()); // autoscroll region should take up no more than one third of visible scroller area S32 auto_scroll_region_width = llmin(inner_rect_local.getWidth() / 3, 10); S32 auto_scroll_region_height = llmin(inner_rect_local.getHeight() / 3, 10); if( mScrollbar[HORIZONTAL]->getVisible() ) { LLRect left_scroll_rect = screen_local_extents; left_scroll_rect.mRight = inner_rect_local.mLeft + auto_scroll_region_width; if( left_scroll_rect.pointInRect( x, y ) && (mScrollbar[HORIZONTAL]->getDocPos() > 0) ) { mScrollbar[HORIZONTAL]->setDocPos( mScrollbar[HORIZONTAL]->getDocPos() - auto_scroll_speed ); mAutoScrolling = TRUE; scrolling = true; } LLRect right_scroll_rect = screen_local_extents; right_scroll_rect.mLeft = inner_rect_local.mRight - auto_scroll_region_width; if( right_scroll_rect.pointInRect( x, y ) && (mScrollbar[HORIZONTAL]->getDocPos() < mScrollbar[HORIZONTAL]->getDocPosMax()) ) { mScrollbar[HORIZONTAL]->setDocPos( mScrollbar[HORIZONTAL]->getDocPos() + auto_scroll_speed ); mAutoScrolling = TRUE; scrolling = true; } } if( mScrollbar[VERTICAL]->getVisible() ) { LLRect bottom_scroll_rect = screen_local_extents; bottom_scroll_rect.mTop = inner_rect_local.mBottom + auto_scroll_region_height; if( bottom_scroll_rect.pointInRect( x, y ) && (mScrollbar[VERTICAL]->getDocPos() < mScrollbar[VERTICAL]->getDocPosMax()) ) { mScrollbar[VERTICAL]->setDocPos( mScrollbar[VERTICAL]->getDocPos() + auto_scroll_speed ); mAutoScrolling = TRUE; scrolling = true; } LLRect top_scroll_rect = screen_local_extents; top_scroll_rect.mBottom = inner_rect_local.mTop - auto_scroll_region_height; if( top_scroll_rect.pointInRect( x, y ) && (mScrollbar[VERTICAL]->getDocPos() > 0) ) { mScrollbar[VERTICAL]->setDocPos( mScrollbar[VERTICAL]->getDocPos() - auto_scroll_speed ); mAutoScrolling = TRUE; scrolling = true; } } } return scrolling; }
/*virtual*/ void LLPanelPrimMediaControls::draw() { F32 alpha = getDrawContext().mAlpha; if(mFadeTimer.getStarted()) { F32 time = mFadeTimer.getElapsedTimeF32(); alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f); if(time >= mControlFadeTime) { if(mClearFaceOnFade) { // Hiding this object makes scroll events go missing after it fades out // (see DEV-41755 for a full description of the train wreck). // Only hide the controls when we're untargeting. setVisible(FALSE); mClearFaceOnFade = false; mVolumeSliderVisible = 0; mTargetImplID = LLUUID::null; mTargetObjectID = LLUUID::null; mTargetObjectFace = 0; } } } // Build rect for icon area in coord system of this panel // Assumes layout_stack is a direct child of this panel mMediaControlsStack->updateLayout(); // adjust for layout stack spacing S32 space = mMediaControlsStack->getPanelSpacing() + 2; LLRect controls_bg_area = mMediaControlsStack->getRect(); controls_bg_area.mTop += space + 2; // adjust to ignore space from volume slider controls_bg_area.mBottom += mVolumeSliderCtrl->getRect().getHeight(); // adjust to ignore space from left bookend padding controls_bg_area.mLeft += mLeftBookend->getRect().getWidth() - space; // ignore space from right bookend padding controls_bg_area.mRight -= mRightBookend->getRect().getWidth() - space - 2; // draw control background UI image mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha); // draw volume slider background UI image if (mVolumeSliderCtrl->getVisible()) { LLRect volume_slider_rect; screenRectToLocal(mVolumeSliderCtrl->calcScreenRect(), &volume_slider_rect); mVolumeSliderBackgroundImage->draw(volume_slider_rect, UI_VERTEX_COLOR % alpha); } { LLViewDrawContext context(alpha); LLPanel::draw(); } }
S32 LLAccordionCtrl::notifyParent(const LLSD& info) { if(info.has("action")) { std::string str_action = info["action"]; if(str_action == "size_changes") { // arrange(); return 1; } else if(str_action == "select_next") { for(size_t i=0;i<mAccordionTabs.size();++i) { LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); if(accordion_tab->hasFocus()) { while(++i<mAccordionTabs.size()) { if(mAccordionTabs[i]->getVisible()) break; } if(i<mAccordionTabs.size()) { accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); accordion_tab->notify(LLSD().with("action","select_first")); return 1; } break; } } return 0; } else if(str_action == "select_prev") { for(size_t i=0;i<mAccordionTabs.size();++i) { LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); if(accordion_tab->hasFocus() && i>0) { bool prev_visible_tab_found = false; while(i>0) { if(mAccordionTabs[--i]->getVisible()) { prev_visible_tab_found = true; break; } } if (prev_visible_tab_found) { accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); accordion_tab->notify(LLSD().with("action","select_last")); return 1; } break; } } return 0; } else if(str_action == "select_current") { for(size_t i=0;i<mAccordionTabs.size();++i) { // Set selection to the currently focused tab. if(mAccordionTabs[i]->hasFocus()) { if (mAccordionTabs[i] != mSelectedTab) { if (mSelectedTab) { mSelectedTab->setSelected(false); } mSelectedTab = mAccordionTabs[i]; mSelectedTab->setSelected(true); } return 1; } } return 0; } else if(str_action == "deselect_current") { // Reset selection to the currently selected tab. if (mSelectedTab) { mSelectedTab->setSelected(false); mSelectedTab = NULL; return 1; } return 0; } } else if (info.has("scrollToShowRect")) { LLRect screen_rc, local_rc; screen_rc.setValue(info["scrollToShowRect"]); screenRectToLocal(screen_rc, &local_rc); // Translate to parent coordinatess to check if we are in visible rectangle local_rc.translate( getRect().mLeft, getRect().mBottom ); if ( !getRect().contains (local_rc) ) { // Back to local coords and calculate position for scroller S32 bottom = mScrollbar->getDocPos() - local_rc.mBottom + getRect().mBottom; S32 top = mScrollbar->getDocPos() - local_rc.mTop + getRect().mTop; S32 scroll_pos = llclamp(mScrollbar->getDocPos(), bottom, // min vertical scroll top); // max vertical scroll mScrollbar->setDocPos( scroll_pos ); } return 1; } else if (info.has("child_visibility_change")) { BOOL new_visibility = info["child_visibility_change"]; if (new_visibility) { // there is at least one visible tab mNoVisibleTabsHelpText->setVisible(FALSE); } else { // it could be the latest visible tab, check all of them updateNoTabsHelpTextVisibility(); } } return LLPanel::notifyParent(info); }
/*virtual*/ void LLPanelPrimMediaControls::draw() { LLViewerMediaImpl* impl = getTargetMediaImpl(); if (impl) { LLNotificationPtr notification = impl->getCurrentNotification(); if (notification != mActiveNotification) { mActiveNotification = notification; if (notification) { showNotification(notification); } else { hideNotification(); } } } F32 alpha = getDrawContext().mAlpha; if(mHideImmediately) { //hide this panel clearFaceOnFade(); mHideImmediately = false; } else if(mFadeTimer.getStarted()) { F32 time = mFadeTimer.getElapsedTimeF32(); alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f); if(time >= mControlFadeTime) { //hide this panel clearFaceOnFade(); } } // Build rect for icon area in coord system of this panel // Assumes layout_stack is a direct child of this panel mMediaControlsStack->updateLayout(); // adjust for layout stack spacing S32 space = mMediaControlsStack->getPanelSpacing() + 2; LLRect controls_bg_area = mMediaControlsStack->getRect(); controls_bg_area.mTop += space + 2; // adjust to ignore space from volume slider controls_bg_area.mBottom += mVolumeSliderCtrl->getRect().getHeight(); // adjust to ignore space from left bookend padding controls_bg_area.mLeft += mLeftBookend->getRect().getWidth() - space; // ignore space from right bookend padding controls_bg_area.mRight -= mRightBookend->getRect().getWidth() - space - 2; // draw control background UI image mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha); // draw volume slider background UI image if (mVolumeSliderCtrl->getVisible()) { LLRect volume_slider_rect; screenRectToLocal(mVolumeSliderCtrl->calcScreenRect(), &volume_slider_rect); mVolumeSliderBackgroundImage->draw(volume_slider_rect, UI_VERTEX_COLOR % alpha); } { LLViewDrawContext context(alpha); LLPanel::draw(); } }
/*virtual*/ void LLPanelPrimMediaControls::draw() { LLViewerMediaImpl* impl = getTargetMediaImpl(); if (impl) { LLNotificationPtr notification = impl->getCurrentNotification(); if (notification != mActiveNotification) { mActiveNotification = notification; if (notification) { showNotification(notification); } else { hideNotification(); } } } F32 alpha = getDrawContext().mAlpha; if(mHideImmediately) { //hide this panel clearFaceOnFade(); mHideImmediately = false; } else if(mFadeTimer.getStarted()) { F32 time = mFadeTimer.getElapsedTimeF32(); alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f); if(time >= mControlFadeTime) { //hide this panel clearFaceOnFade(); } } // Show/hide the lock icon for secure browsing mSecureLockIcon->setVisible(mSecureURL && !mMediaAddress->hasFocus()); // Build rect for icon area in coord system of this panel // Assumes layout_stack is a direct child of this panel mMediaControlsStack->updateLayout(); // adjust for layout stack spacing S32 space = mMediaControlsStack->getPanelSpacing() + 2; LLRect controls_bg_area = mMediaControlsStack->getRect(); controls_bg_area.mTop += space + 2; // adjust to ignore space from volume slider controls_bg_area.mBottom += mVolumeSliderCtrl->getRect().getHeight(); // adjust to ignore space from left bookend padding controls_bg_area.mLeft += mLeftBookend->getRect().getWidth() - space; // ignore space from right bookend padding controls_bg_area.mRight -= mRightBookend->getRect().getWidth() - space - 2; // draw control background UI image // <FS:ND> VWR-29449; Only draw mBackgroundImage when the user has MEDIA_PERM_CONTROL. Otherwise we did hide all media controls above and drawing mBackgroundImage draws a useless grey square. // mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha); LLViewerObject* objectp = getTargetObject(); LLMediaEntry *media_data(0); if( objectp ) media_data = objectp->getTE(mTargetObjectFace)->getMediaData(); if( !dynamic_cast<LLVOVolume*>(objectp) || !media_data || dynamic_cast<LLVOVolume*>(objectp)->hasMediaPermission(media_data, LLVOVolume::MEDIA_PERM_CONTROL) ) mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha); // </FS:ND> // draw volume slider background UI image if (mVolumeSliderCtrl->getVisible()) { LLRect volume_slider_rect; screenRectToLocal(mVolumeSliderCtrl->calcScreenRect(), &volume_slider_rect); mVolumeSliderBackgroundImage->draw(volume_slider_rect, UI_VERTEX_COLOR % alpha); } { LLViewDrawContext context(alpha); LLPanel::draw(); } }
S32 LLAccordionCtrl::notifyParent(const LLSD& info) { if(info.has("action")) { std::string str_action = info["action"]; if(str_action == "size_changes") { // arrange(); return 1; } else if(str_action == "select_next") { for(size_t i=0;i<mAccordionTabs.size();++i) { LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); if(accordion_tab->hasFocus()) { while(++i<mAccordionTabs.size()) { if(mAccordionTabs[i]->getVisible()) break; } if(i<mAccordionTabs.size()) { accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); accordion_tab->notify(LLSD().with("action","select_first")); return 1; } break; } } return 0; } else if(str_action == "select_prev") { for(size_t i=0;i<mAccordionTabs.size();++i) { LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); if(accordion_tab->hasFocus() && i>0) { while(i>0) { if(mAccordionTabs[--i]->getVisible()) break; } accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); accordion_tab->notify(LLSD().with("action","select_last")); return 1; } } return 0; } } else if (info.has("scrollToShowRect")) { LLRect screen_rc, local_rc; screen_rc.setValue(info["scrollToShowRect"]); screenRectToLocal(screen_rc, &local_rc); // Translate to parent coordinatess to check if we are in visible rectangle local_rc.translate( getRect().mLeft, getRect().mBottom ); if ( !getRect().contains (local_rc) ) { // Back to local coords and calculate position for scroller S32 bottom = mScrollbar->getDocPos() - local_rc.mBottom + getRect().mBottom; S32 top = mScrollbar->getDocPos() - local_rc.mTop + getRect().mTop; S32 scroll_pos = llclamp(mScrollbar->getDocPos(), bottom, // min vertical scroll top); // max vertical scroll mScrollbar->setDocPos( scroll_pos ); } return 1; } return LLPanel::notifyParent(info); }