From 5a56ed534cbc24150d68f03ea7fba7cfcc653835 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Thu, 4 Feb 2021 16:16:52 +0000 Subject: [PATCH] Updated all files to new format Change-Id: I89ad98704eacedd18a0b50fd9d6511fc8e436416 --- build/android/app/src/main/cpp/main.cpp | 18 +- .../animated-shapes/animated-shapes-example.cpp | 6 +- examples/arc-visual/arc-visual-example.cpp | 11 +- examples/benchmark/benchmark.cpp | 6 +- examples/bezier-curve/bezier-curve-example.cpp | 6 +- examples/builder/examples.cpp | 4 +- .../color-transition-controller.cpp | 28 ++- .../color-transition/color-transition-controller.h | 20 +- examples/color-transition/color-transition.cpp | 50 +++-- examples/color-transition/utils.cpp | 25 ++- examples/color-transition/utils.h | 22 ++- examples/color-visual/color-visual-example.cpp | 13 +- .../compressed-texture-formats-example.cpp | 6 +- examples/contact-cards/clipped-image.cpp | 4 +- examples/deferred-shading/deferred-shading.cpp | 6 +- examples/fpp-game/game-renderer.cpp | 4 +- .../image-scaling-and-filtering-example.cpp | 15 +- .../image-scaling-irregular-grid-example.cpp | 6 +- examples/image-view-url/image-view-url-example.cpp | 2 +- examples/line-mesh/line-mesh-example.cpp | 7 +- examples/mesh-morph/mesh-morph-example.cpp | 7 +- examples/mesh-visual/mesh-visual-example.cpp | 4 +- .../metaball-explosion-example.cpp | 6 +- .../metaball-refrac/metaball-refrac-example.cpp | 8 +- .../native-image-source-example.cpp | 6 +- examples/particles/float-rand.h | 9 +- examples/particles/particle-field.h | 87 +++++---- examples/particles/particle-view.cpp | 128 ++++++------- examples/particles/particle-view.h | 27 ++- examples/particles/particles-example.cpp | 136 +++++++------- examples/particles/utils.cpp | 181 +++++++++--------- examples/particles/utils.h | 19 +- examples/perf-scroll/perf-scroll.cpp | 6 +- examples/point-mesh/point-mesh-example.cpp | 6 +- .../primitive-shapes/primitive-shapes-example.cpp | 10 +- examples/reflection-demo/gltf-scene.cpp | 3 +- examples/reflection-demo/gltf-scene.h | 5 +- examples/reflection-demo/reflection-example.cpp | 16 +- .../refraction-effect-example.cpp | 10 +- .../renderer-stencil/renderer-stencil-example.cpp | 12 +- .../rendering-basic-light-example.cpp | 4 +- examples/rendering-basic-pbr/ktx-loader.cpp | 4 +- examples/rendering-basic-pbr/model-skybox.cpp | 6 +- examples/rendering-cube/rendering-cube.cpp | 4 +- examples/rendering-line/rendering-line.cpp | 4 +- .../rendering-radial-progress/radial-progress.cpp | 6 +- examples/rendering-skybox/rendering-skybox.cpp | 11 +- .../rendering-textured-cube.cpp | 5 +- examples/rendering-triangle/rendering-triangle.cpp | 4 +- examples/scene-loader/main.cpp | 4 +- examples/scene-loader/scene-loader-example.cpp | 162 ++++++++-------- examples/scene-loader/scene-loader-example.h | 34 ++-- examples/simple-text-field/simple-text-field.cpp | 40 ++-- .../simple-text-renderer-example.cpp | 4 +- examples/sparkle/sparkle-effect.h | 4 +- examples/styling/image-channel-control-impl.cpp | 1 - examples/textured-mesh/textured-mesh-example.cpp | 6 +- examples/waves/utils.cpp | 168 ++++++++--------- examples/waves/utils.h | 33 ++-- examples/waves/waves-example.cpp | 208 ++++++++++----------- shared/bubble-animator.cpp | 31 ++- shared/bubble-animator.h | 15 +- shared/dali-table-view.cpp | 19 +- shared/dali-table-view.h | 13 +- shared/example.h | 4 +- 65 files changed, 855 insertions(+), 884 deletions(-) mode change 100755 => 100644 shared/dali-table-view.cpp diff --git a/build/android/app/src/main/cpp/main.cpp b/build/android/app/src/main/cpp/main.cpp index 7b1d624..0e1ac14 100644 --- a/build/android/app/src/main/cpp/main.cpp +++ b/build/android/app/src/main/cpp/main.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -31,7 +31,7 @@ // 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 @@ -156,7 +156,7 @@ void android_main(struct android_app* state) 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); @@ -186,13 +186,13 @@ void android_main(struct android_app* state) 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()) @@ -217,16 +217,16 @@ void android_main(struct android_app* state) 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) diff --git a/examples/animated-shapes/animated-shapes-example.cpp b/examples/animated-shapes/animated-shapes-example.cpp index 508a75f..204fcef 100644 --- a/examples/animated-shapes/animated-shapes-example.cpp +++ b/examples/animated-shapes/animated-shapes-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -17,9 +17,9 @@ #include #include -#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 diff --git a/examples/arc-visual/arc-visual-example.cpp b/examples/arc-visual/arc-visual-example.cpp index ac60b7e..69d1a06 100644 --- a/examples/arc-visual/arc-visual-example.cpp +++ b/examples/arc-visual/arc-visual-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -183,9 +183,12 @@ private: { 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); diff --git a/examples/benchmark/benchmark.cpp b/examples/benchmark/benchmark.cpp index 4dc1e0a..2187253 100644 --- a/examples/benchmark/benchmark.cpp +++ b/examples/benchmark/benchmark.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -19,9 +19,9 @@ #include // 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; diff --git a/examples/bezier-curve/bezier-curve-example.cpp b/examples/bezier-curve/bezier-curve-example.cpp index d128218..7dc3b8a 100644 --- a/examples/bezier-curve/bezier-curve-example.cpp +++ b/examples/bezier-curve/bezier-curve-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -18,9 +18,9 @@ #include #include #include -#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 diff --git a/examples/builder/examples.cpp b/examples/builder/examples.cpp index cf0f140..7ba6fef 100644 --- a/examples/builder/examples.cpp +++ b/examples/builder/examples.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -202,7 +202,7 @@ bool FileWatcher::FileHasChanged(void) else { const bool result = buf.st_mtime > mLastTime; - mLastTime = buf.st_mtime; + mLastTime = buf.st_mtime; return result; } diff --git a/examples/color-transition/color-transition-controller.cpp b/examples/color-transition/color-transition-controller.cpp index 8963740..2a9296e 100644 --- a/examples/color-transition/color-transition-controller.cpp +++ b/examples/color-transition/color-transition-controller.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -15,21 +15,20 @@ * */ #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 window, Actor content, RenderTaskList tasks, Vector3 initialColor) : mWeakRenderTasks(window) @@ -39,8 +38,7 @@ ColorTransitionController::ColorTransitionController(WeakHandle auto defaultTask = tasks.GetTask(0); // create rendertarget and rendertask - auto rtt = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, - static_cast(contentSize.x), static_cast(contentSize.y)); + auto rtt = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, static_cast(contentSize.x), static_cast(contentSize.y)); auto fbo = FrameBuffer::New(rtt.GetWidth(), rtt.GetHeight(), FrameBuffer::Attachment::NONE); fbo.AttachColorTexture(rtt); @@ -58,10 +56,10 @@ ColorTransitionController::ColorTransitionController(WeakHandle 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(); @@ -89,7 +87,7 @@ ColorTransitionController::ColorTransitionController(WeakHandle ColorTransitionController::~ColorTransitionController() { - if (auto renderTasks = mWeakRenderTasks.GetHandle()) + if(auto renderTasks = mWeakRenderTasks.GetHandle()) { renderTasks.RemoveTask(mRtCompositor); } @@ -103,7 +101,7 @@ Dali::Actor ColorTransitionController::GetComposite() void ColorTransitionController::SetFlowMap(Texture flowMap) { auto renderer = mComposite.GetRendererAt(0); - auto texSet = renderer.GetTextures(); + auto texSet = renderer.GetTextures(); texSet.SetTexture(1, flowMap); } @@ -123,7 +121,7 @@ void ColorTransitionController::RequestTransition(float duration, const Dali::Ve void ColorTransitionController::SetOnFinished(OnFinished onFinished, void* data) { - mOnFinished = onFinished; + mOnFinished = onFinished; mOnFinishedData = data; } @@ -133,7 +131,7 @@ void ColorTransitionController::OnTransitionFinished(Animation& anim) Vector3 color1 = mComposite.GetProperty(mPropRgb[1]).Get(); mComposite.SetProperty(mPropRgb[0], color1); - if (mOnFinished) + if(mOnFinished) { mOnFinished(mOnFinishedData); } diff --git a/examples/color-transition/color-transition-controller.h b/examples/color-transition/color-transition-controller.h index 962ec27..957a9f0 100644 --- a/examples/color-transition/color-transition-controller.h +++ b/examples/color-transition/color-transition-controller.h @@ -1,7 +1,7 @@ #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. @@ -16,18 +16,18 @@ * 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 renderTasks, Dali::Actor content, Dali::RenderTaskList tasks, Dali::Vector3 initialColor); ~ColorTransitionController(); @@ -45,7 +45,7 @@ public: 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]; @@ -54,8 +54,8 @@ private: Dali::Animation mAnimation; - OnFinished mOnFinished = nullptr; - void* mOnFinishedData = nullptr; + OnFinished mOnFinished = nullptr; + void* mOnFinishedData = nullptr; Dali::WeakHandle mWeakRenderTasks; }; diff --git a/examples/color-transition/color-transition.cpp b/examples/color-transition/color-transition.cpp index 095f3e7..3375893 100644 --- a/examples/color-transition/color-transition.cpp +++ b/examples/color-transition/color-transition.cpp @@ -14,10 +14,10 @@ * 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; @@ -26,7 +26,7 @@ namespace { 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", @@ -38,15 +38,13 @@ const char* const FLOW_MAPS[] = { "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; } @@ -64,7 +62,7 @@ TextLabel MakeTextLabel(const char* text, const Vector4& color, float pointSize, return tl; } -} +} // namespace /** * Demonstrates colour transition using flow maps and uv rotation / scaling. @@ -81,7 +79,7 @@ TextLabel MakeTextLabel(const char* text, const Vector4& color, float pointSize, * - 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) @@ -100,8 +98,8 @@ private: 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(); @@ -132,9 +130,9 @@ private: window.Add(mainRoot); mMainRoot = mainRoot; - auto renderTasks = window.GetRenderTaskList(); + auto renderTasks = window.GetRenderTaskList(); auto weakRenderTasks = WeakHandle(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()); @@ -167,9 +165,9 @@ private: 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(); } @@ -178,17 +176,17 @@ private: 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::value]); } else { float theta = fmodf((atan2(clip.y, clip.x) + M_PI) / (M_PI * 2.) + .75f, 1.f); - int i = std::extent::value * theta; + int i = std::extent::value * theta; LoadFlowMap(FLOW_MAPS[i]); } @@ -204,11 +202,11 @@ private: 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); } @@ -216,8 +214,7 @@ private: 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() @@ -241,7 +238,8 @@ int DALI_EXPORT_API main(int argc, char** argv) { auto app = Application::New(&argc, &argv #ifdef WIN32 - , ".//dali-toolkit-default-theme.json" + , + ".//dali-toolkit-default-theme.json" #endif ); ColorTransition ct(app); diff --git a/examples/color-transition/utils.cpp b/examples/color-transition/utils.cpp index c226bfe..7feb9f5 100644 --- a/examples/color-transition/utils.cpp +++ b/examples/color-transition/utils.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -16,8 +16,8 @@ */ #include "utils.h" -#include #include +#include #include @@ -32,14 +32,14 @@ Geometry CreateQuadGeometry() }; 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::value); Geometry geometry = Geometry::New(); @@ -52,17 +52,17 @@ Renderer CreateRenderer(TextureSet textures, Geometry geometry, Shader shader, u { 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(); } @@ -76,4 +76,3 @@ void CenterActor(Actor actor) actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); } - diff --git a/examples/color-transition/utils.h b/examples/color-transition/utils.h index 9a4b1bc..5795d72 100644 --- a/examples/color-transition/utils.h +++ b/examples/color-transition/utils.h @@ -1,5 +1,5 @@ /* - * 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. @@ -22,7 +22,9 @@ #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 @@ -34,12 +36,12 @@ struct RendererOptions { 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, }; }; @@ -49,9 +51,9 @@ struct RendererOptions ///@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); diff --git a/examples/color-visual/color-visual-example.cpp b/examples/color-visual/color-visual-example.cpp index d8e5d44..10e71e7 100644 --- a/examples/color-visual/color-visual-example.cpp +++ b/examples/color-visual/color-visual-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -27,18 +27,19 @@ namespace { 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 diff --git a/examples/compressed-texture-formats/compressed-texture-formats-example.cpp b/examples/compressed-texture-formats/compressed-texture-formats-example.cpp index 28e841b..e1cce1d 100644 --- a/examples/compressed-texture-formats/compressed-texture-formats-example.cpp +++ b/examples/compressed-texture-formats/compressed-texture-formats-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -21,9 +21,9 @@ #include // 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; diff --git a/examples/contact-cards/clipped-image.cpp b/examples/contact-cards/clipped-image.cpp index 539c852..64fc0e3 100644 --- a/examples/contact-cards/clipped-image.cpp +++ b/examples/contact-cards/clipped-image.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -22,8 +22,8 @@ #include // INTERNAL INCLUDES -#include "generated/clipped-image-vert.h" #include "generated/clipped-image-frag.h" +#include "generated/clipped-image-vert.h" namespace ClippedImage { diff --git a/examples/deferred-shading/deferred-shading.cpp b/examples/deferred-shading/deferred-shading.cpp index 28cf835..8a2f93b 100644 --- a/examples/deferred-shading/deferred-shading.cpp +++ b/examples/deferred-shading/deferred-shading.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -21,10 +21,10 @@ #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; diff --git a/examples/fpp-game/game-renderer.cpp b/examples/fpp-game/game-renderer.cpp index c8a24da..d51ce9e 100644 --- a/examples/fpp-game/game-renderer.cpp +++ b/examples/fpp-game/game-renderer.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -19,8 +19,8 @@ #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 diff --git a/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp b/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp index 076f925..2ba4d3a 100644 --- a/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp +++ b/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -134,12 +134,21 @@ SamplingMode::Type NextFilterMode(SamplingMode::Type oldMode) 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 diff --git a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp index 0e5c538..7fe4b6d 100644 --- a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp +++ b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -577,7 +577,9 @@ public: 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; diff --git a/examples/image-view-url/image-view-url-example.cpp b/examples/image-view-url/image-view-url-example.cpp index 7f2b4dd..d3f1038 100644 --- a/examples/image-view-url/image-view-url-example.cpp +++ b/examples/image-view-url/image-view-url-example.cpp @@ -18,8 +18,8 @@ #include #include -#include "shared/view.h" #include "generated/image-view-url-frag.h" +#include "shared/view.h" using namespace Dali; diff --git a/examples/line-mesh/line-mesh-example.cpp b/examples/line-mesh/line-mesh-example.cpp index 1bc3589..a71ce30 100644 --- a/examples/line-mesh/line-mesh-example.cpp +++ b/examples/line-mesh/line-mesh-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -21,9 +21,9 @@ #include // 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 @@ -31,7 +31,6 @@ using namespace Dali; 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}; diff --git a/examples/mesh-morph/mesh-morph-example.cpp b/examples/mesh-morph/mesh-morph-example.cpp index 852449c..0718858 100644 --- a/examples/mesh-morph/mesh-morph-example.cpp +++ b/examples/mesh-morph/mesh-morph-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -20,15 +20,14 @@ #include // 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 diff --git a/examples/mesh-visual/mesh-visual-example.cpp b/examples/mesh-visual/mesh-visual-example.cpp index 7a0548a..63a82b4 100644 --- a/examples/mesh-visual/mesh-visual-example.cpp +++ b/examples/mesh-visual/mesh-visual-example.cpp @@ -417,8 +417,8 @@ public: { //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(); diff --git a/examples/metaball-explosion/metaball-explosion-example.cpp b/examples/metaball-explosion/metaball-explosion-example.cpp index ae39e8d..d9c295f 100644 --- a/examples/metaball-explosion/metaball-explosion-example.cpp +++ b/examples/metaball-explosion/metaball-explosion-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -27,10 +27,10 @@ #include // 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; diff --git a/examples/metaball-refrac/metaball-refrac-example.cpp b/examples/metaball-refrac/metaball-refrac-example.cpp index a25e5c3..6114248 100644 --- a/examples/metaball-refrac/metaball-refrac-example.cpp +++ b/examples/metaball-refrac/metaball-refrac-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -26,11 +26,11 @@ #include // 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; diff --git a/examples/native-image-source/native-image-source-example.cpp b/examples/native-image-source/native-image-source-example.cpp index dad40d3..c1d0f01 100644 --- a/examples/native-image-source/native-image-source-example.cpp +++ b/examples/native-image-source/native-image-source-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -21,9 +21,9 @@ #include // 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; diff --git a/examples/particles/float-rand.h b/examples/particles/float-rand.h index 7589a8e..d050e7a 100644 --- a/examples/particles/float-rand.h +++ b/examples/particles/float-rand.h @@ -1,7 +1,7 @@ #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. @@ -20,14 +20,15 @@ struct FloatRand { - std::random_device mDevice; - std::mt19937 mMersenneTwister; + std::random_device mDevice; + std::mt19937 mMersenneTwister; std::uniform_real_distribution mDistribution; FloatRand() : mMersenneTwister(mDevice()), mDistribution(0., 1.) - {} + { + } float operator()() { diff --git a/examples/particles/particle-field.h b/examples/particles/particle-field.h index eb112db..1d516b5 100644 --- a/examples/particles/particle-field.h +++ b/examples/particles/particle-field.h @@ -1,7 +1,7 @@ #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. @@ -16,34 +16,34 @@ * limitations under the License. * */ -#include "utils.h" -#include "float-rand.h" +#include #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 +#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 @@ -58,14 +58,14 @@ struct ParticleField 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), @@ -75,27 +75,27 @@ struct ParticleField }; Vector3 particlesPerAxis = GetParticlesPerAxisSafe(); - auto numParticles = particlesPerAxis.x * particlesPerAxis.y * particlesPerAxis.z; + auto numParticles = particlesPerAxis.x * particlesPerAxis.y * particlesPerAxis.z; std::vector 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); @@ -108,26 +108,25 @@ struct ParticleField 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; } }; diff --git a/examples/particles/particle-view.cpp b/examples/particles/particle-view.cpp index 966a1e4..3194143 100644 --- a/examples/particles/particle-view.cpp +++ b/examples/particles/particle-view.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -15,13 +15,13 @@ * */ #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 @@ -31,7 +31,6 @@ using namespace Dali; namespace { - const uint32_t POPULATION_GRANULARITY = 128; uint32_t GetSkipValue(uint32_t count, uint32_t prime) @@ -40,19 +39,17 @@ 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(); @@ -61,8 +58,8 @@ ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali:: // 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); @@ -70,16 +67,16 @@ ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali:: 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::value; ++i) + for(uint32_t i = 0; i < std::extent::value; ++i) { char* writep2 = writep + snprintf(writep, sizeof(nameBuffer) - std::distance(nameBuffer, writep), "%d].", i); @@ -97,18 +94,18 @@ ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali:: // 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)); @@ -124,7 +121,7 @@ ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali:: 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); @@ -134,7 +131,7 @@ ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali:: #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 @@ -147,19 +144,19 @@ ParticleView::~ParticleView() 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(); @@ -204,23 +201,26 @@ void ParticleView::SetFadeRange(float near, float far) 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(); @@ -230,7 +230,7 @@ void ParticleView::SetAngularVelocity(float v) void ParticleView::SetLinearVelocity(float v) { - if (mLinearAnim) + if(mLinearAnim) { mLinearAnim.Stop(); mLinearAnim.Clear(); @@ -238,13 +238,13 @@ void ParticleView::SetLinearVelocity(float v) } 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(); + Actor slaveParticles = CloneActor(mMasterParticles); + Vector3 position = mMasterParticles.GetCurrentProperty(Actor::Property::POSITION).Get(); slaveParticles.SetProperty(Actor::Property::POSITION, position + Vector3(0., 0., directedSize)); auto propSecondaryColor = slaveParticles.RegisterProperty("uSecondaryColor", Vector3::XAXIS); @@ -252,24 +252,21 @@ void ParticleView::SetLinearVelocity(float v) 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(slaveParticles, Actor::Property::COLOR, - EqualToConstraint()); + Constraint constraint = Constraint::New(slaveParticles, Actor::Property::COLOR, EqualToConstraint()); constraint.AddSource(Source(mMasterParticles, Actor::Property::COLOR)); constraint.Apply(); - constraint = Constraint::New(slaveParticles, propSecondaryColor, - EqualToConstraint()); + constraint = Constraint::New(slaveParticles, propSecondaryColor, EqualToConstraint()); constraint.AddSource(Source(mMasterParticles, mPropSecondaryColor)); constraint.Apply(); - constraint = Constraint::New(slaveParticles, Actor::Property::ORIENTATION, - EqualToConstraint()); + constraint = Constraint::New(slaveParticles, Actor::Property::ORIENTATION, EqualToConstraint()); constraint.AddSource(Source(mMasterParticles, Actor::Property::ORIENTATION)); constraint.Apply(); @@ -279,7 +276,7 @@ void ParticleView::SetLinearVelocity(float v) anim.SetLoopCount(0); anim.Play(); - mLinearAnim = anim; + mLinearAnim = anim; mSlaveParticles = slaveParticles; } } @@ -289,7 +286,7 @@ void ParticleView::Scatter(float radius, float amount, float durationOut, float mActiveScatter = (mActiveScatter + 1) % std::extent::value; auto& scatter = mScatterProps[mActiveScatter]; - if (scatter.mAnim) + if(scatter.mAnim) { scatter.mAnim.Stop(); } @@ -298,12 +295,10 @@ void ParticleView::Scatter(float radius, float amount, float durationOut, float 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; @@ -312,25 +307,25 @@ void ParticleView::Scatter(float radius, float amount, float durationOut, float 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 onFinished) +void ParticleView::Fade(float duration, float target, AlphaFunction alphaFn, std::function 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); } @@ -339,11 +334,10 @@ void ParticleView::Fade(float duration, float target, AlphaFunction alphaFn, mFadeAnim = anim; } -void ParticleView::Fade(float duration, float target, float from, AlphaFunction alphaFn, - std::function onFinished) +void ParticleView::Fade(float duration, float target, float from, AlphaFunction alphaFn, std::function onFinished) { mMasterParticles.SetProperty(Actor::Property::COLOR_ALPHA, from); - if (mSlaveParticles) + if(mSlaveParticles) { mSlaveParticles.SetProperty(Actor::Property::COLOR_ALPHA, from); } diff --git a/examples/particles/particle-view.h b/examples/particles/particle-view.h index 099f568..e1f5d85 100644 --- a/examples/particles/particle-view.h +++ b/examples/particles/particle-view.h @@ -1,7 +1,7 @@ #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. @@ -17,13 +17,13 @@ * */ -#include "particle-field.h" +#include +#include #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 -#include +#include "particle-field.h" struct ColorRange { @@ -31,11 +31,10 @@ 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); @@ -62,15 +61,13 @@ public: ///@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 onFinished = nullptr); + void Fade(float duration, float target, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT, std::function 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 onFinished = nullptr); + void Fade(float duration, float target, float from, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT, std::function onFinished = nullptr); private: // DATA struct ScatterProps @@ -83,9 +80,9 @@ private: // DATA }; Dali::WeakHandle 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; @@ -93,9 +90,9 @@ private: // DATA 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; diff --git a/examples/particles/particles-example.cpp b/examples/particles/particles-example.cpp index 22dd815..72ff085 100644 --- a/examples/particles/particles-example.cpp +++ b/examples/particles/particles-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -16,38 +16,37 @@ */ // INTERNAL INCLUDES -#include "particle-view.h" -#include "float-rand.h" -#include "particle-field.h" -#include "utils.h" +#include +#include +#include +#include +#include +#include #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 -#include -#include -#include -#include -#include +#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 @@ -63,23 +62,23 @@ const ParticleField PARTICLE_FIELD = { .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; @@ -95,7 +94,7 @@ public: void Add(Dali::Vector2 tilt) { mTiltSamples[mIdxNextSample] = tilt; - mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE; + mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE; } Dali::Vector2 Filter() const @@ -104,17 +103,20 @@ public: } 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); @@ -127,8 +129,8 @@ private: CameraActor mCamera; - Actor mWorld; - Vector2 mAngularPosition; + Actor mWorld; + Vector2 mAngularPosition; ColorRange mColors; std::unique_ptr mParticles; @@ -141,20 +143,20 @@ private: 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 { @@ -164,10 +166,10 @@ private: } // 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(); @@ -205,23 +207,23 @@ private: 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); @@ -230,8 +232,8 @@ private: } break; - default: - break; + default: + break; } } @@ -240,7 +242,7 @@ private: 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)); @@ -251,33 +253,33 @@ private: 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(); 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(); + const float fov = mCamera.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get(); const float tanFov = std::tan(fov); const float zNear = mCamera.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get(); const float hProj = zNear * tanFov; const float aspectRatio = mCamera.GetProperty(CameraActor::Property::ASPECT_RATIO).Get(); - 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; @@ -287,7 +289,7 @@ private: 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(); @@ -303,7 +305,7 @@ private: void TriggerColorTransition(const ColorRange& range) { - if (mParticles) + if(mParticles) { mExpiringParticles = std::move(mParticles); @@ -328,12 +330,12 @@ private: } }; -} // 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; } diff --git a/examples/particles/utils.cpp b/examples/particles/utils.cpp index 7f7432e..3d585ba 100644 --- a/examples/particles/utils.cpp +++ b/examples/particles/utils.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -24,10 +24,10 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) 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; } @@ -40,7 +40,7 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) 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; } @@ -56,7 +56,7 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) 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) { @@ -64,50 +64,50 @@ Vector3 FromHueSaturationLightness(Vector3 hsl) } 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 @@ -120,38 +120,35 @@ Vector3 FromHueSaturationLightness(Vector3 hsl) 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::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::value); Geometry geometry = Geometry::New(); - geometry.AddVertexBuffer( vertexBuffer ); - geometry.SetIndexBuffer( indices, std::extent::value ); + geometry.AddVertexBuffer(vertexBuffer); + geometry.SetIndexBuffer(indices, std::extent::value); geometry.SetType(Geometry::LINES); return geometry; } @@ -160,14 +157,14 @@ Renderer CreateRenderer(TextureSet textures, Geometry geometry, Shader shader, u { 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(); } @@ -178,8 +175,8 @@ Renderer CreateRenderer(TextureSet textures, Geometry geometry, Shader shader, u 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() @@ -191,15 +188,15 @@ 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)); @@ -223,17 +220,17 @@ Actor CloneActor(Actor original) // 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)); } diff --git a/examples/particles/utils.h b/examples/particles/utils.h index 10dee0d..ca7cfa1 100644 --- a/examples/particles/utils.h +++ b/examples/particles/utils.h @@ -1,7 +1,7 @@ #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. @@ -17,20 +17,18 @@ * */ +#include #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 // // Maths // -inline -float FastFloor(float x) +inline float FastFloor(float x) { return static_cast(x) - static_cast(x < 0); } @@ -52,9 +50,9 @@ Dali::Geometry CreateCuboidWireframeGeometry(); 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 }; @@ -62,8 +60,7 @@ enum RendererOptions /// 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); diff --git a/examples/perf-scroll/perf-scroll.cpp b/examples/perf-scroll/perf-scroll.cpp index dc6cdc8..19e2737 100644 --- a/examples/perf-scroll/perf-scroll.cpp +++ b/examples/perf-scroll/perf-scroll.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -17,9 +17,9 @@ #include #include -#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; diff --git a/examples/point-mesh/point-mesh-example.cpp b/examples/point-mesh/point-mesh-example.cpp index 1e66ab5..ba0b435 100644 --- a/examples/point-mesh/point-mesh-example.cpp +++ b/examples/point-mesh/point-mesh-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -19,10 +19,10 @@ #include // 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; diff --git a/examples/primitive-shapes/primitive-shapes-example.cpp b/examples/primitive-shapes/primitive-shapes-example.cpp index 903300a..f19a3d4 100644 --- a/examples/primitive-shapes/primitive-shapes-example.cpp +++ b/examples/primitive-shapes/primitive-shapes-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -639,12 +639,12 @@ public: { //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(); mModel.SetProperty(Actor::Property::ORIENTATION, q * q0); @@ -698,7 +698,7 @@ private: 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) diff --git a/examples/reflection-demo/gltf-scene.cpp b/examples/reflection-demo/gltf-scene.cpp index a303e21..d752149 100644 --- a/examples/reflection-demo/gltf-scene.cpp +++ b/examples/reflection-demo/gltf-scene.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -68,6 +68,7 @@ struct JsonResult { bool success; T result; + operator T() const { return static_cast(result); diff --git a/examples/reflection-demo/gltf-scene.h b/examples/reflection-demo/gltf-scene.h index 048111b..5639c4a 100644 --- a/examples/reflection-demo/gltf-scene.h +++ b/examples/reflection-demo/gltf-scene.h @@ -2,7 +2,7 @@ #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. @@ -18,10 +18,9 @@ * */ - // EXTERNAL INCLUDES -#include #include +#include // INTERNAL INCLUDES #include "third-party/pico-json.h" diff --git a/examples/reflection-demo/reflection-example.cpp b/examples/reflection-demo/reflection-example.cpp index f7f50ae..7731818 100644 --- a/examples/reflection-demo/reflection-example.cpp +++ b/examples/reflection-demo/reflection-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -21,19 +21,18 @@ #include -#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; @@ -467,10 +466,7 @@ private: 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(); diff --git a/examples/refraction-effect/refraction-effect-example.cpp b/examples/refraction-effect/refraction-effect-example.cpp index cbea48b..37e83dd 100644 --- a/examples/refraction-effect/refraction-effect-example.cpp +++ b/examples/refraction-effect/refraction-effect-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -26,12 +26,12 @@ #include // 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; diff --git a/examples/renderer-stencil/renderer-stencil-example.cpp b/examples/renderer-stencil/renderer-stencil-example.cpp index 2290639..d48e6aa 100644 --- a/examples/renderer-stencil/renderer-stencil-example.cpp +++ b/examples/renderer-stencil/renderer-stencil-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -16,16 +16,16 @@ */ // EXTERNAL INCLUDES -#include #include +#include // 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; diff --git a/examples/rendering-basic-light/rendering-basic-light-example.cpp b/examples/rendering-basic-light/rendering-basic-light-example.cpp index 85588c6..e11ce15 100644 --- a/examples/rendering-basic-light/rendering-basic-light-example.cpp +++ b/examples/rendering-basic-light/rendering-basic-light-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -18,8 +18,8 @@ #include #include -#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; diff --git a/examples/rendering-basic-pbr/ktx-loader.cpp b/examples/rendering-basic-pbr/ktx-loader.cpp index bdd45e9..9fc15c1 100644 --- a/examples/rendering-basic-pbr/ktx-loader.cpp +++ b/examples/rendering-basic-pbr/ktx-loader.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -94,7 +94,7 @@ bool ConvertPixelFormat(const uint32_t ktxPixelFormat, Dali::Pixel::Format& form bool LoadCubeMapFromKtxFile(const std::string& path, CubeData& cubedata) { Dali::FileStream daliFileStream(path); - FILE* fp(daliFileStream.GetFile()); + FILE* fp(daliFileStream.GetFile()); if(!fp) { return false; diff --git a/examples/rendering-basic-pbr/model-skybox.cpp b/examples/rendering-basic-pbr/model-skybox.cpp index 03597f7..a4d187e 100644 --- a/examples/rendering-basic-pbr/model-skybox.cpp +++ b/examples/rendering-basic-pbr/model-skybox.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -24,9 +24,9 @@ #include // 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() { diff --git a/examples/rendering-cube/rendering-cube.cpp b/examples/rendering-cube/rendering-cube.cpp index 08cf1c7..89bd5c9 100644 --- a/examples/rendering-cube/rendering-cube.cpp +++ b/examples/rendering-cube/rendering-cube.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -18,8 +18,8 @@ #include #include -#include "generated/rendering-cube-vert.h" #include "generated/rendering-cube-frag.h" +#include "generated/rendering-cube-vert.h" using namespace Dali; using namespace Toolkit; diff --git a/examples/rendering-line/rendering-line.cpp b/examples/rendering-line/rendering-line.cpp index ad20fc9..3b10e56 100644 --- a/examples/rendering-line/rendering-line.cpp +++ b/examples/rendering-line/rendering-line.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -18,8 +18,8 @@ #include #include -#include "generated/rendering-line-vert.h" #include "generated/rendering-line-frag.h" +#include "generated/rendering-line-vert.h" using namespace Dali; using namespace Toolkit; diff --git a/examples/rendering-radial-progress/radial-progress.cpp b/examples/rendering-radial-progress/radial-progress.cpp index 9bd55cd..ed8f450 100644 --- a/examples/rendering-radial-progress/radial-progress.cpp +++ b/examples/rendering-radial-progress/radial-progress.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -18,10 +18,10 @@ #include #include -#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; diff --git a/examples/rendering-skybox/rendering-skybox.cpp b/examples/rendering-skybox/rendering-skybox.cpp index ec4f38c..c0083b9 100644 --- a/examples/rendering-skybox/rendering-skybox.cpp +++ b/examples/rendering-skybox/rendering-skybox.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -18,18 +18,17 @@ #include #include -#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); diff --git a/examples/rendering-textured-cube/rendering-textured-cube.cpp b/examples/rendering-textured-cube/rendering-textured-cube.cpp index 646e296..32d323d 100644 --- a/examples/rendering-textured-cube/rendering-textured-cube.cpp +++ b/examples/rendering-textured-cube/rendering-textured-cube.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -18,15 +18,14 @@ #include #include -#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 diff --git a/examples/rendering-triangle/rendering-triangle.cpp b/examples/rendering-triangle/rendering-triangle.cpp index cecce9a..f7bb8ca 100644 --- a/examples/rendering-triangle/rendering-triangle.cpp +++ b/examples/rendering-triangle/rendering-triangle.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -18,8 +18,8 @@ #include #include -#include "generated/rendering-triangle-vert.h" #include "generated/rendering-triangle-frag.h" +#include "generated/rendering-triangle-vert.h" using namespace Dali; using namespace Toolkit; diff --git a/examples/scene-loader/main.cpp b/examples/scene-loader/main.cpp index c87244a..630aa26 100644 --- a/examples/scene-loader/main.cpp +++ b/examples/scene-loader/main.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -22,7 +22,7 @@ using namespace Dali; int DALI_EXPORT_API main(int argc, char** argv) { - auto app = Application::New(&argc, &argv, DEMO_THEME_PATH); + auto app = Application::New(&argc, &argv, DEMO_THEME_PATH); SceneLoaderExample sceneLoader(app); app.MainLoop(); return 0; diff --git a/examples/scene-loader/scene-loader-example.cpp b/examples/scene-loader/scene-loader-example.cpp index 90df3da..9a1f116 100644 --- a/examples/scene-loader/scene-loader-example.cpp +++ b/examples/scene-loader/scene-loader-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -15,23 +15,23 @@ * */ #include "scene-loader-example.h" +#include +#include +#include +#include "dali-scene-loader/public-api/dli-loader.h" #include "dali-scene-loader/public-api/gltf2-loader.h" -#include "dali-scene-loader/public-api/shader-definition-factory.h" #include "dali-scene-loader/public-api/light-parameters.h" -#include "dali-scene-loader/public-api/dli-loader.h" #include "dali-scene-loader/public-api/load-result.h" -#include "dali/public-api/adaptor-framework/key.h" -#include "dali/public-api/events/key-event.h" -#include "dali/public-api/actors/layer.h" -#include "dali/public-api/render-tasks/render-task-list.h" -#include "dali/public-api/object/property-array.h" -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h" +#include "dali-scene-loader/public-api/shader-definition-factory.h" #include "dali-toolkit/public-api/controls/scrollable/item-view/default-item-layout.h" +#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h" #include "dali-toolkit/public-api/controls/text-controls/text-label.h" #include "dali-toolkit/public-api/visuals/gradient-visual-properties.h" -#include -#include -#include +#include "dali/public-api/actors/layer.h" +#include "dali/public-api/adaptor-framework/key.h" +#include "dali/public-api/events/key-event.h" +#include "dali/public-api/object/property-array.h" +#include "dali/public-api/render-tasks/render-task-list.h" using namespace Dali; using namespace Dali::Toolkit; @@ -39,14 +39,13 @@ using namespace Dali::SceneLoader; namespace { - const float ROTATION_SCALE = 180.f; // the amount of rotation that a swipe whose length is the width of the screen, causes, in degrees. const float ITEM_HEIGHT = 50.f; const Vector3 CAMERA_DEFAULT_POSITION(0.0f, 0.0f, 3.5f); -const std::string_view DLI_EXTENSION = ".dli"; +const std::string_view DLI_EXTENSION = ".dli"; const std::string_view GLTF_EXTENSION = ".gltf"; const std::string RESOURCE_TYPE_DIRS[]{ @@ -58,18 +57,19 @@ const std::string RESOURCE_TYPE_DIRS[]{ using StringVector = std::vector; -StringVector ListFiles(const std::string& path, bool(*predicate)(const char*) = [](const char*) { return true; }) +StringVector ListFiles( + const std::string& path, bool (*predicate)(const char*) = [](const char*) { return true; }) { StringVector results; - if (auto dirp = opendir(path.c_str())) + if(auto dirp = opendir(path.c_str())) { - std::unique_ptr dir(dirp, closedir); + std::unique_ptr dir(dirp, closedir); struct dirent* ent; - while ((ent = readdir(dir.get())) != nullptr) + while((ent = readdir(dir.get())) != nullptr) { - if (ent->d_type == DT_REG && predicate(ent->d_name)) + if(ent->d_type == DT_REG && predicate(ent->d_name)) { results.push_back(ent->d_name); } @@ -91,12 +91,13 @@ TextLabel MakeLabel(std::string msg) struct ItemFactoryImpl : Dali::Toolkit::ItemFactory { const std::vector& mSceneNames; - TapGestureDetector mTapDetector; + TapGestureDetector mTapDetector; ItemFactoryImpl(const std::vector& sceneNames, TapGestureDetector tapDetector) : mSceneNames(sceneNames), mTapDetector(tapDetector) - {} + { + } unsigned int GetNumberOfItems() override { @@ -122,7 +123,7 @@ Actor CreateErrorMessage(std::string msg) void ConfigureCamera(const CameraParameters& params, CameraActor camera) { - if (params.isPerspective) + if(params.isPerspective) { camera.SetProjectionMode(Camera::PERSPECTIVE_PROJECTION); camera.SetNearClippingPlane(params.zNear); @@ -133,16 +134,16 @@ void ConfigureCamera(const CameraParameters& params, CameraActor camera) { camera.SetProjectionMode(Camera::ORTHOGRAPHIC_PROJECTION); camera.SetOrthographicProjection(params.orthographicSize.x, - params.orthographicSize.y, - params.orthographicSize.z, - params.orthographicSize.w, - params.zNear, - params.zFar); + params.orthographicSize.y, + params.orthographicSize.z, + params.orthographicSize.w, + params.zNear, + params.zFar); } // model - Vector3 camTranslation; - Vector3 camScale; + Vector3 camTranslation; + Vector3 camScale; Quaternion camOrientation; params.CalculateTransformComponents(camTranslation, camOrientation, camScale); @@ -155,17 +156,16 @@ void ConfigureCamera(const CameraParameters& params, CameraActor camera) camOrientation.Conjugate(); } -void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root, - std::vector&& requests) +void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root, std::vector&& requests) { std::vector errors; - auto onError = [&errors](const std::string& msg) { + auto onError = [&errors](const std::string& msg) { errors.push_back(msg); }; - if (!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError)) + if(!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError)) { ExceptionFlinger flinger(ASSERT_LOCATION); - for (auto& msg : errors) + for(auto& msg : errors) { flinger << msg << '\n'; } @@ -180,12 +180,12 @@ Actor LoadScene(std::string sceneName, CameraActor camera) auto path = pathProvider(ResourceType::Mesh) + sceneName; - ResourceBundle resources; - SceneDefinition scene; + ResourceBundle resources; + SceneDefinition scene; std::vector animGroups; - std::vector cameraParameters; - std::vector lights; - std::vector animations; + std::vector cameraParameters; + std::vector lights; + std::vector animations; LoadResult output{ resources, @@ -193,12 +193,11 @@ Actor LoadScene(std::string sceneName, CameraActor camera) animations, animGroups, cameraParameters, - lights - }; + lights}; - if (sceneName.rfind(DLI_EXTENSION) == sceneName.size() - DLI_EXTENSION.size()) + if(sceneName.rfind(DLI_EXTENSION) == sceneName.size() - DLI_EXTENSION.size()) { - DliLoader loader; + DliLoader loader; DliLoader::InputParams input{ pathProvider(ResourceType::Mesh), nullptr, @@ -206,8 +205,8 @@ Actor LoadScene(std::string sceneName, CameraActor camera) {}, nullptr, }; - DliLoader::LoadParams loadParams{ input, output }; - if (!loader.LoadScene(path, loadParams)) + DliLoader::LoadParams loadParams{input, output}; + if(!loader.LoadScene(path, loadParams)) { ExceptionFlinger(ASSERT_LOCATION) << "Failed to load scene from '" << path << "': " << loader.GetParseError(); } @@ -221,7 +220,7 @@ Actor LoadScene(std::string sceneName, CameraActor camera) resources.mEnvironmentMaps.push_back({}); } - if (cameraParameters.empty()) + if(cameraParameters.empty()) { cameraParameters.push_back(CameraParameters()); cameraParameters[0].matrix.SetTranslation(CAMERA_DEFAULT_POSITION); @@ -229,20 +228,18 @@ Actor LoadScene(std::string sceneName, CameraActor camera) ConfigureCamera(cameraParameters[0], camera); ViewProjection viewProjection = cameraParameters[0].GetViewProjection(); - Transforms xforms{ + Transforms xforms{ MatrixStack{}, - viewProjection - }; + viewProjection}; NodeDefinition::CreateParams nodeParams{ resources, - xforms - }; + xforms}; Customization::Choices choices; Actor root = Actor::New(); SetActorCentered(root); - for (auto iRoot : scene.GetRoots()) + for(auto iRoot : scene.GetRoots()) { auto resourceRefs = resources.CreateRefCounter(); scene.CountResourceRefs(iRoot, choices, resourceRefs); @@ -250,7 +247,7 @@ Actor LoadScene(std::string sceneName, CameraActor camera) resources.LoadResources(resourceRefs, pathProvider); - if (auto actor = scene.CreateNodes(iRoot, choices, nodeParams)) + if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams)) { scene.ConfigureSkeletonJoints(iRoot, resources.mSkeletons, actor); scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables)); @@ -262,7 +259,7 @@ Actor LoadScene(std::string sceneName, CameraActor camera) } } - if (!animations.empty()) + if(!animations.empty()) { auto getActor = [&root](const std::string& name) { return root.FindChildByName(name); @@ -274,14 +271,14 @@ Actor LoadScene(std::string sceneName, CameraActor camera) return root; } -} // nonamespace +} // namespace SceneLoaderExample::SceneLoaderExample(Dali::Application& app) : mApp(app) { - if (!std::getenv("DALI_APPLICATION_PACKAGE")) + if(!std::getenv("DALI_APPLICATION_PACKAGE")) { - if (auto desktopPrefix = std::getenv("DESKTOP_PREFIX")) + if(auto desktopPrefix = std::getenv("DESKTOP_PREFIX")) { std::stringstream sstr; sstr << desktopPrefix << "/share/com.samsung.dali-demo/res/"; @@ -298,14 +295,14 @@ SceneLoaderExample::SceneLoaderExample(Dali::Application& app) void SceneLoaderExample::OnInit(Application& app) { // get scenes - auto resPath = Application::GetResourcePath(); - auto scenePath = resPath + RESOURCE_TYPE_DIRS[ResourceType::Mesh]; + auto resPath = Application::GetResourcePath(); + auto scenePath = resPath + RESOURCE_TYPE_DIRS[ResourceType::Mesh]; auto sceneNames = ListFiles(scenePath, [](const char* name) { auto len = strlen(name); return (len > DLI_EXTENSION.size() && DLI_EXTENSION.compare(name + (len - DLI_EXTENSION.size())) == 0) || - (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0); + (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0); }); - mSceneNames = sceneNames; + mSceneNames = sceneNames; // create Dali objects auto window = app.GetWindow(); @@ -324,13 +321,14 @@ void SceneLoaderExample::OnInit(Application& app) stopColors.PushBack(Vector4(0.45f, 0.7f, 0.8f, 1.f)); // Medium bright, pastel blue const float percentageWindowHeight = window.GetSize().GetHeight() * 0.6f; - navigationView.SetProperty(Toolkit::Control::Property::BACKGROUND, Dali::Property::Map(). - Add(Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::GRADIENT). - Add(Toolkit::GradientVisual::Property::STOP_OFFSET, stopOffsets). - Add(Toolkit::GradientVisual::Property::STOP_COLOR, stopColors). - Add(Toolkit::GradientVisual::Property::START_POSITION, Vector2(0.f, -percentageWindowHeight)). - Add(Toolkit::GradientVisual::Property::END_POSITION, Vector2(0.f, percentageWindowHeight)). - Add(Toolkit::GradientVisual::Property::UNITS, Toolkit::GradientVisual::Units::USER_SPACE)); + navigationView.SetProperty(Toolkit::Control::Property::BACKGROUND, + Dali::Property::Map() + .Add(Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::GRADIENT) + .Add(Toolkit::GradientVisual::Property::STOP_OFFSET, stopOffsets) + .Add(Toolkit::GradientVisual::Property::STOP_COLOR, stopColors) + .Add(Toolkit::GradientVisual::Property::START_POSITION, Vector2(0.f, -percentageWindowHeight)) + .Add(Toolkit::GradientVisual::Property::END_POSITION, Vector2(0.f, percentageWindowHeight)) + .Add(Toolkit::GradientVisual::Property::UNITS, Toolkit::GradientVisual::Units::USER_SPACE)); window.Add(navigationView); mNavigationView = navigationView; @@ -344,13 +342,13 @@ void SceneLoaderExample::OnInit(Application& app) items.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true); Vector3 windowSize(window.GetSize()); - auto itemLayout = DefaultItemLayout::New(DefaultItemLayout::LIST); + auto itemLayout = DefaultItemLayout::New(DefaultItemLayout::LIST); itemLayout->SetItemSize(Vector3(windowSize.x, ITEM_HEIGHT, 1.f)); items.AddLayout(*itemLayout); navigationView.Push(items); mItemLayout = itemLayout; - mItemView = items; + mItemView = items; // camera auto camera = CameraActor::New(); @@ -373,7 +371,7 @@ void SceneLoaderExample::OnTerminate(Application& app) mTapDetector.Reset(); mPanDetector.Reset(); - auto window = app.GetWindow(); + auto window = app.GetWindow(); auto renderTasks = window.GetRenderTaskList(); renderTasks.RemoveTask(mSceneRender); mSceneRender.Reset(); @@ -386,11 +384,11 @@ void SceneLoaderExample::OnTerminate(Application& app) void SceneLoaderExample::OnKey(const KeyEvent& e) { - if (e.GetState() == KeyEvent::UP) + if(e.GetState() == KeyEvent::UP) { - if (IsKey(e, DALI_KEY_ESCAPE) || IsKey(e, DALI_KEY_BACK)) + if(IsKey(e, DALI_KEY_ESCAPE) || IsKey(e, DALI_KEY_BACK)) { - if (mScene) + if(mScene) { mPanDetector.Reset(); @@ -407,15 +405,15 @@ void SceneLoaderExample::OnKey(const KeyEvent& e) void SceneLoaderExample::OnPan(Actor actor, const PanGesture& pan) { - auto windowSize = mApp.GetWindow().GetSize(); - Vector2 size{ float(windowSize.GetWidth()), float(windowSize.GetHeight()) }; - float aspect = size.y / size.x; + auto windowSize = mApp.GetWindow().GetSize(); + Vector2 size{float(windowSize.GetWidth()), float(windowSize.GetHeight())}; + float aspect = size.y / size.x; size /= ROTATION_SCALE; - Vector2 rotation{ pan.GetDisplacement().x / size.x, pan.GetDisplacement().y / size.y * aspect }; + Vector2 rotation{pan.GetDisplacement().x / size.x, pan.GetDisplacement().y / size.y * aspect}; - Quaternion q = Quaternion(Radian(Degree(rotation.y)), Radian(Degree(rotation.x)), Radian(0.f)); + Quaternion q = Quaternion(Radian(Degree(rotation.y)), Radian(Degree(rotation.x)), Radian(0.f)); Quaternion q0 = mScene.GetProperty(Actor::Property::ORIENTATION).Get(); mScene.SetProperty(Actor::Property::ORIENTATION, q * q0); @@ -427,7 +425,7 @@ void SceneLoaderExample::OnTap(Dali::Actor actor, const Dali::TapGesture& tap) try { - auto window = mApp.GetWindow(); + auto window = mApp.GetWindow(); auto renderTasks = window.GetRenderTaskList(); renderTasks.RemoveTask(mSceneRender); @@ -438,14 +436,14 @@ void SceneLoaderExample::OnTap(Dali::Actor actor, const Dali::TapGesture& tap) sceneRender.SetSourceActor(scene); sceneRender.SetExclusive(true); - mScene = scene; + mScene = scene; mSceneRender = sceneRender; mPanDetector = PanGestureDetector::New(); mPanDetector.DetectedSignal().Connect(this, &SceneLoaderExample::OnPan); mPanDetector.Attach(mNavigationView); } - catch (const DaliException& e) + catch(const DaliException& e) { mScene = CreateErrorMessage(e.condition); } diff --git a/examples/scene-loader/scene-loader-example.h b/examples/scene-loader/scene-loader-example.h index e7183d8..b18c830 100644 --- a/examples/scene-loader/scene-loader-example.h +++ b/examples/scene-loader/scene-loader-example.h @@ -1,7 +1,7 @@ #ifndef SCENE_LAUNCHER_H_ #define SCENE_LAUNCHER_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. @@ -17,19 +17,19 @@ * */ #include "dali-scene-loader/public-api/animation-definition.h" -#include "dali-scene-loader/public-api/scene-definition.h" -#include "dali-scene-loader/public-api/node-definition.h" #include "dali-scene-loader/public-api/camera-parameters.h" +#include "dali-scene-loader/public-api/node-definition.h" +#include "dali-scene-loader/public-api/scene-definition.h" +#include "dali-toolkit/devel-api/controls/navigation-view/navigation-view.h" +#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h" +#include "dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h" +#include "dali-toolkit/public-api/controls/scrollable/item-view/item-view.h" +#include "dali/public-api/actors/camera-actor.h" +#include "dali/public-api/adaptor-framework/application.h" #include "dali/public-api/common/vector-wrapper.h" #include "dali/public-api/events/pan-gesture-detector.h" -#include "dali/public-api/actors/camera-actor.h" #include "dali/public-api/render-tasks/render-task.h" #include "dali/public-api/signals/connection-tracker.h" -#include "dali/public-api/adaptor-framework/application.h" -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-view.h" -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h" -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h" -#include "dali-toolkit/devel-api/controls/navigation-view/navigation-view.h" class SceneLoaderExample : public Dali::ConnectionTracker { @@ -37,7 +37,7 @@ public: SceneLoaderExample(Dali::Application& app); ~SceneLoaderExample() = default; -private: // data +private: // data Dali::Application& mApp; std::vector mSceneNames; @@ -45,19 +45,19 @@ private: // data Dali::Toolkit::NavigationView mNavigationView; std::unique_ptr mItemFactory; - Dali::Toolkit::ItemLayoutPtr mItemLayout; - Dali::Toolkit::ItemView mItemView; + Dali::Toolkit::ItemLayoutPtr mItemLayout; + Dali::Toolkit::ItemView mItemView; Dali::CameraActor mSceneCamera; - Dali::RenderTask mSceneRender; - Dali::Actor mScene; + Dali::RenderTask mSceneRender; + Dali::Actor mScene; Dali::Quaternion mCameraOrientationInv; Dali::TapGestureDetector mTapDetector; - Dali::PanGestureDetector mPanDetector; + Dali::PanGestureDetector mPanDetector; -private: // methods +private: // methods void OnInit(Dali::Application& app); void OnTerminate(Dali::Application& app); @@ -66,4 +66,4 @@ private: // methods void OnTap(Dali::Actor actor, const Dali::TapGesture& tap); }; -#endif //SCENE_LAUNCHER_H_ +#endif //SCENE_LAUNCHER_H_ diff --git a/examples/simple-text-field/simple-text-field.cpp b/examples/simple-text-field/simple-text-field.cpp index c62fb20..c6ab50e 100644 --- a/examples/simple-text-field/simple-text-field.cpp +++ b/examples/simple-text-field/simple-text-field.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -65,7 +65,7 @@ public: 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)); @@ -100,7 +100,7 @@ public: if(button == mButtonSelectionStart) { int iStart = mTextField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get() - 1; - if (iStart < 0) + if(iStart < 0) { iStart = 0; } @@ -108,22 +108,22 @@ public: } else if(button == mButtonSelectionEnd) { - mTextField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END , mTextField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get() + 1); + mTextField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, mTextField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get() + 1); } - else if (mBtnEditable == button) + else if(mBtnEditable == button) { - bool bEditable = !mTextField.GetProperty( DevelTextField::Property::ENABLE_EDITING).Get(); - 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(); + 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; @@ -145,10 +145,10 @@ public: private: Application& mApplication; - TextField mTextField; - PushButton mButtonSelectionStart; - PushButton mButtonSelectionEnd; - PushButton mBtnEditable; + TextField mTextField; + PushButton mButtonSelectionStart; + PushButton mButtonSelectionEnd; + PushButton mBtnEditable; }; void RunTest(Application& application) diff --git a/examples/simple-text-renderer/simple-text-renderer-example.cpp b/examples/simple-text-renderer/simple-text-renderer-example.cpp index c9c0017..9e6d105 100644 --- a/examples/simple-text-renderer/simple-text-renderer-example.cpp +++ b/examples/simple-text-renderer/simple-text-renderer-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -27,8 +27,8 @@ #include // 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; diff --git a/examples/sparkle/sparkle-effect.h b/examples/sparkle/sparkle-effect.h index c78d09c..e7f9002 100644 --- a/examples/sparkle/sparkle-effect.h +++ b/examples/sparkle/sparkle-effect.h @@ -2,7 +2,7 @@ #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. @@ -21,8 +21,8 @@ #include #include -#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; diff --git a/examples/styling/image-channel-control-impl.cpp b/examples/styling/image-channel-control-impl.cpp index cba48d1..9258327 100644 --- a/examples/styling/image-channel-control-impl.cpp +++ b/examples/styling/image-channel-control-impl.cpp @@ -31,7 +31,6 @@ namespace Internal { namespace { - Dali::BaseHandle Create() { return Demo::ImageChannelControl::New(); diff --git a/examples/textured-mesh/textured-mesh-example.cpp b/examples/textured-mesh/textured-mesh-example.cpp index b638a36..2423d8e 100644 --- a/examples/textured-mesh/textured-mesh-example.cpp +++ b/examples/textured-mesh/textured-mesh-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -19,10 +19,10 @@ #include // 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; diff --git a/examples/waves/utils.cpp b/examples/waves/utils.cpp index 8446939..d756e22 100644 --- a/examples/waves/utils.cpp +++ b/examples/waves/utils.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -15,8 +15,8 @@ * */ #include "utils.h" -#include "dali-toolkit/dali-toolkit.h" #include +#include "dali-toolkit/dali-toolkit.h" using namespace Dali; using namespace Dali::Toolkit; @@ -27,10 +27,10 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) 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; } @@ -43,7 +43,7 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) 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; } @@ -59,7 +59,7 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) 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) { @@ -67,50 +67,50 @@ Vector3 FromHueSaturationLightness(Vector3 hsl) } 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 @@ -121,8 +121,7 @@ Vector3 FromHueSaturationLightness(Vector3 hsl) 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; @@ -132,40 +131,40 @@ Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts, Vector2 aTexCoord; }; std::vector 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 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); @@ -178,7 +177,7 @@ Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts, } 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); @@ -201,8 +200,7 @@ 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; } @@ -211,14 +209,14 @@ Renderer CreateRenderer(TextureSet textures, Geometry geometry, Shader shader, u { 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(); } @@ -242,15 +240,15 @@ 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 = Dali::PropertyRanges::DEFAULT_RENDERER_PROPERTY_START_INDEX + i; clone.SetProperty(actualIndex, original.GetProperty(actualIndex)); @@ -274,17 +272,17 @@ Actor CloneActor(Actor original) // 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)); } diff --git a/examples/waves/utils.h b/examples/waves/utils.h index ea4366e..9ec7521 100644 --- a/examples/waves/utils.h +++ b/examples/waves/utils.h @@ -1,7 +1,7 @@ #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. @@ -16,38 +16,37 @@ * limitations under the License. * */ +#include #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 // // Maths // -inline -float FastFloor(float x) +inline float FastFloor(float x) { return static_cast(x) - static_cast(x < 0); } -inline -float Sign(float x) +inline float Sign(float x) { return float(x > 0.f) - float(x < .0f); } -template +template inline -typename std::decay::type Lerp( + typename std::decay::type + Lerp( const T& min, const T& max, float alpha) { return min + (max - min) * alpha; } -template +template T Normalized(T v) { v.Normalize(); @@ -68,22 +67,21 @@ Dali::Vector3 FromHueSaturationLightness(Dali::Vector3 hsl); // // 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 }; @@ -91,8 +89,7 @@ enum RendererOptions /// 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); diff --git a/examples/waves/waves-example.cpp b/examples/waves/waves-example.cpp index a4d2995..d6904b8 100644 --- a/examples/waves/waves-example.cpp +++ b/examples/waves/waves-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -16,59 +16,58 @@ */ // INTERNAL INCLUDES -#include "utils.h" +#include +#include +#include #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 -#include -#include +#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"; @@ -92,7 +91,7 @@ public: void Add(Dali::Vector2 tilt) { mTiltSamples[mIdxNextSample] = tilt; - mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE; + mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE; } Dali::Vector2 Filter() const @@ -101,22 +100,25 @@ public: } 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; @@ -124,9 +126,9 @@ public: private: Application& mApp; - CameraActor mCamera; // no ownership + CameraActor mCamera; // no ownership - Actor mWaves; + Actor mWaves; Shader mWaveShader; Property::Index mUInvLightDir{Property::INVALID_INDEX}; @@ -150,37 +152,35 @@ private: 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()); @@ -197,7 +197,7 @@ private: 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); @@ -206,7 +206,7 @@ private: 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); @@ -215,10 +215,10 @@ private: // 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 { @@ -239,7 +239,7 @@ private: mTimeAnim = animTime; } - void Destroy( Application& app) + void Destroy(Application& app) { mCamera.Reset(); @@ -251,38 +251,38 @@ private: 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(); - ambientColor = mWaveShader.GetProperty(mUAmbientColor).Get(); - invLightDir = mWaveShader.GetProperty(mUInvLightDir).Get(); - scrollScale = mWaveShader.GetProperty(mUScrollScale).Get(); - waveRate = mWaveShader.GetProperty(mUWaveRate).Get(); - waveAmp = mWaveShader.GetProperty(mUWaveAmplitude).Get(); + lightColorSqr = mWaveShader.GetProperty(mULightColorSqr).Get(); + ambientColor = mWaveShader.GetProperty(mUAmbientColor).Get(); + invLightDir = mWaveShader.GetProperty(mUInvLightDir).Get(); + scrollScale = mWaveShader.GetProperty(mUScrollScale).Get(); + waveRate = mWaveShader.GetProperty(mUWaveRate).Get(); + waveAmp = mWaveShader.GetProperty(mUWaveAmplitude).Get(); normalMapWeight = mWaveShader.GetProperty(mUNormalMapWeight).Get(); - specularity = mWaveShader.GetProperty(mUSpecularity).Get(); + specularity = mWaveShader.GetProperty(mUSpecularity).Get(); } - 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); @@ -293,7 +293,7 @@ private: void TriggerColorTransition(Vector3 wavesColor, Vector3 lightColor) { - if (mTransitionAnim) + if(mTransitionAnim) { mTransitionAnim.Stop(); } @@ -336,9 +336,9 @@ private: 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(); } @@ -354,24 +354,24 @@ private: 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())); @@ -380,17 +380,17 @@ private: 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; } diff --git a/shared/bubble-animator.cpp b/shared/bubble-animator.cpp index 5ce8e7c..5344f02 100644 --- a/shared/bubble-animator.cpp +++ b/shared/bubble-animator.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -18,13 +18,13 @@ // CLASS HEADER #include "bubble-animator.h" -#include -#include -#include +#include #include #include #include -#include +#include +#include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -32,19 +32,17 @@ using namespace Dali::Toolkit; namespace { const char* const BUBBLE_COLOR_STYLE_NAME[] = -{ - "BubbleColor1", - "BubbleColor2", - "BubbleColor3", - "BubbleColor4" -}; + { + "BubbleColor1", + "BubbleColor2", + "BubbleColor3", + "BubbleColor4"}; constexpr int NUMBER_OF_BUBBLE_COLORS(sizeof(BUBBLE_COLOR_STYLE_NAME) / sizeof(BUBBLE_COLOR_STYLE_NAME[0])); const char* const SHAPE_IMAGE_TABLE[] = -{ - DEMO_IMAGE_DIR "shape-circle.png", - DEMO_IMAGE_DIR "shape-bubble.png" -}; + { + DEMO_IMAGE_DIR "shape-circle.png", + DEMO_IMAGE_DIR "shape-bubble.png"}; constexpr int NUMBER_OF_SHAPE_IMAGES(sizeof(SHAPE_IMAGE_TABLE) / sizeof(SHAPE_IMAGE_TABLE[0])); constexpr int NUM_BACKGROUND_IMAGES = 18; @@ -157,7 +155,7 @@ void BubbleAnimator::InitializeBackgroundActors(Dali::Actor actor) // Define bubble horizontal parallax and vertical wrapping Actor scrollView = mScrollView.GetHandle(); - if( scrollView ) + if(scrollView) { Constraint animConstraint = Constraint::New(child, Actor::Property::POSITION, AnimateBubbleConstraint(childPos, Random::Range(-0.85f, 0.25f))); animConstraint.AddSource(Source(scrollView, ScrollView::Property::SCROLL_POSITION)); @@ -174,7 +172,6 @@ void BubbleAnimator::InitializeBackgroundActors(Dali::Actor actor) animation.Play(); mBackgroundAnimations.push_back(animation); } - } void BubbleAnimator::AddBackgroundActors(Actor layer, int count) diff --git a/shared/bubble-animator.h b/shared/bubble-animator.h index f8f6ce9..fed6bf1 100644 --- a/shared/bubble-animator.h +++ b/shared/bubble-animator.h @@ -2,7 +2,7 @@ #define DALI_DEMO_BUBBLE_ANIMATOR_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. @@ -19,12 +19,12 @@ */ // EXTERNAL INCLUDES -#include #include #include #include #include #include +#include /** * Creates and animates random sized bubbles @@ -32,7 +32,6 @@ class BubbleAnimator : public Dali::ConnectionTracker { public: - /** * @brief Initilizes the bubble background * @@ -47,7 +46,6 @@ public: void PlayAnimation(); private: - /** * @brief Used by the timer to pause the animation * @@ -71,13 +69,12 @@ private: void AddBackgroundActors(Dali::Actor layer, int count); private: - using AnimationList = std::vector; - Dali::WeakHandle mScrollView; ///< Weak handle to the scroll view used to apply a parallax effect when scrolling. - AnimationList mBackgroundAnimations; ///< List of background bubble animations. - Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period. - bool mBackgroundAnimsPlaying{false}; ///< Are background animations playing. + Dali::WeakHandle mScrollView; ///< Weak handle to the scroll view used to apply a parallax effect when scrolling. + AnimationList mBackgroundAnimations; ///< List of background bubble animations. + Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period. + bool mBackgroundAnimsPlaying{false}; ///< Are background animations playing. }; #endif // DALI_DEMO_BUBBLE_ANIMATOR_H diff --git a/shared/dali-table-view.cpp b/shared/dali-table-view.cpp old mode 100755 new mode 100644 index d45e345..a8743ad --- a/shared/dali-table-view.cpp +++ b/shared/dali-table-view.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -19,13 +19,9 @@ #include "dali-table-view.h" // EXTERNAL INCLUDES -#include -#include -#include -#include -#include #include #include +#include #include #include #include @@ -65,7 +61,7 @@ const float BUTTON_PRESS_ANIMATION_TIME = 0.35f; ///< Time to perform button s 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__; @@ -159,8 +155,7 @@ Dali::Toolkit::Popup CreateVersionPopup(Application& application, ConnectionTrac // 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); @@ -399,7 +394,7 @@ void DaliTableView::Populate() { 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; @@ -501,7 +496,7 @@ Actor DaliTableView::CreateTile(const std::string& name, const std::string& titl 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); }); @@ -532,7 +527,7 @@ bool DaliTableView::DoTilePress(Actor actor, PointState::Type pointState) // ignore Example button presses when scrolling or button animating. if((!mScrolling) && (!mPressedAnimation)) { - std::string name = actor.GetProperty(Dali::Actor::Property::NAME); + std::string name = actor.GetProperty(Dali::Actor::Property::NAME); for(Example& example : mExampleList) { if(example.name == name) diff --git a/shared/dali-table-view.h b/shared/dali-table-view.h index d4fee68..c265c09 100644 --- a/shared/dali-table-view.h +++ b/shared/dali-table-view.h @@ -2,7 +2,7 @@ #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. @@ -33,7 +33,6 @@ class DaliTableView : public Dali::ConnectionTracker { public: - /** * Constructor * @@ -66,7 +65,7 @@ public: */ 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 /** @@ -239,14 +238,14 @@ private: }; FocusEffect mFocusEffect[FOCUS_ANIMATION_ACTOR_NUMBER]; ///< The elements used to create the custom focus effect - std::vector mPages; ///< List of pages. - ExampleList mExampleList; ///< List of examples. + std::vector 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 diff --git a/shared/example.h b/shared/example.h index 978e849..858167e 100644 --- a/shared/example.h +++ b/shared/example.h @@ -2,7 +2,7 @@ #define DALI_DEMO_EXAMPLE_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. @@ -49,7 +49,7 @@ struct Example std::string title; ///< title (caption) of example to appear on tile button. }; -using ExampleList = std::vector; +using ExampleList = std::vector; using ExampleListConstIter = ExampleList::const_iterator; #endif // DALI_DEMO_SHARED_EXAMPLE_H -- 2.7.4