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/Skin.h"
|
||||
#include "Gwen/Controls/Button.h"
|
||||
@@ -13,54 +12,53 @@
|
||||
using namespace Gwen;
|
||||
using namespace Gwen::Controls;
|
||||
|
||||
|
||||
GWEN_CONTROL_CONSTRUCTOR( Button )
|
||||
GWEN_CONTROL_CONSTRUCTOR(Button)
|
||||
{
|
||||
m_Image = NULL;
|
||||
m_bDepressed = false;
|
||||
m_bCenterImage = false;
|
||||
|
||||
SetSize( 100, 20 );
|
||||
SetMouseInputEnabled( true );
|
||||
SetIsToggle( false );
|
||||
SetAlignment( Gwen::Pos::Center );
|
||||
SetTextPadding( Padding( 3, 0, 3, 0 ) );
|
||||
SetSize(100, 20);
|
||||
SetMouseInputEnabled(true);
|
||||
SetIsToggle(false);
|
||||
SetAlignment(Gwen::Pos::Center);
|
||||
SetTextPadding(Padding(3, 0, 3, 0));
|
||||
m_bToggleStatus = false;
|
||||
SetKeyboardInputEnabled( false );
|
||||
SetTabable( false );
|
||||
SetKeyboardInputEnabled(false);
|
||||
SetTabable(false);
|
||||
}
|
||||
|
||||
void Button::Render( Skin::Base* skin )
|
||||
void Button::Render(Skin::Base* skin)
|
||||
{
|
||||
if ( ShouldDrawBackground() )
|
||||
if (ShouldDrawBackground())
|
||||
{
|
||||
bool bDrawDepressed = IsDepressed() && IsHovered();
|
||||
if ( IsToggle() ) bDrawDepressed = bDrawDepressed || GetToggleState();
|
||||
if (IsToggle()) bDrawDepressed = bDrawDepressed || GetToggleState();
|
||||
|
||||
bool bDrawHovered = IsHovered() && ShouldDrawHover();
|
||||
|
||||
skin->DrawButton( this, bDrawDepressed, bDrawHovered );
|
||||
skin->DrawButton(this, bDrawDepressed, bDrawHovered);
|
||||
}
|
||||
}
|
||||
|
||||
void Button::OnMouseClickLeft( int /*x*/, int /*y*/, bool bDown )
|
||||
void Button::OnMouseClickLeft(int /*x*/, int /*y*/, bool bDown)
|
||||
{
|
||||
if ( bDown )
|
||||
if (bDown)
|
||||
{
|
||||
m_bDepressed = true;
|
||||
Gwen::MouseFocus = this;
|
||||
onDown.Call( this );
|
||||
onDown.Call(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( IsHovered() && m_bDepressed )
|
||||
if (IsHovered() && m_bDepressed)
|
||||
{
|
||||
OnPress();
|
||||
}
|
||||
|
||||
m_bDepressed = false;
|
||||
Gwen::MouseFocus = NULL;
|
||||
onUp.Call( this );
|
||||
onUp.Call(this);
|
||||
}
|
||||
|
||||
Redraw();
|
||||
@@ -68,60 +66,59 @@ void Button::OnMouseClickLeft( int /*x*/, int /*y*/, bool bDown )
|
||||
|
||||
void Button::OnPress()
|
||||
{
|
||||
if ( IsToggle() )
|
||||
if (IsToggle())
|
||||
{
|
||||
SetToggleState( !GetToggleState() );
|
||||
SetToggleState(!GetToggleState());
|
||||
}
|
||||
|
||||
onPress.Call( this );
|
||||
onPress.Call(this);
|
||||
}
|
||||
|
||||
|
||||
void Button::SetImage( const TextObject& strName, bool bCenter )
|
||||
void Button::SetImage(const TextObject& strName, bool bCenter)
|
||||
{
|
||||
if ( strName.GetUnicode() == L"" )
|
||||
if (strName.GetUnicode() == L"")
|
||||
{
|
||||
if ( m_Image )
|
||||
if (m_Image)
|
||||
{
|
||||
delete m_Image;
|
||||
m_Image= NULL;
|
||||
m_Image = NULL;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !m_Image )
|
||||
if (!m_Image)
|
||||
{
|
||||
m_Image = new ImagePanel( this );
|
||||
m_Image = new ImagePanel(this);
|
||||
}
|
||||
|
||||
m_Image->SetImage( strName );
|
||||
m_Image->SetImage(strName);
|
||||
m_Image->SizeToContents();
|
||||
m_Image->SetPos( m_Padding.left, 2 );
|
||||
m_Image->SetPos(m_Padding.left, 2);
|
||||
m_bCenterImage = bCenter;
|
||||
|
||||
int IdealTextPadding = m_Image->Right() + m_Padding.left + 4;
|
||||
if ( m_rTextPadding.left < IdealTextPadding )
|
||||
if (m_rTextPadding.left < IdealTextPadding)
|
||||
{
|
||||
m_rTextPadding.left = IdealTextPadding;
|
||||
}
|
||||
}
|
||||
|
||||
void Button::SetToggleState( bool b )
|
||||
{
|
||||
if ( m_bToggleStatus == b ) return;
|
||||
void Button::SetToggleState(bool b)
|
||||
{
|
||||
if (m_bToggleStatus == b) return;
|
||||
|
||||
m_bToggleStatus = b;
|
||||
|
||||
onToggle.Call( this );
|
||||
onToggle.Call(this);
|
||||
|
||||
if ( m_bToggleStatus )
|
||||
if (m_bToggleStatus)
|
||||
{
|
||||
onToggleOn.Call( this );
|
||||
onToggleOn.Call(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
onToggleOff.Call( this );
|
||||
onToggleOff.Call(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,19 +126,19 @@ void Button::SizeToContents()
|
||||
{
|
||||
BaseClass::SizeToContents();
|
||||
|
||||
if ( m_Image )
|
||||
if (m_Image)
|
||||
{
|
||||
int height = m_Image->Height() + 4;
|
||||
if ( Height() < height )
|
||||
if (Height() < height)
|
||||
{
|
||||
SetHeight( height );
|
||||
SetHeight(height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Button::OnKeySpace( bool bDown )
|
||||
bool Button::OnKeySpace(bool bDown)
|
||||
{
|
||||
OnMouseClickLeft( 0, 0, bDown );
|
||||
OnMouseClickLeft(0, 0, bDown);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -150,20 +147,20 @@ void Button::AcceleratePressed()
|
||||
OnPress();
|
||||
}
|
||||
|
||||
void Button::Layout( Skin::Base* pSkin )
|
||||
{
|
||||
BaseClass::Layout( pSkin );
|
||||
if ( m_Image )
|
||||
{
|
||||
Gwen::Align::CenterVertically( m_Image );
|
||||
void Button::Layout(Skin::Base* pSkin)
|
||||
{
|
||||
BaseClass::Layout(pSkin);
|
||||
if (m_Image)
|
||||
{
|
||||
Gwen::Align::CenterVertically(m_Image);
|
||||
|
||||
if ( m_bCenterImage )
|
||||
Gwen::Align::CenterHorizontally( m_Image );
|
||||
if (m_bCenterImage)
|
||||
Gwen::Align::CenterHorizontally(m_Image);
|
||||
}
|
||||
}
|
||||
|
||||
void Button::OnMouseDoubleClickLeft( int x, int y )
|
||||
{
|
||||
OnMouseClickLeft( x, y, true );
|
||||
onDoubleClick.Call( this );
|
||||
void Button::OnMouseDoubleClickLeft(int x, int y)
|
||||
{
|
||||
OnMouseClickLeft(x, y, true);
|
||||
onDoubleClick.Call(this);
|
||||
};
|
||||
Reference in New Issue
Block a user