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:
@@ -13,48 +13,46 @@
|
||||
#include "Gwen/Skin.h"
|
||||
#include "Gwen/Utility.h"
|
||||
|
||||
|
||||
namespace Gwen
|
||||
namespace Gwen
|
||||
{
|
||||
namespace Controls
|
||||
namespace Controls
|
||||
{
|
||||
namespace Property
|
||||
{
|
||||
class GWEN_EXPORT Base : public Gwen::Controls::Base
|
||||
{
|
||||
public:
|
||||
GWEN_CONTROL_INLINE(Base, Gwen::Controls::Base) {}
|
||||
|
||||
virtual String GetPropertyValueAnsi()
|
||||
{
|
||||
namespace Property
|
||||
{
|
||||
class GWEN_EXPORT Base : public Gwen::Controls::Base
|
||||
{
|
||||
public:
|
||||
|
||||
GWEN_CONTROL_INLINE( Base, Gwen::Controls::Base ){}
|
||||
|
||||
virtual String GetPropertyValueAnsi()
|
||||
{
|
||||
return Gwen::Utility::UnicodeToString( GetPropertyValue() );
|
||||
}
|
||||
|
||||
virtual void SetPropertyValue( const String& v, bool bFireChangeEvents = false )
|
||||
{
|
||||
SetPropertyValue( Gwen::Utility::StringToUnicode( v ), bFireChangeEvents );
|
||||
}
|
||||
|
||||
virtual UnicodeString GetPropertyValue() = 0;
|
||||
|
||||
virtual void SetPropertyValue( const UnicodeString& v, bool bFireChangeEvents = false ) = 0;
|
||||
|
||||
virtual bool IsEditing() = 0;
|
||||
|
||||
virtual void DoChanged()
|
||||
{
|
||||
onChange.Call( this );
|
||||
}
|
||||
|
||||
virtual void OnPropertyValueChanged( Gwen::Controls::Base* /*control*/ )
|
||||
{
|
||||
DoChanged();
|
||||
}
|
||||
|
||||
Event::Caller onChange;
|
||||
};
|
||||
}
|
||||
return Gwen::Utility::UnicodeToString(GetPropertyValue());
|
||||
}
|
||||
}
|
||||
|
||||
virtual void SetPropertyValue(const String& v, bool bFireChangeEvents = false)
|
||||
{
|
||||
SetPropertyValue(Gwen::Utility::StringToUnicode(v), bFireChangeEvents);
|
||||
}
|
||||
|
||||
virtual UnicodeString GetPropertyValue() = 0;
|
||||
|
||||
virtual void SetPropertyValue(const UnicodeString& v, bool bFireChangeEvents = false) = 0;
|
||||
|
||||
virtual bool IsEditing() = 0;
|
||||
|
||||
virtual void DoChanged()
|
||||
{
|
||||
onChange.Call(this);
|
||||
}
|
||||
|
||||
virtual void OnPropertyValueChanged(Gwen::Controls::Base* /*control*/)
|
||||
{
|
||||
DoChanged();
|
||||
}
|
||||
|
||||
Event::Caller onChange;
|
||||
};
|
||||
} // namespace Property
|
||||
} // namespace Controls
|
||||
} // namespace Gwen
|
||||
#endif
|
||||
|
||||
@@ -6,75 +6,74 @@
|
||||
#include "Gwen/Controls/WindowControl.h"
|
||||
#include "Gwen/Controls/HSVColorPicker.h"
|
||||
|
||||
namespace Gwen
|
||||
namespace Gwen
|
||||
{
|
||||
namespace Controls
|
||||
namespace Controls
|
||||
{
|
||||
namespace Property
|
||||
{
|
||||
class ColorSelector : public Property::Text
|
||||
{
|
||||
public:
|
||||
GWEN_CONTROL_INLINE(ColorSelector, Property::Text)
|
||||
{
|
||||
namespace Property
|
||||
{
|
||||
class ColorSelector : public Property::Text
|
||||
{
|
||||
public:
|
||||
|
||||
GWEN_CONTROL_INLINE( ColorSelector, Property::Text )
|
||||
{
|
||||
m_Button = new Button( this );
|
||||
m_Button->Dock( Pos::Right );
|
||||
m_Button->SetWidth( 20 );
|
||||
m_Button->onPress.Add( this, &ThisClass::OnButtonPress );
|
||||
}
|
||||
|
||||
void OnButtonPress( Controls::Base* control )
|
||||
{
|
||||
Gwen::Controls::WindowControl* wind = new Gwen::Controls::WindowControl( GetCanvas() );
|
||||
wind->SetTitle( L"Color Selection" );
|
||||
wind->SetSize( 256, 180 );
|
||||
wind->SetPos( GetCanvas()->Width() * 0.5 - 128, GetCanvas()->Height()* 0.5 - 128 );
|
||||
wind->SetDeleteOnClose( true );
|
||||
wind->DisableResizing();
|
||||
wind->MakeModal( true );
|
||||
|
||||
Gwen::Controls::HSVColorPicker* picker = new Gwen::Controls::HSVColorPicker( wind );
|
||||
picker->SetName( "picker" );
|
||||
|
||||
float defaultColor[3];
|
||||
Gwen::Utility::Strings::To::Floats( Gwen::Utility::UnicodeToString( m_TextBox->GetText() ), defaultColor, 3);
|
||||
|
||||
picker->SetColor( Gwen::Color( defaultColor[0], defaultColor[1], defaultColor[2], 255 ), false, true );
|
||||
picker->onColorChanged.Add( this, &ThisClass::ColorChanged );
|
||||
}
|
||||
|
||||
void ColorChanged( Controls::Base* control )
|
||||
{
|
||||
Gwen::Controls::HSVColorPicker* picker = control->DynamicCastHSVColorPicker();
|
||||
|
||||
Gwen::String colorStr;
|
||||
colorStr += Gwen::Utility::ToString( ( int )picker->GetColor().r ) + " ";
|
||||
colorStr += Gwen::Utility::ToString( ( int )picker->GetColor().g ) + " ";
|
||||
colorStr += Gwen::Utility::ToString( ( int )picker->GetColor().b );
|
||||
|
||||
m_TextBox->SetText( colorStr );
|
||||
DoChanged();
|
||||
}
|
||||
|
||||
virtual UnicodeString GetPropertyValue()
|
||||
{
|
||||
return m_TextBox->GetText();
|
||||
}
|
||||
|
||||
virtual void SetPropertyValue( const UnicodeString& v, bool bFireChangeEvents )
|
||||
{
|
||||
m_TextBox->SetText( v, bFireChangeEvents );
|
||||
}
|
||||
|
||||
virtual bool IsEditing()
|
||||
{
|
||||
return m_TextBox == Gwen::KeyboardFocus;
|
||||
}
|
||||
|
||||
Button* m_Button;
|
||||
};
|
||||
}
|
||||
m_Button = new Button(this);
|
||||
m_Button->Dock(Pos::Right);
|
||||
m_Button->SetWidth(20);
|
||||
m_Button->onPress.Add(this, &ThisClass::OnButtonPress);
|
||||
}
|
||||
}
|
||||
|
||||
void OnButtonPress(Controls::Base* control)
|
||||
{
|
||||
Gwen::Controls::WindowControl* wind = new Gwen::Controls::WindowControl(GetCanvas());
|
||||
wind->SetTitle(L"Color Selection");
|
||||
wind->SetSize(256, 180);
|
||||
wind->SetPos(GetCanvas()->Width() * 0.5 - 128, GetCanvas()->Height() * 0.5 - 128);
|
||||
wind->SetDeleteOnClose(true);
|
||||
wind->DisableResizing();
|
||||
wind->MakeModal(true);
|
||||
|
||||
Gwen::Controls::HSVColorPicker* picker = new Gwen::Controls::HSVColorPicker(wind);
|
||||
picker->SetName("picker");
|
||||
|
||||
float defaultColor[3];
|
||||
Gwen::Utility::Strings::To::Floats(Gwen::Utility::UnicodeToString(m_TextBox->GetText()), defaultColor, 3);
|
||||
|
||||
picker->SetColor(Gwen::Color(defaultColor[0], defaultColor[1], defaultColor[2], 255), false, true);
|
||||
picker->onColorChanged.Add(this, &ThisClass::ColorChanged);
|
||||
}
|
||||
|
||||
void ColorChanged(Controls::Base* control)
|
||||
{
|
||||
Gwen::Controls::HSVColorPicker* picker = control->DynamicCastHSVColorPicker();
|
||||
|
||||
Gwen::String colorStr;
|
||||
colorStr += Gwen::Utility::ToString((int)picker->GetColor().r) + " ";
|
||||
colorStr += Gwen::Utility::ToString((int)picker->GetColor().g) + " ";
|
||||
colorStr += Gwen::Utility::ToString((int)picker->GetColor().b);
|
||||
|
||||
m_TextBox->SetText(colorStr);
|
||||
DoChanged();
|
||||
}
|
||||
|
||||
virtual UnicodeString GetPropertyValue()
|
||||
{
|
||||
return m_TextBox->GetText();
|
||||
}
|
||||
|
||||
virtual void SetPropertyValue(const UnicodeString& v, bool bFireChangeEvents)
|
||||
{
|
||||
m_TextBox->SetText(v, bFireChangeEvents);
|
||||
}
|
||||
|
||||
virtual bool IsEditing()
|
||||
{
|
||||
return m_TextBox == Gwen::KeyboardFocus;
|
||||
}
|
||||
|
||||
Button* m_Button;
|
||||
};
|
||||
} // namespace Property
|
||||
} // namespace Controls
|
||||
} // namespace Gwen
|
||||
#endif
|
||||
|
||||
@@ -11,42 +11,41 @@
|
||||
#include "Gwen/Controls/Property/BaseProperty.h"
|
||||
#include "Gwen/Controls/TextBox.h"
|
||||
|
||||
namespace Gwen
|
||||
namespace Gwen
|
||||
{
|
||||
namespace Controls
|
||||
namespace Controls
|
||||
{
|
||||
namespace Property
|
||||
{
|
||||
class GWEN_EXPORT Text : public Property::Base
|
||||
{
|
||||
public:
|
||||
GWEN_CONTROL_INLINE(Text, Property::Base)
|
||||
{
|
||||
namespace Property
|
||||
{
|
||||
class GWEN_EXPORT Text : public Property::Base
|
||||
{
|
||||
public:
|
||||
|
||||
GWEN_CONTROL_INLINE( Text, Property::Base )
|
||||
{
|
||||
m_TextBox = new TextBox( this );
|
||||
m_TextBox->Dock( Pos::Fill );
|
||||
m_TextBox->SetShouldDrawBackground( false );
|
||||
m_TextBox->onTextChanged.Add( this, &BaseClass::OnPropertyValueChanged );
|
||||
}
|
||||
|
||||
virtual UnicodeString GetPropertyValue()
|
||||
{
|
||||
return m_TextBox->GetText();
|
||||
}
|
||||
|
||||
virtual void SetPropertyValue( const UnicodeString& v, bool bFireChangeEvents )
|
||||
{
|
||||
m_TextBox->SetText( v, bFireChangeEvents );
|
||||
}
|
||||
|
||||
virtual bool IsEditing()
|
||||
{
|
||||
return m_TextBox->HasFocus();
|
||||
}
|
||||
|
||||
TextBox* m_TextBox;
|
||||
};
|
||||
}
|
||||
m_TextBox = new TextBox(this);
|
||||
m_TextBox->Dock(Pos::Fill);
|
||||
m_TextBox->SetShouldDrawBackground(false);
|
||||
m_TextBox->onTextChanged.Add(this, &BaseClass::OnPropertyValueChanged);
|
||||
}
|
||||
}
|
||||
|
||||
virtual UnicodeString GetPropertyValue()
|
||||
{
|
||||
return m_TextBox->GetText();
|
||||
}
|
||||
|
||||
virtual void SetPropertyValue(const UnicodeString& v, bool bFireChangeEvents)
|
||||
{
|
||||
m_TextBox->SetText(v, bFireChangeEvents);
|
||||
}
|
||||
|
||||
virtual bool IsEditing()
|
||||
{
|
||||
return m_TextBox->HasFocus();
|
||||
}
|
||||
|
||||
TextBox* m_TextBox;
|
||||
};
|
||||
} // namespace Property
|
||||
} // namespace Controls
|
||||
} // namespace Gwen
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user