rRect ruiSlider::HandleRect(){ rSize size = Size(); float ratio = m_value / 100.0f; int handleOffset = int (size.x * ratio) - (m_handleSize / 2); return rRect(m_position.x + handleOffset, m_position.y - 3, m_handleSize, size.y + 6); }
// **************************************************************************** // // Function Name: REditImageInterfaceImp::GetClippingPath( ) // // Description: Returns the component image's clipping path // (if any). // // Returns: // // Exceptions: // // **************************************************************************** // BOOLEAN REditImageInterfaceImp::GetClippingPath( RClippingPath& rPath ) { // Get a pointer to the image document's image. Note, // normally we can assume that it is a RBitmapImage // as this interface is only provided by image components, // but if this is a placeholder from a layout there is no // RBitmapImage so just return FALSE in that case. RBitmapImage* pImage = dynamic_cast<RBitmapImage*>( m_pImageDocument->GetImage() ); if (!pImage) return FALSE; rPath.Undefine(); RClippingPath* pPath = pImage->GetClippingRPath(); if (pPath) { const RImageEffects& rEffects = GetImageEffects(); RRealSize rSize = RImageLibrary().GetImageDimensions( m_pImageDocument->m_rInternalDataBuffer ); R2dTransform xform; xform.PostScale( rSize.m_dx, rSize.m_dy ); RRealRect rRect( rEffects.m_rCropArea * xform ); xform.MakeIdentity(); xform.PostTranslate( rRect.m_Left, rSize.m_dy - rRect.m_Bottom - rRect.m_Top ); rPath = RClippingPath( *pPath, xform ); return TRUE; } return FALSE; }
void GsScrollbar::processLogic() { // Here we check if the mouse-cursor/Touch entry clicked on something!! const float fx = mRect.x; const float fw = mRect.w; const float fy = mRect.y; const float fh = mRect.h; const float y_innerbound_max = fy+fh; //const float x_innerbound_min = fx + static_cast<float>(TEXT_HEIGHT)/bw; GsRect<float> rRect(fx, fy, fw, fh); GsRect<float> parRect(mpParent->mRect); rRect.transform(parRect); GsPointingState &pointingState = gPointDevice.mPointingState; processPointingState(rRect); Vector2D<float> MousePos = pointingState.mPos; const bool scrollAction = mReleased || mPressed; if( rRect.HasPoint(MousePos) ) { if( MousePos.y > fy && MousePos.y < y_innerbound_max ) { if(scrollAction) // If clicked or pressed on scroll bar { float relPos = float(mScrollPos) / float(mMaxScrollAmt); const float scrollAreaY1 = rRect.y + mArrowHeight + mSliderHeight*0.5f; const float scrollAreaY2 = rRect.y + rRect.h - mArrowHeight - mSliderHeight*0.5f; const float scrollHeight = scrollAreaY2-scrollAreaY1; const float midPart_y = scrollAreaY1+(scrollHeight*relPos); if(mPressed) { if(MousePos.y < scrollAreaY1 || MousePos.y > scrollAreaY2) return; } // The tolerance will remove the jitter effect in scrolling const float tolerance = scrollHeight/float(mMaxScrollAmt); if(MousePos.y < midPart_y-tolerance) // Go up! { scrollUp(); } else if(MousePos.y > midPart_y+tolerance) // Go down! { scrollDown(); } } } } }
void BenchCairo::runFillRectRotate(BenchOutput& output, const BenchParams& params) { cairo_t* cr = cairo_create(screenCairo); configureContext(cr, params); BenchRandom rRect(app); BenchRandom rArgb(app); float cx = (float)params.screenSize.w * 0.5f; float cy = (float)params.screenSize.h * 0.5f; float angle = 0.0f; if (params.source == BENCH_SOURCE_SOLID) { uint32_t i, quantity = params.quantity; for (i = 0; i < quantity; i++, angle += 0.01f) { Fog::RectF r(rRect.getRectF(params.screenSize, params.shapeSize, params.shapeSize)); Fog::Argb32 c0(rArgb.getArgb32()); cairo_translate(cr, cx, cy); cairo_rotate(cr, angle); cairo_translate(cr, -cx, -cy); cairo_set_source_rgba(cr, double(c0.r) * sc, double(c0.g) * sc, double(c0.b) * sc, double(c0.a) * sc); cairo_rectangle(cr, r.x, r.y, r.w, r.h); cairo_fill(cr); cairo_identity_matrix(cr); } } else { uint32_t i, quantity = params.quantity; for (i = 0; i < quantity; i++, angle += 0.01f) { Fog::RectF r(rRect.getRectF(params.screenSize, params.shapeSize, params.shapeSize)); Fog::Argb32 c0(rArgb.getArgb32()); Fog::Argb32 c1(rArgb.getArgb32()); Fog::Argb32 c2(rArgb.getArgb32()); cairo_translate(cr, cx, cy); cairo_rotate(cr, angle); cairo_translate(cr, -cx, -cy); cairo_pattern_t* pattern = createLinearGradient(r.x, r.y, r.x + r.w, r.y + r.h, c0, c1, c2); cairo_set_source(cr, pattern); cairo_rectangle(cr, r.x, r.y, r.w, r.h); cairo_fill(cr); cairo_identity_matrix(cr); cairo_pattern_destroy(pattern); } } cairo_destroy(cr); }
nuiSize nuiPopupMenu::AdjustRectsPos(nuiSize& rX, nuiSize& rY, uint depth, nuiRect CurRect) { nuiTopLevel* pRoot = GetTopLevel(); NGL_ASSERT(pRoot); NGL_ASSERT(depth+1 < mRects.size()); nuiRect MainRect = pRoot->GetRect(); nuiRect& prevRect(mRects[depth]->mRect); // prevRect is the previous rect in the hierarchy (NOT the previous rect of this sub menu) depth++; nuiMenuRect* pMenuRect = mRects[depth]; nuiRect& rRect(pMenuRect->mRect); nuiSize x, y; x = rX + (mXdir * rRect.GetWidth()) - (mXdir < 0 ? prevRect.GetWidth() : 0); // Compute X so that the rect doesn't get out of the main container y = rY + (mYdir * rRect.GetHeight()) + (mYdir < 0 ? CurRect.GetHeight() : 0); // Compute Y so that the rect doesn't get out of the main container if (x > MainRect.GetWidth() || x < 0) // Should we change the current x direction? mXdir *= -1; if (y > MainRect.GetHeight() || y < 0) // Should we change the current y direction? mYdir *= -1; rX = rX - ((mXdir < 0) ? rRect.GetWidth() + prevRect.GetWidth() : 0); rY = rY - ((mYdir < 0) ? rRect.GetHeight() - CurRect.GetHeight() : 0); if (rY < 0) rY = 0; if ( ( (mYdir > 0) && (MainRect.GetHeight() < (rY + rRect.GetHeight()) ) ) || ( (mYdir < 0) && (0 > (rY - rRect.GetHeight()) ) ) ) { nuiSize heightDiff = MainRect.GetHeight() - rRect.GetHeight(); if (heightDiff > 0) { rY = heightDiff; } else { nuiRect r( ToNearest(rX + rRect.GetWidth() - SB_WIDTH), 0, ToNearest(SB_WIDTH), ToNearest(MainRect.GetHeight())); pMenuRect->mpSBar->GetRange().SetRange(0.f, rRect.GetHeight()); pMenuRect->mpSBar->GetRange().SetPageSize(MainRect.GetHeight()); pMenuRect->mpSBar->GetRange().SetIncrement(10.f); pMenuRect->mpSBar->SetLayout(r); pMenuRect->mpSBar->SetVisible(true); pMenuRect->mpSBar->SetSelected(false); pMenuRect->mpSBar->SetEnabled(true); rY = -pMenuRect->mpSBar->GetRange().GetValue(); return (SB_WIDTH); } } if (pMenuRect->mpSBar) { pMenuRect->mpSBar->SetVisible(false); pMenuRect->mpSBar->SetEnabled(false); } return (0.f); }
void LTDrawToolBar::OnSize(UINT nType, int cx, int cy) { CWnd::OnSize(nType, cx, cy); CRect rRect(0, 0, 0, 0); rRect.right = cx; rRect.bottom = cy; Layout(rRect); // TODO: Add your message handler code here }
void CGUITextSelectionList::processLogic() { // Here we check if the mouse-cursor/Touch entry clicked on something!! const float bw = gVideoDriver.getGameResolution().w; const float bh = gVideoDriver.getGameResolution().h; const float fx = mRect.x; const float fw = mRect.w; const float fy = mRect.y; const float fh = mRect.h; const float y_innerbound_min = fy + static_cast<float>(TEXT_SIZE)/bh; const float y_innerbound_max = y_innerbound_min + static_cast<float>( mItemList.size()*TEXT_SIZE )/bh; const float x_innerbound_min = fx + static_cast<float>(TEXT_SIZE)/bw; GsRect<float> rRect(fx, fy, fw, fh); GsPointingState &pointingState = gPointDevice.mPointingState; processPointingState(); Vector2D<float> mousePos = pointingState.mPos; if( rRect.HasPoint(mousePos) ) { // Let scrollbar do it's work mScrollbar.processLogic(); if( mousePos.y > fy && mousePos.y < y_innerbound_max ) { int newselection = ((mousePos.y-fy)*bh/TEXT_SIZE) - 1 + mScrollbar.scrollPos(); if( mousePos.x > x_innerbound_min && mousePos.y > y_innerbound_min) { if(mHovered) mHoverSelection = newselection; if(mPressed) mPressedSelection = newselection; if(mReleased) mReleasedSelection = newselection; } } } else { mHoverSelection = -1; mPressedSelection = -1; } }
void QtOpenCVZedDemo::timerEvent(QTimerEvent *event) { Q_UNUSED(event); updateFps( mElabTime.elapsed() ); mElabTime.restart(); cv::Mat image; mCapture >> image; if( mFlipVert && mFlipHoriz ) cv::flip( image,image, -1); else if( mFlipVert ) cv::flip( image,image, 0); else if( mFlipHoriz ) cv::flip( image,image, 1); // Do what you want with the image :-) int w = image.cols/2; int h = image.rows; cv::Rect lRect( 0,0,w,h ); cv::Rect rRect( w,0,w,h ); cv::Mat left = image(lRect); cv::Mat right = image(rRect); ui->graphicsView_left->setScene( &mLeft ); // Show the image mLeft.setBgImage( left ); mRight.setBgImage( right ); if( ui->tabWidget->currentIndex() == 0 ) { doStereoSGBM_CPU( left, right ); } else if( ui->tabWidget->currentIndex() == 1 ) { // TODO Cuda processing } else if( ui->tabWidget->currentIndex() == 2 ) { #ifndef Q_PROCESSOR_ARM doStereoSBM_OCL(left, right ); //doStereoCSBP_OCL( left, right ); //doStereoBP_OCL(left,right); #endif } mDisp.setBgImage( mDisparity ); }
void RWinColorPaletteWell::OnPaint( ) { CPaintDC dc( this ); CRect rect; GetClientRect( rect ); if (m_crColor.GetFillMethod() != RColor::kTransparent) { // The bounding rect is in logical units, so we // need to create a transform to scale from logical // units to device units. We also divide by 2 to // account for the scaling in the bounding rect to // make the texture more visible in such a small area. RRealSize dpi( ::GetScreenDPI() ); R2dTransform transform; transform.PostScale( dpi.m_dx / kSystemDPI * 0.5, dpi.m_dy / kSystemDPI * 0.5 ); RColor crFillColor = m_crColor; crFillColor *= transform; RIntRect rRect( rect ); RDcDrawingSurface ds; ds.Initialize( (HDC) dc ); RColor oldColor = ds.GetFillColor(); ds.SetFillColor( crFillColor ); ds.FillRectangle( rRect ); ds.SetFillColor( oldColor ); ds.DetachDCs(); } else { dc.FillSolidRect( rect, RGB( 255, 255, 255 ) ); CString strText ; GetWindowText( strText ); CRect rcTextRect( rect ); rcTextRect.DeflateRect( 1, 1 ); CFont* pFont = dc.SelectObject( GetParent()->GetFont() ); dc.DrawText( strText, rcTextRect, DT_CENTER | DT_VCENTER ); dc.SelectObject( pFont ); } dc.MoveTo( rect.left, rect.bottom - 1 ); dc.LineTo( rect.left, rect.top ); dc.LineTo( rect.right, rect.top ); }
void BenchCairo::runFillRound(BenchOutput& output, const BenchParams& params) { cairo_t* cr = cairo_create(screenCairo); configureContext(cr, params); BenchRandom rRect(app); BenchRandom rArgb(app); BenchRandom rRadius(app); if (params.source == BENCH_SOURCE_SOLID) { uint32_t i, quantity = params.quantity; for (i = 0; i < quantity; i++) { Fog::RectF r(rRect.getRectF(params.screenSize, params.shapeSize, params.shapeSize)); float rad = rRadius.getFloat(4.0f, 40.0f); Fog::Argb32 c0(rArgb.getArgb32()); cairo_set_source_rgba(cr, double(c0.r) * sc, double(c0.g) * sc, double(c0.b) * sc, double(c0.a) * sc); addRound(cr, r, rad); cairo_fill(cr); } } else { uint32_t i, quantity = params.quantity; for (i = 0; i < quantity; i++) { Fog::RectF r(rRect.getRectF(params.screenSize, params.shapeSize, params.shapeSize)); float rad = rRadius.getFloat(4.0f, 40.0f); Fog::Argb32 c0(rArgb.getArgb32()); Fog::Argb32 c1(rArgb.getArgb32()); Fog::Argb32 c2(rArgb.getArgb32()); cairo_pattern_t* pattern = createLinearGradient(r.x, r.y, r.x + r.w, r.y + r.h, c0, c1, c2); cairo_set_source(cr, pattern); addRound(cr, r, rad); cairo_fill(cr); cairo_pattern_destroy(pattern); } } cairo_destroy(cr); }
void UNICODE_ARXDrawTextCenteredScroll(Font* font, float x, float y, float x2, const std::string& str, Color col, PlatformDuration iTimeScroll, float fSpeed, int iNbLigne, PlatformDuration iTimeOut) { Rect::Num _x = checked_range_cast<Rect::Num>(x - x2); Rect::Num _y = checked_range_cast<Rect::Num>(y); Rect::Num w = checked_range_cast<Rect::Num>(x + x2); Rect rRect(_x, _y, w, Rect::Limits::max()); if(pTextManage) { pTextManage->AddText(font, str, rRect, col, iTimeOut, iTimeScroll, fSpeed, iNbLigne ); } }
void CFormationEditorObjectSelector::OnDraw(IGenericRender *piRender) { if(m_piSTObjectList) { SGameRect sListRect; m_piSTObjectList->GetRealRect(&sListRect); double dCurrentX=BUTTON_MARGIN; double dCurrentY=sListRect.h-(m_dButtonSizeY+BUTTON_MARGIN); for(unsigned long x=0;x<m_vButtons.size();x++) { if(dCurrentX+m_dButtonSizeX+BUTTON_MARGIN>sListRect.w){dCurrentX=BUTTON_MARGIN;dCurrentY-=m_dButtonSizeY+BUTTON_MARGIN*2.0;} SGameRect rRect(dCurrentX,dCurrentY,m_dButtonSizeX,m_dButtonSizeY); m_vButtons[x].m_piButton->SetRect(&rRect); SGameRect rLabelRect(BUTTON_INTERNAL_MARGIN , BUTTON_INTERNAL_MARGIN , m_dButtonSizeX-(BUTTON_INTERNAL_MARGIN*2.0) , m_dButtonSizeY-(BUTTON_INTERNAL_MARGIN*2.0)); m_vLabels[x].m_piLabel->SetRect(&rLabelRect); dCurrentX+=m_dButtonSizeX+BUTTON_MARGIN*2.0; } } CGameWindowBase::OnDraw(piRender); }
void RWinColorPaletteWell::SetColor( RColor& crColor ) { if (crColor != m_crColor) { m_crColor = crColor; CRect rect; GetClientRect( rect ); RIntRect rRect( rect ); // By making the bounding rect // twice as large, we will make // textures more visible. R2dTransform transform; transform.PostScale( 2, 2 ); rRect *= transform; ::ScreenUnitsToLogicalUnits( rRect ); m_crColor.SetBoundingRect( rRect ); if (m_hWnd) Invalidate( FALSE ); } }
void ruiLinearLayout::SetPosition(const rPoint& position) { ruiWidget::SetPosition(position); Layout(rRect(m_position, rSize::Default)); }