本文整理汇总了C++中SRect类的典型用法代码示例。如果您正苦于以下问题:C++ SRect类的具体用法?C++ SRect怎么用?C++ SRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: intersect
//重なっていたらtrueを返す
bool SRect::intersect(const SRect& rc) const
{
if(rc.l()>m_r) return false;
if(rc.r()<m_l) return false;
if(rc.t()>m_b) return false;
if(rc.b()<m_t) return false;
return true;
}
示例2: InitPrimitiveElement
bool GraphicsElementManager::InitPrimitiveElement( shared_ptr<PrimitiveElement> pElement,
const SRect& non_scaled_rect,
const SFloatRGBAColor& color,
int layer_index )
{
bool res = InitElement( pElement, layer_index );
if( !res )
return false;
pElement->SetColor( 0, color );
AABB2 non_scaled_aabb;
non_scaled_aabb.vMin.x = (float)non_scaled_rect.left;
non_scaled_aabb.vMin.y = (float)non_scaled_rect.top;
non_scaled_aabb.vMax.x = (float)non_scaled_rect.right;
non_scaled_aabb.vMax.y = (float)non_scaled_rect.bottom;
// set as local coord
// the element is owned by a group: local coord
// the element is not owned by any group: global coord
pElement->SetLocalTopLeftPos( non_scaled_rect.GetTopLeftCorner() );
pElement->SetSizeLTRB( non_scaled_aabb.vMin, non_scaled_aabb.vMax );
return true;
}
示例3: pTextElement
shared_ptr<TextElement> GraphicsElementManager::CreateText( int font_id, const std::string& text,
const SRect& textbox, int align_h, int align_v,
const SFloatRGBAColor& color, int font_w, int font_h, int layer )
{
/* int index = GetVacantSlotIndex();
if( !RegisterToLayer( index, layer ) )
return shared_ptr<TextElement>();
*/
AABB2 aabb;
aabb.vMin = Vector2( (float)textbox.left, (float)textbox.top );
aabb.vMax = Vector2( (float)textbox.right, (float)textbox.bottom );
shared_ptr<TextElement> pTextElement( new TextElement( font_id, text, aabb, align_h, align_v, color ) );
pTextElement->SetFontSize( font_w, font_h );
bool res = InitElement( pTextElement, layer );
if( !res )
return shared_ptr<TextElement>();
// manager must be set to the element before calling SetLocalTopLeftPos()
// because it calls UpdateTextAlignment(), which calls GraphicsElementManager::GetFont()
pTextElement->SetLocalTopLeftPos( textbox.GetTopLeftCorner() );
pTextElement->UpdateTextAlignment();
// need to scale text element?
return pTextElement;
}
示例4: testSelectionForDrag
//範囲を選択してドラッグ選択を行う
unsigned SXBSchTag::testSelectionForDrag(const SRect& rc)
{
if( rc.intersect(area()) ) {
return SELECT_ALL;
} else {
return 0;
}
}
示例5: testSelection
//範囲を指定して選択を行う
unsigned SXBSchLabel::testSelection(const SRect& rc)
{
if( rc.intersect(area()) ){
return SELECT_ALL;
}else{
return 0;
}
}
示例6: testSelectionForDrag
//範囲を選択してドラッグ選択を行う
unsigned SXBSchComponent::testSelectionForDrag(const SRect& rc)
{
if( rc.intersect(bodyArea()) ){
return SELECT_ALL;
}else{
return 0;
}
}
示例7: RectThis
void CWindowOSXQT::PaintToBuffer(tuchar* puchBuffer, tuint32 uiInterleave, const SRect& rUpdate)
{
int iBytesNeeded = (mSize.iCX + 1) * (mSize.iCY + 1) * 4;
if (iBytesNeeded > miDrawBufferSize) {
if (mpcDrawBuffer) {
delete[] mpcDrawBuffer;
}
miDrawBufferSize = iBytesNeeded;
mpcDrawBuffer = new tuchar[miDrawBufferSize];
}
if (mpInvalidater->IsRectInvalidated() == true) {
// We need to update the buffer
SRect RectUpdate;
mpInvalidater->GetInvalidatedRect(RectUpdate);
mpInvalidater->Reset();
// Limit update rect to our actual size
SRect RectThis(SPos(0, 0), mSize);
RectUpdate.FitInside(RectThis);
// Limit update rect to, well, the update rect...
RectUpdate.FitInside(rUpdate);
GetPane()->OnDraw(RectUpdate);
if (mpControlOnTop) {
mpControlOnTop->OnDraw(RectUpdate);
}
}
// Copy to buffer delivered
tuint uiY;
for (uiY = rUpdate.iY; uiY < mSize.iCY && uiY < (rUpdate.iY + rUpdate.iCY); uiY++) {
tuchar* puchDest = puchBuffer + (uiInterleave * uiY);
tuchar* puchSource = mpcDrawBuffer + (4 * mSize.iCX * uiY);
tuint uiX;
for (uiX = rUpdate.iX; uiX < mSize.iCX && uiX < (rUpdate.iX + rUpdate.iCX); uiX++) {
((tuint32*)puchDest)[uiX] = ((tuint32*)puchSource)[uiX];
}
}
}
示例8: push
void ScissorClipStack::push( Vec2i const& pos , Vec2i const& size , bool bOverlapPrev )
{
SRect rect;
rect.min = pos;
rect.max = pos + size;
if ( mStack.empty() )
{
mPrevEnable = glIsEnabled( GL_SCISSOR_TEST );
if ( !mPrevEnable )
glEnable( GL_SCISSOR_TEST );
}
else if ( bOverlapPrev )
{
if ( !rect.overlap( mStack.back() ) )
rect.max = rect.min;
}
Vec2i sizeRect = rect.getSize();
glScissor( rect.min.x , rect.min.y , sizeRect.x , sizeRect.y );
mStack.push_back( rect );
}
示例9: testIntersect
//範囲を指定して選択チェックを行う
bool SPtnObjCircle::testIntersect(const SRect& rc)
{
if(!rc.intersect(m_p0)) return false;
if(!rc.intersect(m_p1)) return false;
return true;
}
示例10: qRedraw
//描画が必要かどうかを返す
bool SXBSchTag::qRedraw(const SRect& rc)
{
return rc.intersect(area());
}
示例11: testSelection
//範囲を指定して選択を行う
unsigned SXBSchLine::testSelection(const SRect& rc)
{
unsigned nOutcode1 = SetOutCode(m_p1,rc);
unsigned nOutcode2 = SetOutCode(m_p2,rc);
if(nOutcode1 & nOutcode2) return 0;
if((nOutcode1 == 0 )||(nOutcode2 == 0 )) return SELECT_ALL;
unsigned nOutcode = nOutcode1 | nOutcode2;
if(nOutcode == (OUTCODE_LEFT | OUTCODE_RIGHT)) return SELECT_ALL;
if(nOutcode == (OUTCODE_UPPER | OUTCODE_LOWER)) return SELECT_ALL;
int x,y;
int x1 = m_p1.x();
int y1 = m_p1.y();
int x2 = m_p2.x();
int y2 = m_p2.y();
if(nOutcode & OUTCODE_LEFT){ //片方が左に出ている
x=rc.l();
y=y1+((x-x1)*(y2-y1))/(x2-x1);
if(y >= rc.t() && y <= rc.b()) return SELECT_ALL;
}
if(nOutcode & OUTCODE_RIGHT){ //片方が右に出ている
x=rc.r();
y=y1+((x-x1)*(y2-y1))/(x2-x1);
if(y >= rc.t() && y <= rc.b()) return SELECT_ALL;
}
if(nOutcode & OUTCODE_UPPER){ //片方が上に出ている
y=rc.t();
x=x1+((y-y1)*(x2-x1))/(y2-y1);
if(x >= rc.l() && x <= rc.r()) return SELECT_ALL;
}
if(nOutcode & OUTCODE_LOWER){ //片方が下に出ている
y=rc.b();
x=x1+((y-y1)*(x2-x1))/(y2-y1);
if(x >= rc.l() && x <= rc.r()) return SELECT_ALL;
}
return 0;
}
示例12: if
void Character::Update(float deltaTime, const Map& map)
{
const float kSpeed = 500.0f;
//Check horizontal movement
if (Input_IsKeyDown(Keys::RIGHT))
{
mVelocity.x = kSpeed * deltaTime;
}
else if (Input_IsKeyDown(Keys::LEFT))
{
mVelocity.x = -kSpeed * deltaTime;
}
else
{
mVelocity.x = 0.0f;
}
// Check collision
SRect bb = GetBoundingBox();
SRect newbb = bb + SVector2(mVelocity.x, 0.0f);
SRect rightbb = map.GetBoundingBoxFromSegment(newbb.GetRightSegment());
SRect leftbb = map.GetBoundingBoxFromSegment(newbb.GetLeftSegment());
// Right collision
if (mVelocity.x > 0.0f && rightbb.IsValid())
{
mPosition.x += (int)(rightbb.min.x - bb.max.x) - 1.0f;
}
// Left collision
else if (mVelocity.x < 0.0f && leftbb.IsValid())
{
mPosition.x += (int)(leftbb.max.x - bb.min.x) + 1.0f;
}
else
{
mPosition.x += (int)mVelocity.x;
}
//Check vertical movement
//if (Input_IsKeyDown(Keys::DOWN))
//{
// mVelocity.y = kSpeed * deltaTime;
//}
//else if (Input_IsKeyDown(Keys::UP))
//{
// mVelocity.y = -kSpeed * deltaTime;
//}
//else
//{
// mVelocity.y = 0.0f;
//}
if(!mJumping && Input_IsKeyPressed(Keys::UP))
{
mVelocity.y = -30.0f;
mJumping = true;
}
else
{
mVelocity.y += 100.0f * deltaTime;
}
mVelocity.y = Min(mVelocity.y, 30.0f);
// Check collision
newbb = bb + SVector2(0.0f, mVelocity.y);
SRect bottombb = map.GetBoundingBoxFromSegment(newbb.GetBottomSegment());
SRect topbb = map.GetBoundingBoxFromSegment(newbb.GetTopSegment());
// Bottom collision
if(mVelocity.y > 0.0f && bottombb.IsValid())
{
mPosition.y += (int)(bottombb.min.y - bb.max.y) - 1.0f;
mVelocity.y = 0.0f;
mJumping = false;
}
// Top collision
else if(mVelocity.y < 0.0f && topbb.IsValid())
{
mPosition.y += (int)(topbb.max.y - bb.min.y) + 1.0f;
mVelocity.y = 0.0f;
}
else
{
mPosition.y += (int)mVelocity.y;
}
}
示例13: rcDraw
//描画が必要かどうかを返す
bool SXBSchLine::qRedraw(const SRect& rc)
{
SRect rcDraw(rc.l()-1,rc.t()-1,rc.r()+1,rc.b()+1);
if(testSelection(rcDraw)) return true;
else return false;
}
示例14: switch
tbool CScrollBar::OnMouse(EMouseMsg MouseMsg, const SPos& Pos)
{
if (!IsVisible()) {
return false;
}
if (CPane::OnMouse(MouseMsg, Pos)) {
return true;
}
if (mbScrolling) {
// We're currently scrolling
switch(MouseMsg) {
case MouseMove:
{
switch(mType) {
case TypeHorizontal:
{
// Calculate the mouse delta
tint iMouseDelta = Pos.iX - mMousePosOrg.iX;
// Calculate where we want the handle to be
tint iHandlePosX = mScrollBarRectOrg.iX + iMouseDelta;
// Calculate movememt from mouse delta
std::list<IControl*>::iterator it = mControls.begin();
if (mControls.size() > 2) {
it++;
}
IControl* pControl = *it++;
SRect RctArrowLeft;
pControl->GetRect(RctArrowLeft);
// Left-most possible handle position
SPos PosLeftMost(RctArrowLeft.iX + RctArrowLeft.iCX, RctArrowLeft.iY);
pControl = *it;
SPos PosRightArrow;
pControl->GetPos(PosRightArrow);
tint iMaxWidth = PosRightArrow.iX - PosLeftMost.iX;
// Calculate the relative width we occupy
tfloat64 fWidthRelative = mScrollPos.VisibleRect.iCX / (double)mScrollPos.AreaSize.iCX;
// Calculate the ralative position to be
tfloat64 fPositionRelative = (iHandlePosX - PosLeftMost.iX) / (iMaxWidth - (fWidthRelative * iMaxWidth));
// Update scrolling position
mScrollPos = mScrollPosOrg;
mScrollPos.VisibleRect.iX = (int)((fPositionRelative * (mScrollPos.AreaSize.iCX - mScrollPos.VisibleRect.iCX)) + 0.5f);
// Limit scrolling position
if (mScrollPos.VisibleRect.iX < 0) {
mScrollPos.VisibleRect.iX = 0;
}
if (mScrollPos.VisibleRect.iX > mScrollPos.AreaSize.iCX - mScrollPos.VisibleRect.iCX) {
mScrollPos.VisibleRect.iX = mScrollPos.AreaSize.iCX - mScrollPos.VisibleRect.iCX;
}
// Redraw and set scroll pos (which will cause scroll pane to redraw)
CControl::Redraw();
mpScrollPane->SetScrollPos(mScrollPos);
SetValue(0);
}
break;
case TypeVertical:
{
// Calculate the mouse delta
tint iMouseDelta = Pos.iY - mMousePosOrg.iY;
// Calculate where we want the handle to be
tint iHandlePosY = mScrollBarRectOrg.iY + iMouseDelta;
// Calculate movememt from mouse delta
std::list<IControl*>::iterator it = mControls.begin();
if (mControls.size() > 2) {
it++;
}
IControl* pControl = *it++;
SRect RctArrowTop;
pControl->GetRect(RctArrowTop);
// Top-most possible handle position
SPos PosTopMost(RctArrowTop.iX, RctArrowTop.iY + RctArrowTop.iCY);
pControl = *it;
SPos PosBottomArrow;
pControl->GetPos(PosBottomArrow);
tint iMaxHeight = PosBottomArrow.iY - PosTopMost.iY;
// Calculate the relative height we occupy
tfloat64 fHeightRelative = mScrollPos.VisibleRect.iCY / (double)mScrollPos.AreaSize.iCY;
// Calculate the ralative position to be
tfloat64 fPositionRelative = (iHandlePosY - PosTopMost.iY) / (iMaxHeight - (fHeightRelative * iMaxHeight));
// Update scrolling position
mScrollPos = mScrollPosOrg;
mScrollPos.VisibleRect.iY = (int)((fPositionRelative * (mScrollPos.AreaSize.iCY - mScrollPos.VisibleRect.iCY)) + 0.5f);
//.........这里部分代码省略.........
示例15: GetButtonRect
SRect CGM_Slider::GetLocalButtonRectInOwnerDialogCoord()
{
SRect rect = GetButtonRect();
rect.Offset( -GetOwnerDialog()->GetBoundingBox().GetTopLeftCorner() );
return rect;
}