Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
See license in Gwen.h
|
||||
*/
|
||||
|
||||
|
||||
#include "Gwen/Gwen.h"
|
||||
#include "Gwen/Controls/Canvas.h"
|
||||
#include "Gwen/Skin.h"
|
||||
@@ -18,14 +17,13 @@
|
||||
|
||||
using namespace Gwen::Controls;
|
||||
|
||||
|
||||
Canvas::Canvas( Gwen::Skin::Base* pSkin ) : BaseClass( NULL ), m_bAnyDelete( false ),m_fScale(-1)
|
||||
Canvas::Canvas(Gwen::Skin::Base* pSkin) : BaseClass(NULL), m_bAnyDelete(false), m_fScale(-1)
|
||||
{
|
||||
SetBounds( 0, 0, 10000, 10000 );
|
||||
SetSkin( pSkin );
|
||||
SetScale( 1.0f );
|
||||
SetBackgroundColor( Color( 255, 255, 255, 255 ) );
|
||||
SetDrawBackground( false );
|
||||
SetBounds(0, 0, 10000, 10000);
|
||||
SetSkin(pSkin);
|
||||
SetScale(1.0f);
|
||||
SetBackgroundColor(Color(255, 255, 255, 255));
|
||||
SetDrawBackground(false);
|
||||
}
|
||||
|
||||
void Canvas::RenderCanvas()
|
||||
@@ -35,51 +33,48 @@ void Canvas::RenderCanvas()
|
||||
Gwen::Renderer::Base* render = m_Skin->GetRender();
|
||||
render->Begin();
|
||||
|
||||
|
||||
RecurseLayout( m_Skin );
|
||||
RecurseLayout(m_Skin);
|
||||
|
||||
render->SetClipRegion( GetBounds() );
|
||||
render->SetRenderOffset( Gwen::Point( 0, 0 ) );
|
||||
render->SetScale( Scale() );
|
||||
render->SetClipRegion(GetBounds());
|
||||
render->SetRenderOffset(Gwen::Point(0, 0));
|
||||
render->SetScale(Scale());
|
||||
|
||||
if ( m_bDrawBackground )
|
||||
{
|
||||
render->SetDrawColor( m_BackgroundColor );
|
||||
render->DrawFilledRect( GetRenderBounds() );
|
||||
}
|
||||
if (m_bDrawBackground)
|
||||
{
|
||||
render->SetDrawColor(m_BackgroundColor);
|
||||
render->DrawFilledRect(GetRenderBounds());
|
||||
}
|
||||
|
||||
DoRender( m_Skin );
|
||||
DoRender(m_Skin);
|
||||
|
||||
DragAndDrop::RenderOverlay( this, m_Skin );
|
||||
DragAndDrop::RenderOverlay(this, m_Skin);
|
||||
|
||||
ToolTip::RenderToolTip( m_Skin );
|
||||
ToolTip::RenderToolTip(m_Skin);
|
||||
|
||||
render->EndClip();
|
||||
render->EndClip();
|
||||
|
||||
render->End();
|
||||
ProcessDelayedDeletes();
|
||||
|
||||
}
|
||||
|
||||
void Canvas::Render( Gwen::Skin::Base* /*pRender*/ )
|
||||
void Canvas::Render(Gwen::Skin::Base* /*pRender*/)
|
||||
{
|
||||
m_bNeedsRedraw = false;
|
||||
}
|
||||
|
||||
void Canvas::OnBoundsChanged( Gwen::Rect oldBounds )
|
||||
void Canvas::OnBoundsChanged(Gwen::Rect oldBounds)
|
||||
{
|
||||
BaseClass::OnBoundsChanged( oldBounds );
|
||||
InvalidateChildren( true );
|
||||
BaseClass::OnBoundsChanged(oldBounds);
|
||||
InvalidateChildren(true);
|
||||
}
|
||||
|
||||
|
||||
void Canvas::DoThink()
|
||||
{
|
||||
if ( Hidden() ) return;
|
||||
if (Hidden()) return;
|
||||
|
||||
#ifndef GWEN_NO_ANIMATION
|
||||
#ifndef GWEN_NO_ANIMATION
|
||||
Gwen::Anim::Think();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Reset tabbing
|
||||
{
|
||||
@@ -89,48 +84,47 @@ void Canvas::DoThink()
|
||||
|
||||
ProcessDelayedDeletes();
|
||||
// Check has focus etc..
|
||||
RecurseLayout( m_Skin );
|
||||
RecurseLayout(m_Skin);
|
||||
|
||||
// If we didn't have a next tab, cycle to the start.
|
||||
if ( NextTab == NULL )
|
||||
if (NextTab == NULL)
|
||||
NextTab = FirstTab;
|
||||
|
||||
Gwen::Input::OnCanvasThink( this );
|
||||
|
||||
Gwen::Input::OnCanvasThink(this);
|
||||
}
|
||||
|
||||
void Canvas::SetScale( float f )
|
||||
{
|
||||
if ( m_fScale == f ) return;
|
||||
void Canvas::SetScale(float f)
|
||||
{
|
||||
if (m_fScale == f) return;
|
||||
|
||||
m_fScale = f;
|
||||
|
||||
if ( m_Skin && m_Skin->GetRender() )
|
||||
m_Skin->GetRender()->SetScale( m_fScale );
|
||||
if (m_Skin && m_Skin->GetRender())
|
||||
m_Skin->GetRender()->SetScale(m_fScale);
|
||||
|
||||
OnScaleChanged();
|
||||
Redraw();
|
||||
}
|
||||
|
||||
void Canvas::AddDelayedDelete( Gwen::Controls::Base* pControl )
|
||||
void Canvas::AddDelayedDelete(Gwen::Controls::Base* pControl)
|
||||
{
|
||||
if ( !m_bAnyDelete || m_DeleteSet.find( pControl ) == m_DeleteSet.end() )
|
||||
if (!m_bAnyDelete || m_DeleteSet.find(pControl) == m_DeleteSet.end())
|
||||
{
|
||||
m_bAnyDelete = true;
|
||||
m_DeleteSet.insert( pControl );
|
||||
m_DeleteList.push_back( pControl );
|
||||
m_DeleteSet.insert(pControl);
|
||||
m_DeleteList.push_back(pControl);
|
||||
}
|
||||
}
|
||||
|
||||
void Canvas::PreDelete( Controls::Base * pControl )
|
||||
void Canvas::PreDelete(Controls::Base* pControl)
|
||||
{
|
||||
if ( m_bAnyDelete )
|
||||
if (m_bAnyDelete)
|
||||
{
|
||||
std::set< Controls::Base * >::iterator itFind;
|
||||
if ( ( itFind = m_DeleteSet.find( pControl ) ) != m_DeleteSet.end() )
|
||||
std::set<Controls::Base*>::iterator itFind;
|
||||
if ((itFind = m_DeleteSet.find(pControl)) != m_DeleteSet.end())
|
||||
{
|
||||
m_DeleteList.remove( pControl );
|
||||
m_DeleteSet.erase( pControl );
|
||||
m_DeleteList.remove(pControl);
|
||||
m_DeleteSet.erase(pControl);
|
||||
m_bAnyDelete = !m_DeleteSet.empty();
|
||||
}
|
||||
}
|
||||
@@ -138,7 +132,7 @@ void Canvas::PreDelete( Controls::Base * pControl )
|
||||
|
||||
void Canvas::ProcessDelayedDeletes()
|
||||
{
|
||||
while( m_bAnyDelete )
|
||||
while (m_bAnyDelete)
|
||||
{
|
||||
m_bAnyDelete = false;
|
||||
|
||||
@@ -147,7 +141,7 @@ void Canvas::ProcessDelayedDeletes()
|
||||
m_DeleteList.clear();
|
||||
m_DeleteSet.clear();
|
||||
|
||||
for ( Gwen::Controls::Base::List::iterator it = deleteList.begin(); it != deleteList.end(); ++it )
|
||||
for (Gwen::Controls::Base::List::iterator it = deleteList.begin(); it != deleteList.end(); ++it)
|
||||
{
|
||||
Gwen::Controls::Base* pControl = *it;
|
||||
delete pControl;
|
||||
@@ -158,76 +152,76 @@ void Canvas::ProcessDelayedDeletes()
|
||||
void Canvas::Release()
|
||||
{
|
||||
Base::List::iterator iter = Children.begin();
|
||||
while ( iter != Children.end() )
|
||||
while (iter != Children.end())
|
||||
{
|
||||
Base* pChild = *iter;
|
||||
iter = Children.erase( iter );
|
||||
iter = Children.erase(iter);
|
||||
delete pChild;
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
bool Canvas::InputMouseMoved( int x, int y, int deltaX, int deltaY )
|
||||
bool Canvas::InputMouseMoved(int x, int y, int deltaX, int deltaY)
|
||||
{
|
||||
if ( Hidden() ) return false;
|
||||
if (Hidden()) return false;
|
||||
|
||||
// Todo: Handle scaling here..
|
||||
//float fScale = 1.0f / Scale();
|
||||
|
||||
Gwen::Input::OnMouseMoved( this, x, y, deltaX, deltaY );
|
||||
Gwen::Input::OnMouseMoved(this, x, y, deltaX, deltaY);
|
||||
|
||||
if ( !Gwen::HoveredControl ) return false;
|
||||
if ( Gwen::HoveredControl == this ) return false;
|
||||
if ( Gwen::HoveredControl->GetCanvas() != this ) return false;
|
||||
if (!Gwen::HoveredControl) return false;
|
||||
if (Gwen::HoveredControl == this) return false;
|
||||
if (Gwen::HoveredControl->GetCanvas() != this) return false;
|
||||
|
||||
Gwen::HoveredControl->OnMouseMoved( x, y, deltaX, deltaY );
|
||||
Gwen::HoveredControl->OnMouseMoved(x, y, deltaX, deltaY);
|
||||
Gwen::HoveredControl->UpdateCursor();
|
||||
|
||||
DragAndDrop::OnMouseMoved( Gwen::HoveredControl, x, y );
|
||||
DragAndDrop::OnMouseMoved(Gwen::HoveredControl, x, y);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Canvas::InputMouseButton( int iButton, bool bDown )
|
||||
bool Canvas::InputMouseButton(int iButton, bool bDown)
|
||||
{
|
||||
if ( Hidden() ) return false;
|
||||
if (Hidden()) return false;
|
||||
|
||||
return Gwen::Input::OnMouseClicked( this, iButton, bDown );
|
||||
return Gwen::Input::OnMouseClicked(this, iButton, bDown);
|
||||
}
|
||||
|
||||
bool Canvas::InputKey( int iKey, bool bDown )
|
||||
bool Canvas::InputKey(int iKey, bool bDown)
|
||||
{
|
||||
if ( Hidden() ) return false;
|
||||
if ( iKey <= Gwen::Key::Invalid ) return false;
|
||||
if ( iKey >= Gwen::Key::Count ) return false;
|
||||
if (Hidden()) return false;
|
||||
if (iKey <= Gwen::Key::Invalid) return false;
|
||||
if (iKey >= Gwen::Key::Count) return false;
|
||||
|
||||
return Gwen::Input::OnKeyEvent( this, iKey, bDown );
|
||||
return Gwen::Input::OnKeyEvent(this, iKey, bDown);
|
||||
}
|
||||
|
||||
bool Canvas::InputCharacter( Gwen::UnicodeChar chr )
|
||||
bool Canvas::InputCharacter(Gwen::UnicodeChar chr)
|
||||
{
|
||||
if ( Hidden() ) return false;
|
||||
if ( !iswprint( chr ) ) return false;
|
||||
if (Hidden()) return false;
|
||||
if (!iswprint(chr)) return false;
|
||||
|
||||
//Handle Accelerators
|
||||
if ( Gwen::Input::HandleAccelerator( this, chr ) )
|
||||
if (Gwen::Input::HandleAccelerator(this, chr))
|
||||
return true;
|
||||
|
||||
//Handle characters
|
||||
if ( !Gwen::KeyboardFocus ) return false;
|
||||
if ( Gwen::KeyboardFocus->GetCanvas() != this ) return false;
|
||||
if ( !Gwen::KeyboardFocus->Visible() ) return false;
|
||||
if ( Gwen::Input::IsControlDown() ) return false;
|
||||
if (!Gwen::KeyboardFocus) return false;
|
||||
if (Gwen::KeyboardFocus->GetCanvas() != this) return false;
|
||||
if (!Gwen::KeyboardFocus->Visible()) return false;
|
||||
if (Gwen::Input::IsControlDown()) return false;
|
||||
|
||||
return KeyboardFocus->OnChar( chr );
|
||||
return KeyboardFocus->OnChar(chr);
|
||||
}
|
||||
|
||||
bool Canvas::InputMouseWheel( int val )
|
||||
bool Canvas::InputMouseWheel(int val)
|
||||
{
|
||||
if ( Hidden() ) return false;
|
||||
if ( !Gwen::HoveredControl ) return false;
|
||||
if ( Gwen::HoveredControl == this ) return false;
|
||||
if ( Gwen::HoveredControl->GetCanvas() != this ) return false;
|
||||
if (Hidden()) return false;
|
||||
if (!Gwen::HoveredControl) return false;
|
||||
if (Gwen::HoveredControl == this) return false;
|
||||
if (Gwen::HoveredControl->GetCanvas() != this) return false;
|
||||
|
||||
return Gwen::HoveredControl->OnMouseWheeled( val );
|
||||
return Gwen::HoveredControl->OnMouseWheeled(val);
|
||||
}
|
||||
Reference in New Issue
Block a user