add initial examples, replacing the 'Demos/Demos3'. Will make it work cross-platform, OpenGL3/OpenGL2 and add more examples to it.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
GWEN
|
||||
Copyright (c) 2010 Facepunch Studios
|
||||
See license in Gwen.h
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef GWEN_CONTROLS_PROPERTY_BASEPROPERTY_H
|
||||
#define GWEN_CONTROLS_PROPERTY_BASEPROPERTY_H
|
||||
|
||||
#include "Gwen/Controls/Base.h"
|
||||
#include "Gwen/Gwen.h"
|
||||
#include "Gwen/Skin.h"
|
||||
#include "Gwen/Utility.h"
|
||||
|
||||
|
||||
namespace Gwen
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
#pragma once
|
||||
#ifndef GWEN_CONTROLS_PROPERTY_COLORSELECTOR_H
|
||||
#define GWEN_CONTROLS_PROPERTY_COLORSELECTOR_H
|
||||
|
||||
#include "Gwen/Controls/Properties.h"
|
||||
#include "Gwen/Controls/WindowControl.h"
|
||||
#include "Gwen/Controls/HSVColorPicker.h"
|
||||
|
||||
namespace Gwen
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
52
examples/ThirdPartyLibs/Gwen/Controls/Property/Text.h
Normal file
52
examples/ThirdPartyLibs/Gwen/Controls/Property/Text.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
GWEN
|
||||
Copyright (c) 2010 Facepunch Studios
|
||||
See license in Gwen.h
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef GWEN_CONTROLS_PROPERTY_TEXT_H
|
||||
#define GWEN_CONTROLS_PROPERTY_TEXT_H
|
||||
|
||||
#include "Gwen/Controls/Property/BaseProperty.h"
|
||||
#include "Gwen/Controls/TextBox.h"
|
||||
|
||||
namespace Gwen
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user