当前位置: 首页>>代码示例>>C++>>正文


C++ Widget::GetRect方法代码示例

本文整理汇总了C++中Widget::GetRect方法的典型用法代码示例。如果您正苦于以下问题:C++ Widget::GetRect方法的具体用法?C++ Widget::GetRect怎么用?C++ Widget::GetRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Widget的用法示例。


在下文中一共展示了Widget::GetRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Update

	void GridBox::Update(float elapsedTime)
	{
		if (mVisible)
		{
			float x_base = 0, y_base = 0;

			Rect autoRect;

			for (int i = 0; i < mGridedWidgets.Size(); ++i)
			{
				Widget * widget = mGridedWidgets[i];

				if (x_base >= mColumn * mGridWidth)
				{
					x_base = 0;
					y_base += mGridHeight + 1;
				}

				Rect rect;

				rect.x = x_base;
				rect.y = y_base;
				rect.w = mGridWidth;
				rect.h = mGridHeight;

				rect = Helper::Instance()->GetAlignRect(widget->GetRect(), rect, mGridAlign);

				x_base += mGridWidth + 1;

				autoRect.w = Max(autoRect.w, rect.x + rect.w);
				autoRect.h = Max(autoRect.h, rect.y + rect.h);

				widget->SetRect(rect);
			}

			int type = mAutoResizeType;
			Rect myRect = GetRect();

			if (type & WIDTH)
				myRect.w = autoRect.w;

			if (type & HEIGHT)
				myRect.h = autoRect.h;

			if (type != NONE)
				SetRect(myRect);
		}

		Widget::Update(elapsedTime);
	}
开发者ID:MSoft1115,项目名称:Rad3D,代码行数:50,代码来源:MGUI_GridBox.cpp

示例2: GetWidPt

Widget* WidDispatch::GetWidPt(const std::vector<Widget*>& rgpWid)
{
	Widget* pWid = NULL;
	std::vector<Widget*>::const_iterator it = rgpWid.begin();
	if (it != rgpWid.end())
	{
		pWid = *it;
		WFX_CONDITION(pWid != NULL);
		Rect rcWid = pWid->GetRect();
		float fArea = (rcWid.right - rcWid.left) * (rcWid.bottom - rcWid.top);
		float fMinArea = fArea;
		for (; it != rgpWid.end(); ++it)
		{
			rcWid = pWid->GetRect();
			fArea = (rcWid.right - rcWid.left) * (rcWid.bottom - rcWid.top);
			if (fArea < fMinArea)
			{
				fMinArea = fArea;
			}
			pWid = (*it);
		}
	}
	return pWid;
}
开发者ID:MartinWei,项目名称:wfc,代码行数:24,代码来源:Dispatch.cpp

示例3: UpdateContainerDimensionsImpl

        void VerticalContainer::UpdateContainerDimensionsImpl(const Rect& OldSelfRect, const Rect& NewSelfRect)
        {
            // Clear our old data.
            this->VisibleChildren.clear();
            this->WorkAreaSize.SetIdentity();

            // Setup any additional data for the next series of loops.
            const Real ActPadding = this->LinearPadding.CalculateActualDimension( this->ActDims.Size.Y );
            const Real HalfPadding = ActPadding * 0.5;
            std::vector< std::pair<Real,Vector2> > ChildTransformCache( this->ChildWidgets.size() );

            // To determine the visible children we need to know our view position in the work area as determined by the page provider.
            // To determine our page position we need to know our work area size, which can change when children have their dimensions updated.
            // So we first need to update the size on every child.  We can update our work area at the same time.  After that we can update our page provider and determine screen positions.
            Whole CurrIndex = 0;
            this->WorkAreaSize.Y = HalfPadding;
            for( ChildIterator SizeIt = this->ChildWidgets.begin() ; SizeIt != this->ChildWidgets.end() ; ++SizeIt )
            {
                // Enforce our sizing rules.
                if( this->ForcedSizingRules & SE_OnUpdate ) {
                    (*SizeIt)->SetSizingPolicy( this->ChildSizing );
                }

                // Calculate the sizing with our utility strat, and offset position which we will use later.
                // Since the constantly updating work area size is tracking the same information as a cursor would, we'll use it as our position cursor.
                Vector2 ChildSize = this->LayoutStrat->HandleChildSizing(OldSelfRect,NewSelfRect,(*SizeIt));

                ChildTransformCache.at(CurrIndex).first = this->WorkAreaSize.Y;
                ChildTransformCache.at(CurrIndex).second = ChildSize;

                // Update the cursor position and work area size.
                this->WorkAreaSize.Y += ( ChildSize.Y + ActPadding );
                if( this->WorkAreaSize.X < ChildSize.X )
                    this->WorkAreaSize.X = ChildSize.X;

                // Increment the index before we proceed.
                ++CurrIndex;
            }
            // Trim off half a padding at the end since we were blinding applying full padding for the space between two children.
            this->WorkAreaSize.Y -= HalfPadding;

            // Now our work area is updated, so we can update our provider and get our target work area position.
            Real YTarget = 0;
            if( this->YProvider != NULL ) {
                this->YProvider->_NotifyContainerUpdated();
                Real YTargetLimit = ( this->WorkAreaSize.Y + HalfPadding ) - NewSelfRect.Size.Y;
                YTarget = std::min( ( this->YProvider->GetCurrentYPage() - 1 ) * NewSelfRect.Size.Y, YTargetLimit );
            }

            // Set up our data for the loop (and the loop itself) that will go over all the children that will be "above" the visible children.
            // Reset the index since we are starting from the beginning again.
            CurrIndex = 0;
            ChildIterator ChildUpdateIt = this->ChildWidgets.begin();
            while( ChildUpdateIt != this->ChildWidgets.end() && ChildTransformCache.at(CurrIndex).first < YTarget )
            {
                const Rect OldChildRect = (*ChildUpdateIt)->GetRect();
                Rect NewChildRect;

                // Assign a dummy position since this will be invisible
                NewChildRect.Position = NewSelfRect.Position;
                NewChildRect.Size = ChildTransformCache.at(CurrIndex).second;

                // Perform the update
                (*ChildUpdateIt)->UpdateDimensions(OldChildRect,NewChildRect);

                // Hide the child
                (*ChildUpdateIt)->Hide();

                // Increment the iterator and index before we proceed.
                ++CurrIndex;
                ++ChildUpdateIt;
            }

            // If we've reached the end of the children, there is nothing to render.
            if( ChildUpdateIt != this->ChildWidgets.end() )
            {
                // If we're here, then we have some visible children.
                // Set our new target and create a variable that will track the total size of just the visible children.
                YTarget = NewSelfRect.Size.Y;
                Real TotalLinearSize = HalfPadding;

                // Before we start a loop that will be altering the index, we need to mark the index of the first visible child in our cache.  This will be used in the final processing step.
                // Once saved, start looping over what will be the visible children.  We can (and should) use the index from the previous loop unaltered.
                const Whole VisibleStartIndex = CurrIndex;
                while( ChildUpdateIt != this->ChildWidgets.end() )
                {
                    Vector2 ChildSize = ChildTransformCache.at(CurrIndex).second;
                    // See if our child can fit
                    if( TotalLinearSize + ChildSize.Y < YTarget ) {
                        this->VisibleChildren.push_back( (*ChildUpdateIt) );
                        TotalLinearSize += ( ChildSize.Y + ActPadding );
                        // Increment the index and iterator before we proceed.
                        ++CurrIndex;
                        ++ChildUpdateIt;
                    }else{
                        break;
                    }
                }

                // Any remaining children will be invisible, so put them in the corner with the rest.
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的Widget::GetRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。