Exemplo n.º 1
0
void LLAccordionCtrlTab::draw()
{
	if(mFitPanel)
		LLUICtrl::draw();
	else
	{
		LLRect root_rect = getRootView()->getRect();
		drawChild(root_rect,mHeader);
		drawChild(root_rect,mScrollbar );
		{
			LLRect child_rect;

			S32 width = getRect().getWidth();
			S32 height = getRect().getHeight();

			child_rect.setLeftTopAndSize(
				getPaddingLeft(),
				height - getHeaderHeight() - getPaddingTop(),
				width - getPaddingLeft() - getPaddingRight(), 
				height - getHeaderHeight() - getPaddingTop() - getPaddingBottom() );

			LLLocalClipRect clip(child_rect);
			drawChild(root_rect,mContainerPanel);
		}
	}
}
void LLPanelPathfindingRebakeNavmesh::updatePosition()
{
#if 0
	S32 y_pos = 0;
	S32 bottom_tb_center = 0;

	if (LLToolBar* toolbar_bottom = gToolBarView->getChild<LLToolBar>("toolbar_bottom"))
	{
		y_pos = toolbar_bottom->getRect().getHeight();
		bottom_tb_center = toolbar_bottom->getRect().getCenterX();
	}

	S32 left_tb_width = 0;
	if (LLToolBar* toolbar_left = gToolBarView->getChild<LLToolBar>("toolbar_left"))
	{
		left_tb_width = toolbar_left->getRect().getWidth();
	}

	if(LLPanel* panel_ssf_container = getRootView()->getChild<LLPanel>("state_management_buttons_container"))
	{
		panel_ssf_container->setOrigin(0, y_pos);
	}

	S32 x_pos = bottom_tb_center-getRect().getWidth()/2 - left_tb_width + 113 /* width of stand/fly button *//* + 10 *//* margin */;

	/*setOrigin( x_pos, 0);*/
#endif
}
Exemplo n.º 3
0
/**
 * Updates position of the Stand & Stop Flying panel to be center aligned with Move button.
 */
void LLPanelStandStopFlying::updatePosition()
{
	if (mAttached) return;

	S32 y_pos = 0;
	S32 bottom_tb_center = 0;
	if (LLToolBar* toolbar_bottom = gToolBarView->getChild<LLToolBar>("toolbar_bottom"))
	{
		y_pos = toolbar_bottom->getRect().getHeight();
		bottom_tb_center = toolbar_bottom->getRect().getCenterX();
	}

	S32 left_tb_width = 0;
	if (LLToolBar* toolbar_left = gToolBarView->getChild<LLToolBar>("toolbar_left"))
	{
		left_tb_width = toolbar_left->getRect().getWidth();
	}

	if(LLPanel* panel_ssf_container = getRootView()->getChild<LLPanel>("stand_stop_flying_container"))
	{
		panel_ssf_container->setOrigin(0, y_pos);
	}

	S32 x_pos = bottom_tb_center-getRect().getWidth()/2 - left_tb_width;

	setOrigin( x_pos, 0);
}
void LLFacebookPhotoPanel::onVisibilityChange(BOOL visible)
{
	if (visible)
	{
		if (mPreviewHandle.get())
		{
			LLSnapshotLivePreview* preview = getPreviewView();
			if(preview)
			{
				LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL;
				preview->updateSnapshot(TRUE);
			}
		}
		else
		{
			LLRect full_screen_rect = getRootView()->getRect();
			LLSnapshotLivePreview::Params p;
			p.rect(full_screen_rect);
			LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p);
			mPreviewHandle = previewp->getHandle();	
            mQuality = MAX_QUALITY;

            previewp->setContainer(this);
			previewp->setSnapshotType(previewp->SNAPSHOT_WEB);
			previewp->setSnapshotFormat(LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG);
			previewp->setSnapshotQuality(mQuality, false);
            previewp->setThumbnailSubsampled(TRUE);     // We want the preview to reflect the *saved* image
            previewp->setAllowRenderUI(FALSE);          // We do not want the rendered UI in our snapshots
            previewp->setAllowFullScreenPreview(FALSE);  // No full screen preview in SL Share mode
			previewp->setThumbnailPlaceholderRect(mThumbnailPlaceholder->getRect());

			updateControls();
		}
	}
}
Exemplo n.º 5
0
void LLExpandableTextBox::saveCollapsedState()
{
	mCollapsedRect = getRect();

	mParentRect = getParent()->getRect();
	// convert parent rect to screen coordinates, 
	// this will allow to track parent's position change
	getParent()->localRectToOtherView(mParentRect, &mParentRect, getRootView());
}
Exemplo n.º 6
0
void ClapTrapApp::setup()
{	
    ofxGenericApp::setup();
    
    ofPtr< ofxGenericView > rootView = getRootView();
    if ( rootView )
    {
        rootView->addChildView( CameraView::create( _window->getFrame() ) );
    }
}
void PlatformInfo::setup()
{	
    ofxGenericApp::setup();
    
    ofPtr< ofxGenericView > rootView = getRootView();
    if ( rootView )
    {
        ofPtr< InfoView > infoView = InfoView::create( _window->getFrame() );
        rootView->addChildView( infoView );
    }
}
Exemplo n.º 8
0
void LLDebugView::draw()
{
	if (mFloaterSnapRegion == NULL)
	{
		mFloaterSnapRegion = getRootView()->getChildView("floater_snap_region");
	}

	LLRect debug_rect;
	mFloaterSnapRegion->localRectToOtherView(mFloaterSnapRegion->getLocalRect(), &debug_rect, getParent());

	setShape(debug_rect);
	LLView::draw();
}
Exemplo n.º 9
0
void LLExpandableTextBox::collapseIfPosChanged()
{
	if(mExpanded)
	{
		LLView* parentp = getParent();
		LLRect parent_rect = parentp->getRect();
		parentp->localRectToOtherView(parent_rect, &parent_rect, getRootView());

		if(parent_rect.mLeft != mParentRect.mLeft 
			|| parent_rect.mTop != mParentRect.mTop)
		{
			collapseTextBox();
		}
	}
}
Exemplo n.º 10
0
// add a widget to both the ML and Juce worlds.  The widget is retained by the Juce Component.
// 
void MLWidgetContainer::addWidget(MLWidget* pW, const ml::Symbol name)
{	
	// should be setView() 
	pW->setContainer(this);
	
	// give root context pointer to all new containers
	if(pW->isWidgetContainer())
	{
		MLWidgetContainer& resultContainer = static_cast<MLWidgetContainer&>(*pW);
		
		// all Containers in a tree of Widgets have pointers to the same root context. 
		resultContainer.setRootView(getRootView());
	}
	
	ml::Symbol newName;
	if (name)
	{
		if(mWidgets.find(name) != mWidgets.end())
		{
			//debug() << "MLWidgetContainer::addWidget: name " << name << " already taken! \n";			
			//debug() << mWidgets.size() << " widgets:\n";
			dumpWidgets();
			ml::theSymbolTable().dump();
			ml::theSymbolTable().audit();
		}
		else
		{
			newName = name;
		}
	}
	else // get name for anon widgets
	{
		newName = mWidgetNamer.nextName();
	}

	if(newName)
	{
		mWidgets[newName] = pW;
		pW->setWidgetName(newName);
	}
    
    // add parent JUCE component 
    getComponent()->addChildComponent(pW->getComponent());
}
Exemplo n.º 11
0
const LLView* LLUI::resolvePath(const LLView* context, const std::string& path)
{
	// Create an iterator over slash-separated parts of 'path'. Dereferencing
	// this iterator returns an iterator_range over the substring. Unlike
	// LLStringUtil::getTokens(), this split_iterator doesn't combine adjacent
	// delimiters: leading/trailing slash produces an empty substring, double
	// slash produces an empty substring. That's what we need.
	boost::split_iterator<std::string::const_iterator> ti(path, boost::first_finder("/")), tend;

	if (ti == tend)
	{
		// 'path' is completely empty, no navigation
		return context;
	}

	// leading / means "start at root"
	if (ti->empty())
	{
		context = getRootView();
		++ti;
	}

	bool recurse = false;
	for (; ti != tend && context; ++ti)
	{
		if (ti->empty()) 
		{
			recurse = true;
		}
		else
		{
			std::string part(ti->begin(), ti->end());
			context = context->findChildView(part, recurse);
			recurse = false;
		}
	}

	return context;
}
Exemplo n.º 12
0
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;
}
Exemplo n.º 13
0
S32 LLExpandableTextBox::recalculateTextDelta(S32 text_delta)
{
	LLRect expanded_rect = getLocalRect();
	LLView* root_view = getRootView();
	LLRect window_rect = root_view->getRect();

	LLRect expanded_screen_rect;
	localRectToOtherView(expanded_rect, &expanded_screen_rect, root_view);

	// don't allow expanded text box bottom go off screen
	if(expanded_screen_rect.mBottom - text_delta < window_rect.mBottom)
	{
		text_delta = expanded_screen_rect.mBottom - window_rect.mBottom;
	}
	// show scroll bar if max_height is valid 
	// and expanded size is greater that max_height
	else if(mMaxHeight > 0 && expanded_rect.getHeight() + text_delta > mMaxHeight)
	{
		text_delta = mMaxHeight - expanded_rect.getHeight();
	}

	return text_delta;
}
Exemplo n.º 14
0
/**
 * Updates position of the Stand & Stop Flying panel to be center aligned with Move button.
 */
void LLPanelStandStopFlying::updatePosition()
{
	if (mAttached) return;

	S32 y_pos = 0;
	S32 bottom_tb_center = 0;
	if (LLToolBar* toolbar_bottom = gToolBarView->getToolbar(LLToolBarEnums::TOOLBAR_BOTTOM))
	{
		y_pos = toolbar_bottom->getRect().getHeight();
		bottom_tb_center = toolbar_bottom->getRect().getCenterX();
	}

	S32 left_tb_width = 0;
	if (LLToolBar* toolbar_left = gToolBarView->getToolbar(LLToolBarEnums::TOOLBAR_LEFT))
	{
		left_tb_width = toolbar_left->getRect().getWidth();
	}

	if (!mStateManagementButtons.get())
	{
		LLPanel* panel_ssf_container = getRootView()->getChild<LLPanel>("state_management_buttons_container");
		if (panel_ssf_container)
		{
			mStateManagementButtons = panel_ssf_container->getHandle();
		}
	}

	if(LLPanel* panel_ssf_container = mStateManagementButtons.get())
	{
		panel_ssf_container->setOrigin(0, y_pos);
	}

	S32 x_pos = bottom_tb_center-getRect().getWidth()/2 - left_tb_width;

	setOrigin( x_pos, 0);
}
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;
}
Exemplo n.º 16
0
BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask)
{
	BOOL	handled = FALSE;

	// We only handle the click if the click both started and ended within us
	if( hasMouseCapture() )
	{
		// Make sure the mouse in still over the application.  We don't want to make the parent
		// so big that we can't see the resize handle any more.
	
		S32 screen_x;
		S32 screen_y;
		localPointToScreen(x, y, &screen_x, &screen_y);
		const LLRect valid_rect = getRootView()->getRect();
		screen_x = llclamp( screen_x, valid_rect.mLeft, valid_rect.mRight );
		screen_y = llclamp( screen_y, valid_rect.mBottom, valid_rect.mTop );

		LLView* resizing_view = getParent();
		if( resizing_view )
		{
			// Resize the parent
			LLRect orig_rect = resizing_view->getRect();
			LLRect scaled_rect = orig_rect;
			S32 delta_x = screen_x - mDragLastScreenX;
			S32 delta_y = screen_y - mDragLastScreenY;
			LLCoordGL mouse_dir;
			// use hysteresis on mouse motion to preserve user intent when mouse stops moving
			mouse_dir.mX = (screen_x == mLastMouseScreenX) ? mLastMouseDir.mX : screen_x - mLastMouseScreenX;
			mouse_dir.mY = (screen_y == mLastMouseScreenY) ? mLastMouseDir.mY : screen_y - mLastMouseScreenY;
			mLastMouseScreenX = screen_x;
			mLastMouseScreenY = screen_y;
			mLastMouseDir = mouse_dir;

			S32 x_multiple = 1;
			S32 y_multiple = 1;
			switch( mCorner )
			{
			case LEFT_TOP:
				x_multiple = -1; 
				y_multiple =  1;	
				break;
			case LEFT_BOTTOM:	
				x_multiple = -1; 
				y_multiple = -1;	
				break;
			case RIGHT_TOP:		
				x_multiple =  1; 
				y_multiple =  1;	
				break;
			case RIGHT_BOTTOM:	
				x_multiple =  1; 
				y_multiple = -1;	
				break;
			}

			S32 new_width = orig_rect.getWidth() + x_multiple * delta_x;
			if( new_width < mMinWidth )
			{
				new_width = mMinWidth;
				delta_x = x_multiple * (mMinWidth - orig_rect.getWidth());
			}

			S32 new_height = orig_rect.getHeight() + y_multiple * delta_y;
			if( new_height < mMinHeight )
			{
				new_height = mMinHeight;
				delta_y = y_multiple * (mMinHeight - orig_rect.getHeight());
			}

			switch( mCorner )
			{
			case LEFT_TOP:		
				scaled_rect.translate(delta_x, 0);			
				break;
			case LEFT_BOTTOM:	
				scaled_rect.translate(delta_x, delta_y);	
				break;
			case RIGHT_TOP:		
				break;
			case RIGHT_BOTTOM:	
				scaled_rect.translate(0, delta_y);			
				break;
			}

			// temporarily set new parent rect
			scaled_rect.mRight = scaled_rect.mLeft + new_width;
			scaled_rect.mTop = scaled_rect.mBottom + new_height;
			resizing_view->setRect(scaled_rect);

			LLView* snap_view = NULL;
			LLView* test_view = NULL;

			// now do snapping
			switch(mCorner)
			{
			case LEFT_TOP:		
				snap_view = resizing_view->findSnapEdge(scaled_rect.mLeft, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
				test_view = resizing_view->findSnapEdge(scaled_rect.mTop, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
				if (!snap_view)
				{
					snap_view = test_view;
				}
				break;
			case LEFT_BOTTOM:	
				snap_view = resizing_view->findSnapEdge(scaled_rect.mLeft, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
				test_view = resizing_view->findSnapEdge(scaled_rect.mBottom, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
				if (!snap_view)
				{
					snap_view = test_view;
				}
				break;
			case RIGHT_TOP:		
				snap_view = resizing_view->findSnapEdge(scaled_rect.mRight, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
				test_view = resizing_view->findSnapEdge(scaled_rect.mTop, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
				if (!snap_view)
				{
					snap_view = test_view;
				}
				break;
			case RIGHT_BOTTOM:	
				snap_view = resizing_view->findSnapEdge(scaled_rect.mRight, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
				test_view = resizing_view->findSnapEdge(scaled_rect.mBottom, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
				if (!snap_view)
				{
					snap_view = test_view;
				}
				break;
			}

			// register "snap" behavior with snapped view
			resizing_view->snappedTo(snap_view);

			// reset parent rect
			resizing_view->setRect(orig_rect);

			// translate and scale to new shape
			resizing_view->userSetShape(scaled_rect);
			
			// update last valid mouse cursor position based on resized view's actual size
			LLRect new_rect = resizing_view->getRect();
			switch(mCorner)
			{
			case LEFT_TOP:
				mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft;
				mDragLastScreenY += new_rect.mTop - orig_rect.mTop;
				break;
			case LEFT_BOTTOM:
				mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft;
				mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom;
				break;
			case RIGHT_TOP:
				mDragLastScreenX += new_rect.mRight - orig_rect.mRight;
				mDragLastScreenY += new_rect.mTop - orig_rect.mTop;
				break;
			case RIGHT_BOTTOM:
				mDragLastScreenX += new_rect.mRight - orig_rect.mRight;
				mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom;
				break;
			default:
				break;
			}
		}

		handled = TRUE;
	}
	else // don't have mouse capture
	{
		if( pointInHandle( x, y ) )
		{
			handled = TRUE;
		}
	}

	if( handled )
	{
		switch( mCorner )
		{
		case RIGHT_BOTTOM:
		case LEFT_TOP:	
			getWindow()->setCursor(UI_CURSOR_SIZENWSE); 
			break;
		case LEFT_BOTTOM:
		case RIGHT_TOP:	
			getWindow()->setCursor(UI_CURSOR_SIZENESW); 
			break;
		}
	}

	return handled;
} // end handleHover
Exemplo n.º 17
0
BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask)
{
	BOOL	handled = FALSE;

	// We only handle the click if the click both started and ended within us
	if( hasMouseCapture() )
	{
		S32 screen_x;
		S32 screen_y;
		localPointToScreen(x, y, &screen_x, &screen_y);
		
		S32 delta_x = screen_x - mDragLastScreenX;
		S32 delta_y = screen_y - mDragLastScreenY;
				
		LLCoordGL mouse_dir;
		// use hysteresis on mouse motion to preserve user intent when mouse stops moving
		mouse_dir.mX = (screen_x == mLastMouseScreenX) ? mLastMouseDir.mX : screen_x - mLastMouseScreenX;
		mouse_dir.mY = (screen_y == mLastMouseScreenY) ? mLastMouseDir.mY : screen_y - mLastMouseScreenY;
		mLastMouseDir = mouse_dir;
		mLastMouseScreenX = screen_x;
		mLastMouseScreenY = screen_y;

		// Make sure the mouse in still over the application.  We don't want to make the parent
		// so big that we can't see the resize handle any more.
		LLRect valid_rect = getRootView()->getRect();
		
		if( valid_rect.localPointInRect( screen_x, screen_y ) && mResizingView )
		{
			// Resize the parent
			LLRect orig_rect = mResizingView->getRect();
			LLRect scaled_rect = orig_rect;
				
			S32 new_width = orig_rect.getWidth();
			S32 new_height = orig_rect.getHeight();

			switch( mSide )
			{
			case LEFT:
				new_width = llclamp(orig_rect.getWidth() - delta_x, mMinSize, mMaxSize);
				delta_x = orig_rect.getWidth() - new_width;
				scaled_rect.translate(delta_x, 0);
				break;

			case TOP:
				new_height = llclamp(orig_rect.getHeight() + delta_y, mMinSize, mMaxSize);
				delta_y = new_height - orig_rect.getHeight();
				break;
			
			case RIGHT:
				new_width = llclamp(orig_rect.getWidth() + delta_x, mMinSize, mMaxSize);
				delta_x = new_width - orig_rect.getWidth();
				break;
		
			case BOTTOM:
				new_height = llclamp(orig_rect.getHeight() - delta_y, mMinSize, mMaxSize);
				delta_y = orig_rect.getHeight() - new_height;
				scaled_rect.translate(0, delta_y);
				break;
			}

			scaled_rect.mTop = scaled_rect.mBottom + new_height;
			scaled_rect.mRight = scaled_rect.mLeft + new_width;
			mResizingView->setRect(scaled_rect);

			LLView* snap_view = NULL;

			if (mSnappingEnabled)
			{
				switch( mSide )
				{
				case LEFT:
					snap_view = mResizingView->findSnapEdge(scaled_rect.mLeft, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
					break;
				case TOP:
					snap_view = mResizingView->findSnapEdge(scaled_rect.mTop, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
					break;
				case RIGHT:
					snap_view = mResizingView->findSnapEdge(scaled_rect.mRight, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
					break;
				case BOTTOM:
					snap_view = mResizingView->findSnapEdge(scaled_rect.mBottom, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
					break;
				}
			}

			// register "snap" behavior with snapped view
			mResizingView->snappedTo(snap_view);

			// restore original rectangle so the appropriate changes are detected
			mResizingView->setRect(orig_rect);
			// change view shape as user operation
			mResizingView->userSetShape(scaled_rect);

			if(mDragCallback)mDragCallback(mDragCallbackUserdata);

			// update last valid mouse cursor position based on resized view's actual size
			LLRect new_rect = mResizingView->getRect();
			switch(mSide)
			{
			case LEFT:
				mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft;
				break;
			case RIGHT:
				mDragLastScreenX += new_rect.mRight - orig_rect.mRight;
				break;
			case TOP:
				mDragLastScreenY += new_rect.mTop - orig_rect.mTop;
				break;
			case BOTTOM:
				mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom;
				break;
			default:
				break;
			}
		}

		handled = TRUE;
	}
	else
	{
		handled = TRUE;
	}

	if( handled )
	{
		switch( mSide )
		{
		case LEFT:
		case RIGHT:
			getWindow()->setCursor(UI_CURSOR_SIZEWE);
			break;

		case TOP:
		case BOTTOM:
			getWindow()->setCursor(UI_CURSOR_SIZENS);
			break;
		}
	}

	return handled;
} // end LLResizeBar::handleHover
Exemplo n.º 18
0
void LLComboBox::showList()
{
	// Make sure we don't go off top of screen.
	LLCoordWindow window_size;
	getWindow()->getSize(&window_size);
	//HACK: shouldn't have to know about scale here
	mList->fitContents( 192, llfloor((F32)window_size.mY / LLUI::sGLScaleFactor.mV[VY]) - 50 );

	// Make sure that we can see the whole list
	LLRect root_view_local;
	LLView* root_view = getRootView();
	root_view->localRectToOtherView(root_view->getLocalRect(), &root_view_local, this);
	
	LLRect rect = mList->getRect();

	S32 min_width = getRect().getWidth();
	S32 max_width = llmax(min_width, MAX_COMBO_WIDTH);
	// make sure we have up to date content width metrics
	mList->calcColumnWidths();
	S32 list_width = llclamp(mList->getMaxContentWidth(), min_width, max_width);

	if (mListPosition == BELOW)
	{
		if (rect.getHeight() <= -root_view_local.mBottom)
		{
			// Move rect so it hangs off the bottom of this view
			rect.setLeftTopAndSize(0, 0, list_width, rect.getHeight() );
		}
		else
		{	
			// stack on top or bottom, depending on which has more room
			if (-root_view_local.mBottom > root_view_local.mTop - getRect().getHeight())
			{
				// Move rect so it hangs off the bottom of this view
				rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight()));
			}
			else
			{
				// move rect so it stacks on top of this view (clipped to size of screen)
				rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight()));
			}
		}
	}
	else // ABOVE
	{
		if (rect.getHeight() <= root_view_local.mTop - getRect().getHeight())
		{
			// move rect so it stacks on top of this view (clipped to size of screen)
			rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight()));
		}
		else
		{
			// stack on top or bottom, depending on which has more room
			if (-root_view_local.mBottom > root_view_local.mTop - getRect().getHeight())
			{
				// Move rect so it hangs off the bottom of this view
				rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight()));
			}
			else
			{
				// move rect so it stacks on top of this view (clipped to size of screen)
				rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight()));
			}
		}

	}
	mList->setOrigin(rect.mLeft, rect.mBottom);
	mList->reshape(rect.getWidth(), rect.getHeight());
	mList->translateIntoRect(root_view_local, FALSE);

	// Make sure we didn't go off bottom of screen
	S32 x, y;
	mList->localPointToScreen(0, 0, &x, &y);

	if (y < 0)
	{
		mList->translate(0, -y);
	}

	// NB: this call will trigger the focuslost callback which will hide the list, so do it first
	// before finally showing the list

	mList->setFocus(TRUE);

	// register ourselves as a "top" control
	// effectively putting us into a special draw layer
	// and not affecting the bounding rectangle calculation
	gFocusMgr.setTopCtrl(this);

	// Show the list and push the button down
	mButton->setToggleState(TRUE);
	mList->setVisible(TRUE);
	
	setUseBoundingRect(TRUE);
}