#include "asw/gui/viewport.h" ASW::Gui::Viewport:: Viewport(const TCHAR * p_ptrName) : ASW::Gui::ElementVisible(TEXT("viewport"), p_ptrName), m_ptrRenderIndex(NULL), m_fltFov(45.0f), m_fltNear(0.1f), m_fltFar(10000.0f) {} ASW::Gui::Viewport:: Viewport(const ASW::Gui::Viewport & p_refViewport) : ASW::Gui::ElementVisible(static_cast(p_refViewport)), m_ptrRenderIndex(NULL), m_fltFov(p_refViewport.m_fltFov), m_fltNear(p_refViewport.m_fltNear), m_fltFar(p_refViewport.m_fltFar) {} ASW::Gui::Viewport:: Viewport(const ASW::Gui::Viewport & p_refViewport, const TCHAR * p_ptrType, const TCHAR * p_ptrName) : ASW::Gui::ElementVisible(static_cast(p_refViewport), p_ptrType, p_ptrName), m_ptrRenderIndex(NULL), m_fltFov(p_refViewport.m_fltFov), m_fltNear(p_refViewport.m_fltNear), m_fltFar(p_refViewport.m_fltFar) {} ASW::Gui::Element::AutoPtr ASW::Gui::Viewport:: Clone() const { return ASW::Gui::Element::AutoPtr(new ASW::Gui::Viewport(*this)); } ASW::Gui::Element::AutoPtr ASW::Gui::Viewport:: Clone(const TCHAR * p_ptrType, const TCHAR * p_ptrName) const { return ASW::Gui::Element::AutoPtr(new ASW::Gui::Viewport(*this, p_ptrType, p_ptrName)); } ASW::Script::Variant ASW::Gui::Viewport:: GetProperty(const TCHAR * p_ptrName) const { if ( ASW::Equal(p_ptrName, TEXT("fov")) ) return m_fltFov; else if ( ASW::Equal(p_ptrName, TEXT("near")) ) return m_fltNear; else if ( ASW::Equal(p_ptrName, TEXT("far")) ) return m_fltFar; else return this->ASW::Gui::ElementVisible::GetProperty(p_ptrName); } void ASW::Gui::Viewport:: SetMatrix(const MATH::Matrix3f & p_refMatrix) { m_clsMatrix = p_refMatrix; m_blnShouldRefresh = false; } void ASW::Gui::Viewport:: SetProperty(const TCHAR * p_ptrName, const ASW::Script::Variant & p_refValue) { if ( ASW::Equal(p_ptrName, TEXT("fov")) ) m_fltFov = (float)(p_refValue); else if ( ASW::Equal(p_ptrName, TEXT("near")) ) m_fltNear = (float)(p_refValue); else if ( ASW::Equal(p_ptrName, TEXT("far")) ) m_fltFar = (float)(p_refValue); else this->ASW::Gui::ElementVisible::SetProperty(p_ptrName, p_refValue); } void ASW::Gui::Viewport:: Update(ASW::Gui::UpdateParams & p_refParams, const MATH::Point2s & p_refPosition, const MATH::Point2us & p_refSize, const unsigned int p_uintUpdateMask) { bool blnUpdateSelf = ( (GetUpdateMask() & ASW::Gui::Element::UPDATE_SELF) != 0 || (p_uintUpdateMask & ASW::Gui::Element::UPDATE_CHILDREN) != 0 ); // // Call the base method // this->ASW::Gui::ElementVisible::Update(p_refParams, p_refPosition, p_refSize, p_uintUpdateMask); bool blnDeterminingChildren = ( (p_uintUpdateMask & ASW::Gui::Element::UPDATE_DETERMINING_CHILDREN) != 0 ); if ( blnUpdateSelf && blnDeterminingChildren == false ) { if ( IsVisible() ) { if ( m_ptrRenderIndex == NULL ) { // // We have become visible this frame - add outselves to the list // m_ptrRenderIndex = p_refParams.m_clsViewports.Get(this); } } else if ( m_ptrRenderIndex != NULL ) { // // We have become invisible this frame - remove ourselves from the // list // p_refParams.m_clsViewports.Release(m_ptrRenderIndex); m_ptrRenderIndex = NULL; } } }