+ return connected;
+}
+
+// Setup signals and actions using the type-registry.
+DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
+
+// Note: Properties are registered separately below.
+
+SignalConnectorType registerSignal1( typeRegistration, SIGNAL_KEY_EVENT, &DoConnectSignal );
+SignalConnectorType registerSignal2( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_GAINED, &DoConnectSignal );
+SignalConnectorType registerSignal3( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_LOST, &DoConnectSignal );
+SignalConnectorType registerSignal4( typeRegistration, SIGNAL_TAPPED, &DoConnectSignal );
+SignalConnectorType registerSignal5( typeRegistration, SIGNAL_PANNED, &DoConnectSignal );
+SignalConnectorType registerSignal6( typeRegistration, SIGNAL_PINCHED, &DoConnectSignal );
+SignalConnectorType registerSignal7( typeRegistration, SIGNAL_LONG_PRESSED, &DoConnectSignal );
+
+TypeAction registerAction( typeRegistration, ACTION_CONTROL_ACTIVATED, &DoAction );
+
+DALI_TYPE_REGISTRATION_END()
+
+/**
+ * Structure which holds information about the background of a control
+ */
+struct Background
+{
+ Actor actor; ///< Background actor
+ Vector4 color; ///< The color of the actor.
+
+ /**
+ * Constructor
+ */
+ Background()
+ : actor(),
+ color( Color::WHITE )
+ {
+ }
+};
+
+unsigned int gQuadIndex[6] = { 0, 2, 1, 1, 2, 3 };
+
+Vector2 gQuad[] = {
+ Vector2( -0.5f, -0.5f ),
+ Vector2( 0.5f, -0.5f ),
+ Vector2( -0.5f, 0.5f ),
+ Vector2( 0.5f, 0.5f )
+};
+
+struct VertexWithTexture
+{
+ Vector2 position;
+ Vector2 texCoord;
+};
+
+VertexWithTexture gQuadWithTexture[] = {
+ { Vector2( -0.5f, -0.5f ), Vector2( 0.0f, 0.0f ) },
+ { Vector2( 0.5f, -0.5f ), Vector2( 1.0f, 0.0f ) },
+ { Vector2( -0.5f, 0.5f ), Vector2( 0.0f, 1.0f ) },
+ { Vector2( 0.5f, 0.5f ), Vector2( 1.0f, 1.0f ) }
+};
+
+const char* VERTEX_SHADER_COLOR = DALI_COMPOSE_SHADER(
+ attribute mediump vec2 aPosition;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ void main()\n
+ {\n
+ gl_Position = uMvpMatrix * vec4( aPosition, 0.0, 1.0 );\n
+ }\n
+);
+
+const char* FRAGMENT_SHADER_COLOR = DALI_COMPOSE_SHADER(
+ uniform lowp vec4 uBackgroundColor;\n
+ uniform lowp vec4 uColor;\n
+ void main()\n
+ {\n
+ gl_FragColor = uBackgroundColor * uColor;\n
+ }\n
+);
+
+const char* VERTEX_SHADER_TEXTURE = DALI_COMPOSE_SHADER(
+ attribute mediump vec2 aPosition;\n
+ attribute mediump vec2 aTexCoord;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ varying mediump vec2 vTexCoord;\n
+ void main()\n
+ {\n
+ gl_Position = uMvpMatrix * vec4( aPosition, 0.0, 1.0 );\n
+ vTexCoord = aTexCoord;\n
+ }\n
+);
+
+const char* FRAGMENT_SHADER_TEXTURE = DALI_COMPOSE_SHADER(
+ uniform lowp vec4 uBackgroundColor;\n
+ uniform lowp vec4 uColor;\n
+ uniform sampler2D sTexture;\n
+ varying mediump vec2 vTexCoord;\n
+
+ void main()\n
+ {\n
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uBackgroundColor * uColor;\n
+ }\n
+);
+
+/**
+ * @brief Create the background actor for the control.
+ *
+ * @param[in] actor The parent actor of the background
+ * @param[in] color The background color
+ * @param[in] image If a valid image is supplied this will be the texture used by the background
+ *
+ * @return An actor which will render the background
+ *
+ */
+Actor CreateBackground( Actor parent, const Vector4& color, Image image = Image() )
+{
+ PropertyBuffer vertexBuffer;
+ Shader shader;
+ Material material;
+ if( image )
+ {
+ Property::Map vertexFormat;
+ vertexFormat["aPosition"] = Property::VECTOR2;
+ vertexFormat["aTexCoord"] = Property::VECTOR2;
+
+ //Create a vertex buffer for vertex positions and texture coordinates
+ vertexBuffer = PropertyBuffer::New( vertexFormat, 4u );
+ vertexBuffer.SetData( gQuadWithTexture );
+
+ shader = Shader::New( VERTEX_SHADER_TEXTURE, FRAGMENT_SHADER_TEXTURE );
+ Sampler textureSampler = Sampler::New( image, "sTexture" );
+ material = Material::New( shader );
+ material.AddSampler(textureSampler);
+ }
+ else
+ {
+ Property::Map vertexFormat;
+ vertexFormat["aPosition"] = Property::VECTOR2;
+
+ //Create a vertex buffer for vertex positions
+ vertexBuffer = PropertyBuffer::New( vertexFormat, 4u );
+ vertexBuffer.SetData( gQuad );
+
+ shader = Shader::New( VERTEX_SHADER_COLOR, FRAGMENT_SHADER_COLOR );
+ material = Material::New( shader );
+ }