<commit_before>/*
 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// EXTERNAL INCLUDES
#include <dali/devel-api/rendering/renderer.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/bubble-effect/bubble-emitter.h>

#include <cstdio>
#include <iostream>

// INTERNAL INCLUDES
#include "shared/view.h"

using namespace Dali;
using namespace Dali::Toolkit;

class NewWindowController;

namespace
{
const char * const BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-2.jpg" );
const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" );
const char * const LOSE_CONTEXT_IMAGE( DALI_IMAGE_DIR "icon-cluster-wobble.png" );
const char * const LOSE_CONTEXT_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-cluster-wobble-selected.png" );
const char * const BASE_IMAGE( DALI_IMAGE_DIR "gallery-large-14.jpg" );
const char * const EFFECT_IMAGE( DALI_IMAGE_DIR "gallery-large-18.jpg" );
const char * const LOGO_IMAGE(DALI_IMAGE_DIR "dali-logo.png");

const float EXPLOSION_DURATION(1.2f);
const unsigned int EMIT_INTERVAL_IN_MS(40);
const float TRACK_DURATION_IN_MS(970);

Application gApplication;
NewWindowController* gNewWindowController(NULL);

#define MAKE_SHADER(A)#A

const char* VERTEX_COLOR_MESH = MAKE_SHADER(
attribute mediump vec3  aPosition;\n
attribute lowp    vec3  aColor;\n
uniform   mediump mat4  uMvpMatrix;\n
uniform   mediump vec3  uSize;\n
varying   lowp    vec3  vColor;\n
\n
void main()\n
{\n
  gl_Position = uMvpMatrix * vec4( aPosition*uSize, 1.0 );\n
  vColor = aColor;\n
}\n
);

const char* FRAGMENT_COLOR_MESH = MAKE_SHADER(
uniform lowp vec4  uColor;\n
varying lowp vec3  vColor;\n
\n
void main()\n
{\n
  gl_FragColor = vec4(vColor,1.0)*uColor;
}\n
);

const char* VERTEX_TEXTURE_MESH = MAKE_SHADER(
attribute mediump vec3  aPosition;\n
attribute highp   vec2  aTexCoord;\n
uniform   mediump mat4  uMvpMatrix;\n
uniform   mediump vec3  uSize;\n
varying   mediump vec2  vTexCoord;\n
\n
void main()\n
{\n
  gl_Position = uMvpMatrix * vec4( aPosition*uSize, 1.0 );\n
  vTexCoord = aTexCoord;\n
}\n
);

const char* FRAGMENT_TEXTURE_MESH = MAKE_SHADER(
varying mediump vec2  vTexCoord;\n
uniform lowp    vec4  uColor;\n
uniform sampler2D     sTexture;\n
\n
void main()\n
{\n
  gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
}\n
);

const char* FRAGMENT_BLEND_SHADER = MAKE_SHADER(
uniform mediump float alpha;\n
\n
void main()\n
{\n
  mediump vec4 fragColor = texture2D(sTexture, vTexCoord);\n
  mediump vec4 fxColor   = texture2D(sEffect, vTexCoord);\n
  gl_FragColor = mix(fragColor,fxColor, alpha);\n
}\n
);

}; // anonymous namespace


class NewWindowController : public ConnectionTracker
{
public:
  NewWindowController( Application& app );
  void Create( Application& app );
  void Destroy( Application& app );

  void AddBubbles( Actor& parentActor, const Vector2& stageSize);
  void AddMeshActor( Actor& parentActor );
  void AddBlendingImageActor( Actor& parentActor );
  void AddTextLabel( Actor& parentActor );

  ImageView CreateBlurredMirrorImage(const char* imageName);
  FrameBufferImage CreateFrameBufferForImage( const char* imageName, Property::Map& shaderEffect, const Vector3& rgbDelta );
  void SetUpBubbleEmission( const Vector2& emitPosition, const Vector2& direction );
  Geometry CreateMeshGeometry();
  Dali::Property::Map CreateColorModifierer();

  static void NewWindow(void);

  bool OnTrackTimerTick();
  void OnKeyEvent(const KeyEvent& event);
  bool OnLoseContextButtonClicked( Toolkit::Button button );
  void OnContextLost();
  void OnContextRegained();

private:
  Application                mApplication;
  TextLabel                  mTextActor;

  Toolkit::Control           mView;                              ///< The View instance.
  Toolkit::ToolBar           mToolBar;                           ///< The View's Toolbar.
  TextLabel                  mTitleActor;                        ///< The Toolbar's Title.
  Layer                      mContentLayer;                      ///< Content layer (scrolling cluster content)
  Toolkit::PushButton        mLoseContextButton;

  Toolkit::BubbleEmitter     mEmitter;
  Timer                      mEmitTrackTimer;
  bool                       mNeedNewAnimation;
  unsigned int               mAnimateComponentCount;
  Animation                  mEmitAnimation;
};


NewWindowController::NewWindowController( Application& application )
: mApplication(application),
  mNeedNewAnimation(true)
{
  mApplication.InitSignal().Connect(this, &NewWindowController::Create);
  mApplication.TerminateSignal().Connect(this, &NewWindowController::Destroy);
}

void NewWindowController::Create( Application& app )
{
  Stage stage = Stage::GetCurrent();
  stage.SetBackgroundColor(Color::YELLOW);

  stage.KeyEventSignal().Connect(this, &NewWindowController::OnKeyEvent);

  // The Init signal is received once (only) during the Application lifetime

  // Hide the indicator bar
  mApplication.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );

  mContentLayer = DemoHelper::CreateView( app,
                                          mView,
                                          mToolBar,
                                          "",
                                          TOOLBAR_IMAGE,
                                          "Context recovery" );

  Size stageSize = stage.GetSize();
  Image backgroundImage = ResourceImage::New( BACKGROUND_IMAGE, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
  ImageView backgroundActor = ImageView::New( backgroundImage );
  backgroundActor.SetParentOrigin( ParentOrigin::CENTER );
  mContentLayer.Add(backgroundActor);

  // Point the default render task at the view
  RenderTaskList taskList = stage.GetRenderTaskList();
  RenderTask defaultTask = taskList.GetTask( 0u );
  if ( defaultTask )
  {
    defaultTask.SetSourceActor( mView );
  }

  mLoseContextButton = Toolkit::PushButton::New();
  mLoseContextButton.SetUnselectedImage( LOSE_CONTEXT_IMAGE );
  mLoseContextButton.SetSelectedImage( LOSE_CONTEXT_IMAGE_SELECTED );
  mLoseContextButton.ClickedSignal().Connect( this, &NewWindowController::OnLoseContextButtonClicked );
  mToolBar.AddControl( mLoseContextButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );

  Actor logoLayoutActor = Actor::New();
  logoLayoutActor.SetParentOrigin(ParentOrigin::CENTER);
  logoLayoutActor.SetPosition(0.0f, -200.0f, 0.0f);
  logoLayoutActor.SetScale(0.5f);
  backgroundActor.Add(logoLayoutActor);

  Image image = ResourceImage::New(LOGO_IMAGE);
  ImageView imageView = ImageView::New(image);
  imageView.SetName("daliLogo");
  imageView.SetParentOrigin(ParentOrigin::CENTER);
  imageView.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER);
  logoLayoutActor.Add(imageView);

  ImageView mirrorImageView = CreateBlurredMirrorImage(LOGO_IMAGE);
  mirrorImageView.SetParentOrigin(ParentOrigin::CENTER);
  mirrorImageView.SetAnchorPoint(AnchorPoint::TOP_CENTER);
  logoLayoutActor.Add(mirrorImageView);

  AddBubbles( backgroundActor, stage.GetSize());
  AddMeshActor( backgroundActor );
  AddBlendingImageActor( backgroundActor );
  AddTextLabel( backgroundActor );

  stage.ContextLostSignal().Connect(this, &NewWindowController::OnContextLost);
  stage.ContextRegainedSignal().Connect(this, &NewWindowController::OnContextRegained);
}

void NewWindowController::Destroy( Application& app )
{
  UnparentAndReset(mTextActor);
}

void NewWindowController::AddBubbles( Actor& parentActor, const Vector2& stageSize)
{
  mEmitter = Toolkit::BubbleEmitter::New( stageSize,
                                          ResourceImage::New( DALI_IMAGE_DIR "bubble-ball.png" ),
                                          200, Vector2( 5.0f, 5.0f ) );

  Image background = ResourceImage::New(BACKGROUND_IMAGE);
  mEmitter.SetBackground( background, Vector3(0.5f, 0.f,0.5f) );
  mEmitter.SetBubbleDensity( 9.f );
  Actor bubbleRoot = mEmitter.GetRootActor();
  parentActor.Add( bubbleRoot );
  bubbleRoot.SetParentOrigin(ParentOrigin::CENTER);
  bubbleRoot.SetZ(0.1f);

  mEmitTrackTimer = Timer::New( EMIT_INTERVAL_IN_MS );
  mEmitTrackTimer.TickSignal().Connect(this, &NewWindowController::OnTrackTimerTick);
  mEmitTrackTimer.Start();
}

void NewWindowController::AddMeshActor( Actor& parentActor )
{
  Geometry meshGeometry = CreateMeshGeometry();

  // Create a coloured mesh
  Shader shaderColorMesh = Shader::New( VERTEX_COLOR_MESH, FRAGMENT_COLOR_MESH );
  Material colorMeshmaterial = Material::New( shaderColorMesh );
  Renderer colorMeshRenderer = Renderer::New( meshGeometry, colorMeshmaterial );

  Actor colorMeshActor = Actor::New();
  colorMeshActor.AddRenderer( colorMeshRenderer );
  colorMeshActor.SetSize( 175.f,175.f );
  colorMeshActor.SetParentOrigin( ParentOrigin::CENTER );
  colorMeshActor.SetAnchorPoint(AnchorPoint::TOP_CENTER);
  colorMeshActor.SetPosition(Vector3(0.0f, 50.0f, 0.0f));
  colorMeshActor.SetOrientation( Degree(75.f), Vector3::XAXIS );
  colorMeshActor.SetName("ColorMeshActor");
  parentActor.Add( colorMeshActor );

 // Create a textured mesh
  Image effectImage = ResourceImage::New(EFFECT_IMAGE);
  Shader shaderTextureMesh = Shader::New( VERTEX_TEXTURE_MESH, FRAGMENT_TEXTURE_MESH );
  Material textureMeshMaterial = Material::New( shaderTextureMesh );
  textureMeshMaterial.AddTexture(effectImage, "sTexture");
  Renderer textureMeshRenderer = Renderer::New( meshGeometry, textureMeshMaterial );

  Actor textureMeshActor = Actor::New();
  textureMeshActor.AddRenderer( textureMeshRenderer );
  textureMeshActor.SetSize( 175.f,175.f );
  textureMeshActor.SetParentOrigin( ParentOrigin::CENTER );
  textureMeshActor.SetAnchorPoint(AnchorPoint::TOP_CENTER);
  textureMeshActor.SetPosition(Vector3(0.0f, 200.0f, 0.0f));
  textureMeshActor.SetOrientation( Degree(75.f), Vector3::XAXIS );
  textureMeshActor.SetName("TextureMeshActor");
  parentActor.Add( textureMeshActor );
}

void NewWindowController::AddBlendingImageActor( Actor& parentActor )
{
  Property::Map colorModifier = CreateColorModifierer();

  FrameBufferImage fb2 = CreateFrameBufferForImage( EFFECT_IMAGE, colorModifier, Vector3( 0.5f, 0.5f, 0.5f ) );

  ImageView tmpActor = ImageView::New(fb2);
  parentActor.Add(tmpActor);
  tmpActor.SetParentOrigin(ParentOrigin::CENTER_RIGHT);
  tmpActor.SetAnchorPoint(AnchorPoint::TOP_RIGHT);
  tmpActor.SetPosition(Vector3(0.0f, 150.0f, 0.0f));
  tmpActor.SetScale(0.25f);

  // create blending shader effect
  ShaderEffect blendShader = ShaderEffect::New( "", FRAGMENT_BLEND_SHADER );
  blendShader.SetEffectImage( fb2 );
  blendShader.SetUniform("alpha", 0.5f);

  Image baseImage = ResourceImage::New(BASE_IMAGE);
  ImageActor blendActor = ImageActor::New( baseImage );
  blendActor.SetParentOrigin(ParentOrigin::CENTER_RIGHT);
  blendActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
  blendActor.SetPosition(Vector3(0.0f, 100.0f, 0.0f));
  blendActor.SetSize(140, 140);
  blendActor.SetShaderEffect( blendShader );
  parentActor.Add(blendActor);
}

void NewWindowController::AddTextLabel( Actor& parentActor )
{
  mTextActor = TextLabel::New("Some text");
  mTextActor.SetParentOrigin(ParentOrigin::CENTER);
  mTextActor.SetColor(Color::RED);<commit_msg>Remove ImageActor from Demo<commit_after>/*
 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// EXTERNAL INCLUDES
#include <dali/devel-api/rendering/renderer.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/bubble-effect/bubble-emitter.h>

#include <cstdio>
#include <iostream>

// INTERNAL INCLUDES
#include "shared/view.h"

using namespace Dali;
using namespace Dali::Toolkit;

class NewWindowController;

namespace
{
const char * const BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-2.jpg" );
const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" );
const char * const LOSE_CONTEXT_IMAGE( DALI_IMAGE_DIR "icon-cluster-wobble.png" );
const char * const LOSE_CONTEXT_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-cluster-wobble-selected.png" );
const char * const BASE_IMAGE( DALI_IMAGE_DIR "gallery-large-14.jpg" );
const char * const EFFECT_IMAGE( DALI_IMAGE_DIR "gallery-large-18.jpg" );
const char * const LOGO_IMAGE(DALI_IMAGE_DIR "dali-logo.png");

const float EXPLOSION_DURATION(1.2f);
const unsigned int EMIT_INTERVAL_IN_MS(40);
const float TRACK_DURATION_IN_MS(970);

Application gApplication;
NewWindowController* gNewWindowController(NULL);

#define MAKE_SHADER(A)#A

const char* VERTEX_COLOR_MESH = MAKE_SHADER(
attribute mediump vec3  aPosition;\n
attribute lowp    vec3  aColor;\n
uniform   mediump mat4  uMvpMatrix;\n
uniform   mediump vec3  uSize;\n
varying   lowp    vec3  vColor;\n
\n
void main()\n
{\n
  gl_Position = uMvpMatrix * vec4( aPosition*uSize, 1.0 );\n
  vColor = aColor;\n
}\n
);

const char* FRAGMENT_COLOR_MESH = MAKE_SHADER(
uniform lowp vec4  uColor;\n
varying lowp vec3  vColor;\n
\n
void main()\n
{\n
  gl_FragColor = vec4(vColor,1.0)*uColor;
}\n
);

const char* VERTEX_TEXTURE_MESH = MAKE_SHADER(
attribute mediump vec3  aPosition;\n
attribute highp   vec2  aTexCoord;\n
uniform   mediump mat4  uMvpMatrix;\n
uniform   mediump vec3  uSize;\n
varying   mediump vec2  vTexCoord;\n
\n
void main()\n
{\n
  gl_Position = uMvpMatrix * vec4( aPosition*uSize, 1.0 );\n
  vTexCoord = aTexCoord;\n
}\n
);

const char* FRAGMENT_TEXTURE_MESH = MAKE_SHADER(
varying mediump vec2  vTexCoord;\n
uniform lowp    vec4  uColor;\n
uniform sampler2D     sTexture;\n
\n
void main()\n
{\n
  gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
}\n
);

const char* FRAGMENT_BLEND_SHADER = MAKE_SHADER(
varying mediump vec2  vTexCoord;\n
uniform sampler2D sTexture;\n
uniform sampler2D sEffect;\n
uniform mediump float alpha;\n
\n
void main()\n
{\n
  mediump vec4 fragColor = texture2D(sTexture, vTexCoord);\n
  mediump vec4 fxColor   = texture2D(sEffect, vTexCoord);\n
  gl_FragColor = mix(fragColor,fxColor, alpha);\n
}\n
);

}; // anonymous namespace


class NewWindowController : public ConnectionTracker
{
public:
  NewWindowController( Application& app );
  void Create( Application& app );
  void Destroy( Application& app );

  void AddBubbles( Actor& parentActor, const Vector2& stageSize);
  void AddMeshActor( Actor& parentActor );
  void AddBlendingImageActor( Actor& parentActor );
  void AddTextLabel( Actor& parentActor );

  ImageView CreateBlurredMirrorImage(const char* imageName);
  FrameBufferImage CreateFrameBufferForImage( const char* imageName, Property::Map& shaderEffect, const Vector3& rgbDelta );
  void SetUpBubbleEmission( const Vector2& emitPosition, const Vector2& direction );
  Geometry CreateMeshGeometry();
  Dali::Property::Map CreateColorModifierer();

  static void NewWindow(void);

  bool OnTrackTimerTick();
  void OnKeyEvent(const KeyEvent& event);
  bool OnLoseContextButtonClicked( Toolkit::Button button );
  void OnContextLost();
  void OnContextRegained();

private:
  Application                mApplication;
  TextLabel                  mTextActor;

  Toolkit::Control           mView;                              ///< The View instance.
  Toolkit::ToolBar           mToolBar;                           ///< The View's Toolbar.
  TextLabel                  mTitleActor;                        ///< The Toolbar's Title.
  Layer                      mContentLayer;                      ///< Content layer (scrolling cluster content)
  Toolkit::PushButton        mLoseContextButton;

  Toolkit::BubbleEmitter     mEmitter;
  Timer                      mEmitTrackTimer;
  bool                       mNeedNewAnimation;
  unsigned int               mAnimateComponentCount;
  Animation                  mEmitAnimation;
};


NewWindowController::NewWindowController( Application& application )
: mApplication(application),
  mNeedNewAnimation(true)
{
  mApplication.InitSignal().Connect(this, &NewWindowController::Create);
  mApplication.TerminateSignal().Connect(this, &NewWindowController::Destroy);
}

void NewWindowController::Create( Application& app )
{
  Stage stage = Stage::GetCurrent();
  stage.SetBackgroundColor(Color::YELLOW);

  stage.KeyEventSignal().Connect(this, &NewWindowController::OnKeyEvent);

  // The Init signal is received once (only) during the Application lifetime

  // Hide the indicator bar
  mApplication.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );

  mContentLayer = DemoHelper::CreateView( app,
                                          mView,
                                          mToolBar,
                                          "",
                                          TOOLBAR_IMAGE,
                                          "Context recovery" );

  Size stageSize = stage.GetSize();
  Image backgroundImage = ResourceImage::New( BACKGROUND_IMAGE, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
  ImageView backgroundActor = ImageView::New( backgroundImage );
  backgroundActor.SetParentOrigin( ParentOrigin::CENTER );
  mContentLayer.Add(backgroundActor);

  // Point the default render task at the view
  RenderTaskList taskList = stage.GetRenderTaskList();
  RenderTask defaultTask = taskList.GetTask( 0u );
  if ( defaultTask )
  {
    defaultTask.SetSourceActor( mView );
  }

  mLoseContextButton = Toolkit::PushButton::New();
  mLoseContextButton.SetUnselectedImage( LOSE_CONTEXT_IMAGE );
  mLoseContextButton.SetSelectedImage( LOSE_CONTEXT_IMAGE_SELECTED );
  mLoseContextButton.ClickedSignal().Connect( this, &NewWindowController::OnLoseContextButtonClicked );
  mToolBar.AddControl( mLoseContextButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );

  Actor logoLayoutActor = Actor::New();
  logoLayoutActor.SetParentOrigin(ParentOrigin::CENTER);
  logoLayoutActor.SetPosition(0.0f, -200.0f, 0.0f);
  logoLayoutActor.SetScale(0.5f);
  backgroundActor.Add(logoLayoutActor);

  Image image = ResourceImage::New(LOGO_IMAGE);
  ImageView imageView = ImageView::New(image);
  imageView.SetName("daliLogo");
  imageView.SetParentOrigin(ParentOrigin::CENTER);
  imageView.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER);
  logoLayoutActor.Add(imageView);

  ImageView mirrorImageView = CreateBlurredMirrorImage(LOGO_IMAGE);
  mirrorImageView.SetParentOrigin(ParentOrigin::CENTER);
  mirrorImageView.SetAnchorPoint(AnchorPoint::TOP_CENTER);
  logoLayoutActor.Add(mirrorImageView);

  AddBubbles( backgroundActor, stage.GetSize());
  AddMeshActor( backgroundActor );
  AddBlendingImageActor( backgroundActor );
  AddTextLabel( backgroundActor );

  stage.ContextLostSignal().Connect(this, &NewWindowController::OnContextLost);
  stage.ContextRegainedSignal().Connect(this, &NewWindowController::OnContextRegained);
}

void NewWindowController::Destroy( Application& app )
{
  UnparentAndReset(mTextActor);
}

void NewWindowController::AddBubbles( Actor& parentActor, const Vector2& stageSize)
{
  mEmitter = Toolkit::BubbleEmitter::New( stageSize,
                                          ResourceImage::New( DALI_IMAGE_DIR "bubble-ball.png" ),
                                          200, Vector2( 5.0f, 5.0f ) );

  Image background = ResourceImage::New(BACKGROUND_IMAGE);
  mEmitter.SetBackground( background, Vector3(0.5f, 0.f,0.5f) );
  mEmitter.SetBubbleDensity( 9.f );
  Actor bubbleRoot = mEmitter.GetRootActor();
  parentActor.Add( bubbleRoot );
  bubbleRoot.SetParentOrigin(ParentOrigin::CENTER);
  bubbleRoot.SetZ(0.1f);

  mEmitTrackTimer = Timer::New( EMIT_INTERVAL_IN_MS );
  mEmitTrackTimer.TickSignal().Connect(this, &NewWindowController::OnTrackTimerTick);
  mEmitTrackTimer.Start();
}

void NewWindowController::AddMeshActor( Actor& parentActor )
{
  Geometry meshGeometry = CreateMeshGeometry();

  // Create a coloured mesh
  Shader shaderColorMesh = Shader::New( VERTEX_COLOR_MESH, FRAGMENT_COLOR_MESH );
  Material colorMeshmaterial = Material::New( shaderColorMesh );
  Renderer colorMeshRenderer = Renderer::New( meshGeometry, colorMeshmaterial );

  Actor colorMeshActor = Actor::New();
  colorMeshActor.AddRenderer( colorMeshRenderer );
  colorMeshActor.SetSize( 175.f,175.f, 175.f );
  colorMeshActor.SetParentOrigin( ParentOrigin::CENTER );
  colorMeshActor.SetAnchorPoint(AnchorPoint::TOP_CENTER);
  colorMeshActor.SetPosition(Vector3(0.0f, 50.0f, 0.0f));
  colorMeshActor.SetOrientation( Degree(75.f), Vector3::XAXIS );
  colorMeshActor.SetName("ColorMeshActor");

 // Create a textured mesh
  Image effectImage = ResourceImage::New(EFFECT_IMAGE);
  Shader shaderTextureMesh = Shader::New( VERTEX_TEXTURE_MESH, FRAGMENT_TEXTURE_MESH );
  Material textureMeshMaterial = Material::New( shaderTextureMesh );
  textureMeshMaterial.AddTexture(effectImage, "sTexture");
  Renderer textureMeshRenderer = Renderer::New( meshGeometry, textureMeshMaterial );

  Actor textureMeshActor = Actor::New();
  textureMeshActor.AddRenderer( textureMeshRenderer );
  textureMeshActor.SetSize( 175.f,175.f, 175.f );
  textureMeshActor.SetParentOrigin( ParentOrigin::CENTER );
  textureMeshActor.SetAnchorPoint(AnchorPoint::TOP_CENTER);
  textureMeshActor.SetPosition(Vector3(0.0f, 200.0f, 0.0f));
  textureMeshActor.SetOrientation( Degree(75.f), Vector3::XAXIS );
  textureMeshActor.SetName("TextureMeshActor");

  Layer layer3d = Layer::New();
  layer3d.SetParentOrigin( ParentOrigin::CENTER );
  layer3d.SetAnchorPoint( AnchorPoint::CENTER );
  layer3d.SetBehavior(Layer::LAYER_3D);

  layer3d.Add( colorMeshActor );
  layer3d.Add( textureMeshActor );
  parentActor.Add(layer3d);
}

void NewWindowController::AddBlendingImageActor( Actor& parentActor )
{
  Property::Map colorModifier = CreateColorModifierer();

  FrameBufferImage fb2 = CreateFrameBufferForImage( EFFECT_IMAGE, colorModifier, Vector3( 0.5f, 0.5f, 0.5f ) );

  ImageView tmpActor = ImageView::New(fb2);
  parentActor.Add(tmpActor);
  tmpActor.SetParentOrigin(ParentOrigin::CENTER_RIGHT);
  tmpActor.SetAnchorPoint(AnchorPoint::TOP_RIGHT);
  tmpActor.SetPosition(Vector3(0.0f, 150.0f, 0.0f));
  tmpActor.SetScale(0.25f);

  // create blending shader effect
  Property::Map customShader;
  customShader[ "fragmentShader" ] = FRAGMENT_BLEND_SHADER;
  Property::Map map;
  map[ "shader" ] = customShader;

  Image baseImage = ResourceImage::New(BASE_IMAGE);
  ImageView blendActor = ImageView::New( baseImage );
  blendActor.SetProperty( ImageView::Property::IMAGE, map );
  blendActor.RegisterProperty( "alpha", 0.5f );

  blendActor.SetParentOrigin(ParentOrigin::CENTER_RIGHT);
  blendActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
  blendActor.SetPosition(Vector3(0.0f, 100.0f, 0.0f));
  blendActor.SetSize(140, 140);
  parentActor.Add(blendActor);

  blendActor.GetRendererAt(0u).GetMaterial().AddTexture(fb2, "sEffect");
}

void NewWindowController::AddTextLabel( Actor& parentActor )
{
  mTextActor = TextLabel::New("Some text");
  mTextActor.SetParentOrigin(ParentOrigin::CENTER);
  mTextActor.SetColor(Color::RED);
{'fraction_non_alphanumeric': 0.10598963730569948, 'fraction_numerical': 0.013678756476683937, 'mean_word_length': 4.464552661381654, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4927718', 'n_tokens_mistral': 7745, 'n_tokens_neox': 7409, 'n_words': 1551}