//----------------------------------------------------------------------------------------------------- // Adjusts a 2D Bounding area to scale with screen and safe areas based on the current // layout state. // // in/out : // fX,fY - in: the position, in screen space of the asset's pivot i.e. the (center,left), (top,left) // or (bottom,right) point of the asset (for example) (in Virtual Space) // out: the top left corner of the BB after aligning and scaling with delta screen // resolution and safe areas (out Virtual Space). // // fSizeX,fSizeY - in: the size of the BB before any alignment or adjustments are done (in Virtual Space) // - out: the size of the BB after all appropriate alignments and adjustments are done (out Virtual Space) // // As we want to preserve proportional distance of elements from the screen // edge then the p(x,y) needs to be adjusted based on some proportional // relationship to the delta-screen resolution : // p (is-proportional-to) k*(delta)Screen // // The size of element s(w,h), when not preserving aspect or keeping square // should follow the same rule. // s (is-propotional-to) k*(delta)Screen // // When scaling elements with (delta)ScreenY only, then p is the same as above // (to preserve proportional distance from the screen edge), but s(w.h) varies // as follows : // s.w (is-propotional-to) k*(delta)ScreenY // s.h (is-propotional-to) k*(delta)ScreenY // void ScreenLayoutManager::AdjustToSafeArea( float *fX, float* fY, float* fSizeX /* = NULL*/, float* fSizeY /* = NULL*/, const EUIDRAWHORIZONTAL eUIDrawHorizontal, const EUIDRAWVERTICAL eUIDrawVertical, const EUIDRAWHORIZONTAL eUIDrawHorizontalDocking, const EUIDRAWVERTICAL eUIDrawVerticalDocking ) const { //----------------------------------------------- // Get intermediate p(x,y) in proportional space // at this point the p is at still the (center,left), // (top,left) or (bottom,right) of the asset. Vec2 p( *fX/GetVirtualWidth(), *fY/GetVirtualHeight() ); Vec2 s( 0.0f, 0.0f ); float assetAspect = 1.0f; CRY_ASSERT_MESSAGE( fSizeX && fSizeY || (fSizeX == NULL && fSizeY == NULL), "HUD: Invalid combination of size pointers, probably a mistake in calling code!" ); const bool bHaveSize = fSizeX && fSizeY && (*fSizeY)!=0.0f; if( bHaveSize) { s = Vec2( (*fSizeX)/GetVirtualWidth(), (*fSizeY)/GetVirtualHeight() ); assetAspect = (*fSizeX)/(*fSizeY); } // Do the work and get every thing in proportional space. AdjustToSafeAreaProportional( p,s,assetAspect, eUIDrawHorizontal,eUIDrawVertical,eUIDrawHorizontalDocking,eUIDrawVerticalDocking ); // offset p by the safe-area borders if we are adjusting by safe-areas. if( !(m_flags & eSLO_DoNotAdaptToSafeArea) ) { const Vec2 safeAreaBorderP = GetSafeAreaBorderScreenProportion(m_curSafeAreaID); p.x += safeAreaBorderP.x; // x border width p.y += safeAreaBorderP.y; // y border height } // Publish the results : *fX = p.x * GetVirtualWidth(); *fY = p.y * GetVirtualHeight(); if(bHaveSize) { *fSizeX = s.x * GetVirtualWidth(); *fSizeY = s.y * GetVirtualHeight(); } }
//+++-S-cf------------------------------------------------------------------- // NAME: Draw() // DESC: Draw chart points // PARAMETERS: CHART_HPAINT hp, // int x, // int y // RETURN: None //----------------------------------------------------------------------E-+++ void wxChartWindow::Draw( CHART_HPAINT hp, int x, int y ) { //----------------------------------------------------------------------- // Get window information //----------------------------------------------------------------------- CHART_RECT r; r.x = x; r.y = y; r.xscroll = 0; r.yscroll = 0; GetClientSize( &r.w, &r.h ); //----------------------------------------------------------------------- // Set Background //----------------------------------------------------------------------- #if 0 hp->SetBrush( wxBrush(0xecf1f1, wxSOLID) ); //fcfdd8, *wxLIGHT_GREY_BRUSH hp->SetPen( *wxTRANSPARENT_PEN ); hp->DrawRectangle( r.x + 2, r.y + 5, static_cast<int>(GetVirtualWidth()), r.h - 5 ); #endif //----------------------------------------------------------------------- // Draw horizontal lines //----------------------------------------------------------------------- if ( m_UseGrid ) DrawHLines( hp, &r ); //----------------------------------------------------------------------- // Draw all charts //----------------------------------------------------------------------- m_Chart.Draw( hp, &r ); }
//+++-S-cf------------------------------------------------------------------- // NAME: DrawHLines() // DESC: Draw horizontal lines // PARAMETERS: CHART_HPAINT hp, // CHART_HRECT hr // RETURN: None //----------------------------------------------------------------------E-+++ void wxChartWindow::DrawHLines( CHART_HPAINT hp, CHART_HRECT hr ) { if ( GetVirtualMaxY() > 0 ) { double range = GetVirtualMaxY(); double start = 0; double end = range; int int_log_range = (int)floor( log10( range ) ); double step = 1.0; if (int_log_range > 0) { for (int i = 0; i < int_log_range; i++) step *= 10; } if (int_log_range < 0) { for (int i = 0; i < -int_log_range; i++) step /= 10; } double lower = ceil(start / step) * step; double upper = floor(end / step) * step; // if too few values, shrink size if ((range/step) < 4) { step /= 2; if (lower-step > start) lower -= step; if (upper+step < end) upper += step; } // if still too few, again if ((range/step) < 4) { step /= 2; if (lower-step > start) lower -= step; if (upper+step < end) upper += step; } wxChartSizes *sizes = GetSizes(); /* C::B begin */ // avoid crashes if style contains USE_GRID and no charts are added to chartctrl if(!sizes) return; /* C::B end */ hp->SetPen( *wxBLACK_DASHED_PEN ); double current = lower; while (current < upper+(step/2)) { int y = (int)( (GetVirtualMaxY()-current) / range * ((double)hr->h - sizes->GetSizeHeight())) - 1; if ((y > 10) && (y < hr->h - 7 - sizes->GetSizeHeight())) { hp->DrawLine( hr->x, y + sizes->GetSizeHeight() + hr->y, hr->x + static_cast<int>(GetVirtualWidth()), y + sizes->GetSizeHeight() + hr->y ); } current += step; } } }