VIEW: use BOX2D for view boundary

This commit is contained in:
Tomasz Wlostowski 2018-08-03 14:00:05 +02:00 committed by Jeff Young
parent 26177efba0
commit ef1f01a8bd
2 changed files with 18 additions and 7 deletions

View File

@ -345,8 +345,8 @@ void WX_VIEW_CONTROLS::onScroll( wxScrollWinEvent& aEvent )
if( type == wxEVT_SCROLLWIN_THUMBTRACK ) if( type == wxEVT_SCROLLWIN_THUMBTRACK )
{ {
VECTOR2D center = m_view->GetCenter(); auto center = m_view->GetCenter();
const BOX2I& boundary = m_view->GetBoundary(); const auto& boundary = m_view->GetBoundary();
// Flip scroll direction in flipped view // Flip scroll direction in flipped view
const double xstart = ( m_view->IsMirroredX() ? const double xstart = ( m_view->IsMirroredX() ?
@ -609,7 +609,7 @@ wxPoint WX_VIEW_CONTROLS::getMouseScreenPosition() const
void WX_VIEW_CONTROLS::UpdateScrollbars() void WX_VIEW_CONTROLS::UpdateScrollbars()
{ {
const BOX2D viewport = m_view->GetViewport(); const BOX2D viewport = m_view->GetViewport();
const BOX2I& boundary = m_view->GetBoundary(); const BOX2D& boundary = m_view->GetBoundary();
m_scrollScale.x = 2e3 / viewport.GetWidth(); // TODO it does not have to be updated so often m_scrollScale.x = 2e3 / viewport.GetWidth(); // TODO it does not have to be updated so often
m_scrollScale.y = 2e3 / viewport.GetHeight(); m_scrollScale.y = 2e3 / viewport.GetHeight();

View File

@ -277,16 +277,27 @@ public:
* Sets limits for view area. * Sets limits for view area.
* @param aBoundary is the box that limits view area. * @param aBoundary is the box that limits view area.
*/ */
inline void SetBoundary( const BOX2I& aBoundary ) inline void SetBoundary( const BOX2D& aBoundary )
{ {
m_boundary = aBoundary; m_boundary = aBoundary;
} }
/**
* Function SetBoundary()
* Sets limits for view area.
* @param aBoundary is the box that limits view area.
*/
inline void SetBoundary( const BOX2I& aBoundary )
{
m_boundary.SetOrigin( aBoundary.GetOrigin() );
m_boundary.SetEnd( aBoundary.GetEnd() );
}
/** /**
* Function GetBoundary() * Function GetBoundary()
* @return Current view area boundary. * @return Current view area boundary.
*/ */
inline const BOX2I& GetBoundary() const inline const BOX2D& GetBoundary() const
{ {
return m_boundary; return m_boundary;
} }
@ -688,7 +699,7 @@ public:
std::shared_ptr<VIEW_OVERLAY> MakeOverlay(); std::shared_ptr<VIEW_OVERLAY> MakeOverlay();
private: protected:
struct VIEW_LAYER struct VIEW_LAYER
{ {
bool visible; ///< is the layer to be rendered? bool visible; ///< is the layer to be rendered?
@ -813,7 +824,7 @@ private:
double m_scale; double m_scale;
/// View boundaries /// View boundaries
BOX2I m_boundary; BOX2D m_boundary;
/// Scale lower limit /// Scale lower limit
double m_minScale; double m_minScale;