/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
// from android_native_app_glue.c
#define TAG "dalidemo"
-#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, TAG, ##__VA_ARGS__))
+#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, TAG, ##__VA_ARGS__))
#ifndef NDEBUG
#define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, TAG, ##__VA_ARGS__))
#else
LOGV("android_main() >>");
std::string filesDir = state->activity->internalDataPath;
- LOGV("filesDir=%s", filesDir.c_str() );
+ LOGV("filesDir=%s", filesDir.c_str());
std::string fontconfigPath = filesDir + "/fonts";
setenv("FONTCONFIG_PATH", fontconfigPath.c_str(), 1);
DaliDemoNativeActivity nativeActivity(state->activity);
- int status = 0;
+ int status = 0;
//dali requires Android 8 or higher
//Android 6+ support loading library directly from apk,
//therefore no need to extract to filesystem first then open by specifying full path
//unless there is need to do profiling, or export libraries so that other packages can use
- std::string libpath = "libdali-demo.so";
+ std::string libpath = "libdali-demo.so";
std::string callParam = nativeActivity.GetIntentStringExtra("start");
if(callParam.empty())
dlerror(); /* Clear any existing error */
int (*main)(int, char**) = (int (*)(int, char**))dlsym(handle, "main");
- LOGV("lib=%s handle=%p main=%p", libpath.c_str(), handle, main );
+ LOGV("lib=%s handle=%p main=%p", libpath.c_str(), handle, main);
if(main)
{
status = main(0, nullptr);
}
else
{
- LOGE("lib %s doesn't have main()", libpath.c_str());
- status = EFAULT;
- std::exit(status);
+ LOGE("lib %s doesn't have main()", libpath.c_str());
+ status = EFAULT;
+ std::exit(status);
}
if(handle)
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali/dali.h>
-#include "shared/view.h"
-#include "generated/animated-shapes-vert.h"
#include "generated/animated-shapes-frag.h"
+#include "generated/animated-shapes-vert.h"
+#include "shared/view.h"
#include <sstream>
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
if(touch.GetState(0) == PointState::UP)
{
- DevelControl::DoAction(mControl, Control::Property::BACKGROUND, DevelArcVisual::Action::UPDATE_PROPERTY,
- Property::Map().Add(DevelArcVisual::Property::START_ANGLE, START_ANGLE_INITIAL_VALUE)
- .Add(DevelArcVisual::Property::SWEEP_ANGLE, SWEEP_ANGLE_INITIAL_VALUE));
+ DevelControl::DoAction(mControl,
+ Control::Property::BACKGROUND,
+ DevelArcVisual::Action::UPDATE_PROPERTY,
+ Property::Map()
+ .Add(DevelArcVisual::Property::START_ANGLE, START_ANGLE_INITIAL_VALUE)
+ .Add(DevelArcVisual::Property::SWEEP_ANGLE, SWEEP_ANGLE_INITIAL_VALUE));
Animation animation = Animation::New(ANIMATION_DURATION);
animation.AnimateTo(DevelControl::GetVisualProperty(mControl, Control::Property::BACKGROUND, DevelArcVisual::Property::START_ANGLE), START_ANGLE_TARGET_VALUE);
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
// INTERNAL INCLUDES
-#include "shared/utility.h"
-#include "generated/benchmark-vert.h"
#include "generated/benchmark-frag.h"
+#include "generated/benchmark-vert.h"
+#include "shared/utility.h"
using namespace Dali;
using namespace Dali::Toolkit;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/table-view/table-view.h>
#include <dali/dali.h>
-#include "shared/view.h"
-#include "generated/bezier-curve-vert.h"
#include "generated/bezier-curve-frag.h"
+#include "generated/bezier-curve-vert.h"
+#include "shared/view.h"
#include <sstream>
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
else
{
const bool result = buf.st_mtime > mLastTime;
- mLastTime = buf.st_mtime;
+ mLastTime = buf.st_mtime;
return result;
}
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
#include "color-transition-controller.h"
-#include "utils.h"
-#include "dali/dali.h"
#include "dali-toolkit/dali-toolkit.h"
-#include "generated/color-transition-controller-composite-vert.h"
+#include "dali/dali.h"
#include "generated/color-transition-controller-composite-frag.h"
+#include "generated/color-transition-controller-composite-vert.h"
+#include "utils.h"
using namespace Dali;
using namespace Dali::Toolkit;
namespace
{
-
const Vector4 BG_COLOR = Vector4(0.f, 0.f, 0.f, 0.f);
-} // nonamespace
+} // namespace
ColorTransitionController::ColorTransitionController(WeakHandle<RenderTaskList> window, Actor content, RenderTaskList tasks, Vector3 initialColor)
: mWeakRenderTasks(window)
auto defaultTask = tasks.GetTask(0);
// create rendertarget and rendertask
- auto rtt = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888,
- static_cast<uint32_t>(contentSize.x), static_cast<uint32_t>(contentSize.y));
+ auto rtt = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, static_cast<uint32_t>(contentSize.x), static_cast<uint32_t>(contentSize.y));
auto fbo = FrameBuffer::New(rtt.GetWidth(), rtt.GetHeight(), FrameBuffer::Attachment::NONE);
fbo.AttachColorTexture(rtt);
CenterActor(composite);
composite.SetProperty(Actor::Property::SIZE, contentSize);
- mPropFlow = composite.RegisterProperty("uFlow", -1.f);
+ mPropFlow = composite.RegisterProperty("uFlow", -1.f);
mPropUvTransform = composite.RegisterProperty("uUvTransform", Vector4(0.f, 0.f, 1.f, 1.f));
- mPropRgb[0] = composite.RegisterProperty("uRgb[0]", initialColor);
- mPropRgb[1] = composite.RegisterProperty("uRgb[1]", Vector3::ONE);
+ mPropRgb[0] = composite.RegisterProperty("uRgb[0]", initialColor);
+ mPropRgb[1] = composite.RegisterProperty("uRgb[1]", Vector3::ONE);
auto geomComposite = CreateQuadGeometry();
ColorTransitionController::~ColorTransitionController()
{
- if (auto renderTasks = mWeakRenderTasks.GetHandle())
+ if(auto renderTasks = mWeakRenderTasks.GetHandle())
{
renderTasks.RemoveTask(mRtCompositor);
}
void ColorTransitionController::SetFlowMap(Texture flowMap)
{
auto renderer = mComposite.GetRendererAt(0);
- auto texSet = renderer.GetTextures();
+ auto texSet = renderer.GetTextures();
texSet.SetTexture(1, flowMap);
}
void ColorTransitionController::SetOnFinished(OnFinished onFinished, void* data)
{
- mOnFinished = onFinished;
+ mOnFinished = onFinished;
mOnFinishedData = data;
}
Vector3 color1 = mComposite.GetProperty(mPropRgb[1]).Get<Vector3>();
mComposite.SetProperty(mPropRgb[0], color1);
- if (mOnFinished)
+ if(mOnFinished)
{
mOnFinished(mOnFinishedData);
}
#ifndef DALI_DEMO_COLOR_TRANSITION_CONTROLLER_H
#define DALI_DEMO_COLOR_TRANSITION_CONTROLLER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
* limitations under the License.
*
*/
-#include "dali/public-api/adaptor-framework/window.h"
-#include "dali/public-api/object/weak-handle.h"
#include "dali/public-api/actors/actor.h"
+#include "dali/public-api/adaptor-framework/window.h"
#include "dali/public-api/animation/animation.h"
-#include "dali/public-api/rendering/texture.h"
-#include "dali/public-api/render-tasks/render-task.h"
+#include "dali/public-api/object/weak-handle.h"
#include "dali/public-api/render-tasks/render-task-list.h"
+#include "dali/public-api/render-tasks/render-task.h"
+#include "dali/public-api/rendering/texture.h"
-class ColorTransitionController: public Dali::ConnectionTracker
+class ColorTransitionController : public Dali::ConnectionTracker
{
public:
- using OnFinished = void(*)(void*);
+ using OnFinished = void (*)(void*);
ColorTransitionController(Dali::WeakHandle<Dali::RenderTaskList> renderTasks, Dali::Actor content, Dali::RenderTaskList tasks, Dali::Vector3 initialColor);
~ColorTransitionController();
private:
void OnTransitionFinished(Dali::Animation& anim);
- Dali::Actor mComposite;
+ Dali::Actor mComposite;
Dali::Property::Index mPropFlow;
Dali::Property::Index mPropUvTransform;
Dali::Property::Index mPropRgb[2];
Dali::Animation mAnimation;
- OnFinished mOnFinished = nullptr;
- void* mOnFinishedData = nullptr;
+ OnFinished mOnFinished = nullptr;
+ void* mOnFinishedData = nullptr;
Dali::WeakHandle<Dali::RenderTaskList> mWeakRenderTasks;
};
* limitations under the License.
*
*/
-#include "utils.h"
#include "color-transition-controller.h"
-#include "dali/dali.h"
#include "dali-toolkit/dali-toolkit.h"
+#include "dali/dali.h"
+#include "utils.h"
using namespace Dali;
using namespace Dali::Toolkit;
{
const float TRANSITION_DURATION = 1.f;
-const Vector3 INITIAL_COLOR{ 1.f, 1.f, .25f };
+const Vector3 INITIAL_COLOR{1.f, 1.f, .25f};
const char* const FLOW_MAPS[] = {
"circular",
"radial",
"swipe",
"bubbles",
- "image"
-};
+ "image"};
Texture LoadTexture(const std::string& path)
{
PixelData pixelData = SyncImageLoader::Load(path);
- Texture texture = Texture::New(TextureType::TEXTURE_2D, pixelData.GetPixelFormat(),
- pixelData.GetWidth(), pixelData.GetHeight());
+ Texture texture = Texture::New(TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight());
texture.Upload(pixelData);
return texture;
}
return tl;
}
-}
+} // namespace
/**
* Demonstrates colour transition using flow maps and uv rotation / scaling.
* - Double-tap outside the middle of screen: transition using one of the
* effects (flow maps) mapped to the given segment of the screen;
*/
-class ColorTransition: public ConnectionTracker
+class ColorTransition : public ConnectionTracker
{
public:
ColorTransition(Application& app)
void OnInit(Application& app)
{
- auto window = mApp.GetWindow();
- auto windowSize = Vector2{ window.GetSize() };
+ auto window = mApp.GetWindow();
+ auto windowSize = Vector2{window.GetSize()};
// create content root
Actor content = Actor::New();
window.Add(mainRoot);
mMainRoot = mainRoot;
- auto renderTasks = window.GetRenderTaskList();
+ auto renderTasks = window.GetRenderTaskList();
auto weakRenderTasks = WeakHandle<RenderTaskList>(renderTasks);
- auto controller = new ColorTransitionController(weakRenderTasks, content, window.GetRenderTaskList(), INITIAL_COLOR);
+ auto controller = new ColorTransitionController(weakRenderTasks, content, window.GetRenderTaskList(), INITIAL_COLOR);
mController.reset(controller);
mainRoot.Add(mController->GetComposite());
void OnKeyEvent(const KeyEvent& event)
{
- if (event.GetState() == KeyEvent::DOWN)
+ if(event.GetState() == KeyEvent::DOWN)
{
- if (IsKey(event, DALI_KEY_ESCAPE) || IsKey(event, DALI_KEY_BACK))
+ if(IsKey(event, DALI_KEY_ESCAPE) || IsKey(event, DALI_KEY_BACK))
{
mApp.Quit();
}
void OnDoubleTap(Actor /*actor*/, const TapGesture& tap)
{
- auto window = mApp.GetWindow();
- auto windowSize = Vector2{ window.GetSize() };
- Vector2 clip = tap.GetScreenPoint() / windowSize - Vector2::ONE * .5f; // [-.5, .5]
- if (clip.Length() < .333f * .5f)
+ auto window = mApp.GetWindow();
+ auto windowSize = Vector2{window.GetSize()};
+ Vector2 clip = tap.GetScreenPoint() / windowSize - Vector2::ONE * .5f; // [-.5, .5]
+ if(clip.Length() < .333f * .5f)
{
LoadFlowMap(FLOW_MAPS[rand() % std::extent<decltype(FLOW_MAPS)>::value]);
}
else
{
float theta = fmodf((atan2(clip.y, clip.x) + M_PI) / (M_PI * 2.) + .75f, 1.f);
- int i = std::extent<decltype(FLOW_MAPS)>::value * theta;
+ int i = std::extent<decltype(FLOW_MAPS)>::value * theta;
LoadFlowMap(FLOW_MAPS[i]);
}
void LoadFlowMap(const char* const name)
{
DALI_ASSERT_DEBUG(name && "Flow map name must be given");
- if (mLastFlowMap != name)
+ if(mLastFlowMap != name)
{
- std::string flowMapDir = Application::GetResourcePath() + "images/color-transition/";
+ std::string flowMapDir = Application::GetResourcePath() + "images/color-transition/";
std::string flowMapPath = flowMapDir + name + ".png";
- auto flowMap = LoadTexture(flowMapPath);
+ auto flowMap = LoadTexture(flowMapPath);
DALI_ASSERT_DEBUG(flowMap && "Failed to load flow map.");
mController->SetFlowMap(flowMap);
}
void RandomizeUvTransform()
{
- mController->SetUvTransform((rand() % 12) * M_PI / 12., 1.f,
- (rand() % 12) * M_PI / 12., .5f);
+ mController->SetUvTransform((rand() % 12) * M_PI / 12., 1.f, (rand() % 12) * M_PI / 12., .5f);
}
void OnTransitionFinished()
{
auto app = Application::New(&argc, &argv
#ifdef WIN32
- , ".//dali-toolkit-default-theme.json"
+ ,
+ ".//dali-toolkit-default-theme.json"
#endif
);
ColorTransition ct(app);
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
#include "utils.h"
-#include <cstdio>
#include <cstdarg>
+#include <cstdio>
#include <cmath>
};
Vertex vertexData[] = {
- { Vector3(-.5f, .5f, .0f) },
- { Vector3(.5f, .5f, .0f) },
- { Vector3(-.5f, -.5f, .0f) },
- { Vector3(.5f, -.5f, .0f) },
+ {Vector3(-.5f, .5f, .0f)},
+ {Vector3(.5f, .5f, .0f)},
+ {Vector3(-.5f, -.5f, .0f)},
+ {Vector3(.5f, -.5f, .0f)},
};
VertexBuffer vertexBuffer = VertexBuffer::New(Property::Map()
- .Add("aPosition", Property::VECTOR3));
+ .Add("aPosition", Property::VECTOR3));
vertexBuffer.SetData(vertexData, std::extent<decltype(vertexData)>::value);
Geometry geometry = Geometry::New();
{
Renderer renderer = Renderer::New(geometry, shader);
renderer.SetProperty(Renderer::Property::BLEND_MODE,
- (options & RendererOptions::BLEND) ? BlendMode::ON : BlendMode::OFF);
+ (options & RendererOptions::BLEND) ? BlendMode::ON : BlendMode::OFF);
renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE,
- (options & RendererOptions::DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF);
+ (options & RendererOptions::DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF);
renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE,
- (options & RendererOptions::DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF);
+ (options & RendererOptions::DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF);
int faceCulling = (((options & RendererOptions::CULL_BACK) != 0) << 1) |
- ((options & RendererOptions::CULL_FRONT) != 0);
+ ((options & RendererOptions::CULL_FRONT) != 0);
renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, faceCulling);
- if (!textures)
+ if(!textures)
{
textures = TextureSet::New();
}
actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
}
-
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include "dali/public-api/rendering/renderer.h"
#include "dali/public-api/rendering/texture.h"
-#define ACTOR_DECL(x) auto x = Dali::Actor::New(); x.SetProperty(Actor::Property::NAME, #x);
+#define ACTOR_DECL(x) \
+ auto x = Dali::Actor::New(); \
+ x.SetProperty(Actor::Property::NAME, #x);
/**
* @brief Creates a unit quad centered on the origin (i.e. vertex positions
{
enum
{
- NONE = 0x0,
- BLEND = 0x01,
- DEPTH_TEST = 0x02,
+ NONE = 0x0,
+ BLEND = 0x01,
+ DEPTH_TEST = 0x02,
DEPTH_WRITE = 0x04,
- CULL_BACK = 0x08,
- CULL_FRONT = 0x10,
+ CULL_BACK = 0x08,
+ CULL_FRONT = 0x10,
};
};
///@note If textures is not a valid handle, an empty texture set will be created.
Dali::Renderer CreateRenderer(
Dali::TextureSet textures,
- Dali::Geometry geometry,
- Dali::Shader shader,
- uint32_t options = RendererOptions::NONE);
+ Dali::Geometry geometry,
+ Dali::Shader shader,
+ uint32_t options = RendererOptions::NONE);
///@brief Sets @a actor's anchor point and parent origin to center.
void CenterActor(Dali::Actor actor);
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
const char* IMAGE_FILE(DEMO_IMAGE_DIR "gallery-medium-1.jpg");
-const float BLUR_RADIUS_VALUE(15.0f);
+const float BLUR_RADIUS_VALUE(15.0f);
const Vector2 BLUR_OFFSET_VALUE(0.05f, 0.05f);
const Vector2 BLUR_SIZE_VALUE(1.1f, 1.1f);
const Vector2 NO_BLUR_SIZE_VALUE(1.05f, 1.05f);
-const float ANIMATION_DURATION(2.0f);
+const float ANIMATION_DURATION(2.0f);
const Property::Value SHADOW{
{Visual::Property::TYPE, Visual::COLOR},
{Visual::Property::MIX_COLOR, Vector4(0.0f, 0.0f, 0.0f, 0.5f)},
- {Visual::Property::TRANSFORM, Property::Map{{Visual::Transform::Property::SIZE, NO_BLUR_SIZE_VALUE},
- {Visual::Transform::Property::ORIGIN, Align::CENTER},
- {Visual::Transform::Property::ANCHOR_POINT, Align::CENTER}}}};
+ {Visual::Property::TRANSFORM,
+ Property::Map{{Visual::Transform::Property::SIZE, NO_BLUR_SIZE_VALUE},
+ {Visual::Transform::Property::ORIGIN, Align::CENTER},
+ {Visual::Transform::Property::ANCHOR_POINT, Align::CENTER}}}};
} // namespace
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/dali.h>
// INTERNAL INCLUDES
-#include "shared/utility.h"
-#include "generated/compressed-texture-formats-example-vert.h"
#include "generated/compressed-texture-formats-example-frag.h"
+#include "generated/compressed-texture-formats-example-vert.h"
+#include "shared/utility.h"
using namespace Dali;
using Dali::Toolkit::TextLabel;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
// INTERNAL INCLUDES
-#include "generated/clipped-image-vert.h"
#include "generated/clipped-image-frag.h"
+#include "generated/clipped-image-vert.h"
namespace ClippedImage
{
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include "dali/public-api/actors/actor.h"
#include "dali/public-api/rendering/renderer.h"
-#include "generated/deferred-shading-mainpass-vert.h"
#include "generated/deferred-shading-mainpass-frag.h"
-#include "generated/deferred-shading-prepass-vert.h"
+#include "generated/deferred-shading-mainpass-vert.h"
#include "generated/deferred-shading-prepass-frag.h"
+#include "generated/deferred-shading-prepass-vert.h"
using namespace Dali;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include "game-model.h"
#include "game-texture.h"
-#include "generated/game-renderer-vert.h"
#include "generated/game-renderer-frag.h"
+#include "generated/game-renderer-vert.h"
#include <dali/dali.h>
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
const char* StringFromScalingMode(FittingMode::Type scalingMode)
{
- return scalingMode == FittingMode::SCALE_TO_FILL ? "SCALE_TO_FILL" : scalingMode == FittingMode::SHRINK_TO_FIT ? "SHRINK_TO_FIT" : scalingMode == FittingMode::FIT_WIDTH ? "FIT_WIDTH" : scalingMode == FittingMode::FIT_HEIGHT ? "FIT_HEIGHT" : "UnknownScalingMode";
+ return scalingMode == FittingMode::SCALE_TO_FILL ? "SCALE_TO_FILL" : scalingMode == FittingMode::SHRINK_TO_FIT ? "SHRINK_TO_FIT"
+ : scalingMode == FittingMode::FIT_WIDTH ? "FIT_WIDTH"
+ : scalingMode == FittingMode::FIT_HEIGHT ? "FIT_HEIGHT"
+ : "UnknownScalingMode";
}
const char* StringFromFilterMode(SamplingMode::Type filterMode)
{
- return filterMode == SamplingMode::BOX ? "BOX" : filterMode == SamplingMode::BOX_THEN_NEAREST ? "BOX_THEN_NEAREST" : filterMode == SamplingMode::BOX_THEN_LINEAR ? "BOX_THEN_LINEAR" : filterMode == SamplingMode::NEAREST ? "NEAREST" : filterMode == SamplingMode::LINEAR ? "LINEAR" : filterMode == SamplingMode::NO_FILTER ? "NO_FILTER" : filterMode == SamplingMode::DONT_CARE ? "DONT_CARE" : "UnknownFilterMode";
+ return filterMode == SamplingMode::BOX ? "BOX" : filterMode == SamplingMode::BOX_THEN_NEAREST ? "BOX_THEN_NEAREST"
+ : filterMode == SamplingMode::BOX_THEN_LINEAR ? "BOX_THEN_LINEAR"
+ : filterMode == SamplingMode::NEAREST ? "NEAREST"
+ : filterMode == SamplingMode::LINEAR ? "LINEAR"
+ : filterMode == SamplingMode::NO_FILTER ? "NO_FILTER"
+ : filterMode == SamplingMode::DONT_CARE ? "DONT_CARE"
+ : "UnknownFilterMode";
}
} // namespace
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
mFittingModes[id] = newMode;
- SetTitle(std::string(newMode == FittingMode::SHRINK_TO_FIT ? "SHRINK_TO_FIT" : newMode == FittingMode::SCALE_TO_FILL ? "SCALE_TO_FILL" : newMode == FittingMode::FIT_WIDTH ? "FIT_WIDTH" : "FIT_HEIGHT"));
+ SetTitle(std::string(newMode == FittingMode::SHRINK_TO_FIT ? "SHRINK_TO_FIT" : newMode == FittingMode::SCALE_TO_FILL ? "SCALE_TO_FILL"
+ : newMode == FittingMode::FIT_WIDTH ? "FIT_WIDTH"
+ : "FIT_HEIGHT"));
}
}
return true;
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/image-loader/texture-manager.h>
-#include "shared/view.h"
#include "generated/image-view-url-frag.h"
+#include "shared/view.h"
using namespace Dali;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/devel-api/actors/actor-devel.h>
// INTERNAL INCLUDES
-#include "shared/view.h"
-#include "generated/line-mesh-vert.h"
#include "generated/line-mesh-frag.h"
+#include "generated/line-mesh-vert.h"
+#include "shared/view.h"
#include <sstream>
namespace
{
-
const unsigned short INDEX_LINES[] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 0};
const unsigned short INDEX_LOOP[] = {0, 1, 2, 3, 4};
const unsigned short INDEX_STRIP[] = {0, 1, 2, 3, 4, 0};
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/devel-api/actors/actor-devel.h>
// INTERNAL INCLUDES
-#include "shared/view.h"
-#include "generated/mesh-morph-vert.h"
#include "generated/mesh-morph-frag.h"
+#include "generated/mesh-morph-vert.h"
+#include "shared/view.h"
using namespace Dali;
namespace
{
-
Geometry CreateGeometry()
{
// Create vertices
{
//Calculate displacement and corresponding rotation.
const Vector2 touchPosition = touch.GetScreenPosition(0);
- const Vector2 displacement = touchPosition - mLastTouchPosition;
- mLastTouchPosition = touchPosition;
+ const Vector2 displacement = touchPosition - mLastTouchPosition;
+ mLastTouchPosition = touchPosition;
const Quaternion q(Radian(displacement.y / -Y_ROTATION_DISPLACEMENT_FACTOR), Radian(displacement.x / X_ROTATION_DISPLACEMENT_FACTOR), Radian(0.f));
const Quaternion q0 = mModels[mSelectedModelIndex].control.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/public-api/rendering/texture.h>
// INTERNAL INCLUDES
-#include "shared/utility.h" // DemoHelper::LoadTexture
-#include "generated/metaball-vert.h"
#include "generated/metaball-frag.h"
#include "generated/metaball-refraction-frag.h"
+#include "generated/metaball-vert.h"
+#include "shared/utility.h" // DemoHelper::LoadTexture
using namespace Dali;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/public-api/rendering/texture.h>
// INTERNAL INCLUDES
-#include "shared/utility.h" // DemoHelper::LoadTexture
-#include "generated/metaball-vert.h"
+#include "generated/fragment-frag.h"
#include "generated/metaball-frag.h"
#include "generated/metaball-refraction-frag.h"
-#include "generated/fragment-frag.h"
+#include "generated/metaball-vert.h"
+#include "shared/utility.h" // DemoHelper::LoadTexture
using namespace Dali;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstring>
// INTERNAL INCLUDES
-#include "shared/utility.h"
-#include "generated/native-image-source-texture-vert.h"
#include "generated/native-image-source-texture-frag.h"
+#include "generated/native-image-source-texture-vert.h"
+#include "shared/utility.h"
using namespace Dali;
using namespace Toolkit;
#ifndef PARTICLES_FLOAT_RAND_H_
#define PARTICLES_FLOAT_RAND_H_
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
struct FloatRand
{
- std::random_device mDevice;
- std::mt19937 mMersenneTwister;
+ std::random_device mDevice;
+ std::mt19937 mMersenneTwister;
std::uniform_real_distribution<float> mDistribution;
FloatRand()
: mMersenneTwister(mDevice()),
mDistribution(0., 1.)
- {}
+ {
+ }
float operator()()
{
#ifndef PARTICLES_PARTICLE_FIELD_H_
#define PARTICLES_PARTICLE_FIELD_H_
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
* limitations under the License.
*
*/
-#include "utils.h"
-#include "float-rand.h"
+#include <vector>
#include "dali/public-api/math/vector2.h"
#include "dali/public-api/math/vector3.h"
#include "dali/public-api/math/vector4.h"
#include "dali/public-api/rendering/geometry.h"
-#include <vector>
+#include "float-rand.h"
+#include "utils.h"
struct ParticleField
{
- float mSize;
+ float mSize;
Dali::Vector3 mBoxSize;
Dali::Vector3 mParticlesPerAxis;
- float mSizeVariance;
- float mNoiseAmount; // affects color, motion (phase), twinkle (frequency, phase, size, opacity),
- float mDisperse;
- float mMotionScale;
- float mMotionCycleLength; // seconds
- float mTwinkleFrequency; // per motion cycle
- float mTwinkleSizeScale;
- float mTwinkleOpacityWeight;
+ float mSizeVariance;
+ float mNoiseAmount; // affects color, motion (phase), twinkle (frequency, phase, size, opacity),
+ float mDisperse;
+ float mMotionScale;
+ float mMotionCycleLength; // seconds
+ float mTwinkleFrequency; // per motion cycle
+ float mTwinkleSizeScale;
+ float mTwinkleOpacityWeight;
Dali::Vector3 GetParticlesPerAxisSafe() const
{
using namespace Dali;
return Vector3(std::max(1.f, FastFloor(mParticlesPerAxis.x)),
- std::max(1.f, FastFloor(mParticlesPerAxis.y)),
- std::max(1.f, FastFloor(mParticlesPerAxis.z)));
+ std::max(1.f, FastFloor(mParticlesPerAxis.y)),
+ std::max(1.f, FastFloor(mParticlesPerAxis.z)));
}
Dali::Geometry MakeGeometry() const
struct Vertex
{
Vector3 aPosition;
- float aSeed;
+ float aSeed;
Vector4 aPath;
Vector2 aSubPosition;
- float aSize;
+ float aSize;
};
- const int numPatternVertices = 6;
- Vector2 vertexPattern[numPatternVertices] = {
+ const int numPatternVertices = 6;
+ Vector2 vertexPattern[numPatternVertices] = {
Vector2(-1.f, 1.f),
Vector2(-1.f, -1.f),
Vector2(1.f, 1.f),
};
Vector3 particlesPerAxis = GetParticlesPerAxisSafe();
- auto numParticles = particlesPerAxis.x * particlesPerAxis.y * particlesPerAxis.z;
+ auto numParticles = particlesPerAxis.x * particlesPerAxis.y * particlesPerAxis.z;
std::vector<Vertex> vertices;
vertices.reserve(numParticles * numPatternVertices);
Vector3 invBoxSize(1. / std::max(mBoxSize.x, 1.f),
- 1. / std::max(mBoxSize.y, 1.f),
- 1. / std::max(mBoxSize.z, 1.f));
+ 1. / std::max(mBoxSize.y, 1.f),
+ 1. / std::max(mBoxSize.z, 1.f));
Vector3 spacing(mBoxSize.x / particlesPerAxis.x,
- mBoxSize.y / particlesPerAxis.y,
- mBoxSize.z / particlesPerAxis.z);
- auto offset = (mBoxSize - spacing) * .5;
- int nx = particlesPerAxis.x;
- int ny = particlesPerAxis.y;
- int nxy = nx * ny;
- for (size_t i = 0; i < numParticles; ++i)
+ mBoxSize.y / particlesPerAxis.y,
+ mBoxSize.z / particlesPerAxis.z);
+ auto offset = (mBoxSize - spacing) * .5;
+ int nx = particlesPerAxis.x;
+ int ny = particlesPerAxis.y;
+ int nxy = nx * ny;
+ for(size_t i = 0; i < numParticles; ++i)
{
Vertex v;
- float x = float(i % nx);
- float y = float((i / nx) % ny);
- float z = float(i / nxy);
+ float x = float(i % nx);
+ float y = float((i / nx) % ny);
+ float z = float(i / nxy);
v.aPosition = Vector3(x, y, z) * spacing - offset;
Vector3 disperseDir(frandDisperse() - .5, frandDisperse() - .5, frandDisperse() - .5);
v.aPath = Vector4(frandPath() - .5, frandPath() - .5, frandPath() - .5, frandPath() - .5) * mMotionScale;
const float size = mSize * ((1.f + (frandSize() - .5) * mSizeVariance) * .5f);
- for (int j = 0; j < numPatternVertices; ++j)
+ for(int j = 0; j < numPatternVertices; ++j)
{
v.aSubPosition = vertexPattern[j];
- v.aSize = size;
+ v.aSize = size;
vertices.push_back(v);
}
}
- VertexBuffer vertexBuffer = VertexBuffer::New( Property::Map()
- .Add( "aPosition", Property::VECTOR3 )
- .Add( "aSeed", Property::FLOAT )
- .Add( "aPath", Property::VECTOR4 )
- .Add( "aSubPosition", Property::VECTOR2 )
- .Add( "aSize", Property::FLOAT )
- );
- vertexBuffer.SetData( vertices.data(), vertices.size() );
+ VertexBuffer vertexBuffer = VertexBuffer::New(Property::Map()
+ .Add("aPosition", Property::VECTOR3)
+ .Add("aSeed", Property::FLOAT)
+ .Add("aPath", Property::VECTOR4)
+ .Add("aSubPosition", Property::VECTOR2)
+ .Add("aSize", Property::FLOAT));
+ vertexBuffer.SetData(vertices.data(), vertices.size());
Geometry geometry = Geometry::New();
- geometry.AddVertexBuffer( vertexBuffer );
- geometry.SetType( Geometry::TRIANGLES );
+ geometry.AddVertexBuffer(vertexBuffer);
+ geometry.SetType(Geometry::TRIANGLES);
return geometry;
}
};
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
#include "particle-view.h"
-#include "utils.h"
#include "dali/public-api/animation/constraints.h"
+#include "utils.h"
-#include "generated/particle-view-vert.h"
#include "generated/particle-view-frag.h"
-#include "generated/particle-view-simple-vert.h"
#include "generated/particle-view-simple-frag.h"
+#include "generated/particle-view-simple-vert.h"
+#include "generated/particle-view-vert.h"
//#define ENABLE_DEBUG_VOLUME
namespace
{
-
const uint32_t POPULATION_GRANULARITY = 128;
uint32_t GetSkipValue(uint32_t count, uint32_t prime)
do
{
skip = (rand() % prime) * count * count + (rand() % prime) * count + (rand() % prime);
- }
- while (skip % prime == 0);
+ } while(skip % prime == 0);
return skip;
}
-}
+} // namespace
-ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali::CameraActor camera,
- Dali::Geometry particleGeom)
+ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali::CameraActor camera, Dali::Geometry particleGeom)
: mWorld(world),
mParticleBoxSize(field.mBoxSize)
{
- if (!particleGeom)
+ if(!particleGeom)
{
// create particles
particleGeom = field.MakeGeometry();
// create shader
Shader particleShader = Shader::New(SHADER_PARTICLE_VIEW_VERT, SHADER_PARTICLE_VIEW_FRAG, Shader::Hint::MODIFIES_GEOMETRY);
- float zNear = camera.GetNearClippingPlane();
- float zFar = camera.GetFarClippingPlane();
+ float zNear = camera.GetNearClippingPlane();
+ float zFar = camera.GetFarClippingPlane();
const Vector2 depthRange(zNear, 1.f / (zFar - zNear));
particleShader.RegisterProperty("uDepthRange", depthRange);
particleShader.RegisterProperty("uTwinkleSizeScale", field.mTwinkleSizeScale);
particleShader.RegisterProperty("uTwinkleOpacityWeight", field.mTwinkleOpacityWeight);
- mPropPopulation = particleShader.RegisterProperty("uPopulation", 1.f);
- mPropFocalLength = particleShader.RegisterProperty("uFocalLength", .5f);
- mPropAperture = particleShader.RegisterProperty("uAperture", 8.f);
+ mPropPopulation = particleShader.RegisterProperty("uPopulation", 1.f);
+ mPropFocalLength = particleShader.RegisterProperty("uFocalLength", .5f);
+ mPropAperture = particleShader.RegisterProperty("uAperture", 8.f);
mPropAlphaTestRefValue = particleShader.RegisterProperty("uAlphaTestRefValue", 0.f);
- mPropFadeRange = particleShader.RegisterProperty("uFadeRange", Vector2(0.f, 1.f));
+ mPropFadeRange = particleShader.RegisterProperty("uFadeRange", Vector2(0.f, 1.f));
// scatter variables
- char nameBuffer[64];
+ char nameBuffer[64];
char* writep = nameBuffer + snprintf(nameBuffer, sizeof(nameBuffer), "uScatter[");
- for (uint32_t i = 0; i < std::extent<decltype(mScatterProps)>::value; ++i)
+ for(uint32_t i = 0; i < std::extent<decltype(mScatterProps)>::value; ++i)
{
char* writep2 = writep + snprintf(writep, sizeof(nameBuffer) - std::distance(nameBuffer, writep), "%d].", i);
// Our particle mesh is sorted in Z; changing the population should remove
// particles "randomly", not from one end.
// Algorithm described in Mike McShaffry & al: Game Coding Complete.
- const uint32_t prime = 131; // next prime after POPULATION_GRANULARITY
- const uint32_t skip = GetSkipValue(POPULATION_GRANULARITY, prime);
- uint32_t next = 0;
+ const uint32_t prime = 131; // next prime after POPULATION_GRANULARITY
+ const uint32_t skip = GetSkipValue(POPULATION_GRANULARITY, prime);
+ uint32_t next = 0;
writep = nameBuffer + snprintf(nameBuffer, sizeof(nameBuffer), "uOrderLookUp[");
- for (uint32_t i = 0; i < POPULATION_GRANULARITY; ++i)
+ for(uint32_t i = 0; i < POPULATION_GRANULARITY; ++i)
{
- do {
+ do
+ {
next += skip;
next %= prime;
- }
- while (next == 0 || next > POPULATION_GRANULARITY);
+ } while(next == 0 || next > POPULATION_GRANULARITY);
snprintf(writep, sizeof(nameBuffer) - std::distance(nameBuffer, writep), "%d]", i);
particleShader.RegisterProperty(nameBuffer, float(next - 1));
mParticleShader = particleShader;
- auto renderer = CreateRenderer(TextureSet::New(), particleGeom, particleShader, OPTION_BLEND);
+ auto renderer = CreateRenderer(TextureSet::New(), particleGeom, particleShader, OPTION_BLEND);
auto masterParticles = CreateActor();
masterParticles.SetProperty(Actor::Property::SIZE, field.mBoxSize);
masterParticles.SetProperty(Actor::Property::VISIBLE, true);
#ifdef ENABLE_DEBUG_VOLUME
Geometry cubeGeom = CreateCuboidWireframeGeometry();
- renderer = CreateRenderer(renderer.GetTextures(), cubeGeom, Shader::New(SHADER_PARTICLE_VIEW_SIMPLE_VERT, SHADER_PARTICLE_VIEW_SIMPLE_FRAG));
+ renderer = CreateRenderer(renderer.GetTextures(), cubeGeom, Shader::New(SHADER_PARTICLE_VIEW_SIMPLE_VERT, SHADER_PARTICLE_VIEW_SIMPLE_FRAG));
masterParticles.AddRenderer(renderer);
#endif
UnparentAndReset(mMasterParticles);
UnparentAndReset(mSlaveParticles);
- for (auto anim: { mAngularAnim, mLinearAnim })
+ for(auto anim : {mAngularAnim, mLinearAnim})
{
- if (anim)
+ if(anim)
{
anim.Stop();
anim.Reset();
}
}
- for (auto& s: mScatterProps)
+ for(auto& s : mScatterProps)
{
auto& anim = s.mAnim;
- if (anim)
+ if(anim)
{
anim.Stop();
anim.Reset();
void ParticleView::SetAngularVelocity(float v)
{
- if (mAngularAnim)
+ if(mAngularAnim)
{
mAngularAnim.Stop();
mAngularAnim.Clear();
mAngularAnim.Reset();
}
- if (v * v > .0f)
+ if(v * v > .0f)
{
float sign = Sign(v);
- auto anim = Animation::New(std::abs(2. * M_PI / v));
+ auto anim = Animation::New(std::abs(2. * M_PI / v));
anim.AnimateTo(Property(mMasterParticles, Actor::Property::ORIENTATION),
- Quaternion(Radian(Degree(120. * sign)), Vector3::ZAXIS), TimePeriod(0., anim.GetDuration() / 3.));
+ Quaternion(Radian(Degree(120. * sign)), Vector3::ZAXIS),
+ TimePeriod(0., anim.GetDuration() / 3.));
anim.AnimateTo(Property(mMasterParticles, Actor::Property::ORIENTATION),
- Quaternion(Radian(Degree(240. * sign)), Vector3::ZAXIS), TimePeriod(anim.GetDuration() / 3., anim.GetDuration() / 3.));
+ Quaternion(Radian(Degree(240. * sign)), Vector3::ZAXIS),
+ TimePeriod(anim.GetDuration() / 3., anim.GetDuration() / 3.));
anim.AnimateTo(Property(mMasterParticles, Actor::Property::ORIENTATION),
- Quaternion(Radian(Degree(360. * sign)), Vector3::ZAXIS), TimePeriod(2. * anim.GetDuration() / 3., anim.GetDuration() / 3.));
+ Quaternion(Radian(Degree(360. * sign)), Vector3::ZAXIS),
+ TimePeriod(2. * anim.GetDuration() / 3., anim.GetDuration() / 3.));
anim.SetLoopCount(0);
anim.Play();
void ParticleView::SetLinearVelocity(float v)
{
- if (mLinearAnim)
+ if(mLinearAnim)
{
mLinearAnim.Stop();
mLinearAnim.Clear();
}
UnparentAndReset(mSlaveParticles);
- if (v * v > .0f)
+ if(v * v > .0f)
{
- float sign = Sign(v);
+ float sign = Sign(v);
float directedSize = sign * mParticleBoxSize.z;
- Actor slaveParticles = CloneActor(mMasterParticles);
- Vector3 position = mMasterParticles.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>();
+ Actor slaveParticles = CloneActor(mMasterParticles);
+ Vector3 position = mMasterParticles.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>();
slaveParticles.SetProperty(Actor::Property::POSITION, position + Vector3(0., 0., directedSize));
auto propSecondaryColor = slaveParticles.RegisterProperty("uSecondaryColor", Vector3::XAXIS);
Actor world = mWorld.GetHandle();
world.Add(slaveParticles);
- if (sign < 0.) // fix draw order
+ if(sign < 0.) // fix draw order
{
world.Remove(mMasterParticles);
world.Add(mMasterParticles);
}
- Constraint constraint = Constraint::New<Vector4>(slaveParticles, Actor::Property::COLOR,
- EqualToConstraint());
+ Constraint constraint = Constraint::New<Vector4>(slaveParticles, Actor::Property::COLOR, EqualToConstraint());
constraint.AddSource(Source(mMasterParticles, Actor::Property::COLOR));
constraint.Apply();
- constraint = Constraint::New<Vector3>(slaveParticles, propSecondaryColor,
- EqualToConstraint());
+ constraint = Constraint::New<Vector3>(slaveParticles, propSecondaryColor, EqualToConstraint());
constraint.AddSource(Source(mMasterParticles, mPropSecondaryColor));
constraint.Apply();
- constraint = Constraint::New<Quaternion>(slaveParticles, Actor::Property::ORIENTATION,
- EqualToConstraint());
+ constraint = Constraint::New<Quaternion>(slaveParticles, Actor::Property::ORIENTATION, EqualToConstraint());
constraint.AddSource(Source(mMasterParticles, Actor::Property::ORIENTATION));
constraint.Apply();
anim.SetLoopCount(0);
anim.Play();
- mLinearAnim = anim;
+ mLinearAnim = anim;
mSlaveParticles = slaveParticles;
}
}
mActiveScatter = (mActiveScatter + 1) % std::extent<decltype(mScatterProps)>::value;
auto& scatter = mScatterProps[mActiveScatter];
- if (scatter.mAnim)
+ if(scatter.mAnim)
{
scatter.mAnim.Stop();
}
radius *= radius;
mParticleShader.SetProperty(scatter.mPropRadius, radius);
- Animation anim = Animation::New(durationOut + durationIn);
- auto scatterAmount = Property(mParticleShader, scatter.mPropAmount);
- anim.AnimateTo(scatterAmount, amount, AlphaFunction::EASE_OUT,
- TimePeriod(0.f, durationOut));
- anim.AnimateTo(scatterAmount, 0.f, AlphaFunction::EASE_IN_OUT_SINE,
- TimePeriod(durationOut, durationIn));
+ Animation anim = Animation::New(durationOut + durationIn);
+ auto scatterAmount = Property(mParticleShader, scatter.mPropAmount);
+ anim.AnimateTo(scatterAmount, amount, AlphaFunction::EASE_OUT, TimePeriod(0.f, durationOut));
+ anim.AnimateTo(scatterAmount, 0.f, AlphaFunction::EASE_IN_OUT_SINE, TimePeriod(durationOut, durationIn));
anim.Play();
scatter.mAnim = anim;
void ParticleView::SetScatterRay(Dali::Vector3 rayDir)
{
auto& scatter = mScatterProps[mActiveScatter];
- mParticleShader.SetProperty(scatter.mPropRay, rayDir);;
+ mParticleShader.SetProperty(scatter.mPropRay, rayDir);
+ ;
}
-void ParticleView::Fade(float duration, float target, AlphaFunction alphaFn,
- std::function<void(Dali::Animation&)> onFinished)
+void ParticleView::Fade(float duration, float target, AlphaFunction alphaFn, std::function<void(Dali::Animation&)> onFinished)
{
- if (mFadeAnim)
+ if(mFadeAnim)
{
mFadeAnim.Stop();
}
Animation anim = Animation::New(duration);
anim.AnimateTo(Property(mMasterParticles, Actor::Property::COLOR_ALPHA), target, alphaFn);
- if (mSlaveParticles)
+ if(mSlaveParticles)
{
anim.AnimateTo(Property(mSlaveParticles, Actor::Property::COLOR_ALPHA), target, alphaFn);
}
- if (onFinished)
+ if(onFinished)
{
anim.FinishedSignal().Connect(this, onFinished);
}
mFadeAnim = anim;
}
-void ParticleView::Fade(float duration, float target, float from, AlphaFunction alphaFn,
- std::function<void(Dali::Animation&)> onFinished)
+void ParticleView::Fade(float duration, float target, float from, AlphaFunction alphaFn, std::function<void(Dali::Animation&)> onFinished)
{
mMasterParticles.SetProperty(Actor::Property::COLOR_ALPHA, from);
- if (mSlaveParticles)
+ if(mSlaveParticles)
{
mSlaveParticles.SetProperty(Actor::Property::COLOR_ALPHA, from);
}
#ifndef PARTICLES_PARTICLE_VIEW_H_
#define PARTICLES_PARTICLE_VIEW_H_
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
-#include "particle-field.h"
+#include <functional>
+#include <vector>
#include "dali/public-api/actors/camera-actor.h"
#include "dali/public-api/animation/animation.h"
#include "dali/public-api/object/weak-handle.h"
#include "dali/public-api/rendering/shader.h"
-#include <vector>
-#include <functional>
+#include "particle-field.h"
struct ColorRange
{
Dali::Vector3 rgb1;
};
-class ParticleView: public Dali::ConnectionTracker
+class ParticleView : public Dali::ConnectionTracker
{
public:
- ParticleView(const ParticleField& field, Dali::Actor world, Dali::CameraActor camera,
- Dali::Geometry particleGeom = Dali::Geometry());
+ ParticleView(const ParticleField& field, Dali::Actor world, Dali::CameraActor camera, Dali::Geometry particleGeom = Dali::Geometry());
~ParticleView();
void SetColorRange(const ColorRange& range);
///@brief Starts an animation to change the opacity of the particles to @a target.
///@param duration Number of seconds to complete transition in.
///@param target Target opacity in the 0..1.f range.
- void Fade(float duration, float target, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT,
- std::function<void(Dali::Animation&)> onFinished = nullptr);
+ void Fade(float duration, float target, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT, std::function<void(Dali::Animation&)> onFinished = nullptr);
///@brief Starts an animation to change the opacity of the particles to @a target.
///@param duration Number of seconds to complete transition in.
///@param target Target opacity in the 0..1.f range.
///@param from The value to set the opacity to prior to the animation.
- void Fade(float duration, float target, float from, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT,
- std::function<void(Dali::Animation&)> onFinished = nullptr);
+ void Fade(float duration, float target, float from, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT, std::function<void(Dali::Animation&)> onFinished = nullptr);
private: // DATA
struct ScatterProps
};
Dali::WeakHandle<Dali::Actor> mWorld;
- Dali::Vector3 mParticleBoxSize;
+ Dali::Vector3 mParticleBoxSize;
- Dali::Shader mParticleShader;
+ Dali::Shader mParticleShader;
Dali::Property::Index mPropPopulation;
Dali::Property::Index mPropFocalLength;
Dali::Property::Index mPropAperture;
Dali::Property::Index mPropFadeRange;
ScatterProps mScatterProps[6];
- int mActiveScatter = 0;
+ int mActiveScatter = 0;
- Dali::Actor mMasterParticles;
+ Dali::Actor mMasterParticles;
Dali::Property::Index mPropSecondaryColor;
Dali::Actor mSlaveParticles;
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
// INTERNAL INCLUDES
-#include "particle-view.h"
-#include "float-rand.h"
-#include "particle-field.h"
-#include "utils.h"
+#include <fstream>
+#include <iostream>
+#include <list>
+#include <memory>
+#include <numeric>
+#include <random>
#include "dali/devel-api/adaptor-framework/tilt-sensor.h"
-#include "dali/public-api/adaptor-framework/application.h"
-#include "dali/public-api/adaptor-framework/key.h"
#include "dali/public-api/actors/camera-actor.h"
#include "dali/public-api/actors/layer.h"
-#include "dali/public-api/events/tap-gesture-detector.h"
+#include "dali/public-api/adaptor-framework/application.h"
+#include "dali/public-api/adaptor-framework/key.h"
#include "dali/public-api/events/pan-gesture-detector.h"
+#include "dali/public-api/events/tap-gesture-detector.h"
#include "dali/public-api/events/touch-event.h"
+#include "dali/public-api/object/property-index-ranges.h"
#include "dali/public-api/render-tasks/render-task-list.h"
#include "dali/public-api/render-tasks/render-task.h"
-#include "dali/public-api/object/property-index-ranges.h"
-#include <fstream>
-#include <iostream>
-#include <numeric>
-#include <list>
-#include <memory>
-#include <random>
+#include "float-rand.h"
+#include "particle-field.h"
+#include "particle-view.h"
+#include "utils.h"
using namespace Dali;
namespace
{
-
-const float PARTICLE_ALPHA = .75;
+const float PARTICLE_ALPHA = .75;
const float ALPHA_TEST_REF_VALUE = .0625;
-const float NEAR_FADE = 0.04; // normalized depth
-const float FAR_FADE = 0.8; // normalized depth
+const float NEAR_FADE = 0.04; // normalized depth
+const float FAR_FADE = 0.8; // normalized depth
const ParticleField PARTICLE_FIELD = {
200.f, // particle size
.333 // twinkle opacity weight
};
-const float WORLD_ANGULAR_VELOCITY = .08; // radians per seconds
-const float WORLD_LINEAR_VELOCITY = -500; // units along z
+const float WORLD_ANGULAR_VELOCITY = .08; // radians per seconds
+const float WORLD_LINEAR_VELOCITY = -500; // units along z
-const float SCATTER_RADIUS = 450.0f;
-const float SCATTER_AMOUNT = 180.0f;
+const float SCATTER_RADIUS = 450.0f;
+const float SCATTER_AMOUNT = 180.0f;
const float SCATTER_DURATION_OUT = .8f;
-const float SCATTER_DURATION_IN = 1.5f;
+const float SCATTER_DURATION_IN = 1.5f;
-const float FADE_DURATION = 1.2f;
+const float FADE_DURATION = 1.2f;
const float FADEOUT_SPEED_MULTIPLIER = 4.f; // speed multiplier upon fading out.
const float FOCAL_LENGTH = 0.5f; // normalized depth value where particles appear sharp.
-const float APERTURE = 2.2f; // distance scale - the higher it is, the quicker the particles get blurred out moving away from the focal length.
+const float APERTURE = 2.2f; // distance scale - the higher it is, the quicker the particles get blurred out moving away from the focal length.
-const ColorRange DEFAULT_COLOR_RANGE { Vector3(0., 48. / 255., 1.), Vector3(0., 216. / 255., 1.) };
+const ColorRange DEFAULT_COLOR_RANGE{Vector3(0., 48. / 255., 1.), Vector3(0., 216. / 255., 1.)};
-const float TILT_SCALE = 0.2;
+const float TILT_SCALE = 0.2;
const float TILT_RANGE_DEGREES = 30.f;
FloatRand sFloatRand;
void Add(Dali::Vector2 tilt)
{
mTiltSamples[mIdxNextSample] = tilt;
- mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE;
+ mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE;
}
Dali::Vector2 Filter() const
}
private:
- enum { FILTER_SIZE = 8u };
+ enum
+ {
+ FILTER_SIZE = 8u
+ };
Dali::Vector2 mTiltSamples[FILTER_SIZE];
- size_t mIdxNextSample = 0;
+ size_t mIdxNextSample = 0;
};
class ParticlesExample : public ConnectionTracker
{
public:
- ParticlesExample( Application& app )
- : mApp( app )
+ ParticlesExample(Application& app)
+ : mApp(app)
{
mApp.InitSignal().Connect(this, &ParticlesExample::OnInit);
mApp.TerminateSignal().Connect(this, &ParticlesExample::OnTerminate);
CameraActor mCamera;
- Actor mWorld;
- Vector2 mAngularPosition;
+ Actor mWorld;
+ Vector2 mAngularPosition;
ColorRange mColors;
std::unique_ptr<ParticleView> mParticles;
PanGestureDetector mPanGesture;
- void OnInit( Application& application )
+ void OnInit(Application& application)
{
- Window window = application.GetWindow();
- auto rootLayer = window.GetRootLayer();
+ Window window = application.GetWindow();
+ auto rootLayer = window.GetRootLayer();
rootLayer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
- window.KeyEventSignal().Connect( this, &ParticlesExample::OnKeyEvent );
- window.GetRootLayer().TouchedSignal().Connect( this, &ParticlesExample::OnTouched );
+ window.KeyEventSignal().Connect(this, &ParticlesExample::OnKeyEvent);
+ window.GetRootLayer().TouchedSignal().Connect(this, &ParticlesExample::OnTouched);
auto tiltSensor = TiltSensor::Get();
- if ( tiltSensor.Start() )
+ if(tiltSensor.Start())
{
// Get notifications when the device is tilted
- tiltSensor.TiltedSignal().Connect( this, &ParticlesExample::OnTilted );
+ tiltSensor.TiltedSignal().Connect(this, &ParticlesExample::OnTilted);
}
else
{
}
// Get camera
- RenderTaskList tasks = window.GetRenderTaskList();
- RenderTask mainPass = tasks.GetTask(0);
- CameraActor camera = mainPass.GetCameraActor();
- mCamera = camera;
+ RenderTaskList tasks = window.GetRenderTaskList();
+ RenderTask mainPass = tasks.GetTask(0);
+ CameraActor camera = mainPass.GetCameraActor();
+ mCamera = camera;
// Create world - particles and clock are added to it; this is what we apply tilt to.
auto world = CreateActor();
void OnKeyEvent(const KeyEvent& event)
{
- if ( event.GetState() == KeyEvent::UP) // single keystrokes
+ if(event.GetState() == KeyEvent::UP) // single keystrokes
{
- if( IsKey( event, DALI_KEY_ESCAPE ) || IsKey( event, DALI_KEY_BACK ) )
+ if(IsKey(event, DALI_KEY_ESCAPE) || IsKey(event, DALI_KEY_BACK))
{
mApp.Quit();
}
}
}
- bool OnTouched( Actor a, const TouchEvent& event )
+ bool OnTouched(Actor a, const TouchEvent& event)
{
- if (event.GetPointCount() > 0)
+ if(event.GetPointCount() > 0)
{
auto screenPos = event.GetScreenPosition(0);
- switch (event.GetState(0))
+ switch(event.GetState(0))
{
- case PointState::STARTED:
+ case PointState::STARTED:
{
mParticles->Scatter(SCATTER_RADIUS, SCATTER_AMOUNT, SCATTER_DURATION_OUT, SCATTER_DURATION_IN);
}
break;
- default:
- break;
+ default:
+ break;
}
}
void OnDoubleTap(Actor /*actor*/, const TapGesture& /*gesture*/)
{
- if (!mExpiringParticles)
+ if(!mExpiringParticles)
{
mColors.rgb0 = Vector3::ONE - mColors.rgb1;
mColors.rgb1 = FromHueSaturationLightness(Vector3(sFloatRand() * 360.f, sFloatRand() * .5f + .5f, sFloatRand() * .25 + .75f));
void OnPan(Actor actor, const PanGesture& gesture)
{
- auto tilt = gesture.GetDisplacement() / Vector2(mApp.GetWindow().GetSize()) * TILT_SCALE;
+ auto tilt = gesture.GetDisplacement() / Vector2(mApp.GetWindow().GetSize()) * TILT_SCALE;
Quaternion q(Radian(-tilt.y), Radian(tilt.x), Radian(0.f));
Quaternion q0 = mWorld.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>();
mWorld.SetProperty(Actor::Property::ORIENTATION, q * q0);
}
- void OnTilted( const TiltSensor& sensor)
+ void OnTilted(const TiltSensor& sensor)
{
mTiltFilter.Add(Vector2(sensor.GetPitch(), sensor.GetRoll()));
- Vector2 tilt = mTiltFilter.Filter() * TILT_RANGE_DEGREES;
+ Vector2 tilt = mTiltFilter.Filter() * TILT_RANGE_DEGREES;
Quaternion q(Radian(Degree(tilt.x)), Radian(Degree(tilt.y)), Radian(0.f));
mWorld.SetProperty(Actor::Property::ORIENTATION, q);
}
Vector3 GetViewRay(const Vector2& screenPos)
{
- Vector2 screenSize = mApp.GetWindow().GetSize();
+ Vector2 screenSize = mApp.GetWindow().GetSize();
Vector2 normScreenPos = (screenPos / screenSize) * 2.f - Vector2::ONE;
- const float fov = mCamera.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>();
+ const float fov = mCamera.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>();
const float tanFov = std::tan(fov);
const float zNear = mCamera.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get<float>();
const float hProj = zNear * tanFov;
const float aspectRatio = mCamera.GetProperty(CameraActor::Property::ASPECT_RATIO).Get<float>();
- const float wProj = hProj * aspectRatio;
+ const float wProj = hProj * aspectRatio;
// Get camera orientation for view space ray casting. Assume:
// - this to be world space, i.e. no parent transforms;
Matrix worldCamera;
worldCamera.SetTransformComponents(Vector3::ONE, cameraOrientation, Vector3::ZERO);
- float* data = worldCamera.AsFloat();
+ float* data = worldCamera.AsFloat();
Vector3 xWorldCamera(data[0], data[4], data[8]);
xWorldCamera *= wProj * normScreenPos.x / xWorldCamera.Length();
void TriggerColorTransition(const ColorRange& range)
{
- if (mParticles)
+ if(mParticles)
{
mExpiringParticles = std::move(mParticles);
}
};
-} // nonamespace
+} // namespace
-int DALI_EXPORT_API main( int argc, char **argv )
+int DALI_EXPORT_API main(int argc, char** argv)
{
- Application application = Application::New( &argc, &argv, DEMO_THEME_PATH );
- ParticlesExample example( application);
+ Application application = Application::New(&argc, &argv, DEMO_THEME_PATH);
+ ParticlesExample example(application);
application.MainLoop();
return 0;
}
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
float max = std::max(rgb.r, std::max(rgb.g, rgb.b));
Vector3 hsl(max - min, 0.f, (max + min) * .5f);
- if (hsl.x * hsl.x > .0f)
+ if(hsl.x * hsl.x > .0f)
{
hsl.y = hsl.x / max;
- if (max == rgb.r)
+ if(max == rgb.r)
{
hsl.x = (rgb.g - rgb.b) / hsl.x;
}
hsl.x = 4.f + (rgb.r - rgb.g) / hsl.x;
}
hsl.x *= 60.f;
- if (hsl.x < 0.f)
+ if(hsl.x < 0.f)
{
hsl.x += 360.f;
}
Vector3 FromHueSaturationLightness(Vector3 hsl)
{
Vector3 rgb;
- if (hsl.y * hsl.y > 0.f)
+ if(hsl.y * hsl.y > 0.f)
{
if(hsl.x >= 360.f)
{
}
hsl.x /= 60.f;
- int i = FastFloor(hsl.x);
+ int i = FastFloor(hsl.x);
float ff = hsl.x - i;
- float p = hsl.z * (1.0 - hsl.y);
- float q = hsl.z * (1.0 - (hsl.y * ff));
- float t = hsl.z * (1.0 - (hsl.y * (1.f - ff)));
+ float p = hsl.z * (1.0 - hsl.y);
+ float q = hsl.z * (1.0 - (hsl.y * ff));
+ float t = hsl.z * (1.0 - (hsl.y * (1.f - ff)));
- switch (i)
+ switch(i)
{
- case 0:
- rgb.r = hsl.z;
- rgb.g = t;
- rgb.b = p;
- break;
-
- case 1:
- rgb.r = q;
- rgb.g = hsl.z;
- rgb.b = p;
- break;
-
- case 2:
- rgb.r = p;
- rgb.g = hsl.z;
- rgb.b = t;
- break;
-
- case 3:
- rgb.r = p;
- rgb.g = q;
- rgb.b = hsl.z;
- break;
-
- case 4:
- rgb.r = t;
- rgb.g = p;
- rgb.b = hsl.z;
- break;
-
- case 5:
- default:
- rgb.r = hsl.z;
- rgb.g = p;
- rgb.b = q;
- break;
+ case 0:
+ rgb.r = hsl.z;
+ rgb.g = t;
+ rgb.b = p;
+ break;
+
+ case 1:
+ rgb.r = q;
+ rgb.g = hsl.z;
+ rgb.b = p;
+ break;
+
+ case 2:
+ rgb.r = p;
+ rgb.g = hsl.z;
+ rgb.b = t;
+ break;
+
+ case 3:
+ rgb.r = p;
+ rgb.g = q;
+ rgb.b = hsl.z;
+ break;
+
+ case 4:
+ rgb.r = t;
+ rgb.g = p;
+ rgb.b = hsl.z;
+ break;
+
+ case 5:
+ default:
+ rgb.r = hsl.z;
+ rgb.g = p;
+ rgb.b = q;
+ break;
}
}
else
Geometry CreateCuboidWireframeGeometry()
{
-//
-// 2---3
-// |- |-
-// | 6---7
-// | | | |
-// 0-|-1 |
-// -| -|
-// 4---5
-//
+ //
+ // 2---3
+ // |- |-
+ // | 6---7
+ // | | | |
+ // 0-|-1 |
+ // -| -|
+ // 4---5
+ //
Vector3 vertexData[] = {
Vector3(-.5, -.5, -.5),
- Vector3( .5, -.5, -.5),
- Vector3(-.5, .5, -.5),
- Vector3( .5, .5, -.5),
- Vector3(-.5, -.5, .5),
- Vector3( .5, -.5, .5),
- Vector3(-.5, .5, .5),
- Vector3( .5, .5, .5),
+ Vector3(.5, -.5, -.5),
+ Vector3(-.5, .5, -.5),
+ Vector3(.5, .5, -.5),
+ Vector3(-.5, -.5, .5),
+ Vector3(.5, -.5, .5),
+ Vector3(-.5, .5, .5),
+ Vector3(.5, .5, .5),
};
uint16_t indices[] = {
- 0, 1, 1, 3, 3, 2, 2, 0,
- 0, 4, 1, 5, 3, 7, 2, 6,
- 4, 5, 5, 7, 7, 6, 6, 4
- };
- VertexBuffer vertexBuffer = VertexBuffer::New( Property::Map()
- .Add( "aPosition", Property::VECTOR3));
- vertexBuffer.SetData(vertexData, std::extent<decltype(vertexData)>::value );
+ 0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 1, 5, 3, 7, 2, 6, 4, 5, 5, 7, 7, 6, 6, 4};
+ VertexBuffer vertexBuffer = VertexBuffer::New(Property::Map()
+ .Add("aPosition", Property::VECTOR3));
+ vertexBuffer.SetData(vertexData, std::extent<decltype(vertexData)>::value);
Geometry geometry = Geometry::New();
- geometry.AddVertexBuffer( vertexBuffer );
- geometry.SetIndexBuffer( indices, std::extent<decltype(indices)>::value );
+ geometry.AddVertexBuffer(vertexBuffer);
+ geometry.SetIndexBuffer(indices, std::extent<decltype(indices)>::value);
geometry.SetType(Geometry::LINES);
return geometry;
}
{
Renderer renderer = Renderer::New(geometry, shader);
renderer.SetProperty(Renderer::Property::BLEND_MODE,
- (options & OPTION_BLEND) ? BlendMode::ON : BlendMode::OFF);
+ (options & OPTION_BLEND) ? BlendMode::ON : BlendMode::OFF);
renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE,
- (options & OPTION_DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF);
+ (options & OPTION_DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF);
renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE,
- (options & OPTION_DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF);
+ (options & OPTION_DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF);
renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK);
- if (!textures)
+ if(!textures)
{
textures = TextureSet::New();
}
void CenterActor(Actor actor)
{
- actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
- actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
}
Actor CreateActor()
Renderer CloneRenderer(Renderer original)
{
- Geometry geom = original.GetGeometry();
- Shader shader = original.GetShader();
- Renderer clone = Renderer::New(geom, shader);
+ Geometry geom = original.GetGeometry();
+ Shader shader = original.GetShader();
+ Renderer clone = Renderer::New(geom, shader);
// Copy properties.
Property::IndexContainer indices;
original.GetPropertyIndices(indices);
- for (auto& i: indices)
+ for(auto& i : indices)
{
auto actualIndex = PropertyRanges::DEFAULT_RENDERER_PROPERTY_START_INDEX + i;
clone.SetProperty(actualIndex, original.GetProperty(actualIndex));
// Don't copy every single one of them.
// Definitely don't copy resize policy related things, which will internally enable
// relayout, which in turn will result in losing the ability to set Z size.
- for (auto i : {
- Actor::Property::PARENT_ORIGIN,
- Actor::Property::ANCHOR_POINT,
- Actor::Property::SIZE,
- Actor::Property::POSITION,
- Actor::Property::ORIENTATION,
- Actor::Property::SCALE,
- Actor::Property::VISIBLE,
- Actor::Property::COLOR,
- Actor::Property::NAME,
- })
+ for(auto i : {
+ Actor::Property::PARENT_ORIGIN,
+ Actor::Property::ANCHOR_POINT,
+ Actor::Property::SIZE,
+ Actor::Property::POSITION,
+ Actor::Property::ORIENTATION,
+ Actor::Property::SCALE,
+ Actor::Property::VISIBLE,
+ Actor::Property::COLOR,
+ Actor::Property::NAME,
+ })
{
clone.SetProperty(i, original.GetProperty(i));
}
#ifndef PARTICLES_UTILS_H_
#define PARTICLES_UTILS_H_
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
+#include <cmath>
#include "dali/public-api/actors/actor.h"
-#include "dali/public-api/actors/actor.h"
+#include "dali/public-api/math/vector3.h"
#include "dali/public-api/rendering/geometry.h"
#include "dali/public-api/rendering/renderer.h"
#include "dali/public-api/rendering/shader.h"
#include "dali/public-api/rendering/texture.h"
-#include "dali/public-api/math/vector3.h"
-#include <cmath>
//
// Maths
//
-inline
-float FastFloor(float x)
+inline float FastFloor(float x)
{
return static_cast<int>(x) - static_cast<int>(x < 0);
}
enum RendererOptions
{
- OPTION_NONE = 0x0,
- OPTION_BLEND = 0x01,
- OPTION_DEPTH_TEST = 0x02,
+ OPTION_NONE = 0x0,
+ OPTION_BLEND = 0x01,
+ OPTION_DEPTH_TEST = 0x02,
OPTION_DEPTH_WRITE = 0x04
};
/// and @a options from above.
///@note Back face culling is on.
///@note If textures is not a valid handle, an empty texture set will be created.
-Dali::Renderer CreateRenderer(Dali::TextureSet textures, Dali::Geometry geometry,
- Dali::Shader shader, uint32_t options = OPTION_NONE);
+Dali::Renderer CreateRenderer(Dali::TextureSet textures, Dali::Geometry geometry, Dali::Shader shader, uint32_t options = OPTION_NONE);
///@brief Sets @a actor's anchor point and parent origin to center.
void CenterActor(Dali::Actor actor);
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
-#include "shared/utility.h"
-#include "generated/perf-scroll-vert.h"
#include "generated/perf-scroll-frag.h"
+#include "generated/perf-scroll-vert.h"
+#include "shared/utility.h"
using namespace Dali;
using namespace Dali::Toolkit;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
// INTERNAL INCLUDES
+#include "generated/point-mesh-frag.h"
+#include "generated/point-mesh-vert.h"
#include "shared/utility.h"
#include "shared/view.h"
-#include "generated/point-mesh-vert.h"
-#include "generated/point-mesh-frag.h"
using namespace Dali;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
//Rotate based off the gesture.
Vector2 displacement = gesture.GetDisplacement();
- Vector2 rotation {
+ Vector2 rotation{
-displacement.y / X_ROTATION_DISPLACEMENT_FACTOR, // Y displacement rotates around X axis
- displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR // X displacement rotates around Y axis
+ displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR // X displacement rotates around Y axis
};
- Quaternion q = Quaternion(Radian(rotation.x), Radian(rotation.y), Radian(0.f));
+ Quaternion q = Quaternion(Radian(rotation.x), Radian(rotation.y), Radian(0.f));
Quaternion q0 = mModel.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>();
mModel.SetProperty(Actor::Property::ORIENTATION, q * q0);
PanGestureDetector mPanGestureDetector; ///< Detects pan gestures for rotation of the model.
Animation mRotationAnimation; ///< Automatically rotates the model, unless it is being panned.
- Vector4 mColor; ///< Color to set all shapes.
+ Vector4 mColor; ///< Color to set all shapes.
};
int DALI_EXPORT_API main(int argc, char** argv)
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
bool success;
T result;
+
operator T() const
{
return static_cast<T>(result);
#define GLTF_SCENE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
-
// EXTERNAL INCLUDES
-#include <string>
#include <dali/integration-api/debug.h>
+#include <string>
// INTERNAL INCLUDES
#include "third-party/pico-json.h"
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <map>
-#include "gltf-scene.h"
-#include "generated/reflection-vert.h"
#include "generated/reflection-frag.h"
-#include "generated/reflection-simple-frag.h"
-#include "generated/reflection-textured-frag.h"
#include "generated/reflection-plasma-frag.h"
+#include "generated/reflection-simple-frag.h"
#include "generated/reflection-tex-frag.h"
+#include "generated/reflection-textured-frag.h"
+#include "generated/reflection-vert.h"
+#include "gltf-scene.h"
using namespace Dali;
namespace
{
-
struct Model
{
Shader shader;
void OnPan(Actor actor, const PanGesture& panGesture)
{
Vector2 displacement = panGesture.GetScreenDisplacement();
- Vector2 rotation{
- displacement.y * -0.1f,
- displacement.x * 0.1f
- };
+ Vector2 rotation{displacement.y * -0.1f, displacement.x * 0.1f};
Quaternion q(Degree(0.f), Degree(rotation.y), Degree(rotation.x));
Quaternion q0 = mCenterActor.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <sstream>
// INTERNAL INCLUDES
-#include "shared/utility.h"
-#include "shared/view.h"
-#include "generated/refraction-effect-flat-vert.h"
#include "generated/refraction-effect-flat-frag.h"
-#include "generated/refraction-effect-refraction-vert.h"
+#include "generated/refraction-effect-flat-vert.h"
#include "generated/refraction-effect-refraction-frag.h"
+#include "generated/refraction-effect-refraction-vert.h"
+#include "shared/utility.h"
+#include "shared/view.h"
using namespace Dali;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/rendering/shader.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali/public-api/rendering/shader.h>
// INTERNAL INCLUDES
-#include "shared/utility.h"
-#include "shared/view.h"
-#include "generated/render-stencil-vert.h"
#include "generated/render-stencil-frag.h"
-#include "generated/render-stencil-textured-vert.h"
#include "generated/render-stencil-textured-frag.h"
+#include "generated/render-stencil-textured-vert.h"
+#include "generated/render-stencil-vert.h"
+#include "shared/utility.h"
+#include "shared/view.h"
using namespace Dali;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali/dali.h>
-#include "generated/rendering-basic-light-vert.h"
#include "generated/rendering-basic-light-frag.h"
+#include "generated/rendering-basic-light-vert.h"
using namespace Dali;
using namespace Toolkit;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
bool LoadCubeMapFromKtxFile(const std::string& path, CubeData& cubedata)
{
Dali::FileStream daliFileStream(path);
- FILE* fp(daliFileStream.GetFile());
+ FILE* fp(daliFileStream.GetFile());
if(!fp)
{
return false;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstdio>
// INTERNAL INCLUDES
-#include "obj-loader.h"
-#include "generated/skybox-vert.h"
#include "generated/skybox-frag.h"
+#include "generated/skybox-vert.h"
+#include "obj-loader.h"
ModelSkybox::ModelSkybox()
{
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali/dali.h>
-#include "generated/rendering-cube-vert.h"
#include "generated/rendering-cube-frag.h"
+#include "generated/rendering-cube-vert.h"
using namespace Dali;
using namespace Toolkit;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali/dali.h>
-#include "generated/rendering-line-vert.h"
#include "generated/rendering-line-frag.h"
+#include "generated/rendering-line-vert.h"
using namespace Dali;
using namespace Toolkit;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali/dali.h>
-#include "generated/radial-progress-basic-vert.h"
#include "generated/radial-progress-basic-frag.h"
-#include "generated/radial-progress-textured-vert.h"
+#include "generated/radial-progress-basic-vert.h"
#include "generated/radial-progress-textured-frag.h"
+#include "generated/radial-progress-textured-vert.h"
using namespace Dali;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali/dali.h>
-#include "look-camera.h"
-#include "generated/rendering-skybox-vert.h"
-#include "generated/rendering-skybox-frag.h"
-#include "generated/rendering-skybox-cube-vert.h"
#include "generated/rendering-skybox-cube-frag.h"
+#include "generated/rendering-skybox-cube-vert.h"
+#include "generated/rendering-skybox-frag.h"
+#include "generated/rendering-skybox-vert.h"
+#include "look-camera.h"
using namespace Dali;
using namespace Toolkit;
namespace
{
-
const float CAMERA_DEFAULT_FOV(60.0f);
const float CAMERA_DEFAULT_NEAR(0.1f);
const float CAMERA_DEFAULT_FAR(1000.0f);
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali/dali.h>
-#include "generated/rendering-textured-cube-vert.h"
#include "generated/rendering-textured-cube-frag.h"
+#include "generated/rendering-textured-cube-vert.h"
using namespace Dali;
using namespace Toolkit;
namespace
{
-
const char* TEXTURE_URL = DEMO_IMAGE_DIR "wood.png";
} // namespace
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali/dali.h>
-#include "generated/rendering-triangle-vert.h"
#include "generated/rendering-triangle-frag.h"
+#include "generated/rendering-triangle-vert.h"
using namespace Dali;
using namespace Toolkit;
/*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
int DALI_EXPORT_API main(int argc, char** argv)\r
{\r
- auto app = Application::New(&argc, &argv, DEMO_THEME_PATH);\r
+ auto app = Application::New(&argc, &argv, DEMO_THEME_PATH);\r
SceneLoaderExample sceneLoader(app);\r
app.MainLoop();\r
return 0;\r
/*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
*\r
*/\r
#include "scene-loader-example.h"\r
+#include <dirent.h>\r
+#include <cstring>\r
+#include <string_view>\r
+#include "dali-scene-loader/public-api/dli-loader.h"\r
#include "dali-scene-loader/public-api/gltf2-loader.h"\r
-#include "dali-scene-loader/public-api/shader-definition-factory.h"\r
#include "dali-scene-loader/public-api/light-parameters.h"\r
-#include "dali-scene-loader/public-api/dli-loader.h"\r
#include "dali-scene-loader/public-api/load-result.h"\r
-#include "dali/public-api/adaptor-framework/key.h"\r
-#include "dali/public-api/events/key-event.h"\r
-#include "dali/public-api/actors/layer.h"\r
-#include "dali/public-api/render-tasks/render-task-list.h"\r
-#include "dali/public-api/object/property-array.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h"\r
+#include "dali-scene-loader/public-api/shader-definition-factory.h"\r
#include "dali-toolkit/public-api/controls/scrollable/item-view/default-item-layout.h"\r
+#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h"\r
#include "dali-toolkit/public-api/controls/text-controls/text-label.h"\r
#include "dali-toolkit/public-api/visuals/gradient-visual-properties.h"\r
-#include <string_view>\r
-#include <cstring>\r
-#include <dirent.h>\r
+#include "dali/public-api/actors/layer.h"\r
+#include "dali/public-api/adaptor-framework/key.h"\r
+#include "dali/public-api/events/key-event.h"\r
+#include "dali/public-api/object/property-array.h"\r
+#include "dali/public-api/render-tasks/render-task-list.h"\r
\r
using namespace Dali;\r
using namespace Dali::Toolkit;\r
\r
namespace\r
{\r
-\r
const float ROTATION_SCALE = 180.f; // the amount of rotation that a swipe whose length is the width of the screen, causes, in degrees.\r
\r
const float ITEM_HEIGHT = 50.f;\r
\r
const Vector3 CAMERA_DEFAULT_POSITION(0.0f, 0.0f, 3.5f);\r
\r
-const std::string_view DLI_EXTENSION = ".dli";\r
+const std::string_view DLI_EXTENSION = ".dli";\r
const std::string_view GLTF_EXTENSION = ".gltf";\r
\r
const std::string RESOURCE_TYPE_DIRS[]{\r
\r
using StringVector = std::vector<std::string>;\r
\r
-StringVector ListFiles(const std::string& path, bool(*predicate)(const char*) = [](const char*) { return true; })\r
+StringVector ListFiles(\r
+ const std::string& path, bool (*predicate)(const char*) = [](const char*) { return true; })\r
{\r
StringVector results;\r
\r
- if (auto dirp = opendir(path.c_str()))\r
+ if(auto dirp = opendir(path.c_str()))\r
{\r
- std::unique_ptr<DIR, int(*)(DIR*)> dir(dirp, closedir);\r
+ std::unique_ptr<DIR, int (*)(DIR*)> dir(dirp, closedir);\r
\r
struct dirent* ent;\r
- while ((ent = readdir(dir.get())) != nullptr)\r
+ while((ent = readdir(dir.get())) != nullptr)\r
{\r
- if (ent->d_type == DT_REG && predicate(ent->d_name))\r
+ if(ent->d_type == DT_REG && predicate(ent->d_name))\r
{\r
results.push_back(ent->d_name);\r
}\r
struct ItemFactoryImpl : Dali::Toolkit::ItemFactory\r
{\r
const std::vector<std::string>& mSceneNames;\r
- TapGestureDetector mTapDetector;\r
+ TapGestureDetector mTapDetector;\r
\r
ItemFactoryImpl(const std::vector<std::string>& sceneNames, TapGestureDetector tapDetector)\r
: mSceneNames(sceneNames),\r
mTapDetector(tapDetector)\r
- {}\r
+ {\r
+ }\r
\r
unsigned int GetNumberOfItems() override\r
{\r
\r
void ConfigureCamera(const CameraParameters& params, CameraActor camera)\r
{\r
- if (params.isPerspective)\r
+ if(params.isPerspective)\r
{\r
camera.SetProjectionMode(Camera::PERSPECTIVE_PROJECTION);\r
camera.SetNearClippingPlane(params.zNear);\r
{\r
camera.SetProjectionMode(Camera::ORTHOGRAPHIC_PROJECTION);\r
camera.SetOrthographicProjection(params.orthographicSize.x,\r
- params.orthographicSize.y,\r
- params.orthographicSize.z,\r
- params.orthographicSize.w,\r
- params.zNear,\r
- params.zFar);\r
+ params.orthographicSize.y,\r
+ params.orthographicSize.z,\r
+ params.orthographicSize.w,\r
+ params.zNear,\r
+ params.zFar);\r
}\r
\r
// model\r
- Vector3 camTranslation;\r
- Vector3 camScale;\r
+ Vector3 camTranslation;\r
+ Vector3 camScale;\r
Quaternion camOrientation;\r
params.CalculateTransformComponents(camTranslation, camOrientation, camScale);\r
\r
camOrientation.Conjugate();\r
}\r
\r
-void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root,\r
- std::vector<BlendshapeShaderConfigurationRequest>&& requests)\r
+void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root, std::vector<BlendshapeShaderConfigurationRequest>&& requests)\r
{\r
std::vector<std::string> errors;\r
- auto onError = [&errors](const std::string& msg) {\r
+ auto onError = [&errors](const std::string& msg) {\r
errors.push_back(msg);\r
};\r
- if (!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError))\r
+ if(!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError))\r
{\r
ExceptionFlinger flinger(ASSERT_LOCATION);\r
- for (auto& msg : errors)\r
+ for(auto& msg : errors)\r
{\r
flinger << msg << '\n';\r
}\r
\r
auto path = pathProvider(ResourceType::Mesh) + sceneName;\r
\r
- ResourceBundle resources;\r
- SceneDefinition scene;\r
+ ResourceBundle resources;\r
+ SceneDefinition scene;\r
std::vector<AnimationGroupDefinition> animGroups;\r
- std::vector<CameraParameters> cameraParameters;\r
- std::vector<LightParameters> lights;\r
- std::vector<AnimationDefinition> animations;\r
+ std::vector<CameraParameters> cameraParameters;\r
+ std::vector<LightParameters> lights;\r
+ std::vector<AnimationDefinition> animations;\r
\r
LoadResult output{\r
resources,\r
animations,\r
animGroups,\r
cameraParameters,\r
- lights\r
- };\r
+ lights};\r
\r
- if (sceneName.rfind(DLI_EXTENSION) == sceneName.size() - DLI_EXTENSION.size())\r
+ if(sceneName.rfind(DLI_EXTENSION) == sceneName.size() - DLI_EXTENSION.size())\r
{\r
- DliLoader loader;\r
+ DliLoader loader;\r
DliLoader::InputParams input{\r
pathProvider(ResourceType::Mesh),\r
nullptr,\r
{},\r
nullptr,\r
};\r
- DliLoader::LoadParams loadParams{ input, output };\r
- if (!loader.LoadScene(path, loadParams))\r
+ DliLoader::LoadParams loadParams{input, output};\r
+ if(!loader.LoadScene(path, loadParams))\r
{\r
ExceptionFlinger(ASSERT_LOCATION) << "Failed to load scene from '" << path << "': " << loader.GetParseError();\r
}\r
resources.mEnvironmentMaps.push_back({});\r
}\r
\r
- if (cameraParameters.empty())\r
+ if(cameraParameters.empty())\r
{\r
cameraParameters.push_back(CameraParameters());\r
cameraParameters[0].matrix.SetTranslation(CAMERA_DEFAULT_POSITION);\r
ConfigureCamera(cameraParameters[0], camera);\r
\r
ViewProjection viewProjection = cameraParameters[0].GetViewProjection();\r
- Transforms xforms{\r
+ Transforms xforms{\r
MatrixStack{},\r
- viewProjection\r
- };\r
+ viewProjection};\r
NodeDefinition::CreateParams nodeParams{\r
resources,\r
- xforms\r
- };\r
+ xforms};\r
Customization::Choices choices;\r
\r
Actor root = Actor::New();\r
SetActorCentered(root);\r
\r
- for (auto iRoot : scene.GetRoots())\r
+ for(auto iRoot : scene.GetRoots())\r
{\r
auto resourceRefs = resources.CreateRefCounter();\r
scene.CountResourceRefs(iRoot, choices, resourceRefs);\r
\r
resources.LoadResources(resourceRefs, pathProvider);\r
\r
- if (auto actor = scene.CreateNodes(iRoot, choices, nodeParams))\r
+ if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams))\r
{\r
scene.ConfigureSkeletonJoints(iRoot, resources.mSkeletons, actor);\r
scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables));\r
}\r
}\r
\r
- if (!animations.empty())\r
+ if(!animations.empty())\r
{\r
auto getActor = [&root](const std::string& name) {\r
return root.FindChildByName(name);\r
return root;\r
}\r
\r
-} // nonamespace\r
+} // namespace\r
\r
SceneLoaderExample::SceneLoaderExample(Dali::Application& app)\r
: mApp(app)\r
{\r
- if (!std::getenv("DALI_APPLICATION_PACKAGE"))\r
+ if(!std::getenv("DALI_APPLICATION_PACKAGE"))\r
{\r
- if (auto desktopPrefix = std::getenv("DESKTOP_PREFIX"))\r
+ if(auto desktopPrefix = std::getenv("DESKTOP_PREFIX"))\r
{\r
std::stringstream sstr;\r
sstr << desktopPrefix << "/share/com.samsung.dali-demo/res/";\r
void SceneLoaderExample::OnInit(Application& app)\r
{\r
// get scenes\r
- auto resPath = Application::GetResourcePath();\r
- auto scenePath = resPath + RESOURCE_TYPE_DIRS[ResourceType::Mesh];\r
+ auto resPath = Application::GetResourcePath();\r
+ auto scenePath = resPath + RESOURCE_TYPE_DIRS[ResourceType::Mesh];\r
auto sceneNames = ListFiles(scenePath, [](const char* name) {\r
auto len = strlen(name);\r
return (len > DLI_EXTENSION.size() && DLI_EXTENSION.compare(name + (len - DLI_EXTENSION.size())) == 0) ||\r
- (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0);\r
+ (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0);\r
});\r
- mSceneNames = sceneNames;\r
+ mSceneNames = sceneNames;\r
\r
// create Dali objects\r
auto window = app.GetWindow();\r
stopColors.PushBack(Vector4(0.45f, 0.7f, 0.8f, 1.f)); // Medium bright, pastel blue\r
const float percentageWindowHeight = window.GetSize().GetHeight() * 0.6f;\r
\r
- navigationView.SetProperty(Toolkit::Control::Property::BACKGROUND, Dali::Property::Map().\r
- Add(Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::GRADIENT).\r
- Add(Toolkit::GradientVisual::Property::STOP_OFFSET, stopOffsets).\r
- Add(Toolkit::GradientVisual::Property::STOP_COLOR, stopColors).\r
- Add(Toolkit::GradientVisual::Property::START_POSITION, Vector2(0.f, -percentageWindowHeight)).\r
- Add(Toolkit::GradientVisual::Property::END_POSITION, Vector2(0.f, percentageWindowHeight)).\r
- Add(Toolkit::GradientVisual::Property::UNITS, Toolkit::GradientVisual::Units::USER_SPACE));\r
+ navigationView.SetProperty(Toolkit::Control::Property::BACKGROUND,\r
+ Dali::Property::Map()\r
+ .Add(Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::GRADIENT)\r
+ .Add(Toolkit::GradientVisual::Property::STOP_OFFSET, stopOffsets)\r
+ .Add(Toolkit::GradientVisual::Property::STOP_COLOR, stopColors)\r
+ .Add(Toolkit::GradientVisual::Property::START_POSITION, Vector2(0.f, -percentageWindowHeight))\r
+ .Add(Toolkit::GradientVisual::Property::END_POSITION, Vector2(0.f, percentageWindowHeight))\r
+ .Add(Toolkit::GradientVisual::Property::UNITS, Toolkit::GradientVisual::Units::USER_SPACE));\r
window.Add(navigationView);\r
mNavigationView = navigationView;\r
\r
items.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);\r
\r
Vector3 windowSize(window.GetSize());\r
- auto itemLayout = DefaultItemLayout::New(DefaultItemLayout::LIST);\r
+ auto itemLayout = DefaultItemLayout::New(DefaultItemLayout::LIST);\r
itemLayout->SetItemSize(Vector3(windowSize.x, ITEM_HEIGHT, 1.f));\r
items.AddLayout(*itemLayout);\r
navigationView.Push(items);\r
\r
mItemLayout = itemLayout;\r
- mItemView = items;\r
+ mItemView = items;\r
\r
// camera\r
auto camera = CameraActor::New();\r
mTapDetector.Reset();\r
mPanDetector.Reset();\r
\r
- auto window = app.GetWindow();\r
+ auto window = app.GetWindow();\r
auto renderTasks = window.GetRenderTaskList();\r
renderTasks.RemoveTask(mSceneRender);\r
mSceneRender.Reset();\r
\r
void SceneLoaderExample::OnKey(const KeyEvent& e)\r
{\r
- if (e.GetState() == KeyEvent::UP)\r
+ if(e.GetState() == KeyEvent::UP)\r
{\r
- if (IsKey(e, DALI_KEY_ESCAPE) || IsKey(e, DALI_KEY_BACK))\r
+ if(IsKey(e, DALI_KEY_ESCAPE) || IsKey(e, DALI_KEY_BACK))\r
{\r
- if (mScene)\r
+ if(mScene)\r
{\r
mPanDetector.Reset();\r
\r
\r
void SceneLoaderExample::OnPan(Actor actor, const PanGesture& pan)\r
{\r
- auto windowSize = mApp.GetWindow().GetSize();\r
- Vector2 size{ float(windowSize.GetWidth()), float(windowSize.GetHeight()) };\r
- float aspect = size.y / size.x;\r
+ auto windowSize = mApp.GetWindow().GetSize();\r
+ Vector2 size{float(windowSize.GetWidth()), float(windowSize.GetHeight())};\r
+ float aspect = size.y / size.x;\r
\r
size /= ROTATION_SCALE;\r
\r
- Vector2 rotation{ pan.GetDisplacement().x / size.x, pan.GetDisplacement().y / size.y * aspect };\r
+ Vector2 rotation{pan.GetDisplacement().x / size.x, pan.GetDisplacement().y / size.y * aspect};\r
\r
- Quaternion q = Quaternion(Radian(Degree(rotation.y)), Radian(Degree(rotation.x)), Radian(0.f));\r
+ Quaternion q = Quaternion(Radian(Degree(rotation.y)), Radian(Degree(rotation.x)), Radian(0.f));\r
Quaternion q0 = mScene.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>();\r
\r
mScene.SetProperty(Actor::Property::ORIENTATION, q * q0);\r
\r
try\r
{\r
- auto window = mApp.GetWindow();\r
+ auto window = mApp.GetWindow();\r
auto renderTasks = window.GetRenderTaskList();\r
renderTasks.RemoveTask(mSceneRender);\r
\r
sceneRender.SetSourceActor(scene);\r
sceneRender.SetExclusive(true);\r
\r
- mScene = scene;\r
+ mScene = scene;\r
mSceneRender = sceneRender;\r
\r
mPanDetector = PanGestureDetector::New();\r
mPanDetector.DetectedSignal().Connect(this, &SceneLoaderExample::OnPan);\r
mPanDetector.Attach(mNavigationView);\r
}\r
- catch (const DaliException& e)\r
+ catch(const DaliException& e)\r
{\r
mScene = CreateErrorMessage(e.condition);\r
}\r
#ifndef SCENE_LAUNCHER_H_\r
#define SCENE_LAUNCHER_H_\r
/*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
*\r
*/\r
#include "dali-scene-loader/public-api/animation-definition.h"\r
-#include "dali-scene-loader/public-api/scene-definition.h"\r
-#include "dali-scene-loader/public-api/node-definition.h"\r
#include "dali-scene-loader/public-api/camera-parameters.h"\r
+#include "dali-scene-loader/public-api/node-definition.h"\r
+#include "dali-scene-loader/public-api/scene-definition.h"\r
+#include "dali-toolkit/devel-api/controls/navigation-view/navigation-view.h"\r
+#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h"\r
+#include "dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h"\r
+#include "dali-toolkit/public-api/controls/scrollable/item-view/item-view.h"\r
+#include "dali/public-api/actors/camera-actor.h"\r
+#include "dali/public-api/adaptor-framework/application.h"\r
#include "dali/public-api/common/vector-wrapper.h"\r
#include "dali/public-api/events/pan-gesture-detector.h"\r
-#include "dali/public-api/actors/camera-actor.h"\r
#include "dali/public-api/render-tasks/render-task.h"\r
#include "dali/public-api/signals/connection-tracker.h"\r
-#include "dali/public-api/adaptor-framework/application.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-view.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h"\r
-#include "dali-toolkit/devel-api/controls/navigation-view/navigation-view.h"\r
\r
class SceneLoaderExample : public Dali::ConnectionTracker\r
{\r
SceneLoaderExample(Dali::Application& app);\r
~SceneLoaderExample() = default;\r
\r
-private: // data\r
+private: // data\r
Dali::Application& mApp;\r
\r
std::vector<std::string> mSceneNames;\r
Dali::Toolkit::NavigationView mNavigationView;\r
\r
std::unique_ptr<Dali::Toolkit::ItemFactory> mItemFactory;\r
- Dali::Toolkit::ItemLayoutPtr mItemLayout;\r
- Dali::Toolkit::ItemView mItemView;\r
+ Dali::Toolkit::ItemLayoutPtr mItemLayout;\r
+ Dali::Toolkit::ItemView mItemView;\r
\r
Dali::CameraActor mSceneCamera;\r
- Dali::RenderTask mSceneRender;\r
- Dali::Actor mScene;\r
+ Dali::RenderTask mSceneRender;\r
+ Dali::Actor mScene;\r
\r
Dali::Quaternion mCameraOrientationInv;\r
\r
Dali::TapGestureDetector mTapDetector;\r
- Dali::PanGestureDetector mPanDetector;\r
+ Dali::PanGestureDetector mPanDetector;\r
\r
-private: // methods\r
+private: // methods\r
void OnInit(Dali::Application& app);\r
void OnTerminate(Dali::Application& app);\r
\r
void OnTap(Dali::Actor actor, const Dali::TapGesture& tap);\r
};\r
\r
-#endif //SCENE_LAUNCHER_H_\r
+#endif //SCENE_LAUNCHER_H_\r
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
mTextField.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Enter folder name.");
mButtonSelectionStart = PushButton::New();
- mButtonSelectionEnd = PushButton::New();
+ mButtonSelectionEnd = PushButton::New();
mButtonSelectionStart.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
mButtonSelectionStart.SetProperty(Actor::Property::SIZE, Vector2(140.f, 50.f));
if(button == mButtonSelectionStart)
{
int iStart = mTextField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>() - 1;
- if (iStart < 0)
+ if(iStart < 0)
{
iStart = 0;
}
}
else if(button == mButtonSelectionEnd)
{
- mTextField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END , mTextField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>() + 1);
+ mTextField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, mTextField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>() + 1);
}
- else if (mBtnEditable == button)
+ else if(mBtnEditable == button)
{
- bool bEditable = !mTextField.GetProperty( DevelTextField::Property::ENABLE_EDITING).Get<int>();
- mTextField.SetProperty( DevelTextField::Property::ENABLE_EDITING , bEditable);
- if (bEditable)
- {
- mBtnEditable.SetProperty(Button::Property::LABEL, "Non-editable");
- mBtnEditable.SetBackgroundColor(Color::RED);
- }
+ bool bEditable = !mTextField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<int>();
+ mTextField.SetProperty(DevelTextField::Property::ENABLE_EDITING, bEditable);
+ if(bEditable)
+ {
+ mBtnEditable.SetProperty(Button::Property::LABEL, "Non-editable");
+ mBtnEditable.SetBackgroundColor(Color::RED);
+ }
else
- {
- mBtnEditable.SetProperty(Button::Property::LABEL, "editable");
- mBtnEditable.SetBackgroundColor(Color::GREEN);
- }
+ {
+ mBtnEditable.SetProperty(Button::Property::LABEL, "editable");
+ mBtnEditable.SetBackgroundColor(Color::GREEN);
+ }
}
return true;
private:
Application& mApplication;
- TextField mTextField;
- PushButton mButtonSelectionStart;
- PushButton mButtonSelectionEnd;
- PushButton mBtnEditable;
+ TextField mTextField;
+ PushButton mButtonSelectionStart;
+ PushButton mButtonSelectionEnd;
+ PushButton mBtnEditable;
};
void RunTest(Application& application)
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
// INTERNAL INCLUDES
-#include "generated/simple-text-renderer-vert.h"
#include "generated/simple-text-renderer-frag.h"
+#include "generated/simple-text-renderer-vert.h"
using namespace std;
using namespace Dali;
#define DALI_SPARKLE_EFFECT_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali/dali.h>
-#include "generated/sparkle-effect-vert.h"
#include "generated/sparkle-effect-frag.h"
+#include "generated/sparkle-effect-vert.h"
using namespace Dali;
using Dali::Toolkit::ImageView;
{
namespace
{
-
Dali::BaseHandle Create()
{
return Demo::ImageChannelControl::New();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-toolkit/dali-toolkit.h>
// INTERNAL INCLUDES
+#include "generated/textured-mesh-frag.h"
+#include "generated/textured-mesh-vert.h"
#include "shared/utility.h"
#include "shared/view.h"
-#include "generated/textured-mesh-vert.h"
-#include "generated/textured-mesh-frag.h"
using namespace Dali;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
#include "utils.h"
-#include "dali-toolkit/dali-toolkit.h"
#include <fstream>
+#include "dali-toolkit/dali-toolkit.h"
using namespace Dali;
using namespace Dali::Toolkit;
float max = std::max(rgb.r, std::max(rgb.g, rgb.b));
Vector3 hsl(max - min, 0.f, (max + min) * .5f);
- if (hsl.x * hsl.x > .0f)
+ if(hsl.x * hsl.x > .0f)
{
hsl.y = hsl.x / max;
- if (max == rgb.r)
+ if(max == rgb.r)
{
hsl.x = (rgb.g - rgb.b) / hsl.x;
}
hsl.x = 4.f + (rgb.r - rgb.g) / hsl.x;
}
hsl.x *= 60.f;
- if (hsl.x < 0.f)
+ if(hsl.x < 0.f)
{
hsl.x += 360.f;
}
Vector3 FromHueSaturationLightness(Vector3 hsl)
{
Vector3 rgb;
- if (hsl.y * hsl.y > 0.f)
+ if(hsl.y * hsl.y > 0.f)
{
if(hsl.x >= 360.f)
{
}
hsl.x /= 60.f;
- int i = FastFloor(hsl.x);
+ int i = FastFloor(hsl.x);
float ff = hsl.x - i;
- float p = hsl.z * (1.0 - hsl.y);
- float q = hsl.z * (1.0 - (hsl.y * ff));
- float t = hsl.z * (1.0 - (hsl.y * (1.f - ff)));
+ float p = hsl.z * (1.0 - hsl.y);
+ float q = hsl.z * (1.0 - (hsl.y * ff));
+ float t = hsl.z * (1.0 - (hsl.y * (1.f - ff)));
- switch (i)
+ switch(i)
{
- case 0:
- rgb.r = hsl.z;
- rgb.g = t;
- rgb.b = p;
- break;
-
- case 1:
- rgb.r = q;
- rgb.g = hsl.z;
- rgb.b = p;
- break;
-
- case 2:
- rgb.r = p;
- rgb.g = hsl.z;
- rgb.b = t;
- break;
-
- case 3:
- rgb.r = p;
- rgb.g = q;
- rgb.b = hsl.z;
- break;
-
- case 4:
- rgb.r = t;
- rgb.g = p;
- rgb.b = hsl.z;
- break;
-
- case 5:
- default:
- rgb.r = hsl.z;
- rgb.g = p;
- rgb.b = q;
- break;
+ case 0:
+ rgb.r = hsl.z;
+ rgb.g = t;
+ rgb.b = p;
+ break;
+
+ case 1:
+ rgb.r = q;
+ rgb.g = hsl.z;
+ rgb.b = p;
+ break;
+
+ case 2:
+ rgb.r = p;
+ rgb.g = hsl.z;
+ rgb.b = t;
+ break;
+
+ case 3:
+ rgb.r = p;
+ rgb.g = q;
+ rgb.b = hsl.z;
+ break;
+
+ case 4:
+ rgb.r = t;
+ rgb.g = p;
+ rgb.b = hsl.z;
+ break;
+
+ case 5:
+ default:
+ rgb.r = hsl.z;
+ rgb.g = p;
+ rgb.b = q;
+ break;
}
}
else
return rgb;
}
-Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts,
- Vector2 scale, VertexFn positionFn, VertexFn texCoordFn)
+Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts, Vector2 scale, VertexFn positionFn, VertexFn texCoordFn)
{
DALI_ASSERT_DEBUG(xVerts > 1 && yVerts > 1);
int numVerts = xVerts * yVerts;
Vector2 aTexCoord;
};
std::vector<Vertex> vertices;
- vertices.reserve( numVerts);
+ vertices.reserve(numVerts);
float dx = 1.f / (xVerts - 1);
float dz = 1.f / (yVerts - 1);
- Vector2 pos{ 0.f, 0.f };
- for (unsigned int i = 0; i < yVerts; ++i)
+ Vector2 pos{0.f, 0.f};
+ for(unsigned int i = 0; i < yVerts; ++i)
{
pos.x = float(int((i & 1) * 2) - 1) * dx * .25f;
- for (unsigned int j = 0; j < xVerts; ++j)
+ for(unsigned int j = 0; j < xVerts; ++j)
{
- auto vPos = pos + Vector2{ -.5f, -.5f };
- vertices.push_back(Vertex{ (positionFn ? positionFn(vPos) : vPos) * scale,
- texCoordFn ? texCoordFn(pos) : pos });
+ auto vPos = pos + Vector2{-.5f, -.5f};
+ vertices.push_back(Vertex{(positionFn ? positionFn(vPos) : vPos) * scale,
+ texCoordFn ? texCoordFn(pos) : pos});
pos.x += dx;
}
pos.y += dz;
}
- VertexBuffer vertexBuffer = VertexBuffer::New( Property::Map()
- .Add( "aPosition", Property::VECTOR2 )
- .Add( "aTexCoord", Property::VECTOR2 ));
+ VertexBuffer vertexBuffer = VertexBuffer::New(Property::Map()
+ .Add("aPosition", Property::VECTOR2)
+ .Add("aTexCoord", Property::VECTOR2));
vertexBuffer.SetData(vertices.data(), vertices.size());
- int numInds = (xVerts - 1) * (yVerts - 1) * 6;
+ int numInds = (xVerts - 1) * (yVerts - 1) * 6;
std::vector<uint16_t> indices;
indices.reserve(numInds);
- for (unsigned int i = 1; i < yVerts; ++i)
+ for(unsigned int i = 1; i < yVerts; ++i)
{
- if ((i & 1) == 0)
+ if((i & 1) == 0)
{
- for (unsigned int j = 1; j < xVerts; ++j)
+ for(unsigned int j = 1; j < xVerts; ++j)
{
int iBase = i * xVerts + j;
indices.push_back(iBase);
}
else
{
- for (unsigned int j = 1; j < xVerts; ++j)
+ for(unsigned int j = 1; j < xVerts; ++j)
{
int iBase = i * xVerts + j;
indices.push_back(iBase);
{
PixelData pixelData = SyncImageLoader::Load(path);
- Texture texture = Texture::New(TextureType::TEXTURE_2D, pixelData.GetPixelFormat(),
- pixelData.GetWidth(), pixelData.GetHeight());
+ Texture texture = Texture::New(TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight());
texture.Upload(pixelData);
return texture;
}
{
Renderer renderer = Renderer::New(geometry, shader);
renderer.SetProperty(Renderer::Property::BLEND_MODE,
- (options & OPTION_BLEND) ? BlendMode::ON : BlendMode::OFF);
+ (options & OPTION_BLEND) ? BlendMode::ON : BlendMode::OFF);
renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE,
- (options & OPTION_DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF);
+ (options & OPTION_DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF);
renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE,
- (options & OPTION_DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF);
+ (options & OPTION_DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF);
renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK);
- if (!textures)
+ if(!textures)
{
textures = TextureSet::New();
}
Renderer CloneRenderer(Renderer original)
{
- Geometry geom = original.GetGeometry();
- Shader shader = original.GetShader();
- Renderer clone = Renderer::New(geom, shader);
+ Geometry geom = original.GetGeometry();
+ Shader shader = original.GetShader();
+ Renderer clone = Renderer::New(geom, shader);
// Copy properties.
Property::IndexContainer indices;
original.GetPropertyIndices(indices);
- for (auto& i: indices)
+ for(auto& i : indices)
{
auto actualIndex = Dali::PropertyRanges::DEFAULT_RENDERER_PROPERTY_START_INDEX + i;
clone.SetProperty(actualIndex, original.GetProperty(actualIndex));
// Don't copy every single one of them.
// Definitely don't copy resize policy related things, which will internally enable
// relayout, which in turn will result in losing the ability to set Z size.
- for (auto i : {
- Actor::Property::PARENT_ORIGIN,
- Actor::Property::ANCHOR_POINT,
- Actor::Property::SIZE,
- Actor::Property::POSITION,
- Actor::Property::ORIENTATION,
- Actor::Property::SCALE,
- Actor::Property::VISIBLE,
- Actor::Property::COLOR,
- Actor::Property::NAME,
- })
+ for(auto i : {
+ Actor::Property::PARENT_ORIGIN,
+ Actor::Property::ANCHOR_POINT,
+ Actor::Property::SIZE,
+ Actor::Property::POSITION,
+ Actor::Property::ORIENTATION,
+ Actor::Property::SCALE,
+ Actor::Property::VISIBLE,
+ Actor::Property::COLOR,
+ Actor::Property::NAME,
+ })
{
clone.SetProperty(i, original.GetProperty(i));
}
#ifndef WAVES_UTILS_H_
#define WAVES_UTILS_H_
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
* limitations under the License.
*
*/
+#include <cmath>
#include "dali/public-api/actors/actor.h"
+#include "dali/public-api/math/vector3.h"
#include "dali/public-api/rendering/geometry.h"
#include "dali/public-api/rendering/renderer.h"
#include "dali/public-api/rendering/shader.h"
#include "dali/public-api/rendering/texture.h"
-#include "dali/public-api/math/vector3.h"
-#include <cmath>
//
// Maths
//
-inline
-float FastFloor(float x)
+inline float FastFloor(float x)
{
return static_cast<int>(x) - static_cast<int>(x < 0);
}
-inline
-float Sign(float x)
+inline float Sign(float x)
{
return float(x > 0.f) - float(x < .0f);
}
-template <typename T>
+template<typename T>
inline
-typename std::decay<T>::type Lerp(
+ typename std::decay<T>::type
+ Lerp(
const T& min, const T& max, float alpha)
{
return min + (max - min) * alpha;
}
-template <typename T>
+template<typename T>
T Normalized(T v)
{
v.Normalize();
//
// Dali entities
//
-using VertexFn = Dali::Vector2(*)(const Dali::Vector2&);
+using VertexFn = Dali::Vector2 (*)(const Dali::Vector2&);
///@brief Creates a tesselated quad with @a xVerts vertices horizontally and @a yVerts
/// vertices vertically. Allows the use of an optional @a shaderFn, which can be used to
/// modify the vertex positions - these will be in the [{ 0.f, 0.f}, { 1.f, 1.f}] range.
/// After returning from the shader, they're transformed
-Dali::Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts,
- Dali::Vector2 scale, VertexFn positionFn = nullptr, VertexFn texCoordFn = nullptr);
+Dali::Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts, Dali::Vector2 scale, VertexFn positionFn = nullptr, VertexFn texCoordFn = nullptr);
Dali::Texture LoadTexture(const std::string& path);
enum RendererOptions
{
- OPTION_NONE = 0x0,
- OPTION_BLEND = 0x01,
- OPTION_DEPTH_TEST = 0x02,
+ OPTION_NONE = 0x0,
+ OPTION_BLEND = 0x01,
+ OPTION_DEPTH_TEST = 0x02,
OPTION_DEPTH_WRITE = 0x04
};
/// and @a options from above.
///@note Back face culling is on.
///@note If textures is not a valid handle, an empty texture set will be created.
-Dali::Renderer CreateRenderer(Dali::TextureSet textures, Dali::Geometry geometry,
- Dali::Shader shader, uint32_t options = OPTION_NONE);
+Dali::Renderer CreateRenderer(Dali::TextureSet textures, Dali::Geometry geometry, Dali::Shader shader, uint32_t options = OPTION_NONE);
///@brief Sets @a actor's anchor point and parent origin to center.
void CenterActor(Dali::Actor actor);
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 ( "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include "utils.h"
+#include <fstream>
+#include <iostream>
+#include <numeric>
#include "dali/devel-api/adaptor-framework/tilt-sensor.h"
+#include "dali/public-api/actors/camera-actor.h"
+#include "dali/public-api/actors/layer.h"
#include "dali/public-api/adaptor-framework/application.h"
#include "dali/public-api/adaptor-framework/key.h"
#include "dali/public-api/animation/animation.h"
+#include "dali/public-api/events/key-event.h"
#include "dali/public-api/events/pan-gesture-detector.h"
#include "dali/public-api/events/tap-gesture-detector.h"
-#include "dali/public-api/events/key-event.h"
-#include "dali/public-api/actors/camera-actor.h"
-#include "dali/public-api/actors/layer.h"
-#include "dali/public-api/render-tasks/render-task.h"
#include "dali/public-api/render-tasks/render-task-list.h"
-#include <fstream>
-#include <iostream>
-#include <numeric>
+#include "dali/public-api/render-tasks/render-task.h"
+#include "utils.h"
-#include "generated/waves-vert.h"
#include "generated/waves-frag.h"
+#include "generated/waves-vert.h"
using namespace Dali;
namespace
{
-
const float TIME_STEP = 0.0952664626;
-const std::string UNIFORM_LIGHT_COLOR_SQR = "uLightColorSqr";
-const std::string UNIFORM_AMBIENT_COLOR = "uAmbientColor";
-const std::string UNIFORM_INV_LIGHT_DIR = "uInvLightDir";
-const std::string UNIFORM_SCROLL_SCALE = "uScrollScale";
-const std::string UNIFORM_WAVE_RATE = "uWaveRate";
-const std::string UNIFORM_WAVE_AMPLITUDE = "uWaveAmplitude";
+const std::string UNIFORM_LIGHT_COLOR_SQR = "uLightColorSqr";
+const std::string UNIFORM_AMBIENT_COLOR = "uAmbientColor";
+const std::string UNIFORM_INV_LIGHT_DIR = "uInvLightDir";
+const std::string UNIFORM_SCROLL_SCALE = "uScrollScale";
+const std::string UNIFORM_WAVE_RATE = "uWaveRate";
+const std::string UNIFORM_WAVE_AMPLITUDE = "uWaveAmplitude";
const std::string UNIFORM_NORMAL_MAP_WEIGHT = "uNormalMapWeight";
-const std::string UNIFORM_SPECULARITY = "uSpecularity";
-const std::string UNIFORM_PARALLAX_AMOUNT = "uParallaxAmount";
-const std::string UNIFORM_TIME = "uTime";
+const std::string UNIFORM_SPECULARITY = "uSpecularity";
+const std::string UNIFORM_PARALLAX_AMOUNT = "uParallaxAmount";
+const std::string UNIFORM_TIME = "uTime";
-const Vector3 WAVES_COLOR { .78f, .64f, .26f };
-const Vector3 LIGHT_COLOR { 1.0f, 0.91f, 0.6f };
-const Vector3 AMBIENT_COLOR { .002f, .001f, .001f };
+const Vector3 WAVES_COLOR{.78f, .64f, .26f};
+const Vector3 LIGHT_COLOR{1.0f, 0.91f, 0.6f};
+const Vector3 AMBIENT_COLOR{.002f, .001f, .001f};
-const Vector3 INV_LIGHT_DIR = Normalized(Vector3{ .125f, .8f, -.55f });
+const Vector3 INV_LIGHT_DIR = Normalized(Vector3{.125f, .8f, -.55f});
-const Vector2 SCROLL_SCALE{ 1.f, 3.5f };
-const float WAVE_RATE = 12.17f;
-const float WAVE_AMPLITUDE = 1.f;
-const float NORMAL_MAP_WEIGHT = 0.05f;
-const float SPECULARITY = 512.f;
-const float PARALLAX_AMOUNT = .25f;
+const Vector2 SCROLL_SCALE{1.f, 3.5f};
+const float WAVE_RATE = 12.17f;
+const float WAVE_AMPLITUDE = 1.f;
+const float NORMAL_MAP_WEIGHT = 0.05f;
+const float SPECULARITY = 512.f;
+const float PARALLAX_AMOUNT = .25f;
const float TILT_RANGE_DEGREES = 30.f;
-const float TRANSITION_DURATION = 1.2f;
+const float TRANSITION_DURATION = 1.2f;
const float TRANSITION_TIME_SCALE = 6.f;
const std::string_view NORMAL_MAP_NAME = "noise512.png";
void Add(Dali::Vector2 tilt)
{
mTiltSamples[mIdxNextSample] = tilt;
- mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE;
+ mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE;
}
Dali::Vector2 Filter() const
}
private:
- enum { FILTER_SIZE = 8u };
+ enum
+ {
+ FILTER_SIZE = 8u
+ };
Dali::Vector2 mTiltSamples[FILTER_SIZE];
- size_t mIdxNextSample = 0;
+ size_t mIdxNextSample = 0;
};
-} // nonamespace
+} // namespace
class WavesExample : public ConnectionTracker
{
public:
- WavesExample( Application& app )
- : mApp( app )
+ WavesExample(Application& app)
+ : mApp(app)
{
- mApp.InitSignal().Connect( this, &WavesExample::Create );
- mApp.TerminateSignal().Connect( this, &WavesExample::Destroy );
+ mApp.InitSignal().Connect(this, &WavesExample::Create);
+ mApp.TerminateSignal().Connect(this, &WavesExample::Destroy);
}
~WavesExample() = default;
private:
Application& mApp;
- CameraActor mCamera; // no ownership
+ CameraActor mCamera; // no ownership
- Actor mWaves;
+ Actor mWaves;
Shader mWaveShader;
Property::Index mUInvLightDir{Property::INVALID_INDEX};
Animation mTimeAnim;
Animation mTransitionAnim;
- void Create( Application& application )
+ void Create(Application& application)
{
- Window window = application.GetWindow();
- auto rootLayer = window.GetRootLayer();
+ Window window = application.GetWindow();
+ auto rootLayer = window.GetRootLayer();
window.SetBackgroundColor(Vector4(WAVES_COLOR * .5f));
// Get camera
- RenderTaskList tasks = window.GetRenderTaskList();
- RenderTask mainPass = tasks.GetTask(0);
- CameraActor camera = mainPass.GetCameraActor();
- mCamera = camera;
+ RenderTaskList tasks = window.GetRenderTaskList();
+ RenderTask mainPass = tasks.GetTask(0);
+ CameraActor camera = mainPass.GetCameraActor();
+ mCamera = camera;
// NOTE: watchface doesn't tolerate modification of the camera well;
/// we're better off rotating the world.
- Quaternion baseOrientation (Radian(Degree(-150.f)), Radian(M_PI), Radian(0.f));
+ Quaternion baseOrientation(Radian(Degree(-150.f)), Radian(M_PI), Radian(0.f));
auto shader = CreateShader();
// Create geometry
- Geometry geom = CreateTesselatedQuad(16, 64, Vector2{ .25f, 3.8f }, [](const Vector2& v) {
+ Geometry geom = CreateTesselatedQuad(
+ 16, 64, Vector2{.25f, 3.8f}, [](const Vector2& v) {
float y = v.y + .5f; // 0..1
y = std::sqrt(y) - .5f; // perspective correction - increase vertex density closer to viewer
float x = v.x + v.x * (1.f - y) * 5.5f;
y -= .24f; // further translation
- return Vector2{ x, y };
- }, [](const Vector2& v) {
- return Vector2{ v.x, std::sqrt(v.y) };
- });
+ return Vector2{ x, y }; }, [](const Vector2& v) { return Vector2{v.x, std::sqrt(v.y)}; });
// Create texture
auto normalMap = LoadTexture(std::string(DEMO_IMAGE_DIR) + NORMAL_MAP_NAME.data());
Renderer renderer = CreateRenderer(textures, geom, shader, OPTION_DEPTH_TEST | OPTION_DEPTH_WRITE);
auto waves = CreateActor();
- auto size = Vector2(window.GetSize());
+ auto size = Vector2(window.GetSize());
waves.SetProperty(Actor::Property::SIZE, Vector3(size.x, 100.f, size.y));
waves.SetProperty(Actor::Property::ORIENTATION, baseOrientation);
waves.SetProperty(Actor::Property::COLOR, WAVES_COLOR);
window.Add(waves);
mWaves = waves;
- window.KeyEventSignal().Connect( this, &WavesExample::OnKeyEvent );
+ window.KeyEventSignal().Connect(this, &WavesExample::OnKeyEvent);
// Setup double tap detector for color change
mDoubleTapGesture = TapGestureDetector::New(2);
// Touch controls
mTiltSensor = TiltSensor::Get();
- if ( mTiltSensor.Start() )
+ if(mTiltSensor.Start())
{
// Get notifications when the device is tilted
- mTiltSensor.TiltedSignal().Connect( this, &WavesExample::OnTilted );
+ mTiltSensor.TiltedSignal().Connect(this, &WavesExample::OnTilted);
}
else
{
mTimeAnim = animTime;
}
- void Destroy( Application& app)
+ void Destroy(Application& app)
{
mCamera.Reset();
Shader CreateShader()
{
- Vector3 lightColorSqr{ LIGHT_COLOR };
- Vector3 ambientColor = AMBIENT_COLOR;
- Vector3 invLightDir = INV_LIGHT_DIR;
- Vector2 scrollScale = SCROLL_SCALE;
- float waveRate = WAVE_RATE;
- float waveAmp = WAVE_AMPLITUDE;
- float normalMapWeight = NORMAL_MAP_WEIGHT;
- float specularity = SPECULARITY;
- float parallaxAmount = PARALLAX_AMOUNT;
- if (mWaveShader)
+ Vector3 lightColorSqr{LIGHT_COLOR};
+ Vector3 ambientColor = AMBIENT_COLOR;
+ Vector3 invLightDir = INV_LIGHT_DIR;
+ Vector2 scrollScale = SCROLL_SCALE;
+ float waveRate = WAVE_RATE;
+ float waveAmp = WAVE_AMPLITUDE;
+ float normalMapWeight = NORMAL_MAP_WEIGHT;
+ float specularity = SPECULARITY;
+ float parallaxAmount = PARALLAX_AMOUNT;
+ if(mWaveShader)
{
- lightColorSqr = mWaveShader.GetProperty(mULightColorSqr).Get<Vector3>();
- ambientColor = mWaveShader.GetProperty(mUAmbientColor).Get<Vector3>();
- invLightDir = mWaveShader.GetProperty(mUInvLightDir).Get<Vector3>();
- scrollScale = mWaveShader.GetProperty(mUScrollScale).Get<Vector2>();
- waveRate = mWaveShader.GetProperty(mUWaveRate).Get<float>();
- waveAmp = mWaveShader.GetProperty(mUWaveAmplitude).Get<float>();
+ lightColorSqr = mWaveShader.GetProperty(mULightColorSqr).Get<Vector3>();
+ ambientColor = mWaveShader.GetProperty(mUAmbientColor).Get<Vector3>();
+ invLightDir = mWaveShader.GetProperty(mUInvLightDir).Get<Vector3>();
+ scrollScale = mWaveShader.GetProperty(mUScrollScale).Get<Vector2>();
+ waveRate = mWaveShader.GetProperty(mUWaveRate).Get<float>();
+ waveAmp = mWaveShader.GetProperty(mUWaveAmplitude).Get<float>();
normalMapWeight = mWaveShader.GetProperty(mUNormalMapWeight).Get<float>();
- specularity = mWaveShader.GetProperty(mUSpecularity).Get<float>();
+ specularity = mWaveShader.GetProperty(mUSpecularity).Get<float>();
}
- Shader shader = Shader::New(SHADER_WAVES_VERT, SHADER_WAVES_FRAG, Shader::Hint::MODIFIES_GEOMETRY);
- mULightColorSqr = shader.RegisterProperty(UNIFORM_LIGHT_COLOR_SQR, lightColorSqr);
- mUAmbientColor = shader.RegisterProperty(UNIFORM_AMBIENT_COLOR, ambientColor);
- mUInvLightDir = shader.RegisterProperty(UNIFORM_INV_LIGHT_DIR, invLightDir);
- mUScrollScale = shader.RegisterProperty(UNIFORM_SCROLL_SCALE, scrollScale);
- mUWaveRate = shader.RegisterProperty(UNIFORM_WAVE_RATE, waveRate);
- mUWaveAmplitude = shader.RegisterProperty(UNIFORM_WAVE_AMPLITUDE, waveAmp);
+ Shader shader = Shader::New(SHADER_WAVES_VERT, SHADER_WAVES_FRAG, Shader::Hint::MODIFIES_GEOMETRY);
+ mULightColorSqr = shader.RegisterProperty(UNIFORM_LIGHT_COLOR_SQR, lightColorSqr);
+ mUAmbientColor = shader.RegisterProperty(UNIFORM_AMBIENT_COLOR, ambientColor);
+ mUInvLightDir = shader.RegisterProperty(UNIFORM_INV_LIGHT_DIR, invLightDir);
+ mUScrollScale = shader.RegisterProperty(UNIFORM_SCROLL_SCALE, scrollScale);
+ mUWaveRate = shader.RegisterProperty(UNIFORM_WAVE_RATE, waveRate);
+ mUWaveAmplitude = shader.RegisterProperty(UNIFORM_WAVE_AMPLITUDE, waveAmp);
mUNormalMapWeight = shader.RegisterProperty(UNIFORM_NORMAL_MAP_WEIGHT, normalMapWeight);
- mUSpecularity = shader.RegisterProperty(UNIFORM_SPECULARITY, specularity);
- mUParallaxAmount = shader.RegisterProperty(UNIFORM_PARALLAX_AMOUNT, parallaxAmount);
- mUTime = shader.RegisterProperty(UNIFORM_TIME, 0.f);
+ mUSpecularity = shader.RegisterProperty(UNIFORM_SPECULARITY, specularity);
+ mUParallaxAmount = shader.RegisterProperty(UNIFORM_PARALLAX_AMOUNT, parallaxAmount);
+ mUTime = shader.RegisterProperty(UNIFORM_TIME, 0.f);
auto window = mApp.GetWindow();
shader.RegisterProperty("uScreenHalfSize", Vector2(window.GetSize()) * .5f);
void TriggerColorTransition(Vector3 wavesColor, Vector3 lightColor)
{
- if (mTransitionAnim)
+ if(mTransitionAnim)
{
mTransitionAnim.Stop();
}
void OnKeyEvent(const KeyEvent& event)
{
- if ( event.GetState() == KeyEvent::UP) // single keystrokes
+ if(event.GetState() == KeyEvent::UP) // single keystrokes
{
- if( IsKey( event, DALI_KEY_ESCAPE ) || IsKey( event, DALI_KEY_BACK ) )
+ if(IsKey(event, DALI_KEY_ESCAPE) || IsKey(event, DALI_KEY_BACK))
{
mApp.Quit();
}
void OnPan(Actor actor, const PanGesture& gesture)
{
auto tilt = gesture.GetDisplacement() / Vector2(mApp.GetWindow().GetSize());
- switch (gesture.GetState())
+ switch(gesture.GetState())
{
- case GestureState::STARTED:
- mTiltFilter.Add(tilt);
- break;
+ case GestureState::STARTED:
+ mTiltFilter.Add(tilt);
+ break;
- case GestureState::CONTINUING:
- mTiltFilter.Add(mTiltFilter.Filter() + tilt);
- break;
+ case GestureState::CONTINUING:
+ mTiltFilter.Add(mTiltFilter.Filter() + tilt);
+ break;
- default:
- break;
+ default:
+ break;
}
UpdateLightDirection();
}
- void OnTilted( const TiltSensor& sensor)
+ void OnTilted(const TiltSensor& sensor)
{
mTiltFilter.Add(Vector2(sensor.GetPitch(), sensor.GetRoll()));
void UpdateLightDirection()
{
- Vector2 tilt = mTiltFilter.Filter();
+ Vector2 tilt = mTiltFilter.Filter();
Quaternion q(Radian(tilt.y), Radian(-tilt.x), Radian(0.f));
- Vector3 lightDir = q.Rotate(INV_LIGHT_DIR);
+ Vector3 lightDir = q.Rotate(INV_LIGHT_DIR);
mWaveShader.SetProperty(mUInvLightDir, lightDir);
}
};
-int DALI_EXPORT_API main( int argc, char **argv )
+int DALI_EXPORT_API main(int argc, char** argv)
{
- Application application = Application::New( &argc, &argv, DEMO_THEME_PATH );
- WavesExample example( application);
+ Application application = Application::New(&argc, &argv, DEMO_THEME_PATH);
+ WavesExample example(application);
application.MainLoop();
return 0;
}
/*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
// CLASS HEADER\r
#include "bubble-animator.h"\r
\r
-#include <dali/public-api/animation/constraint.h>\r
-#include <dali/public-api/math/random.h>\r
-#include <dali/public-api/rendering/shader.h>\r
+#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h>\r
#include <dali-toolkit/public-api/controls/image-view/image-view.h>\r
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>\r
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>\r
-#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h>\r
+#include <dali/public-api/animation/constraint.h>\r
+#include <dali/public-api/math/random.h>\r
+#include <dali/public-api/rendering/shader.h>\r
\r
using namespace Dali;\r
using namespace Dali::Toolkit;\r
namespace\r
{\r
const char* const BUBBLE_COLOR_STYLE_NAME[] =\r
-{\r
- "BubbleColor1",\r
- "BubbleColor2",\r
- "BubbleColor3",\r
- "BubbleColor4"\r
-};\r
+ {\r
+ "BubbleColor1",\r
+ "BubbleColor2",\r
+ "BubbleColor3",\r
+ "BubbleColor4"};\r
constexpr int NUMBER_OF_BUBBLE_COLORS(sizeof(BUBBLE_COLOR_STYLE_NAME) / sizeof(BUBBLE_COLOR_STYLE_NAME[0]));\r
\r
const char* const SHAPE_IMAGE_TABLE[] =\r
-{\r
- DEMO_IMAGE_DIR "shape-circle.png",\r
- DEMO_IMAGE_DIR "shape-bubble.png"\r
-};\r
+ {\r
+ DEMO_IMAGE_DIR "shape-circle.png",\r
+ DEMO_IMAGE_DIR "shape-bubble.png"};\r
constexpr int NUMBER_OF_SHAPE_IMAGES(sizeof(SHAPE_IMAGE_TABLE) / sizeof(SHAPE_IMAGE_TABLE[0]));\r
\r
constexpr int NUM_BACKGROUND_IMAGES = 18;\r
\r
// Define bubble horizontal parallax and vertical wrapping\r
Actor scrollView = mScrollView.GetHandle();\r
- if( scrollView )\r
+ if(scrollView)\r
{\r
Constraint animConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, AnimateBubbleConstraint(childPos, Random::Range(-0.85f, 0.25f)));\r
animConstraint.AddSource(Source(scrollView, ScrollView::Property::SCROLL_POSITION));\r
animation.Play();\r
mBackgroundAnimations.push_back(animation);\r
}\r
-\r
}\r
\r
void BubbleAnimator::AddBackgroundActors(Actor layer, int count)\r
#define DALI_DEMO_BUBBLE_ANIMATOR_H\r
\r
/*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
*/\r
\r
// EXTERNAL INCLUDES\r
-#include <vector>\r
#include <dali/public-api/actors/actor.h>\r
#include <dali/public-api/adaptor-framework/timer.h>\r
#include <dali/public-api/animation/animation.h>\r
#include <dali/public-api/object/weak-handle.h>\r
#include <dali/public-api/signals/connection-tracker.h>\r
+#include <vector>\r
\r
/**\r
* Creates and animates random sized bubbles\r
class BubbleAnimator : public Dali::ConnectionTracker\r
{\r
public:\r
-\r
/**\r
* @brief Initilizes the bubble background\r
*\r
void PlayAnimation();\r
\r
private:\r
-\r
/**\r
* @brief Used by the timer to pause the animation\r
*\r
void AddBackgroundActors(Dali::Actor layer, int count);\r
\r
private:\r
-\r
using AnimationList = std::vector<Dali::Animation>;\r
\r
- Dali::WeakHandle<Dali::Actor> mScrollView; ///< Weak handle to the scroll view used to apply a parallax effect when scrolling.\r
- AnimationList mBackgroundAnimations; ///< List of background bubble animations.\r
- Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period.\r
- bool mBackgroundAnimsPlaying{false}; ///< Are background animations playing.\r
+ Dali::WeakHandle<Dali::Actor> mScrollView; ///< Weak handle to the scroll view used to apply a parallax effect when scrolling.\r
+ AnimationList mBackgroundAnimations; ///< List of background bubble animations.\r
+ Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period.\r
+ bool mBackgroundAnimsPlaying{false}; ///< Are background animations playing.\r
};\r
\r
#endif // DALI_DEMO_BUBBLE_ANIMATOR_H\r
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include "dali-table-view.h"
// EXTERNAL INCLUDES
-#include <dali/devel-api/actors/actor-devel.h>
-#include <dali/devel-api/images/distance-field.h>
-#include <dali-toolkit/devel-api/controls/control-devel.h>
-#include <dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h>
-#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/accessibility-manager/accessibility-manager.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/controls/table-view/table-view.h>
#include <dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h>
#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h>
const int EXAMPLES_PER_ROW = 3;
const int ROWS_PER_PAGE = 3;
const int EXAMPLES_PER_PAGE = EXAMPLES_PER_ROW * ROWS_PER_PAGE;
-const Vector3 TABLE_RELATIVE_SIZE(0.95f, 0.9f, 0.8f); ///< TableView's relative size to the entire stage. The Y value means sum of the logo and table relative heights.
+const Vector3 TABLE_RELATIVE_SIZE(0.95f, 0.9f, 0.8f); ///< TableView's relative size to the entire stage. The Y value means sum of the logo and table relative heights.
const char* const DEMO_BUILD_DATE = __DATE__ " " __TIME__;
// Hide the popup when touched outside
popup.OutsideTouchedSignal().Connect(
&connectionTracker,
- [popup]() mutable
- {
+ [popup]() mutable {
if(popup && (popup.GetDisplayState() == Toolkit::Popup::SHOWN))
{
popup.SetDisplayState(Popup::HIDDEN);
{
if(mSortAlphabetically)
{
- sort(mExampleList.begin(), mExampleList.end(), [](auto& lhs, auto& rhs)->bool { return lhs.title < rhs.title; } );
+ sort(mExampleList.begin(), mExampleList.end(), [](auto& lhs, auto& rhs) -> bool { return lhs.title < rhs.title; });
}
unsigned int exampleCount = 0;
focusableTile.TouchedSignal().Connect(this, &DaliTableView::OnTilePressed);
focusableTile.HoveredSignal().Connect(this, &DaliTableView::OnTileHovered);
focusableTile.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::PUSH_BUTTON);
- DevelControl::AccessibilityActivateSignal(focusableTile).Connect(this, [=](){
+ DevelControl::AccessibilityActivateSignal(focusableTile).Connect(this, [=]() {
DoTilePress(focusableTile, PointState::DOWN);
DoTilePress(focusableTile, PointState::UP);
});
// ignore Example button presses when scrolling or button animating.
if((!mScrolling) && (!mPressedAnimation))
{
- std::string name = actor.GetProperty<std::string>(Dali::Actor::Property::NAME);
+ std::string name = actor.GetProperty<std::string>(Dali::Actor::Property::NAME);
for(Example& example : mExampleList)
{
if(example.name == name)
#define DALI_DEMO_TABLEVIEW_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
class DaliTableView : public Dali::ConnectionTracker
{
public:
-
/**
* Constructor
*
*/
void SortAlphabetically(bool sortAlphabetically);
-private: // Application callbacks & implementation
+private: // Application callbacks & implementation
static constexpr unsigned int FOCUS_ANIMATION_ACTOR_NUMBER = 2; ///< The number of elements used to form the custom focus effect
/**
};
FocusEffect mFocusEffect[FOCUS_ANIMATION_ACTOR_NUMBER]; ///< The elements used to create the custom focus effect
- std::vector<Dali::Actor> mPages; ///< List of pages.
- ExampleList mExampleList; ///< List of examples.
+ std::vector<Dali::Actor> mPages; ///< List of pages.
+ ExampleList mExampleList; ///< List of examples.
float mPageWidth; ///< The width of a page within the scroll-view, used to calculate the domain
int mTotalPages; ///< Total pages within scrollview.
- bool mScrolling : 1; ///< Flag indicating whether view is currently being scrolled
- bool mSortAlphabetically : 1; ///< Sort examples alphabetically.
+ bool mScrolling : 1; ///< Flag indicating whether view is currently being scrolled
+ bool mSortAlphabetically : 1; ///< Sort examples alphabetically.
};
#endif // DALI_DEMO_TABLEVIEW_H
#define DALI_DEMO_EXAMPLE_H\r
\r
/*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
std::string title; ///< title (caption) of example to appear on tile button.\r
};\r
\r
-using ExampleList = std::vector<Example>;\r
+using ExampleList = std::vector<Example>;\r
using ExampleListConstIter = ExampleList::const_iterator;\r
\r
#endif // DALI_DEMO_SHARED_EXAMPLE_H\r