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:
erwincoumans
2018-09-23 14:17:31 -07:00
parent b73b05e9fb
commit ab8f16961e
1773 changed files with 1081087 additions and 474249 deletions

View File

@@ -4,7 +4,6 @@
See license in Gwen.h
*/
#include "Gwen/Gwen.h"
#include "Gwen/Controls/Text.h"
#include "Gwen/Skin.h"
@@ -13,11 +12,11 @@
using namespace Gwen;
using namespace Gwen::ControlsInternal;
GWEN_CONTROL_CONSTRUCTOR( Text )
GWEN_CONTROL_CONSTRUCTOR(Text)
{
m_Font = NULL;
m_Color = Gwen::Colors::Black; // TODO: From skin somehow..
SetMouseInputEnabled( false );
m_Color = Gwen::Colors::Black; // TODO: From skin somehow..
SetMouseInputEnabled(false);
}
Text::~Text()
@@ -28,78 +27,79 @@ Text::~Text()
void Text::RefreshSize()
{
if ( !GetFont() )
if (!GetFont())
{
Debug::AssertCheck( 0, "Text::RefreshSize() - No Font!!\n" );
Debug::AssertCheck(0, "Text::RefreshSize() - No Font!!\n");
return;
}
Gwen::Point p( 1, GetFont()->size );
if ( Length() > 0 )
Gwen::Point p(1, GetFont()->size);
if (Length() > 0)
{
p = GetSkin()->GetRender()->MeasureText( GetFont(), m_String );
p = GetSkin()->GetRender()->MeasureText(GetFont(), m_String);
}
if ( p.x == Width() && p.y == Height() )
if (p.x == Width() && p.y == Height())
return;
SetSize( p.x, p.y );
SetSize(p.x, p.y);
InvalidateParent();
Invalidate();
}
Gwen::Font* Text::GetFont()
{
return m_Font;
}
void Text::SetString( const UnicodeString& str ){ m_String = str; Invalidate(); }
void Text::SetString( const String& str ){ SetString( Gwen::Utility::StringToUnicode( str ) ); }
void Text::Render( Skin::Base* skin )
void Text::SetString(const UnicodeString& str)
{
if ( Length() == 0 || !GetFont() ) return;
m_String = str;
Invalidate();
}
void Text::SetString(const String& str) { SetString(Gwen::Utility::StringToUnicode(str)); }
skin->GetRender()->SetDrawColor( m_Color );
skin->GetRender()->RenderText( GetFont(), Gwen::Point( 0, 0 ), m_String );
void Text::Render(Skin::Base* skin)
{
if (Length() == 0 || !GetFont()) return;
skin->GetRender()->SetDrawColor(m_Color);
skin->GetRender()->RenderText(GetFont(), Gwen::Point(0, 0), m_String);
}
void Text::Layout( Skin::Base* /*skin*/ )
void Text::Layout(Skin::Base* /*skin*/)
{
RefreshSize();
}
Gwen::Point Text::GetCharacterPosition( int iChar )
Gwen::Point Text::GetCharacterPosition(int iChar)
{
if ( Length() == 0 || iChar == 0 )
if (Length() == 0 || iChar == 0)
{
return Gwen::Point( 1, 0 );
return Gwen::Point(1, 0);
}
UnicodeString sub = m_String.substr( 0, iChar );
Gwen::Point p = GetSkin()->GetRender()->MeasureText( GetFont(), sub );
if ( p.y >= m_Font->size )
UnicodeString sub = m_String.substr(0, iChar);
Gwen::Point p = GetSkin()->GetRender()->MeasureText(GetFont(), sub);
if (p.y >= m_Font->size)
p.y -= m_Font->size;
return p;
}
int Text::GetClosestCharacter( Gwen::Point p )
int Text::GetClosestCharacter(Gwen::Point p)
{
int iDistance = 4096;
int iChar = 0;
for ( size_t i=0; i<m_String.length()+1; i++ )
for (size_t i = 0; i < m_String.length() + 1; i++)
{
Gwen::Point cp = GetCharacterPosition( i );
int iDist = abs(cp.x - p.x) + abs(cp.y - p.y); // this isn't proper
Gwen::Point cp = GetCharacterPosition(i);
int iDist = abs(cp.x - p.x) + abs(cp.y - p.y); // this isn't proper
if ( iDist > iDistance ) continue;
if (iDist > iDistance) continue;
iDistance = iDist;
iChar = i;