Commit 5a56ed534cbc24150d68f03ea7fba7cfcc653835
1 parent
e6806c11
Updated all files to new format
Change-Id: I89ad98704eacedd18a0b50fd9d6511fc8e436416
Showing
65 changed files
with
855 additions
and
884 deletions
build/android/app/src/main/cpp/main.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -31,7 +31,7 @@ |
| 31 | 31 | // from android_native_app_glue.c |
| 32 | 32 | |
| 33 | 33 | #define TAG "dalidemo" |
| 34 | -#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, TAG, ##__VA_ARGS__)) | |
| 34 | +#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, TAG, ##__VA_ARGS__)) | |
| 35 | 35 | #ifndef NDEBUG |
| 36 | 36 | #define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, TAG, ##__VA_ARGS__)) |
| 37 | 37 | #else |
| ... | ... | @@ -156,7 +156,7 @@ void android_main(struct android_app* state) |
| 156 | 156 | LOGV("android_main() >>"); |
| 157 | 157 | |
| 158 | 158 | std::string filesDir = state->activity->internalDataPath; |
| 159 | - LOGV("filesDir=%s", filesDir.c_str() ); | |
| 159 | + LOGV("filesDir=%s", filesDir.c_str()); | |
| 160 | 160 | |
| 161 | 161 | std::string fontconfigPath = filesDir + "/fonts"; |
| 162 | 162 | setenv("FONTCONFIG_PATH", fontconfigPath.c_str(), 1); |
| ... | ... | @@ -186,13 +186,13 @@ void android_main(struct android_app* state) |
| 186 | 186 | |
| 187 | 187 | DaliDemoNativeActivity nativeActivity(state->activity); |
| 188 | 188 | |
| 189 | - int status = 0; | |
| 189 | + int status = 0; | |
| 190 | 190 | |
| 191 | 191 | //dali requires Android 8 or higher |
| 192 | 192 | //Android 6+ support loading library directly from apk, |
| 193 | 193 | //therefore no need to extract to filesystem first then open by specifying full path |
| 194 | 194 | //unless there is need to do profiling, or export libraries so that other packages can use |
| 195 | - std::string libpath = "libdali-demo.so"; | |
| 195 | + std::string libpath = "libdali-demo.so"; | |
| 196 | 196 | |
| 197 | 197 | std::string callParam = nativeActivity.GetIntentStringExtra("start"); |
| 198 | 198 | if(callParam.empty()) |
| ... | ... | @@ -217,16 +217,16 @@ void android_main(struct android_app* state) |
| 217 | 217 | dlerror(); /* Clear any existing error */ |
| 218 | 218 | |
| 219 | 219 | int (*main)(int, char**) = (int (*)(int, char**))dlsym(handle, "main"); |
| 220 | - LOGV("lib=%s handle=%p main=%p", libpath.c_str(), handle, main ); | |
| 220 | + LOGV("lib=%s handle=%p main=%p", libpath.c_str(), handle, main); | |
| 221 | 221 | if(main) |
| 222 | 222 | { |
| 223 | 223 | status = main(0, nullptr); |
| 224 | 224 | } |
| 225 | 225 | else |
| 226 | 226 | { |
| 227 | - LOGE("lib %s doesn't have main()", libpath.c_str()); | |
| 228 | - status = EFAULT; | |
| 229 | - std::exit(status); | |
| 227 | + LOGE("lib %s doesn't have main()", libpath.c_str()); | |
| 228 | + status = EFAULT; | |
| 229 | + std::exit(status); | |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | if(handle) | ... | ... |
examples/animated-shapes/animated-shapes-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -17,9 +17,9 @@ |
| 17 | 17 | |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali/dali.h> |
| 20 | -#include "shared/view.h" | |
| 21 | -#include "generated/animated-shapes-vert.h" | |
| 22 | 20 | #include "generated/animated-shapes-frag.h" |
| 21 | +#include "generated/animated-shapes-vert.h" | |
| 22 | +#include "shared/view.h" | |
| 23 | 23 | |
| 24 | 24 | #include <sstream> |
| 25 | 25 | ... | ... |
examples/arc-visual/arc-visual-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -183,9 +183,12 @@ private: |
| 183 | 183 | { |
| 184 | 184 | if(touch.GetState(0) == PointState::UP) |
| 185 | 185 | { |
| 186 | - DevelControl::DoAction(mControl, Control::Property::BACKGROUND, DevelArcVisual::Action::UPDATE_PROPERTY, | |
| 187 | - Property::Map().Add(DevelArcVisual::Property::START_ANGLE, START_ANGLE_INITIAL_VALUE) | |
| 188 | - .Add(DevelArcVisual::Property::SWEEP_ANGLE, SWEEP_ANGLE_INITIAL_VALUE)); | |
| 186 | + DevelControl::DoAction(mControl, | |
| 187 | + Control::Property::BACKGROUND, | |
| 188 | + DevelArcVisual::Action::UPDATE_PROPERTY, | |
| 189 | + Property::Map() | |
| 190 | + .Add(DevelArcVisual::Property::START_ANGLE, START_ANGLE_INITIAL_VALUE) | |
| 191 | + .Add(DevelArcVisual::Property::SWEEP_ANGLE, SWEEP_ANGLE_INITIAL_VALUE)); | |
| 189 | 192 | |
| 190 | 193 | Animation animation = Animation::New(ANIMATION_DURATION); |
| 191 | 194 | animation.AnimateTo(DevelControl::GetVisualProperty(mControl, Control::Property::BACKGROUND, DevelArcVisual::Property::START_ANGLE), START_ANGLE_TARGET_VALUE); | ... | ... |
examples/benchmark/benchmark.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -19,9 +19,9 @@ |
| 19 | 19 | #include <dali-toolkit/dali-toolkit.h> |
| 20 | 20 | |
| 21 | 21 | // INTERNAL INCLUDES |
| 22 | -#include "shared/utility.h" | |
| 23 | -#include "generated/benchmark-vert.h" | |
| 24 | 22 | #include "generated/benchmark-frag.h" |
| 23 | +#include "generated/benchmark-vert.h" | |
| 24 | +#include "shared/utility.h" | |
| 25 | 25 | |
| 26 | 26 | using namespace Dali; |
| 27 | 27 | using namespace Dali::Toolkit; | ... | ... |
examples/bezier-curve/bezier-curve-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -18,9 +18,9 @@ |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali-toolkit/devel-api/controls/table-view/table-view.h> |
| 20 | 20 | #include <dali/dali.h> |
| 21 | -#include "shared/view.h" | |
| 22 | -#include "generated/bezier-curve-vert.h" | |
| 23 | 21 | #include "generated/bezier-curve-frag.h" |
| 22 | +#include "generated/bezier-curve-vert.h" | |
| 23 | +#include "shared/view.h" | |
| 24 | 24 | |
| 25 | 25 | #include <sstream> |
| 26 | 26 | ... | ... |
examples/builder/examples.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -202,7 +202,7 @@ bool FileWatcher::FileHasChanged(void) |
| 202 | 202 | else |
| 203 | 203 | { |
| 204 | 204 | const bool result = buf.st_mtime > mLastTime; |
| 205 | - mLastTime = buf.st_mtime; | |
| 205 | + mLastTime = buf.st_mtime; | |
| 206 | 206 | return result; |
| 207 | 207 | } |
| 208 | 208 | ... | ... |
examples/color-transition/color-transition-controller.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -15,21 +15,20 @@ |
| 15 | 15 | * |
| 16 | 16 | */ |
| 17 | 17 | #include "color-transition-controller.h" |
| 18 | -#include "utils.h" | |
| 19 | -#include "dali/dali.h" | |
| 20 | 18 | #include "dali-toolkit/dali-toolkit.h" |
| 21 | -#include "generated/color-transition-controller-composite-vert.h" | |
| 19 | +#include "dali/dali.h" | |
| 22 | 20 | #include "generated/color-transition-controller-composite-frag.h" |
| 21 | +#include "generated/color-transition-controller-composite-vert.h" | |
| 22 | +#include "utils.h" | |
| 23 | 23 | |
| 24 | 24 | using namespace Dali; |
| 25 | 25 | using namespace Dali::Toolkit; |
| 26 | 26 | |
| 27 | 27 | namespace |
| 28 | 28 | { |
| 29 | - | |
| 30 | 29 | const Vector4 BG_COLOR = Vector4(0.f, 0.f, 0.f, 0.f); |
| 31 | 30 | |
| 32 | -} // nonamespace | |
| 31 | +} // namespace | |
| 33 | 32 | |
| 34 | 33 | ColorTransitionController::ColorTransitionController(WeakHandle<RenderTaskList> window, Actor content, RenderTaskList tasks, Vector3 initialColor) |
| 35 | 34 | : mWeakRenderTasks(window) |
| ... | ... | @@ -39,8 +38,7 @@ ColorTransitionController::ColorTransitionController(WeakHandle<RenderTaskList> |
| 39 | 38 | auto defaultTask = tasks.GetTask(0); |
| 40 | 39 | |
| 41 | 40 | // create rendertarget and rendertask |
| 42 | - auto rtt = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, | |
| 43 | - static_cast<uint32_t>(contentSize.x), static_cast<uint32_t>(contentSize.y)); | |
| 41 | + auto rtt = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, static_cast<uint32_t>(contentSize.x), static_cast<uint32_t>(contentSize.y)); | |
| 44 | 42 | |
| 45 | 43 | auto fbo = FrameBuffer::New(rtt.GetWidth(), rtt.GetHeight(), FrameBuffer::Attachment::NONE); |
| 46 | 44 | fbo.AttachColorTexture(rtt); |
| ... | ... | @@ -58,10 +56,10 @@ ColorTransitionController::ColorTransitionController(WeakHandle<RenderTaskList> |
| 58 | 56 | CenterActor(composite); |
| 59 | 57 | composite.SetProperty(Actor::Property::SIZE, contentSize); |
| 60 | 58 | |
| 61 | - mPropFlow = composite.RegisterProperty("uFlow", -1.f); | |
| 59 | + mPropFlow = composite.RegisterProperty("uFlow", -1.f); | |
| 62 | 60 | mPropUvTransform = composite.RegisterProperty("uUvTransform", Vector4(0.f, 0.f, 1.f, 1.f)); |
| 63 | - mPropRgb[0] = composite.RegisterProperty("uRgb[0]", initialColor); | |
| 64 | - mPropRgb[1] = composite.RegisterProperty("uRgb[1]", Vector3::ONE); | |
| 61 | + mPropRgb[0] = composite.RegisterProperty("uRgb[0]", initialColor); | |
| 62 | + mPropRgb[1] = composite.RegisterProperty("uRgb[1]", Vector3::ONE); | |
| 65 | 63 | |
| 66 | 64 | auto geomComposite = CreateQuadGeometry(); |
| 67 | 65 | |
| ... | ... | @@ -89,7 +87,7 @@ ColorTransitionController::ColorTransitionController(WeakHandle<RenderTaskList> |
| 89 | 87 | |
| 90 | 88 | ColorTransitionController::~ColorTransitionController() |
| 91 | 89 | { |
| 92 | - if (auto renderTasks = mWeakRenderTasks.GetHandle()) | |
| 90 | + if(auto renderTasks = mWeakRenderTasks.GetHandle()) | |
| 93 | 91 | { |
| 94 | 92 | renderTasks.RemoveTask(mRtCompositor); |
| 95 | 93 | } |
| ... | ... | @@ -103,7 +101,7 @@ Dali::Actor ColorTransitionController::GetComposite() |
| 103 | 101 | void ColorTransitionController::SetFlowMap(Texture flowMap) |
| 104 | 102 | { |
| 105 | 103 | auto renderer = mComposite.GetRendererAt(0); |
| 106 | - auto texSet = renderer.GetTextures(); | |
| 104 | + auto texSet = renderer.GetTextures(); | |
| 107 | 105 | texSet.SetTexture(1, flowMap); |
| 108 | 106 | } |
| 109 | 107 | |
| ... | ... | @@ -123,7 +121,7 @@ void ColorTransitionController::RequestTransition(float duration, const Dali::Ve |
| 123 | 121 | |
| 124 | 122 | void ColorTransitionController::SetOnFinished(OnFinished onFinished, void* data) |
| 125 | 123 | { |
| 126 | - mOnFinished = onFinished; | |
| 124 | + mOnFinished = onFinished; | |
| 127 | 125 | mOnFinishedData = data; |
| 128 | 126 | } |
| 129 | 127 | |
| ... | ... | @@ -133,7 +131,7 @@ void ColorTransitionController::OnTransitionFinished(Animation& anim) |
| 133 | 131 | Vector3 color1 = mComposite.GetProperty(mPropRgb[1]).Get<Vector3>(); |
| 134 | 132 | mComposite.SetProperty(mPropRgb[0], color1); |
| 135 | 133 | |
| 136 | - if (mOnFinished) | |
| 134 | + if(mOnFinished) | |
| 137 | 135 | { |
| 138 | 136 | mOnFinished(mOnFinishedData); |
| 139 | 137 | } | ... | ... |
examples/color-transition/color-transition-controller.h
| 1 | 1 | #ifndef DALI_DEMO_COLOR_TRANSITION_CONTROLLER_H |
| 2 | 2 | #define DALI_DEMO_COLOR_TRANSITION_CONTROLLER_H |
| 3 | 3 | /* |
| 4 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 4 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 5 | 5 | * |
| 6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | 7 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -16,18 +16,18 @@ |
| 16 | 16 | * limitations under the License. |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | -#include "dali/public-api/adaptor-framework/window.h" | |
| 20 | -#include "dali/public-api/object/weak-handle.h" | |
| 21 | 19 | #include "dali/public-api/actors/actor.h" |
| 20 | +#include "dali/public-api/adaptor-framework/window.h" | |
| 22 | 21 | #include "dali/public-api/animation/animation.h" |
| 23 | -#include "dali/public-api/rendering/texture.h" | |
| 24 | -#include "dali/public-api/render-tasks/render-task.h" | |
| 22 | +#include "dali/public-api/object/weak-handle.h" | |
| 25 | 23 | #include "dali/public-api/render-tasks/render-task-list.h" |
| 24 | +#include "dali/public-api/render-tasks/render-task.h" | |
| 25 | +#include "dali/public-api/rendering/texture.h" | |
| 26 | 26 | |
| 27 | -class ColorTransitionController: public Dali::ConnectionTracker | |
| 27 | +class ColorTransitionController : public Dali::ConnectionTracker | |
| 28 | 28 | { |
| 29 | 29 | public: |
| 30 | - using OnFinished = void(*)(void*); | |
| 30 | + using OnFinished = void (*)(void*); | |
| 31 | 31 | |
| 32 | 32 | ColorTransitionController(Dali::WeakHandle<Dali::RenderTaskList> renderTasks, Dali::Actor content, Dali::RenderTaskList tasks, Dali::Vector3 initialColor); |
| 33 | 33 | ~ColorTransitionController(); |
| ... | ... | @@ -45,7 +45,7 @@ public: |
| 45 | 45 | private: |
| 46 | 46 | void OnTransitionFinished(Dali::Animation& anim); |
| 47 | 47 | |
| 48 | - Dali::Actor mComposite; | |
| 48 | + Dali::Actor mComposite; | |
| 49 | 49 | Dali::Property::Index mPropFlow; |
| 50 | 50 | Dali::Property::Index mPropUvTransform; |
| 51 | 51 | Dali::Property::Index mPropRgb[2]; |
| ... | ... | @@ -54,8 +54,8 @@ private: |
| 54 | 54 | |
| 55 | 55 | Dali::Animation mAnimation; |
| 56 | 56 | |
| 57 | - OnFinished mOnFinished = nullptr; | |
| 58 | - void* mOnFinishedData = nullptr; | |
| 57 | + OnFinished mOnFinished = nullptr; | |
| 58 | + void* mOnFinishedData = nullptr; | |
| 59 | 59 | |
| 60 | 60 | Dali::WeakHandle<Dali::RenderTaskList> mWeakRenderTasks; |
| 61 | 61 | }; | ... | ... |
examples/color-transition/color-transition.cpp
| ... | ... | @@ -14,10 +14,10 @@ |
| 14 | 14 | * limitations under the License. |
| 15 | 15 | * |
| 16 | 16 | */ |
| 17 | -#include "utils.h" | |
| 18 | 17 | #include "color-transition-controller.h" |
| 19 | -#include "dali/dali.h" | |
| 20 | 18 | #include "dali-toolkit/dali-toolkit.h" |
| 19 | +#include "dali/dali.h" | |
| 20 | +#include "utils.h" | |
| 21 | 21 | |
| 22 | 22 | using namespace Dali; |
| 23 | 23 | using namespace Dali::Toolkit; |
| ... | ... | @@ -26,7 +26,7 @@ namespace |
| 26 | 26 | { |
| 27 | 27 | const float TRANSITION_DURATION = 1.f; |
| 28 | 28 | |
| 29 | -const Vector3 INITIAL_COLOR{ 1.f, 1.f, .25f }; | |
| 29 | +const Vector3 INITIAL_COLOR{1.f, 1.f, .25f}; | |
| 30 | 30 | |
| 31 | 31 | const char* const FLOW_MAPS[] = { |
| 32 | 32 | "circular", |
| ... | ... | @@ -38,15 +38,13 @@ const char* const FLOW_MAPS[] = { |
| 38 | 38 | "radial", |
| 39 | 39 | "swipe", |
| 40 | 40 | "bubbles", |
| 41 | - "image" | |
| 42 | -}; | |
| 41 | + "image"}; | |
| 43 | 42 | |
| 44 | 43 | Texture LoadTexture(const std::string& path) |
| 45 | 44 | { |
| 46 | 45 | PixelData pixelData = SyncImageLoader::Load(path); |
| 47 | 46 | |
| 48 | - Texture texture = Texture::New(TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), | |
| 49 | - pixelData.GetWidth(), pixelData.GetHeight()); | |
| 47 | + Texture texture = Texture::New(TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight()); | |
| 50 | 48 | texture.Upload(pixelData); |
| 51 | 49 | return texture; |
| 52 | 50 | } |
| ... | ... | @@ -64,7 +62,7 @@ TextLabel MakeTextLabel(const char* text, const Vector4& color, float pointSize, |
| 64 | 62 | return tl; |
| 65 | 63 | } |
| 66 | 64 | |
| 67 | -} | |
| 65 | +} // namespace | |
| 68 | 66 | |
| 69 | 67 | /** |
| 70 | 68 | * Demonstrates colour transition using flow maps and uv rotation / scaling. |
| ... | ... | @@ -81,7 +79,7 @@ TextLabel MakeTextLabel(const char* text, const Vector4& color, float pointSize, |
| 81 | 79 | * - Double-tap outside the middle of screen: transition using one of the |
| 82 | 80 | * effects (flow maps) mapped to the given segment of the screen; |
| 83 | 81 | */ |
| 84 | -class ColorTransition: public ConnectionTracker | |
| 82 | +class ColorTransition : public ConnectionTracker | |
| 85 | 83 | { |
| 86 | 84 | public: |
| 87 | 85 | ColorTransition(Application& app) |
| ... | ... | @@ -100,8 +98,8 @@ private: |
| 100 | 98 | |
| 101 | 99 | void OnInit(Application& app) |
| 102 | 100 | { |
| 103 | - auto window = mApp.GetWindow(); | |
| 104 | - auto windowSize = Vector2{ window.GetSize() }; | |
| 101 | + auto window = mApp.GetWindow(); | |
| 102 | + auto windowSize = Vector2{window.GetSize()}; | |
| 105 | 103 | |
| 106 | 104 | // create content root |
| 107 | 105 | Actor content = Actor::New(); |
| ... | ... | @@ -132,9 +130,9 @@ private: |
| 132 | 130 | window.Add(mainRoot); |
| 133 | 131 | mMainRoot = mainRoot; |
| 134 | 132 | |
| 135 | - auto renderTasks = window.GetRenderTaskList(); | |
| 133 | + auto renderTasks = window.GetRenderTaskList(); | |
| 136 | 134 | auto weakRenderTasks = WeakHandle<RenderTaskList>(renderTasks); |
| 137 | - auto controller = new ColorTransitionController(weakRenderTasks, content, window.GetRenderTaskList(), INITIAL_COLOR); | |
| 135 | + auto controller = new ColorTransitionController(weakRenderTasks, content, window.GetRenderTaskList(), INITIAL_COLOR); | |
| 138 | 136 | mController.reset(controller); |
| 139 | 137 | mainRoot.Add(mController->GetComposite()); |
| 140 | 138 | |
| ... | ... | @@ -167,9 +165,9 @@ private: |
| 167 | 165 | |
| 168 | 166 | void OnKeyEvent(const KeyEvent& event) |
| 169 | 167 | { |
| 170 | - if (event.GetState() == KeyEvent::DOWN) | |
| 168 | + if(event.GetState() == KeyEvent::DOWN) | |
| 171 | 169 | { |
| 172 | - if (IsKey(event, DALI_KEY_ESCAPE) || IsKey(event, DALI_KEY_BACK)) | |
| 170 | + if(IsKey(event, DALI_KEY_ESCAPE) || IsKey(event, DALI_KEY_BACK)) | |
| 173 | 171 | { |
| 174 | 172 | mApp.Quit(); |
| 175 | 173 | } |
| ... | ... | @@ -178,17 +176,17 @@ private: |
| 178 | 176 | |
| 179 | 177 | void OnDoubleTap(Actor /*actor*/, const TapGesture& tap) |
| 180 | 178 | { |
| 181 | - auto window = mApp.GetWindow(); | |
| 182 | - auto windowSize = Vector2{ window.GetSize() }; | |
| 183 | - Vector2 clip = tap.GetScreenPoint() / windowSize - Vector2::ONE * .5f; // [-.5, .5] | |
| 184 | - if (clip.Length() < .333f * .5f) | |
| 179 | + auto window = mApp.GetWindow(); | |
| 180 | + auto windowSize = Vector2{window.GetSize()}; | |
| 181 | + Vector2 clip = tap.GetScreenPoint() / windowSize - Vector2::ONE * .5f; // [-.5, .5] | |
| 182 | + if(clip.Length() < .333f * .5f) | |
| 185 | 183 | { |
| 186 | 184 | LoadFlowMap(FLOW_MAPS[rand() % std::extent<decltype(FLOW_MAPS)>::value]); |
| 187 | 185 | } |
| 188 | 186 | else |
| 189 | 187 | { |
| 190 | 188 | float theta = fmodf((atan2(clip.y, clip.x) + M_PI) / (M_PI * 2.) + .75f, 1.f); |
| 191 | - int i = std::extent<decltype(FLOW_MAPS)>::value * theta; | |
| 189 | + int i = std::extent<decltype(FLOW_MAPS)>::value * theta; | |
| 192 | 190 | |
| 193 | 191 | LoadFlowMap(FLOW_MAPS[i]); |
| 194 | 192 | } |
| ... | ... | @@ -204,11 +202,11 @@ private: |
| 204 | 202 | void LoadFlowMap(const char* const name) |
| 205 | 203 | { |
| 206 | 204 | DALI_ASSERT_DEBUG(name && "Flow map name must be given"); |
| 207 | - if (mLastFlowMap != name) | |
| 205 | + if(mLastFlowMap != name) | |
| 208 | 206 | { |
| 209 | - std::string flowMapDir = Application::GetResourcePath() + "images/color-transition/"; | |
| 207 | + std::string flowMapDir = Application::GetResourcePath() + "images/color-transition/"; | |
| 210 | 208 | std::string flowMapPath = flowMapDir + name + ".png"; |
| 211 | - auto flowMap = LoadTexture(flowMapPath); | |
| 209 | + auto flowMap = LoadTexture(flowMapPath); | |
| 212 | 210 | DALI_ASSERT_DEBUG(flowMap && "Failed to load flow map."); |
| 213 | 211 | mController->SetFlowMap(flowMap); |
| 214 | 212 | } |
| ... | ... | @@ -216,8 +214,7 @@ private: |
| 216 | 214 | |
| 217 | 215 | void RandomizeUvTransform() |
| 218 | 216 | { |
| 219 | - mController->SetUvTransform((rand() % 12) * M_PI / 12., 1.f, | |
| 220 | - (rand() % 12) * M_PI / 12., .5f); | |
| 217 | + mController->SetUvTransform((rand() % 12) * M_PI / 12., 1.f, (rand() % 12) * M_PI / 12., .5f); | |
| 221 | 218 | } |
| 222 | 219 | |
| 223 | 220 | void OnTransitionFinished() |
| ... | ... | @@ -241,7 +238,8 @@ int DALI_EXPORT_API main(int argc, char** argv) |
| 241 | 238 | { |
| 242 | 239 | auto app = Application::New(&argc, &argv |
| 243 | 240 | #ifdef WIN32 |
| 244 | - , ".//dali-toolkit-default-theme.json" | |
| 241 | + , | |
| 242 | + ".//dali-toolkit-default-theme.json" | |
| 245 | 243 | #endif |
| 246 | 244 | ); |
| 247 | 245 | ColorTransition ct(app); | ... | ... |
examples/color-transition/utils.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -16,8 +16,8 @@ |
| 16 | 16 | */ |
| 17 | 17 | #include "utils.h" |
| 18 | 18 | |
| 19 | -#include <cstdio> | |
| 20 | 19 | #include <cstdarg> |
| 20 | +#include <cstdio> | |
| 21 | 21 | |
| 22 | 22 | #include <cmath> |
| 23 | 23 | |
| ... | ... | @@ -32,14 +32,14 @@ Geometry CreateQuadGeometry() |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | 34 | Vertex vertexData[] = { |
| 35 | - { Vector3(-.5f, .5f, .0f) }, | |
| 36 | - { Vector3(.5f, .5f, .0f) }, | |
| 37 | - { Vector3(-.5f, -.5f, .0f) }, | |
| 38 | - { Vector3(.5f, -.5f, .0f) }, | |
| 35 | + {Vector3(-.5f, .5f, .0f)}, | |
| 36 | + {Vector3(.5f, .5f, .0f)}, | |
| 37 | + {Vector3(-.5f, -.5f, .0f)}, | |
| 38 | + {Vector3(.5f, -.5f, .0f)}, | |
| 39 | 39 | }; |
| 40 | 40 | |
| 41 | 41 | VertexBuffer vertexBuffer = VertexBuffer::New(Property::Map() |
| 42 | - .Add("aPosition", Property::VECTOR3)); | |
| 42 | + .Add("aPosition", Property::VECTOR3)); | |
| 43 | 43 | vertexBuffer.SetData(vertexData, std::extent<decltype(vertexData)>::value); |
| 44 | 44 | |
| 45 | 45 | Geometry geometry = Geometry::New(); |
| ... | ... | @@ -52,17 +52,17 @@ Renderer CreateRenderer(TextureSet textures, Geometry geometry, Shader shader, u |
| 52 | 52 | { |
| 53 | 53 | Renderer renderer = Renderer::New(geometry, shader); |
| 54 | 54 | renderer.SetProperty(Renderer::Property::BLEND_MODE, |
| 55 | - (options & RendererOptions::BLEND) ? BlendMode::ON : BlendMode::OFF); | |
| 55 | + (options & RendererOptions::BLEND) ? BlendMode::ON : BlendMode::OFF); | |
| 56 | 56 | renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE, |
| 57 | - (options & RendererOptions::DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF); | |
| 57 | + (options & RendererOptions::DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF); | |
| 58 | 58 | renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, |
| 59 | - (options & RendererOptions::DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF); | |
| 59 | + (options & RendererOptions::DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF); | |
| 60 | 60 | |
| 61 | 61 | int faceCulling = (((options & RendererOptions::CULL_BACK) != 0) << 1) | |
| 62 | - ((options & RendererOptions::CULL_FRONT) != 0); | |
| 62 | + ((options & RendererOptions::CULL_FRONT) != 0); | |
| 63 | 63 | renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, faceCulling); |
| 64 | 64 | |
| 65 | - if (!textures) | |
| 65 | + if(!textures) | |
| 66 | 66 | { |
| 67 | 67 | textures = TextureSet::New(); |
| 68 | 68 | } |
| ... | ... | @@ -76,4 +76,3 @@ void CenterActor(Actor actor) |
| 76 | 76 | actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); |
| 77 | 77 | actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); |
| 78 | 78 | } |
| 79 | - | ... | ... |
examples/color-transition/utils.h
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -22,7 +22,9 @@ |
| 22 | 22 | #include "dali/public-api/rendering/renderer.h" |
| 23 | 23 | #include "dali/public-api/rendering/texture.h" |
| 24 | 24 | |
| 25 | -#define ACTOR_DECL(x) auto x = Dali::Actor::New(); x.SetProperty(Actor::Property::NAME, #x); | |
| 25 | +#define ACTOR_DECL(x) \ | |
| 26 | + auto x = Dali::Actor::New(); \ | |
| 27 | + x.SetProperty(Actor::Property::NAME, #x); | |
| 26 | 28 | |
| 27 | 29 | /** |
| 28 | 30 | * @brief Creates a unit quad centered on the origin (i.e. vertex positions |
| ... | ... | @@ -34,12 +36,12 @@ struct RendererOptions |
| 34 | 36 | { |
| 35 | 37 | enum |
| 36 | 38 | { |
| 37 | - NONE = 0x0, | |
| 38 | - BLEND = 0x01, | |
| 39 | - DEPTH_TEST = 0x02, | |
| 39 | + NONE = 0x0, | |
| 40 | + BLEND = 0x01, | |
| 41 | + DEPTH_TEST = 0x02, | |
| 40 | 42 | DEPTH_WRITE = 0x04, |
| 41 | - CULL_BACK = 0x08, | |
| 42 | - CULL_FRONT = 0x10, | |
| 43 | + CULL_BACK = 0x08, | |
| 44 | + CULL_FRONT = 0x10, | |
| 43 | 45 | }; |
| 44 | 46 | }; |
| 45 | 47 | |
| ... | ... | @@ -49,9 +51,9 @@ struct RendererOptions |
| 49 | 51 | ///@note If textures is not a valid handle, an empty texture set will be created. |
| 50 | 52 | Dali::Renderer CreateRenderer( |
| 51 | 53 | Dali::TextureSet textures, |
| 52 | - Dali::Geometry geometry, | |
| 53 | - Dali::Shader shader, | |
| 54 | - uint32_t options = RendererOptions::NONE); | |
| 54 | + Dali::Geometry geometry, | |
| 55 | + Dali::Shader shader, | |
| 56 | + uint32_t options = RendererOptions::NONE); | |
| 55 | 57 | |
| 56 | 58 | ///@brief Sets @a actor's anchor point and parent origin to center. |
| 57 | 59 | void CenterActor(Dali::Actor actor); | ... | ... |
examples/color-visual/color-visual-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -27,18 +27,19 @@ namespace |
| 27 | 27 | { |
| 28 | 28 | const char* IMAGE_FILE(DEMO_IMAGE_DIR "gallery-medium-1.jpg"); |
| 29 | 29 | |
| 30 | -const float BLUR_RADIUS_VALUE(15.0f); | |
| 30 | +const float BLUR_RADIUS_VALUE(15.0f); | |
| 31 | 31 | const Vector2 BLUR_OFFSET_VALUE(0.05f, 0.05f); |
| 32 | 32 | const Vector2 BLUR_SIZE_VALUE(1.1f, 1.1f); |
| 33 | 33 | const Vector2 NO_BLUR_SIZE_VALUE(1.05f, 1.05f); |
| 34 | -const float ANIMATION_DURATION(2.0f); | |
| 34 | +const float ANIMATION_DURATION(2.0f); | |
| 35 | 35 | |
| 36 | 36 | const Property::Value SHADOW{ |
| 37 | 37 | {Visual::Property::TYPE, Visual::COLOR}, |
| 38 | 38 | {Visual::Property::MIX_COLOR, Vector4(0.0f, 0.0f, 0.0f, 0.5f)}, |
| 39 | - {Visual::Property::TRANSFORM, Property::Map{{Visual::Transform::Property::SIZE, NO_BLUR_SIZE_VALUE}, | |
| 40 | - {Visual::Transform::Property::ORIGIN, Align::CENTER}, | |
| 41 | - {Visual::Transform::Property::ANCHOR_POINT, Align::CENTER}}}}; | |
| 39 | + {Visual::Property::TRANSFORM, | |
| 40 | + Property::Map{{Visual::Transform::Property::SIZE, NO_BLUR_SIZE_VALUE}, | |
| 41 | + {Visual::Transform::Property::ORIGIN, Align::CENTER}, | |
| 42 | + {Visual::Transform::Property::ANCHOR_POINT, Align::CENTER}}}}; | |
| 42 | 43 | |
| 43 | 44 | } // namespace |
| 44 | 45 | ... | ... |
examples/compressed-texture-formats/compressed-texture-formats-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -21,9 +21,9 @@ |
| 21 | 21 | #include <dali/dali.h> |
| 22 | 22 | |
| 23 | 23 | // INTERNAL INCLUDES |
| 24 | -#include "shared/utility.h" | |
| 25 | -#include "generated/compressed-texture-formats-example-vert.h" | |
| 26 | 24 | #include "generated/compressed-texture-formats-example-frag.h" |
| 25 | +#include "generated/compressed-texture-formats-example-vert.h" | |
| 26 | +#include "shared/utility.h" | |
| 27 | 27 | |
| 28 | 28 | using namespace Dali; |
| 29 | 29 | using Dali::Toolkit::TextLabel; | ... | ... |
examples/contact-cards/clipped-image.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -22,8 +22,8 @@ |
| 22 | 22 | #include <dali-toolkit/dali-toolkit.h> |
| 23 | 23 | |
| 24 | 24 | // INTERNAL INCLUDES |
| 25 | -#include "generated/clipped-image-vert.h" | |
| 26 | 25 | #include "generated/clipped-image-frag.h" |
| 26 | +#include "generated/clipped-image-vert.h" | |
| 27 | 27 | |
| 28 | 28 | namespace ClippedImage |
| 29 | 29 | { | ... | ... |
examples/deferred-shading/deferred-shading.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -21,10 +21,10 @@ |
| 21 | 21 | #include "dali/public-api/actors/actor.h" |
| 22 | 22 | #include "dali/public-api/rendering/renderer.h" |
| 23 | 23 | |
| 24 | -#include "generated/deferred-shading-mainpass-vert.h" | |
| 25 | 24 | #include "generated/deferred-shading-mainpass-frag.h" |
| 26 | -#include "generated/deferred-shading-prepass-vert.h" | |
| 25 | +#include "generated/deferred-shading-mainpass-vert.h" | |
| 27 | 26 | #include "generated/deferred-shading-prepass-frag.h" |
| 27 | +#include "generated/deferred-shading-prepass-vert.h" | |
| 28 | 28 | |
| 29 | 29 | using namespace Dali; |
| 30 | 30 | ... | ... |
examples/fpp-game/game-renderer.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -19,8 +19,8 @@ |
| 19 | 19 | #include "game-model.h" |
| 20 | 20 | #include "game-texture.h" |
| 21 | 21 | |
| 22 | -#include "generated/game-renderer-vert.h" | |
| 23 | 22 | #include "generated/game-renderer-frag.h" |
| 23 | +#include "generated/game-renderer-vert.h" | |
| 24 | 24 | |
| 25 | 25 | #include <dali/dali.h> |
| 26 | 26 | ... | ... |
examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -134,12 +134,21 @@ SamplingMode::Type NextFilterMode(SamplingMode::Type oldMode) |
| 134 | 134 | |
| 135 | 135 | const char* StringFromScalingMode(FittingMode::Type scalingMode) |
| 136 | 136 | { |
| 137 | - 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"; | |
| 137 | + return scalingMode == FittingMode::SCALE_TO_FILL ? "SCALE_TO_FILL" : scalingMode == FittingMode::SHRINK_TO_FIT ? "SHRINK_TO_FIT" | |
| 138 | + : scalingMode == FittingMode::FIT_WIDTH ? "FIT_WIDTH" | |
| 139 | + : scalingMode == FittingMode::FIT_HEIGHT ? "FIT_HEIGHT" | |
| 140 | + : "UnknownScalingMode"; | |
| 138 | 141 | } |
| 139 | 142 | |
| 140 | 143 | const char* StringFromFilterMode(SamplingMode::Type filterMode) |
| 141 | 144 | { |
| 142 | - 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"; | |
| 145 | + return filterMode == SamplingMode::BOX ? "BOX" : filterMode == SamplingMode::BOX_THEN_NEAREST ? "BOX_THEN_NEAREST" | |
| 146 | + : filterMode == SamplingMode::BOX_THEN_LINEAR ? "BOX_THEN_LINEAR" | |
| 147 | + : filterMode == SamplingMode::NEAREST ? "NEAREST" | |
| 148 | + : filterMode == SamplingMode::LINEAR ? "LINEAR" | |
| 149 | + : filterMode == SamplingMode::NO_FILTER ? "NO_FILTER" | |
| 150 | + : filterMode == SamplingMode::DONT_CARE ? "DONT_CARE" | |
| 151 | + : "UnknownFilterMode"; | |
| 143 | 152 | } |
| 144 | 153 | |
| 145 | 154 | } // namespace | ... | ... |
examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -577,7 +577,9 @@ public: |
| 577 | 577 | |
| 578 | 578 | mFittingModes[id] = newMode; |
| 579 | 579 | |
| 580 | - 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")); | |
| 580 | + SetTitle(std::string(newMode == FittingMode::SHRINK_TO_FIT ? "SHRINK_TO_FIT" : newMode == FittingMode::SCALE_TO_FILL ? "SCALE_TO_FILL" | |
| 581 | + : newMode == FittingMode::FIT_WIDTH ? "FIT_WIDTH" | |
| 582 | + : "FIT_HEIGHT")); | |
| 581 | 583 | } |
| 582 | 584 | } |
| 583 | 585 | return true; | ... | ... |
examples/image-view-url/image-view-url-example.cpp
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali-toolkit/devel-api/image-loader/texture-manager.h> |
| 20 | 20 | |
| 21 | -#include "shared/view.h" | |
| 22 | 21 | #include "generated/image-view-url-frag.h" |
| 22 | +#include "shared/view.h" | |
| 23 | 23 | |
| 24 | 24 | using namespace Dali; |
| 25 | 25 | ... | ... |
examples/line-mesh/line-mesh-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -21,9 +21,9 @@ |
| 21 | 21 | #include <dali/devel-api/actors/actor-devel.h> |
| 22 | 22 | |
| 23 | 23 | // INTERNAL INCLUDES |
| 24 | -#include "shared/view.h" | |
| 25 | -#include "generated/line-mesh-vert.h" | |
| 26 | 24 | #include "generated/line-mesh-frag.h" |
| 25 | +#include "generated/line-mesh-vert.h" | |
| 26 | +#include "shared/view.h" | |
| 27 | 27 | |
| 28 | 28 | #include <sstream> |
| 29 | 29 | |
| ... | ... | @@ -31,7 +31,6 @@ using namespace Dali; |
| 31 | 31 | |
| 32 | 32 | namespace |
| 33 | 33 | { |
| 34 | - | |
| 35 | 34 | const unsigned short INDEX_LINES[] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 0}; |
| 36 | 35 | const unsigned short INDEX_LOOP[] = {0, 1, 2, 3, 4}; |
| 37 | 36 | const unsigned short INDEX_STRIP[] = {0, 1, 2, 3, 4, 0}; | ... | ... |
examples/mesh-morph/mesh-morph-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -20,15 +20,14 @@ |
| 20 | 20 | #include <dali/devel-api/actors/actor-devel.h> |
| 21 | 21 | |
| 22 | 22 | // INTERNAL INCLUDES |
| 23 | -#include "shared/view.h" | |
| 24 | -#include "generated/mesh-morph-vert.h" | |
| 25 | 23 | #include "generated/mesh-morph-frag.h" |
| 24 | +#include "generated/mesh-morph-vert.h" | |
| 25 | +#include "shared/view.h" | |
| 26 | 26 | |
| 27 | 27 | using namespace Dali; |
| 28 | 28 | |
| 29 | 29 | namespace |
| 30 | 30 | { |
| 31 | - | |
| 32 | 31 | Geometry CreateGeometry() |
| 33 | 32 | { |
| 34 | 33 | // Create vertices | ... | ... |
examples/mesh-visual/mesh-visual-example.cpp
| ... | ... | @@ -417,8 +417,8 @@ public: |
| 417 | 417 | { |
| 418 | 418 | //Calculate displacement and corresponding rotation. |
| 419 | 419 | const Vector2 touchPosition = touch.GetScreenPosition(0); |
| 420 | - const Vector2 displacement = touchPosition - mLastTouchPosition; | |
| 421 | - mLastTouchPosition = touchPosition; | |
| 420 | + const Vector2 displacement = touchPosition - mLastTouchPosition; | |
| 421 | + mLastTouchPosition = touchPosition; | |
| 422 | 422 | |
| 423 | 423 | const Quaternion q(Radian(displacement.y / -Y_ROTATION_DISPLACEMENT_FACTOR), Radian(displacement.x / X_ROTATION_DISPLACEMENT_FACTOR), Radian(0.f)); |
| 424 | 424 | const Quaternion q0 = mModels[mSelectedModelIndex].control.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>(); | ... | ... |
examples/metaball-explosion/metaball-explosion-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -27,10 +27,10 @@ |
| 27 | 27 | #include <dali/public-api/rendering/texture.h> |
| 28 | 28 | |
| 29 | 29 | // INTERNAL INCLUDES |
| 30 | -#include "shared/utility.h" // DemoHelper::LoadTexture | |
| 31 | -#include "generated/metaball-vert.h" | |
| 32 | 30 | #include "generated/metaball-frag.h" |
| 33 | 31 | #include "generated/metaball-refraction-frag.h" |
| 32 | +#include "generated/metaball-vert.h" | |
| 33 | +#include "shared/utility.h" // DemoHelper::LoadTexture | |
| 34 | 34 | |
| 35 | 35 | using namespace Dali; |
| 36 | 36 | ... | ... |
examples/metaball-refrac/metaball-refrac-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -26,11 +26,11 @@ |
| 26 | 26 | #include <dali/public-api/rendering/texture.h> |
| 27 | 27 | |
| 28 | 28 | // INTERNAL INCLUDES |
| 29 | -#include "shared/utility.h" // DemoHelper::LoadTexture | |
| 30 | -#include "generated/metaball-vert.h" | |
| 29 | +#include "generated/fragment-frag.h" | |
| 31 | 30 | #include "generated/metaball-frag.h" |
| 32 | 31 | #include "generated/metaball-refraction-frag.h" |
| 33 | -#include "generated/fragment-frag.h" | |
| 32 | +#include "generated/metaball-vert.h" | |
| 33 | +#include "shared/utility.h" // DemoHelper::LoadTexture | |
| 34 | 34 | |
| 35 | 35 | using namespace Dali; |
| 36 | 36 | ... | ... |
examples/native-image-source/native-image-source-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -21,9 +21,9 @@ |
| 21 | 21 | #include <cstring> |
| 22 | 22 | |
| 23 | 23 | // INTERNAL INCLUDES |
| 24 | -#include "shared/utility.h" | |
| 25 | -#include "generated/native-image-source-texture-vert.h" | |
| 26 | 24 | #include "generated/native-image-source-texture-frag.h" |
| 25 | +#include "generated/native-image-source-texture-vert.h" | |
| 26 | +#include "shared/utility.h" | |
| 27 | 27 | |
| 28 | 28 | using namespace Dali; |
| 29 | 29 | using namespace Toolkit; | ... | ... |
examples/particles/float-rand.h
| 1 | 1 | #ifndef PARTICLES_FLOAT_RAND_H_ |
| 2 | 2 | #define PARTICLES_FLOAT_RAND_H_ |
| 3 | 3 | /* |
| 4 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 4 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 5 | 5 | * |
| 6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | 7 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -20,14 +20,15 @@ |
| 20 | 20 | |
| 21 | 21 | struct FloatRand |
| 22 | 22 | { |
| 23 | - std::random_device mDevice; | |
| 24 | - std::mt19937 mMersenneTwister; | |
| 23 | + std::random_device mDevice; | |
| 24 | + std::mt19937 mMersenneTwister; | |
| 25 | 25 | std::uniform_real_distribution<float> mDistribution; |
| 26 | 26 | |
| 27 | 27 | FloatRand() |
| 28 | 28 | : mMersenneTwister(mDevice()), |
| 29 | 29 | mDistribution(0., 1.) |
| 30 | - {} | |
| 30 | + { | |
| 31 | + } | |
| 31 | 32 | |
| 32 | 33 | float operator()() |
| 33 | 34 | { | ... | ... |
examples/particles/particle-field.h
| 1 | 1 | #ifndef PARTICLES_PARTICLE_FIELD_H_ |
| 2 | 2 | #define PARTICLES_PARTICLE_FIELD_H_ |
| 3 | 3 | /* |
| 4 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 4 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 5 | 5 | * |
| 6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | 7 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -16,34 +16,34 @@ |
| 16 | 16 | * limitations under the License. |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | -#include "utils.h" | |
| 20 | -#include "float-rand.h" | |
| 19 | +#include <vector> | |
| 21 | 20 | #include "dali/public-api/math/vector2.h" |
| 22 | 21 | #include "dali/public-api/math/vector3.h" |
| 23 | 22 | #include "dali/public-api/math/vector4.h" |
| 24 | 23 | #include "dali/public-api/rendering/geometry.h" |
| 25 | -#include <vector> | |
| 24 | +#include "float-rand.h" | |
| 25 | +#include "utils.h" | |
| 26 | 26 | |
| 27 | 27 | struct ParticleField |
| 28 | 28 | { |
| 29 | - float mSize; | |
| 29 | + float mSize; | |
| 30 | 30 | Dali::Vector3 mBoxSize; |
| 31 | 31 | Dali::Vector3 mParticlesPerAxis; |
| 32 | - float mSizeVariance; | |
| 33 | - float mNoiseAmount; // affects color, motion (phase), twinkle (frequency, phase, size, opacity), | |
| 34 | - float mDisperse; | |
| 35 | - float mMotionScale; | |
| 36 | - float mMotionCycleLength; // seconds | |
| 37 | - float mTwinkleFrequency; // per motion cycle | |
| 38 | - float mTwinkleSizeScale; | |
| 39 | - float mTwinkleOpacityWeight; | |
| 32 | + float mSizeVariance; | |
| 33 | + float mNoiseAmount; // affects color, motion (phase), twinkle (frequency, phase, size, opacity), | |
| 34 | + float mDisperse; | |
| 35 | + float mMotionScale; | |
| 36 | + float mMotionCycleLength; // seconds | |
| 37 | + float mTwinkleFrequency; // per motion cycle | |
| 38 | + float mTwinkleSizeScale; | |
| 39 | + float mTwinkleOpacityWeight; | |
| 40 | 40 | |
| 41 | 41 | Dali::Vector3 GetParticlesPerAxisSafe() const |
| 42 | 42 | { |
| 43 | 43 | using namespace Dali; |
| 44 | 44 | return Vector3(std::max(1.f, FastFloor(mParticlesPerAxis.x)), |
| 45 | - std::max(1.f, FastFloor(mParticlesPerAxis.y)), | |
| 46 | - std::max(1.f, FastFloor(mParticlesPerAxis.z))); | |
| 45 | + std::max(1.f, FastFloor(mParticlesPerAxis.y)), | |
| 46 | + std::max(1.f, FastFloor(mParticlesPerAxis.z))); | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | Dali::Geometry MakeGeometry() const |
| ... | ... | @@ -58,14 +58,14 @@ struct ParticleField |
| 58 | 58 | struct Vertex |
| 59 | 59 | { |
| 60 | 60 | Vector3 aPosition; |
| 61 | - float aSeed; | |
| 61 | + float aSeed; | |
| 62 | 62 | Vector4 aPath; |
| 63 | 63 | Vector2 aSubPosition; |
| 64 | - float aSize; | |
| 64 | + float aSize; | |
| 65 | 65 | }; |
| 66 | 66 | |
| 67 | - const int numPatternVertices = 6; | |
| 68 | - Vector2 vertexPattern[numPatternVertices] = { | |
| 67 | + const int numPatternVertices = 6; | |
| 68 | + Vector2 vertexPattern[numPatternVertices] = { | |
| 69 | 69 | Vector2(-1.f, 1.f), |
| 70 | 70 | Vector2(-1.f, -1.f), |
| 71 | 71 | Vector2(1.f, 1.f), |
| ... | ... | @@ -75,27 +75,27 @@ struct ParticleField |
| 75 | 75 | }; |
| 76 | 76 | |
| 77 | 77 | Vector3 particlesPerAxis = GetParticlesPerAxisSafe(); |
| 78 | - auto numParticles = particlesPerAxis.x * particlesPerAxis.y * particlesPerAxis.z; | |
| 78 | + auto numParticles = particlesPerAxis.x * particlesPerAxis.y * particlesPerAxis.z; | |
| 79 | 79 | |
| 80 | 80 | std::vector<Vertex> vertices; |
| 81 | 81 | vertices.reserve(numParticles * numPatternVertices); |
| 82 | 82 | |
| 83 | 83 | Vector3 invBoxSize(1. / std::max(mBoxSize.x, 1.f), |
| 84 | - 1. / std::max(mBoxSize.y, 1.f), | |
| 85 | - 1. / std::max(mBoxSize.z, 1.f)); | |
| 84 | + 1. / std::max(mBoxSize.y, 1.f), | |
| 85 | + 1. / std::max(mBoxSize.z, 1.f)); | |
| 86 | 86 | Vector3 spacing(mBoxSize.x / particlesPerAxis.x, |
| 87 | - mBoxSize.y / particlesPerAxis.y, | |
| 88 | - mBoxSize.z / particlesPerAxis.z); | |
| 89 | - auto offset = (mBoxSize - spacing) * .5; | |
| 90 | - int nx = particlesPerAxis.x; | |
| 91 | - int ny = particlesPerAxis.y; | |
| 92 | - int nxy = nx * ny; | |
| 93 | - for (size_t i = 0; i < numParticles; ++i) | |
| 87 | + mBoxSize.y / particlesPerAxis.y, | |
| 88 | + mBoxSize.z / particlesPerAxis.z); | |
| 89 | + auto offset = (mBoxSize - spacing) * .5; | |
| 90 | + int nx = particlesPerAxis.x; | |
| 91 | + int ny = particlesPerAxis.y; | |
| 92 | + int nxy = nx * ny; | |
| 93 | + for(size_t i = 0; i < numParticles; ++i) | |
| 94 | 94 | { |
| 95 | 95 | Vertex v; |
| 96 | - float x = float(i % nx); | |
| 97 | - float y = float((i / nx) % ny); | |
| 98 | - float z = float(i / nxy); | |
| 96 | + float x = float(i % nx); | |
| 97 | + float y = float((i / nx) % ny); | |
| 98 | + float z = float(i / nxy); | |
| 99 | 99 | v.aPosition = Vector3(x, y, z) * spacing - offset; |
| 100 | 100 | |
| 101 | 101 | Vector3 disperseDir(frandDisperse() - .5, frandDisperse() - .5, frandDisperse() - .5); |
| ... | ... | @@ -108,26 +108,25 @@ struct ParticleField |
| 108 | 108 | v.aPath = Vector4(frandPath() - .5, frandPath() - .5, frandPath() - .5, frandPath() - .5) * mMotionScale; |
| 109 | 109 | |
| 110 | 110 | const float size = mSize * ((1.f + (frandSize() - .5) * mSizeVariance) * .5f); |
| 111 | - for (int j = 0; j < numPatternVertices; ++j) | |
| 111 | + for(int j = 0; j < numPatternVertices; ++j) | |
| 112 | 112 | { |
| 113 | 113 | v.aSubPosition = vertexPattern[j]; |
| 114 | - v.aSize = size; | |
| 114 | + v.aSize = size; | |
| 115 | 115 | vertices.push_back(v); |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - VertexBuffer vertexBuffer = VertexBuffer::New( Property::Map() | |
| 120 | - .Add( "aPosition", Property::VECTOR3 ) | |
| 121 | - .Add( "aSeed", Property::FLOAT ) | |
| 122 | - .Add( "aPath", Property::VECTOR4 ) | |
| 123 | - .Add( "aSubPosition", Property::VECTOR2 ) | |
| 124 | - .Add( "aSize", Property::FLOAT ) | |
| 125 | - ); | |
| 126 | - vertexBuffer.SetData( vertices.data(), vertices.size() ); | |
| 119 | + VertexBuffer vertexBuffer = VertexBuffer::New(Property::Map() | |
| 120 | + .Add("aPosition", Property::VECTOR3) | |
| 121 | + .Add("aSeed", Property::FLOAT) | |
| 122 | + .Add("aPath", Property::VECTOR4) | |
| 123 | + .Add("aSubPosition", Property::VECTOR2) | |
| 124 | + .Add("aSize", Property::FLOAT)); | |
| 125 | + vertexBuffer.SetData(vertices.data(), vertices.size()); | |
| 127 | 126 | |
| 128 | 127 | Geometry geometry = Geometry::New(); |
| 129 | - geometry.AddVertexBuffer( vertexBuffer ); | |
| 130 | - geometry.SetType( Geometry::TRIANGLES ); | |
| 128 | + geometry.AddVertexBuffer(vertexBuffer); | |
| 129 | + geometry.SetType(Geometry::TRIANGLES); | |
| 131 | 130 | return geometry; |
| 132 | 131 | } |
| 133 | 132 | }; | ... | ... |
examples/particles/particle-view.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -15,13 +15,13 @@ |
| 15 | 15 | * |
| 16 | 16 | */ |
| 17 | 17 | #include "particle-view.h" |
| 18 | -#include "utils.h" | |
| 19 | 18 | #include "dali/public-api/animation/constraints.h" |
| 19 | +#include "utils.h" | |
| 20 | 20 | |
| 21 | -#include "generated/particle-view-vert.h" | |
| 22 | 21 | #include "generated/particle-view-frag.h" |
| 23 | -#include "generated/particle-view-simple-vert.h" | |
| 24 | 22 | #include "generated/particle-view-simple-frag.h" |
| 23 | +#include "generated/particle-view-simple-vert.h" | |
| 24 | +#include "generated/particle-view-vert.h" | |
| 25 | 25 | |
| 26 | 26 | //#define ENABLE_DEBUG_VOLUME |
| 27 | 27 | |
| ... | ... | @@ -31,7 +31,6 @@ using namespace Dali; |
| 31 | 31 | |
| 32 | 32 | namespace |
| 33 | 33 | { |
| 34 | - | |
| 35 | 34 | const uint32_t POPULATION_GRANULARITY = 128; |
| 36 | 35 | |
| 37 | 36 | uint32_t GetSkipValue(uint32_t count, uint32_t prime) |
| ... | ... | @@ -40,19 +39,17 @@ uint32_t GetSkipValue(uint32_t count, uint32_t prime) |
| 40 | 39 | do |
| 41 | 40 | { |
| 42 | 41 | skip = (rand() % prime) * count * count + (rand() % prime) * count + (rand() % prime); |
| 43 | - } | |
| 44 | - while (skip % prime == 0); | |
| 42 | + } while(skip % prime == 0); | |
| 45 | 43 | return skip; |
| 46 | 44 | } |
| 47 | 45 | |
| 48 | -} | |
| 46 | +} // namespace | |
| 49 | 47 | |
| 50 | -ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali::CameraActor camera, | |
| 51 | - Dali::Geometry particleGeom) | |
| 48 | +ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali::CameraActor camera, Dali::Geometry particleGeom) | |
| 52 | 49 | : mWorld(world), |
| 53 | 50 | mParticleBoxSize(field.mBoxSize) |
| 54 | 51 | { |
| 55 | - if (!particleGeom) | |
| 52 | + if(!particleGeom) | |
| 56 | 53 | { |
| 57 | 54 | // create particles |
| 58 | 55 | particleGeom = field.MakeGeometry(); |
| ... | ... | @@ -61,8 +58,8 @@ ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali:: |
| 61 | 58 | // create shader |
| 62 | 59 | Shader particleShader = Shader::New(SHADER_PARTICLE_VIEW_VERT, SHADER_PARTICLE_VIEW_FRAG, Shader::Hint::MODIFIES_GEOMETRY); |
| 63 | 60 | |
| 64 | - float zNear = camera.GetNearClippingPlane(); | |
| 65 | - float zFar = camera.GetFarClippingPlane(); | |
| 61 | + float zNear = camera.GetNearClippingPlane(); | |
| 62 | + float zFar = camera.GetFarClippingPlane(); | |
| 66 | 63 | const Vector2 depthRange(zNear, 1.f / (zFar - zNear)); |
| 67 | 64 | particleShader.RegisterProperty("uDepthRange", depthRange); |
| 68 | 65 | |
| ... | ... | @@ -70,16 +67,16 @@ ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali:: |
| 70 | 67 | particleShader.RegisterProperty("uTwinkleSizeScale", field.mTwinkleSizeScale); |
| 71 | 68 | particleShader.RegisterProperty("uTwinkleOpacityWeight", field.mTwinkleOpacityWeight); |
| 72 | 69 | |
| 73 | - mPropPopulation = particleShader.RegisterProperty("uPopulation", 1.f); | |
| 74 | - mPropFocalLength = particleShader.RegisterProperty("uFocalLength", .5f); | |
| 75 | - mPropAperture = particleShader.RegisterProperty("uAperture", 8.f); | |
| 70 | + mPropPopulation = particleShader.RegisterProperty("uPopulation", 1.f); | |
| 71 | + mPropFocalLength = particleShader.RegisterProperty("uFocalLength", .5f); | |
| 72 | + mPropAperture = particleShader.RegisterProperty("uAperture", 8.f); | |
| 76 | 73 | mPropAlphaTestRefValue = particleShader.RegisterProperty("uAlphaTestRefValue", 0.f); |
| 77 | - mPropFadeRange = particleShader.RegisterProperty("uFadeRange", Vector2(0.f, 1.f)); | |
| 74 | + mPropFadeRange = particleShader.RegisterProperty("uFadeRange", Vector2(0.f, 1.f)); | |
| 78 | 75 | |
| 79 | 76 | // scatter variables |
| 80 | - char nameBuffer[64]; | |
| 77 | + char nameBuffer[64]; | |
| 81 | 78 | char* writep = nameBuffer + snprintf(nameBuffer, sizeof(nameBuffer), "uScatter["); |
| 82 | - for (uint32_t i = 0; i < std::extent<decltype(mScatterProps)>::value; ++i) | |
| 79 | + for(uint32_t i = 0; i < std::extent<decltype(mScatterProps)>::value; ++i) | |
| 83 | 80 | { |
| 84 | 81 | char* writep2 = writep + snprintf(writep, sizeof(nameBuffer) - std::distance(nameBuffer, writep), "%d].", i); |
| 85 | 82 | |
| ... | ... | @@ -97,18 +94,18 @@ ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali:: |
| 97 | 94 | // Our particle mesh is sorted in Z; changing the population should remove |
| 98 | 95 | // particles "randomly", not from one end. |
| 99 | 96 | // Algorithm described in Mike McShaffry & al: Game Coding Complete. |
| 100 | - const uint32_t prime = 131; // next prime after POPULATION_GRANULARITY | |
| 101 | - const uint32_t skip = GetSkipValue(POPULATION_GRANULARITY, prime); | |
| 102 | - uint32_t next = 0; | |
| 97 | + const uint32_t prime = 131; // next prime after POPULATION_GRANULARITY | |
| 98 | + const uint32_t skip = GetSkipValue(POPULATION_GRANULARITY, prime); | |
| 99 | + uint32_t next = 0; | |
| 103 | 100 | |
| 104 | 101 | writep = nameBuffer + snprintf(nameBuffer, sizeof(nameBuffer), "uOrderLookUp["); |
| 105 | - for (uint32_t i = 0; i < POPULATION_GRANULARITY; ++i) | |
| 102 | + for(uint32_t i = 0; i < POPULATION_GRANULARITY; ++i) | |
| 106 | 103 | { |
| 107 | - do { | |
| 104 | + do | |
| 105 | + { | |
| 108 | 106 | next += skip; |
| 109 | 107 | next %= prime; |
| 110 | - } | |
| 111 | - while (next == 0 || next > POPULATION_GRANULARITY); | |
| 108 | + } while(next == 0 || next > POPULATION_GRANULARITY); | |
| 112 | 109 | |
| 113 | 110 | snprintf(writep, sizeof(nameBuffer) - std::distance(nameBuffer, writep), "%d]", i); |
| 114 | 111 | particleShader.RegisterProperty(nameBuffer, float(next - 1)); |
| ... | ... | @@ -124,7 +121,7 @@ ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali:: |
| 124 | 121 | |
| 125 | 122 | mParticleShader = particleShader; |
| 126 | 123 | |
| 127 | - auto renderer = CreateRenderer(TextureSet::New(), particleGeom, particleShader, OPTION_BLEND); | |
| 124 | + auto renderer = CreateRenderer(TextureSet::New(), particleGeom, particleShader, OPTION_BLEND); | |
| 128 | 125 | auto masterParticles = CreateActor(); |
| 129 | 126 | masterParticles.SetProperty(Actor::Property::SIZE, field.mBoxSize); |
| 130 | 127 | masterParticles.SetProperty(Actor::Property::VISIBLE, true); |
| ... | ... | @@ -134,7 +131,7 @@ ParticleView::ParticleView(const ParticleField& field, Dali::Actor world, Dali:: |
| 134 | 131 | |
| 135 | 132 | #ifdef ENABLE_DEBUG_VOLUME |
| 136 | 133 | Geometry cubeGeom = CreateCuboidWireframeGeometry(); |
| 137 | - renderer = CreateRenderer(renderer.GetTextures(), cubeGeom, Shader::New(SHADER_PARTICLE_VIEW_SIMPLE_VERT, SHADER_PARTICLE_VIEW_SIMPLE_FRAG)); | |
| 134 | + renderer = CreateRenderer(renderer.GetTextures(), cubeGeom, Shader::New(SHADER_PARTICLE_VIEW_SIMPLE_VERT, SHADER_PARTICLE_VIEW_SIMPLE_FRAG)); | |
| 138 | 135 | masterParticles.AddRenderer(renderer); |
| 139 | 136 | #endif |
| 140 | 137 | |
| ... | ... | @@ -147,19 +144,19 @@ ParticleView::~ParticleView() |
| 147 | 144 | UnparentAndReset(mMasterParticles); |
| 148 | 145 | UnparentAndReset(mSlaveParticles); |
| 149 | 146 | |
| 150 | - for (auto anim: { mAngularAnim, mLinearAnim }) | |
| 147 | + for(auto anim : {mAngularAnim, mLinearAnim}) | |
| 151 | 148 | { |
| 152 | - if (anim) | |
| 149 | + if(anim) | |
| 153 | 150 | { |
| 154 | 151 | anim.Stop(); |
| 155 | 152 | anim.Reset(); |
| 156 | 153 | } |
| 157 | 154 | } |
| 158 | 155 | |
| 159 | - for (auto& s: mScatterProps) | |
| 156 | + for(auto& s : mScatterProps) | |
| 160 | 157 | { |
| 161 | 158 | auto& anim = s.mAnim; |
| 162 | - if (anim) | |
| 159 | + if(anim) | |
| 163 | 160 | { |
| 164 | 161 | anim.Stop(); |
| 165 | 162 | anim.Reset(); |
| ... | ... | @@ -204,23 +201,26 @@ void ParticleView::SetFadeRange(float near, float far) |
| 204 | 201 | |
| 205 | 202 | void ParticleView::SetAngularVelocity(float v) |
| 206 | 203 | { |
| 207 | - if (mAngularAnim) | |
| 204 | + if(mAngularAnim) | |
| 208 | 205 | { |
| 209 | 206 | mAngularAnim.Stop(); |
| 210 | 207 | mAngularAnim.Clear(); |
| 211 | 208 | mAngularAnim.Reset(); |
| 212 | 209 | } |
| 213 | 210 | |
| 214 | - if (v * v > .0f) | |
| 211 | + if(v * v > .0f) | |
| 215 | 212 | { |
| 216 | 213 | float sign = Sign(v); |
| 217 | - auto anim = Animation::New(std::abs(2. * M_PI / v)); | |
| 214 | + auto anim = Animation::New(std::abs(2. * M_PI / v)); | |
| 218 | 215 | anim.AnimateTo(Property(mMasterParticles, Actor::Property::ORIENTATION), |
| 219 | - Quaternion(Radian(Degree(120. * sign)), Vector3::ZAXIS), TimePeriod(0., anim.GetDuration() / 3.)); | |
| 216 | + Quaternion(Radian(Degree(120. * sign)), Vector3::ZAXIS), | |
| 217 | + TimePeriod(0., anim.GetDuration() / 3.)); | |
| 220 | 218 | anim.AnimateTo(Property(mMasterParticles, Actor::Property::ORIENTATION), |
| 221 | - Quaternion(Radian(Degree(240. * sign)), Vector3::ZAXIS), TimePeriod(anim.GetDuration() / 3., anim.GetDuration() / 3.)); | |
| 219 | + Quaternion(Radian(Degree(240. * sign)), Vector3::ZAXIS), | |
| 220 | + TimePeriod(anim.GetDuration() / 3., anim.GetDuration() / 3.)); | |
| 222 | 221 | anim.AnimateTo(Property(mMasterParticles, Actor::Property::ORIENTATION), |
| 223 | - Quaternion(Radian(Degree(360. * sign)), Vector3::ZAXIS), TimePeriod(2. * anim.GetDuration() / 3., anim.GetDuration() / 3.)); | |
| 222 | + Quaternion(Radian(Degree(360. * sign)), Vector3::ZAXIS), | |
| 223 | + TimePeriod(2. * anim.GetDuration() / 3., anim.GetDuration() / 3.)); | |
| 224 | 224 | anim.SetLoopCount(0); |
| 225 | 225 | anim.Play(); |
| 226 | 226 | |
| ... | ... | @@ -230,7 +230,7 @@ void ParticleView::SetAngularVelocity(float v) |
| 230 | 230 | |
| 231 | 231 | void ParticleView::SetLinearVelocity(float v) |
| 232 | 232 | { |
| 233 | - if (mLinearAnim) | |
| 233 | + if(mLinearAnim) | |
| 234 | 234 | { |
| 235 | 235 | mLinearAnim.Stop(); |
| 236 | 236 | mLinearAnim.Clear(); |
| ... | ... | @@ -238,13 +238,13 @@ void ParticleView::SetLinearVelocity(float v) |
| 238 | 238 | } |
| 239 | 239 | UnparentAndReset(mSlaveParticles); |
| 240 | 240 | |
| 241 | - if (v * v > .0f) | |
| 241 | + if(v * v > .0f) | |
| 242 | 242 | { |
| 243 | - float sign = Sign(v); | |
| 243 | + float sign = Sign(v); | |
| 244 | 244 | float directedSize = sign * mParticleBoxSize.z; |
| 245 | 245 | |
| 246 | - Actor slaveParticles = CloneActor(mMasterParticles); | |
| 247 | - Vector3 position = mMasterParticles.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(); | |
| 246 | + Actor slaveParticles = CloneActor(mMasterParticles); | |
| 247 | + Vector3 position = mMasterParticles.GetCurrentProperty(Actor::Property::POSITION).Get<Vector3>(); | |
| 248 | 248 | slaveParticles.SetProperty(Actor::Property::POSITION, position + Vector3(0., 0., directedSize)); |
| 249 | 249 | |
| 250 | 250 | auto propSecondaryColor = slaveParticles.RegisterProperty("uSecondaryColor", Vector3::XAXIS); |
| ... | ... | @@ -252,24 +252,21 @@ void ParticleView::SetLinearVelocity(float v) |
| 252 | 252 | Actor world = mWorld.GetHandle(); |
| 253 | 253 | world.Add(slaveParticles); |
| 254 | 254 | |
| 255 | - if (sign < 0.) // fix draw order | |
| 255 | + if(sign < 0.) // fix draw order | |
| 256 | 256 | { |
| 257 | 257 | world.Remove(mMasterParticles); |
| 258 | 258 | world.Add(mMasterParticles); |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - Constraint constraint = Constraint::New<Vector4>(slaveParticles, Actor::Property::COLOR, | |
| 262 | - EqualToConstraint()); | |
| 261 | + Constraint constraint = Constraint::New<Vector4>(slaveParticles, Actor::Property::COLOR, EqualToConstraint()); | |
| 263 | 262 | constraint.AddSource(Source(mMasterParticles, Actor::Property::COLOR)); |
| 264 | 263 | constraint.Apply(); |
| 265 | 264 | |
| 266 | - constraint = Constraint::New<Vector3>(slaveParticles, propSecondaryColor, | |
| 267 | - EqualToConstraint()); | |
| 265 | + constraint = Constraint::New<Vector3>(slaveParticles, propSecondaryColor, EqualToConstraint()); | |
| 268 | 266 | constraint.AddSource(Source(mMasterParticles, mPropSecondaryColor)); |
| 269 | 267 | constraint.Apply(); |
| 270 | 268 | |
| 271 | - constraint = Constraint::New<Quaternion>(slaveParticles, Actor::Property::ORIENTATION, | |
| 272 | - EqualToConstraint()); | |
| 269 | + constraint = Constraint::New<Quaternion>(slaveParticles, Actor::Property::ORIENTATION, EqualToConstraint()); | |
| 273 | 270 | constraint.AddSource(Source(mMasterParticles, Actor::Property::ORIENTATION)); |
| 274 | 271 | constraint.Apply(); |
| 275 | 272 | |
| ... | ... | @@ -279,7 +276,7 @@ void ParticleView::SetLinearVelocity(float v) |
| 279 | 276 | anim.SetLoopCount(0); |
| 280 | 277 | anim.Play(); |
| 281 | 278 | |
| 282 | - mLinearAnim = anim; | |
| 279 | + mLinearAnim = anim; | |
| 283 | 280 | mSlaveParticles = slaveParticles; |
| 284 | 281 | } |
| 285 | 282 | } |
| ... | ... | @@ -289,7 +286,7 @@ void ParticleView::Scatter(float radius, float amount, float durationOut, float |
| 289 | 286 | mActiveScatter = (mActiveScatter + 1) % std::extent<decltype(mScatterProps)>::value; |
| 290 | 287 | |
| 291 | 288 | auto& scatter = mScatterProps[mActiveScatter]; |
| 292 | - if (scatter.mAnim) | |
| 289 | + if(scatter.mAnim) | |
| 293 | 290 | { |
| 294 | 291 | scatter.mAnim.Stop(); |
| 295 | 292 | } |
| ... | ... | @@ -298,12 +295,10 @@ void ParticleView::Scatter(float radius, float amount, float durationOut, float |
| 298 | 295 | radius *= radius; |
| 299 | 296 | mParticleShader.SetProperty(scatter.mPropRadius, radius); |
| 300 | 297 | |
| 301 | - Animation anim = Animation::New(durationOut + durationIn); | |
| 302 | - auto scatterAmount = Property(mParticleShader, scatter.mPropAmount); | |
| 303 | - anim.AnimateTo(scatterAmount, amount, AlphaFunction::EASE_OUT, | |
| 304 | - TimePeriod(0.f, durationOut)); | |
| 305 | - anim.AnimateTo(scatterAmount, 0.f, AlphaFunction::EASE_IN_OUT_SINE, | |
| 306 | - TimePeriod(durationOut, durationIn)); | |
| 298 | + Animation anim = Animation::New(durationOut + durationIn); | |
| 299 | + auto scatterAmount = Property(mParticleShader, scatter.mPropAmount); | |
| 300 | + anim.AnimateTo(scatterAmount, amount, AlphaFunction::EASE_OUT, TimePeriod(0.f, durationOut)); | |
| 301 | + anim.AnimateTo(scatterAmount, 0.f, AlphaFunction::EASE_IN_OUT_SINE, TimePeriod(durationOut, durationIn)); | |
| 307 | 302 | anim.Play(); |
| 308 | 303 | |
| 309 | 304 | scatter.mAnim = anim; |
| ... | ... | @@ -312,25 +307,25 @@ void ParticleView::Scatter(float radius, float amount, float durationOut, float |
| 312 | 307 | void ParticleView::SetScatterRay(Dali::Vector3 rayDir) |
| 313 | 308 | { |
| 314 | 309 | auto& scatter = mScatterProps[mActiveScatter]; |
| 315 | - mParticleShader.SetProperty(scatter.mPropRay, rayDir);; | |
| 310 | + mParticleShader.SetProperty(scatter.mPropRay, rayDir); | |
| 311 | + ; | |
| 316 | 312 | } |
| 317 | 313 | |
| 318 | -void ParticleView::Fade(float duration, float target, AlphaFunction alphaFn, | |
| 319 | - std::function<void(Dali::Animation&)> onFinished) | |
| 314 | +void ParticleView::Fade(float duration, float target, AlphaFunction alphaFn, std::function<void(Dali::Animation&)> onFinished) | |
| 320 | 315 | { |
| 321 | - if (mFadeAnim) | |
| 316 | + if(mFadeAnim) | |
| 322 | 317 | { |
| 323 | 318 | mFadeAnim.Stop(); |
| 324 | 319 | } |
| 325 | 320 | |
| 326 | 321 | Animation anim = Animation::New(duration); |
| 327 | 322 | anim.AnimateTo(Property(mMasterParticles, Actor::Property::COLOR_ALPHA), target, alphaFn); |
| 328 | - if (mSlaveParticles) | |
| 323 | + if(mSlaveParticles) | |
| 329 | 324 | { |
| 330 | 325 | anim.AnimateTo(Property(mSlaveParticles, Actor::Property::COLOR_ALPHA), target, alphaFn); |
| 331 | 326 | } |
| 332 | 327 | |
| 333 | - if (onFinished) | |
| 328 | + if(onFinished) | |
| 334 | 329 | { |
| 335 | 330 | anim.FinishedSignal().Connect(this, onFinished); |
| 336 | 331 | } |
| ... | ... | @@ -339,11 +334,10 @@ void ParticleView::Fade(float duration, float target, AlphaFunction alphaFn, |
| 339 | 334 | mFadeAnim = anim; |
| 340 | 335 | } |
| 341 | 336 | |
| 342 | -void ParticleView::Fade(float duration, float target, float from, AlphaFunction alphaFn, | |
| 343 | - std::function<void(Dali::Animation&)> onFinished) | |
| 337 | +void ParticleView::Fade(float duration, float target, float from, AlphaFunction alphaFn, std::function<void(Dali::Animation&)> onFinished) | |
| 344 | 338 | { |
| 345 | 339 | mMasterParticles.SetProperty(Actor::Property::COLOR_ALPHA, from); |
| 346 | - if (mSlaveParticles) | |
| 340 | + if(mSlaveParticles) | |
| 347 | 341 | { |
| 348 | 342 | mSlaveParticles.SetProperty(Actor::Property::COLOR_ALPHA, from); |
| 349 | 343 | } | ... | ... |
examples/particles/particle-view.h
| 1 | 1 | #ifndef PARTICLES_PARTICLE_VIEW_H_ |
| 2 | 2 | #define PARTICLES_PARTICLE_VIEW_H_ |
| 3 | 3 | /* |
| 4 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 4 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 5 | 5 | * |
| 6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | 7 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -17,13 +17,13 @@ |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -#include "particle-field.h" | |
| 20 | +#include <functional> | |
| 21 | +#include <vector> | |
| 21 | 22 | #include "dali/public-api/actors/camera-actor.h" |
| 22 | 23 | #include "dali/public-api/animation/animation.h" |
| 23 | 24 | #include "dali/public-api/object/weak-handle.h" |
| 24 | 25 | #include "dali/public-api/rendering/shader.h" |
| 25 | -#include <vector> | |
| 26 | -#include <functional> | |
| 26 | +#include "particle-field.h" | |
| 27 | 27 | |
| 28 | 28 | struct ColorRange |
| 29 | 29 | { |
| ... | ... | @@ -31,11 +31,10 @@ struct ColorRange |
| 31 | 31 | Dali::Vector3 rgb1; |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | -class ParticleView: public Dali::ConnectionTracker | |
| 34 | +class ParticleView : public Dali::ConnectionTracker | |
| 35 | 35 | { |
| 36 | 36 | public: |
| 37 | - ParticleView(const ParticleField& field, Dali::Actor world, Dali::CameraActor camera, | |
| 38 | - Dali::Geometry particleGeom = Dali::Geometry()); | |
| 37 | + ParticleView(const ParticleField& field, Dali::Actor world, Dali::CameraActor camera, Dali::Geometry particleGeom = Dali::Geometry()); | |
| 39 | 38 | ~ParticleView(); |
| 40 | 39 | |
| 41 | 40 | void SetColorRange(const ColorRange& range); |
| ... | ... | @@ -62,15 +61,13 @@ public: |
| 62 | 61 | ///@brief Starts an animation to change the opacity of the particles to @a target. |
| 63 | 62 | ///@param duration Number of seconds to complete transition in. |
| 64 | 63 | ///@param target Target opacity in the 0..1.f range. |
| 65 | - void Fade(float duration, float target, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT, | |
| 66 | - std::function<void(Dali::Animation&)> onFinished = nullptr); | |
| 64 | + void Fade(float duration, float target, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT, std::function<void(Dali::Animation&)> onFinished = nullptr); | |
| 67 | 65 | |
| 68 | 66 | ///@brief Starts an animation to change the opacity of the particles to @a target. |
| 69 | 67 | ///@param duration Number of seconds to complete transition in. |
| 70 | 68 | ///@param target Target opacity in the 0..1.f range. |
| 71 | 69 | ///@param from The value to set the opacity to prior to the animation. |
| 72 | - void Fade(float duration, float target, float from, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT, | |
| 73 | - std::function<void(Dali::Animation&)> onFinished = nullptr); | |
| 70 | + void Fade(float duration, float target, float from, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT, std::function<void(Dali::Animation&)> onFinished = nullptr); | |
| 74 | 71 | |
| 75 | 72 | private: // DATA |
| 76 | 73 | struct ScatterProps |
| ... | ... | @@ -83,9 +80,9 @@ private: // DATA |
| 83 | 80 | }; |
| 84 | 81 | |
| 85 | 82 | Dali::WeakHandle<Dali::Actor> mWorld; |
| 86 | - Dali::Vector3 mParticleBoxSize; | |
| 83 | + Dali::Vector3 mParticleBoxSize; | |
| 87 | 84 | |
| 88 | - Dali::Shader mParticleShader; | |
| 85 | + Dali::Shader mParticleShader; | |
| 89 | 86 | Dali::Property::Index mPropPopulation; |
| 90 | 87 | Dali::Property::Index mPropFocalLength; |
| 91 | 88 | Dali::Property::Index mPropAperture; |
| ... | ... | @@ -93,9 +90,9 @@ private: // DATA |
| 93 | 90 | Dali::Property::Index mPropFadeRange; |
| 94 | 91 | |
| 95 | 92 | ScatterProps mScatterProps[6]; |
| 96 | - int mActiveScatter = 0; | |
| 93 | + int mActiveScatter = 0; | |
| 97 | 94 | |
| 98 | - Dali::Actor mMasterParticles; | |
| 95 | + Dali::Actor mMasterParticles; | |
| 99 | 96 | Dali::Property::Index mPropSecondaryColor; |
| 100 | 97 | |
| 101 | 98 | Dali::Actor mSlaveParticles; | ... | ... |
examples/particles/particles-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2018 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -16,38 +16,37 @@ |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | // INTERNAL INCLUDES |
| 19 | -#include "particle-view.h" | |
| 20 | -#include "float-rand.h" | |
| 21 | -#include "particle-field.h" | |
| 22 | -#include "utils.h" | |
| 19 | +#include <fstream> | |
| 20 | +#include <iostream> | |
| 21 | +#include <list> | |
| 22 | +#include <memory> | |
| 23 | +#include <numeric> | |
| 24 | +#include <random> | |
| 23 | 25 | #include "dali/devel-api/adaptor-framework/tilt-sensor.h" |
| 24 | -#include "dali/public-api/adaptor-framework/application.h" | |
| 25 | -#include "dali/public-api/adaptor-framework/key.h" | |
| 26 | 26 | #include "dali/public-api/actors/camera-actor.h" |
| 27 | 27 | #include "dali/public-api/actors/layer.h" |
| 28 | -#include "dali/public-api/events/tap-gesture-detector.h" | |
| 28 | +#include "dali/public-api/adaptor-framework/application.h" | |
| 29 | +#include "dali/public-api/adaptor-framework/key.h" | |
| 29 | 30 | #include "dali/public-api/events/pan-gesture-detector.h" |
| 31 | +#include "dali/public-api/events/tap-gesture-detector.h" | |
| 30 | 32 | #include "dali/public-api/events/touch-event.h" |
| 33 | +#include "dali/public-api/object/property-index-ranges.h" | |
| 31 | 34 | #include "dali/public-api/render-tasks/render-task-list.h" |
| 32 | 35 | #include "dali/public-api/render-tasks/render-task.h" |
| 33 | -#include "dali/public-api/object/property-index-ranges.h" | |
| 34 | -#include <fstream> | |
| 35 | -#include <iostream> | |
| 36 | -#include <numeric> | |
| 37 | -#include <list> | |
| 38 | -#include <memory> | |
| 39 | -#include <random> | |
| 36 | +#include "float-rand.h" | |
| 37 | +#include "particle-field.h" | |
| 38 | +#include "particle-view.h" | |
| 39 | +#include "utils.h" | |
| 40 | 40 | |
| 41 | 41 | using namespace Dali; |
| 42 | 42 | |
| 43 | 43 | namespace |
| 44 | 44 | { |
| 45 | - | |
| 46 | -const float PARTICLE_ALPHA = .75; | |
| 45 | +const float PARTICLE_ALPHA = .75; | |
| 47 | 46 | const float ALPHA_TEST_REF_VALUE = .0625; |
| 48 | 47 | |
| 49 | -const float NEAR_FADE = 0.04; // normalized depth | |
| 50 | -const float FAR_FADE = 0.8; // normalized depth | |
| 48 | +const float NEAR_FADE = 0.04; // normalized depth | |
| 49 | +const float FAR_FADE = 0.8; // normalized depth | |
| 51 | 50 | |
| 52 | 51 | const ParticleField PARTICLE_FIELD = { |
| 53 | 52 | 200.f, // particle size |
| ... | ... | @@ -63,23 +62,23 @@ const ParticleField PARTICLE_FIELD = { |
| 63 | 62 | .333 // twinkle opacity weight |
| 64 | 63 | }; |
| 65 | 64 | |
| 66 | -const float WORLD_ANGULAR_VELOCITY = .08; // radians per seconds | |
| 67 | -const float WORLD_LINEAR_VELOCITY = -500; // units along z | |
| 65 | +const float WORLD_ANGULAR_VELOCITY = .08; // radians per seconds | |
| 66 | +const float WORLD_LINEAR_VELOCITY = -500; // units along z | |
| 68 | 67 | |
| 69 | -const float SCATTER_RADIUS = 450.0f; | |
| 70 | -const float SCATTER_AMOUNT = 180.0f; | |
| 68 | +const float SCATTER_RADIUS = 450.0f; | |
| 69 | +const float SCATTER_AMOUNT = 180.0f; | |
| 71 | 70 | const float SCATTER_DURATION_OUT = .8f; |
| 72 | -const float SCATTER_DURATION_IN = 1.5f; | |
| 71 | +const float SCATTER_DURATION_IN = 1.5f; | |
| 73 | 72 | |
| 74 | -const float FADE_DURATION = 1.2f; | |
| 73 | +const float FADE_DURATION = 1.2f; | |
| 75 | 74 | const float FADEOUT_SPEED_MULTIPLIER = 4.f; // speed multiplier upon fading out. |
| 76 | 75 | |
| 77 | 76 | const float FOCAL_LENGTH = 0.5f; // normalized depth value where particles appear sharp. |
| 78 | -const float APERTURE = 2.2f; // distance scale - the higher it is, the quicker the particles get blurred out moving away from the focal length. | |
| 77 | +const float APERTURE = 2.2f; // distance scale - the higher it is, the quicker the particles get blurred out moving away from the focal length. | |
| 79 | 78 | |
| 80 | -const ColorRange DEFAULT_COLOR_RANGE { Vector3(0., 48. / 255., 1.), Vector3(0., 216. / 255., 1.) }; | |
| 79 | +const ColorRange DEFAULT_COLOR_RANGE{Vector3(0., 48. / 255., 1.), Vector3(0., 216. / 255., 1.)}; | |
| 81 | 80 | |
| 82 | -const float TILT_SCALE = 0.2; | |
| 81 | +const float TILT_SCALE = 0.2; | |
| 83 | 82 | const float TILT_RANGE_DEGREES = 30.f; |
| 84 | 83 | |
| 85 | 84 | FloatRand sFloatRand; |
| ... | ... | @@ -95,7 +94,7 @@ public: |
| 95 | 94 | void Add(Dali::Vector2 tilt) |
| 96 | 95 | { |
| 97 | 96 | mTiltSamples[mIdxNextSample] = tilt; |
| 98 | - mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE; | |
| 97 | + mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE; | |
| 99 | 98 | } |
| 100 | 99 | |
| 101 | 100 | Dali::Vector2 Filter() const |
| ... | ... | @@ -104,17 +103,20 @@ public: |
| 104 | 103 | } |
| 105 | 104 | |
| 106 | 105 | private: |
| 107 | - enum { FILTER_SIZE = 8u }; | |
| 106 | + enum | |
| 107 | + { | |
| 108 | + FILTER_SIZE = 8u | |
| 109 | + }; | |
| 108 | 110 | |
| 109 | 111 | Dali::Vector2 mTiltSamples[FILTER_SIZE]; |
| 110 | - size_t mIdxNextSample = 0; | |
| 112 | + size_t mIdxNextSample = 0; | |
| 111 | 113 | }; |
| 112 | 114 | |
| 113 | 115 | class ParticlesExample : public ConnectionTracker |
| 114 | 116 | { |
| 115 | 117 | public: |
| 116 | - ParticlesExample( Application& app ) | |
| 117 | - : mApp( app ) | |
| 118 | + ParticlesExample(Application& app) | |
| 119 | + : mApp(app) | |
| 118 | 120 | { |
| 119 | 121 | mApp.InitSignal().Connect(this, &ParticlesExample::OnInit); |
| 120 | 122 | mApp.TerminateSignal().Connect(this, &ParticlesExample::OnTerminate); |
| ... | ... | @@ -127,8 +129,8 @@ private: |
| 127 | 129 | |
| 128 | 130 | CameraActor mCamera; |
| 129 | 131 | |
| 130 | - Actor mWorld; | |
| 131 | - Vector2 mAngularPosition; | |
| 132 | + Actor mWorld; | |
| 133 | + Vector2 mAngularPosition; | |
| 132 | 134 | ColorRange mColors; |
| 133 | 135 | |
| 134 | 136 | std::unique_ptr<ParticleView> mParticles; |
| ... | ... | @@ -141,20 +143,20 @@ private: |
| 141 | 143 | |
| 142 | 144 | PanGestureDetector mPanGesture; |
| 143 | 145 | |
| 144 | - void OnInit( Application& application ) | |
| 146 | + void OnInit(Application& application) | |
| 145 | 147 | { |
| 146 | - Window window = application.GetWindow(); | |
| 147 | - auto rootLayer = window.GetRootLayer(); | |
| 148 | + Window window = application.GetWindow(); | |
| 149 | + auto rootLayer = window.GetRootLayer(); | |
| 148 | 150 | rootLayer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D); |
| 149 | 151 | |
| 150 | - window.KeyEventSignal().Connect( this, &ParticlesExample::OnKeyEvent ); | |
| 151 | - window.GetRootLayer().TouchedSignal().Connect( this, &ParticlesExample::OnTouched ); | |
| 152 | + window.KeyEventSignal().Connect(this, &ParticlesExample::OnKeyEvent); | |
| 153 | + window.GetRootLayer().TouchedSignal().Connect(this, &ParticlesExample::OnTouched); | |
| 152 | 154 | |
| 153 | 155 | auto tiltSensor = TiltSensor::Get(); |
| 154 | - if ( tiltSensor.Start() ) | |
| 156 | + if(tiltSensor.Start()) | |
| 155 | 157 | { |
| 156 | 158 | // Get notifications when the device is tilted |
| 157 | - tiltSensor.TiltedSignal().Connect( this, &ParticlesExample::OnTilted ); | |
| 159 | + tiltSensor.TiltedSignal().Connect(this, &ParticlesExample::OnTilted); | |
| 158 | 160 | } |
| 159 | 161 | else |
| 160 | 162 | { |
| ... | ... | @@ -164,10 +166,10 @@ private: |
| 164 | 166 | } |
| 165 | 167 | |
| 166 | 168 | // Get camera |
| 167 | - RenderTaskList tasks = window.GetRenderTaskList(); | |
| 168 | - RenderTask mainPass = tasks.GetTask(0); | |
| 169 | - CameraActor camera = mainPass.GetCameraActor(); | |
| 170 | - mCamera = camera; | |
| 169 | + RenderTaskList tasks = window.GetRenderTaskList(); | |
| 170 | + RenderTask mainPass = tasks.GetTask(0); | |
| 171 | + CameraActor camera = mainPass.GetCameraActor(); | |
| 172 | + mCamera = camera; | |
| 171 | 173 | |
| 172 | 174 | // Create world - particles and clock are added to it; this is what we apply tilt to. |
| 173 | 175 | auto world = CreateActor(); |
| ... | ... | @@ -205,23 +207,23 @@ private: |
| 205 | 207 | |
| 206 | 208 | void OnKeyEvent(const KeyEvent& event) |
| 207 | 209 | { |
| 208 | - if ( event.GetState() == KeyEvent::UP) // single keystrokes | |
| 210 | + if(event.GetState() == KeyEvent::UP) // single keystrokes | |
| 209 | 211 | { |
| 210 | - if( IsKey( event, DALI_KEY_ESCAPE ) || IsKey( event, DALI_KEY_BACK ) ) | |
| 212 | + if(IsKey(event, DALI_KEY_ESCAPE) || IsKey(event, DALI_KEY_BACK)) | |
| 211 | 213 | { |
| 212 | 214 | mApp.Quit(); |
| 213 | 215 | } |
| 214 | 216 | } |
| 215 | 217 | } |
| 216 | 218 | |
| 217 | - bool OnTouched( Actor a, const TouchEvent& event ) | |
| 219 | + bool OnTouched(Actor a, const TouchEvent& event) | |
| 218 | 220 | { |
| 219 | - if (event.GetPointCount() > 0) | |
| 221 | + if(event.GetPointCount() > 0) | |
| 220 | 222 | { |
| 221 | 223 | auto screenPos = event.GetScreenPosition(0); |
| 222 | - switch (event.GetState(0)) | |
| 224 | + switch(event.GetState(0)) | |
| 223 | 225 | { |
| 224 | - case PointState::STARTED: | |
| 226 | + case PointState::STARTED: | |
| 225 | 227 | { |
| 226 | 228 | mParticles->Scatter(SCATTER_RADIUS, SCATTER_AMOUNT, SCATTER_DURATION_OUT, SCATTER_DURATION_IN); |
| 227 | 229 | |
| ... | ... | @@ -230,8 +232,8 @@ private: |
| 230 | 232 | } |
| 231 | 233 | break; |
| 232 | 234 | |
| 233 | - default: | |
| 234 | - break; | |
| 235 | + default: | |
| 236 | + break; | |
| 235 | 237 | } |
| 236 | 238 | } |
| 237 | 239 | |
| ... | ... | @@ -240,7 +242,7 @@ private: |
| 240 | 242 | |
| 241 | 243 | void OnDoubleTap(Actor /*actor*/, const TapGesture& /*gesture*/) |
| 242 | 244 | { |
| 243 | - if (!mExpiringParticles) | |
| 245 | + if(!mExpiringParticles) | |
| 244 | 246 | { |
| 245 | 247 | mColors.rgb0 = Vector3::ONE - mColors.rgb1; |
| 246 | 248 | mColors.rgb1 = FromHueSaturationLightness(Vector3(sFloatRand() * 360.f, sFloatRand() * .5f + .5f, sFloatRand() * .25 + .75f)); |
| ... | ... | @@ -251,33 +253,33 @@ private: |
| 251 | 253 | |
| 252 | 254 | void OnPan(Actor actor, const PanGesture& gesture) |
| 253 | 255 | { |
| 254 | - auto tilt = gesture.GetDisplacement() / Vector2(mApp.GetWindow().GetSize()) * TILT_SCALE; | |
| 256 | + auto tilt = gesture.GetDisplacement() / Vector2(mApp.GetWindow().GetSize()) * TILT_SCALE; | |
| 255 | 257 | Quaternion q(Radian(-tilt.y), Radian(tilt.x), Radian(0.f)); |
| 256 | 258 | Quaternion q0 = mWorld.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>(); |
| 257 | 259 | mWorld.SetProperty(Actor::Property::ORIENTATION, q * q0); |
| 258 | 260 | } |
| 259 | 261 | |
| 260 | - void OnTilted( const TiltSensor& sensor) | |
| 262 | + void OnTilted(const TiltSensor& sensor) | |
| 261 | 263 | { |
| 262 | 264 | mTiltFilter.Add(Vector2(sensor.GetPitch(), sensor.GetRoll())); |
| 263 | - Vector2 tilt = mTiltFilter.Filter() * TILT_RANGE_DEGREES; | |
| 265 | + Vector2 tilt = mTiltFilter.Filter() * TILT_RANGE_DEGREES; | |
| 264 | 266 | Quaternion q(Radian(Degree(tilt.x)), Radian(Degree(tilt.y)), Radian(0.f)); |
| 265 | 267 | mWorld.SetProperty(Actor::Property::ORIENTATION, q); |
| 266 | 268 | } |
| 267 | 269 | |
| 268 | 270 | Vector3 GetViewRay(const Vector2& screenPos) |
| 269 | 271 | { |
| 270 | - Vector2 screenSize = mApp.GetWindow().GetSize(); | |
| 272 | + Vector2 screenSize = mApp.GetWindow().GetSize(); | |
| 271 | 273 | Vector2 normScreenPos = (screenPos / screenSize) * 2.f - Vector2::ONE; |
| 272 | 274 | |
| 273 | - const float fov = mCamera.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>(); | |
| 275 | + const float fov = mCamera.GetProperty(CameraActor::Property::FIELD_OF_VIEW).Get<float>(); | |
| 274 | 276 | const float tanFov = std::tan(fov); |
| 275 | 277 | |
| 276 | 278 | const float zNear = mCamera.GetProperty(CameraActor::Property::NEAR_PLANE_DISTANCE).Get<float>(); |
| 277 | 279 | const float hProj = zNear * tanFov; |
| 278 | 280 | |
| 279 | 281 | const float aspectRatio = mCamera.GetProperty(CameraActor::Property::ASPECT_RATIO).Get<float>(); |
| 280 | - const float wProj = hProj * aspectRatio; | |
| 282 | + const float wProj = hProj * aspectRatio; | |
| 281 | 283 | |
| 282 | 284 | // Get camera orientation for view space ray casting. Assume: |
| 283 | 285 | // - this to be world space, i.e. no parent transforms; |
| ... | ... | @@ -287,7 +289,7 @@ private: |
| 287 | 289 | Matrix worldCamera; |
| 288 | 290 | worldCamera.SetTransformComponents(Vector3::ONE, cameraOrientation, Vector3::ZERO); |
| 289 | 291 | |
| 290 | - float* data = worldCamera.AsFloat(); | |
| 292 | + float* data = worldCamera.AsFloat(); | |
| 291 | 293 | Vector3 xWorldCamera(data[0], data[4], data[8]); |
| 292 | 294 | xWorldCamera *= wProj * normScreenPos.x / xWorldCamera.Length(); |
| 293 | 295 | |
| ... | ... | @@ -303,7 +305,7 @@ private: |
| 303 | 305 | |
| 304 | 306 | void TriggerColorTransition(const ColorRange& range) |
| 305 | 307 | { |
| 306 | - if (mParticles) | |
| 308 | + if(mParticles) | |
| 307 | 309 | { |
| 308 | 310 | mExpiringParticles = std::move(mParticles); |
| 309 | 311 | |
| ... | ... | @@ -328,12 +330,12 @@ private: |
| 328 | 330 | } |
| 329 | 331 | }; |
| 330 | 332 | |
| 331 | -} // nonamespace | |
| 333 | +} // namespace | |
| 332 | 334 | |
| 333 | -int DALI_EXPORT_API main( int argc, char **argv ) | |
| 335 | +int DALI_EXPORT_API main(int argc, char** argv) | |
| 334 | 336 | { |
| 335 | - Application application = Application::New( &argc, &argv, DEMO_THEME_PATH ); | |
| 336 | - ParticlesExample example( application); | |
| 337 | + Application application = Application::New(&argc, &argv, DEMO_THEME_PATH); | |
| 338 | + ParticlesExample example(application); | |
| 337 | 339 | application.MainLoop(); |
| 338 | 340 | return 0; |
| 339 | 341 | } | ... | ... |
examples/particles/utils.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -24,10 +24,10 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) |
| 24 | 24 | float max = std::max(rgb.r, std::max(rgb.g, rgb.b)); |
| 25 | 25 | |
| 26 | 26 | Vector3 hsl(max - min, 0.f, (max + min) * .5f); |
| 27 | - if (hsl.x * hsl.x > .0f) | |
| 27 | + if(hsl.x * hsl.x > .0f) | |
| 28 | 28 | { |
| 29 | 29 | hsl.y = hsl.x / max; |
| 30 | - if (max == rgb.r) | |
| 30 | + if(max == rgb.r) | |
| 31 | 31 | { |
| 32 | 32 | hsl.x = (rgb.g - rgb.b) / hsl.x; |
| 33 | 33 | } |
| ... | ... | @@ -40,7 +40,7 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) |
| 40 | 40 | hsl.x = 4.f + (rgb.r - rgb.g) / hsl.x; |
| 41 | 41 | } |
| 42 | 42 | hsl.x *= 60.f; |
| 43 | - if (hsl.x < 0.f) | |
| 43 | + if(hsl.x < 0.f) | |
| 44 | 44 | { |
| 45 | 45 | hsl.x += 360.f; |
| 46 | 46 | } |
| ... | ... | @@ -56,7 +56,7 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) |
| 56 | 56 | Vector3 FromHueSaturationLightness(Vector3 hsl) |
| 57 | 57 | { |
| 58 | 58 | Vector3 rgb; |
| 59 | - if (hsl.y * hsl.y > 0.f) | |
| 59 | + if(hsl.y * hsl.y > 0.f) | |
| 60 | 60 | { |
| 61 | 61 | if(hsl.x >= 360.f) |
| 62 | 62 | { |
| ... | ... | @@ -64,50 +64,50 @@ Vector3 FromHueSaturationLightness(Vector3 hsl) |
| 64 | 64 | } |
| 65 | 65 | hsl.x /= 60.f; |
| 66 | 66 | |
| 67 | - int i = FastFloor(hsl.x); | |
| 67 | + int i = FastFloor(hsl.x); | |
| 68 | 68 | float ff = hsl.x - i; |
| 69 | - float p = hsl.z * (1.0 - hsl.y); | |
| 70 | - float q = hsl.z * (1.0 - (hsl.y * ff)); | |
| 71 | - float t = hsl.z * (1.0 - (hsl.y * (1.f - ff))); | |
| 69 | + float p = hsl.z * (1.0 - hsl.y); | |
| 70 | + float q = hsl.z * (1.0 - (hsl.y * ff)); | |
| 71 | + float t = hsl.z * (1.0 - (hsl.y * (1.f - ff))); | |
| 72 | 72 | |
| 73 | - switch (i) | |
| 73 | + switch(i) | |
| 74 | 74 | { |
| 75 | - case 0: | |
| 76 | - rgb.r = hsl.z; | |
| 77 | - rgb.g = t; | |
| 78 | - rgb.b = p; | |
| 79 | - break; | |
| 80 | - | |
| 81 | - case 1: | |
| 82 | - rgb.r = q; | |
| 83 | - rgb.g = hsl.z; | |
| 84 | - rgb.b = p; | |
| 85 | - break; | |
| 86 | - | |
| 87 | - case 2: | |
| 88 | - rgb.r = p; | |
| 89 | - rgb.g = hsl.z; | |
| 90 | - rgb.b = t; | |
| 91 | - break; | |
| 92 | - | |
| 93 | - case 3: | |
| 94 | - rgb.r = p; | |
| 95 | - rgb.g = q; | |
| 96 | - rgb.b = hsl.z; | |
| 97 | - break; | |
| 98 | - | |
| 99 | - case 4: | |
| 100 | - rgb.r = t; | |
| 101 | - rgb.g = p; | |
| 102 | - rgb.b = hsl.z; | |
| 103 | - break; | |
| 104 | - | |
| 105 | - case 5: | |
| 106 | - default: | |
| 107 | - rgb.r = hsl.z; | |
| 108 | - rgb.g = p; | |
| 109 | - rgb.b = q; | |
| 110 | - break; | |
| 75 | + case 0: | |
| 76 | + rgb.r = hsl.z; | |
| 77 | + rgb.g = t; | |
| 78 | + rgb.b = p; | |
| 79 | + break; | |
| 80 | + | |
| 81 | + case 1: | |
| 82 | + rgb.r = q; | |
| 83 | + rgb.g = hsl.z; | |
| 84 | + rgb.b = p; | |
| 85 | + break; | |
| 86 | + | |
| 87 | + case 2: | |
| 88 | + rgb.r = p; | |
| 89 | + rgb.g = hsl.z; | |
| 90 | + rgb.b = t; | |
| 91 | + break; | |
| 92 | + | |
| 93 | + case 3: | |
| 94 | + rgb.r = p; | |
| 95 | + rgb.g = q; | |
| 96 | + rgb.b = hsl.z; | |
| 97 | + break; | |
| 98 | + | |
| 99 | + case 4: | |
| 100 | + rgb.r = t; | |
| 101 | + rgb.g = p; | |
| 102 | + rgb.b = hsl.z; | |
| 103 | + break; | |
| 104 | + | |
| 105 | + case 5: | |
| 106 | + default: | |
| 107 | + rgb.r = hsl.z; | |
| 108 | + rgb.g = p; | |
| 109 | + rgb.b = q; | |
| 110 | + break; | |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | else |
| ... | ... | @@ -120,38 +120,35 @@ Vector3 FromHueSaturationLightness(Vector3 hsl) |
| 120 | 120 | |
| 121 | 121 | Geometry CreateCuboidWireframeGeometry() |
| 122 | 122 | { |
| 123 | -// | |
| 124 | -// 2---3 | |
| 125 | -// |- |- | |
| 126 | -// | 6---7 | |
| 127 | -// | | | | | |
| 128 | -// 0-|-1 | | |
| 129 | -// -| -| | |
| 130 | -// 4---5 | |
| 131 | -// | |
| 123 | + // | |
| 124 | + // 2---3 | |
| 125 | + // |- |- | |
| 126 | + // | 6---7 | |
| 127 | + // | | | | | |
| 128 | + // 0-|-1 | | |
| 129 | + // -| -| | |
| 130 | + // 4---5 | |
| 131 | + // | |
| 132 | 132 | Vector3 vertexData[] = { |
| 133 | 133 | Vector3(-.5, -.5, -.5), |
| 134 | - Vector3( .5, -.5, -.5), | |
| 135 | - Vector3(-.5, .5, -.5), | |
| 136 | - Vector3( .5, .5, -.5), | |
| 137 | - Vector3(-.5, -.5, .5), | |
| 138 | - Vector3( .5, -.5, .5), | |
| 139 | - Vector3(-.5, .5, .5), | |
| 140 | - Vector3( .5, .5, .5), | |
| 134 | + Vector3(.5, -.5, -.5), | |
| 135 | + Vector3(-.5, .5, -.5), | |
| 136 | + Vector3(.5, .5, -.5), | |
| 137 | + Vector3(-.5, -.5, .5), | |
| 138 | + Vector3(.5, -.5, .5), | |
| 139 | + Vector3(-.5, .5, .5), | |
| 140 | + Vector3(.5, .5, .5), | |
| 141 | 141 | }; |
| 142 | 142 | |
| 143 | 143 | uint16_t indices[] = { |
| 144 | - 0, 1, 1, 3, 3, 2, 2, 0, | |
| 145 | - 0, 4, 1, 5, 3, 7, 2, 6, | |
| 146 | - 4, 5, 5, 7, 7, 6, 6, 4 | |
| 147 | - }; | |
| 148 | - VertexBuffer vertexBuffer = VertexBuffer::New( Property::Map() | |
| 149 | - .Add( "aPosition", Property::VECTOR3)); | |
| 150 | - vertexBuffer.SetData(vertexData, std::extent<decltype(vertexData)>::value ); | |
| 144 | + 0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 1, 5, 3, 7, 2, 6, 4, 5, 5, 7, 7, 6, 6, 4}; | |
| 145 | + VertexBuffer vertexBuffer = VertexBuffer::New(Property::Map() | |
| 146 | + .Add("aPosition", Property::VECTOR3)); | |
| 147 | + vertexBuffer.SetData(vertexData, std::extent<decltype(vertexData)>::value); | |
| 151 | 148 | |
| 152 | 149 | Geometry geometry = Geometry::New(); |
| 153 | - geometry.AddVertexBuffer( vertexBuffer ); | |
| 154 | - geometry.SetIndexBuffer( indices, std::extent<decltype(indices)>::value ); | |
| 150 | + geometry.AddVertexBuffer(vertexBuffer); | |
| 151 | + geometry.SetIndexBuffer(indices, std::extent<decltype(indices)>::value); | |
| 155 | 152 | geometry.SetType(Geometry::LINES); |
| 156 | 153 | return geometry; |
| 157 | 154 | } |
| ... | ... | @@ -160,14 +157,14 @@ Renderer CreateRenderer(TextureSet textures, Geometry geometry, Shader shader, u |
| 160 | 157 | { |
| 161 | 158 | Renderer renderer = Renderer::New(geometry, shader); |
| 162 | 159 | renderer.SetProperty(Renderer::Property::BLEND_MODE, |
| 163 | - (options & OPTION_BLEND) ? BlendMode::ON : BlendMode::OFF); | |
| 160 | + (options & OPTION_BLEND) ? BlendMode::ON : BlendMode::OFF); | |
| 164 | 161 | renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE, |
| 165 | - (options & OPTION_DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF); | |
| 162 | + (options & OPTION_DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF); | |
| 166 | 163 | renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, |
| 167 | - (options & OPTION_DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF); | |
| 164 | + (options & OPTION_DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF); | |
| 168 | 165 | renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK); |
| 169 | 166 | |
| 170 | - if (!textures) | |
| 167 | + if(!textures) | |
| 171 | 168 | { |
| 172 | 169 | textures = TextureSet::New(); |
| 173 | 170 | } |
| ... | ... | @@ -178,8 +175,8 @@ Renderer CreateRenderer(TextureSet textures, Geometry geometry, Shader shader, u |
| 178 | 175 | |
| 179 | 176 | void CenterActor(Actor actor) |
| 180 | 177 | { |
| 181 | - actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); | |
| 182 | - actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); | |
| 178 | + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); | |
| 179 | + actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); | |
| 183 | 180 | } |
| 184 | 181 | |
| 185 | 182 | Actor CreateActor() |
| ... | ... | @@ -191,15 +188,15 @@ Actor CreateActor() |
| 191 | 188 | |
| 192 | 189 | Renderer CloneRenderer(Renderer original) |
| 193 | 190 | { |
| 194 | - Geometry geom = original.GetGeometry(); | |
| 195 | - Shader shader = original.GetShader(); | |
| 196 | - Renderer clone = Renderer::New(geom, shader); | |
| 191 | + Geometry geom = original.GetGeometry(); | |
| 192 | + Shader shader = original.GetShader(); | |
| 193 | + Renderer clone = Renderer::New(geom, shader); | |
| 197 | 194 | |
| 198 | 195 | // Copy properties. |
| 199 | 196 | Property::IndexContainer indices; |
| 200 | 197 | original.GetPropertyIndices(indices); |
| 201 | 198 | |
| 202 | - for (auto& i: indices) | |
| 199 | + for(auto& i : indices) | |
| 203 | 200 | { |
| 204 | 201 | auto actualIndex = PropertyRanges::DEFAULT_RENDERER_PROPERTY_START_INDEX + i; |
| 205 | 202 | clone.SetProperty(actualIndex, original.GetProperty(actualIndex)); |
| ... | ... | @@ -223,17 +220,17 @@ Actor CloneActor(Actor original) |
| 223 | 220 | // Don't copy every single one of them. |
| 224 | 221 | // Definitely don't copy resize policy related things, which will internally enable |
| 225 | 222 | // relayout, which in turn will result in losing the ability to set Z size. |
| 226 | - for (auto i : { | |
| 227 | - Actor::Property::PARENT_ORIGIN, | |
| 228 | - Actor::Property::ANCHOR_POINT, | |
| 229 | - Actor::Property::SIZE, | |
| 230 | - Actor::Property::POSITION, | |
| 231 | - Actor::Property::ORIENTATION, | |
| 232 | - Actor::Property::SCALE, | |
| 233 | - Actor::Property::VISIBLE, | |
| 234 | - Actor::Property::COLOR, | |
| 235 | - Actor::Property::NAME, | |
| 236 | - }) | |
| 223 | + for(auto i : { | |
| 224 | + Actor::Property::PARENT_ORIGIN, | |
| 225 | + Actor::Property::ANCHOR_POINT, | |
| 226 | + Actor::Property::SIZE, | |
| 227 | + Actor::Property::POSITION, | |
| 228 | + Actor::Property::ORIENTATION, | |
| 229 | + Actor::Property::SCALE, | |
| 230 | + Actor::Property::VISIBLE, | |
| 231 | + Actor::Property::COLOR, | |
| 232 | + Actor::Property::NAME, | |
| 233 | + }) | |
| 237 | 234 | { |
| 238 | 235 | clone.SetProperty(i, original.GetProperty(i)); |
| 239 | 236 | } | ... | ... |
examples/particles/utils.h
| 1 | 1 | #ifndef PARTICLES_UTILS_H_ |
| 2 | 2 | #define PARTICLES_UTILS_H_ |
| 3 | 3 | /* |
| 4 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 4 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 5 | 5 | * |
| 6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | 7 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -17,20 +17,18 @@ |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | +#include <cmath> | |
| 20 | 21 | #include "dali/public-api/actors/actor.h" |
| 21 | -#include "dali/public-api/actors/actor.h" | |
| 22 | +#include "dali/public-api/math/vector3.h" | |
| 22 | 23 | #include "dali/public-api/rendering/geometry.h" |
| 23 | 24 | #include "dali/public-api/rendering/renderer.h" |
| 24 | 25 | #include "dali/public-api/rendering/shader.h" |
| 25 | 26 | #include "dali/public-api/rendering/texture.h" |
| 26 | -#include "dali/public-api/math/vector3.h" | |
| 27 | -#include <cmath> | |
| 28 | 27 | |
| 29 | 28 | // |
| 30 | 29 | // Maths |
| 31 | 30 | // |
| 32 | -inline | |
| 33 | -float FastFloor(float x) | |
| 31 | +inline float FastFloor(float x) | |
| 34 | 32 | { |
| 35 | 33 | return static_cast<int>(x) - static_cast<int>(x < 0); |
| 36 | 34 | } |
| ... | ... | @@ -52,9 +50,9 @@ Dali::Geometry CreateCuboidWireframeGeometry(); |
| 52 | 50 | |
| 53 | 51 | enum RendererOptions |
| 54 | 52 | { |
| 55 | - OPTION_NONE = 0x0, | |
| 56 | - OPTION_BLEND = 0x01, | |
| 57 | - OPTION_DEPTH_TEST = 0x02, | |
| 53 | + OPTION_NONE = 0x0, | |
| 54 | + OPTION_BLEND = 0x01, | |
| 55 | + OPTION_DEPTH_TEST = 0x02, | |
| 58 | 56 | OPTION_DEPTH_WRITE = 0x04 |
| 59 | 57 | }; |
| 60 | 58 | |
| ... | ... | @@ -62,8 +60,7 @@ enum RendererOptions |
| 62 | 60 | /// and @a options from above. |
| 63 | 61 | ///@note Back face culling is on. |
| 64 | 62 | ///@note If textures is not a valid handle, an empty texture set will be created. |
| 65 | -Dali::Renderer CreateRenderer(Dali::TextureSet textures, Dali::Geometry geometry, | |
| 66 | - Dali::Shader shader, uint32_t options = OPTION_NONE); | |
| 63 | +Dali::Renderer CreateRenderer(Dali::TextureSet textures, Dali::Geometry geometry, Dali::Shader shader, uint32_t options = OPTION_NONE); | |
| 67 | 64 | |
| 68 | 65 | ///@brief Sets @a actor's anchor point and parent origin to center. |
| 69 | 66 | void CenterActor(Dali::Actor actor); | ... | ... |
examples/perf-scroll/perf-scroll.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -17,9 +17,9 @@ |
| 17 | 17 | |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> |
| 20 | -#include "shared/utility.h" | |
| 21 | -#include "generated/perf-scroll-vert.h" | |
| 22 | 20 | #include "generated/perf-scroll-frag.h" |
| 21 | +#include "generated/perf-scroll-vert.h" | |
| 22 | +#include "shared/utility.h" | |
| 23 | 23 | |
| 24 | 24 | using namespace Dali; |
| 25 | 25 | using namespace Dali::Toolkit; | ... | ... |
examples/point-mesh/point-mesh-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -19,10 +19,10 @@ |
| 19 | 19 | #include <dali-toolkit/dali-toolkit.h> |
| 20 | 20 | |
| 21 | 21 | // INTERNAL INCLUDES |
| 22 | +#include "generated/point-mesh-frag.h" | |
| 23 | +#include "generated/point-mesh-vert.h" | |
| 22 | 24 | #include "shared/utility.h" |
| 23 | 25 | #include "shared/view.h" |
| 24 | -#include "generated/point-mesh-vert.h" | |
| 25 | -#include "generated/point-mesh-frag.h" | |
| 26 | 26 | |
| 27 | 27 | using namespace Dali; |
| 28 | 28 | ... | ... |
examples/primitive-shapes/primitive-shapes-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -639,12 +639,12 @@ public: |
| 639 | 639 | { |
| 640 | 640 | //Rotate based off the gesture. |
| 641 | 641 | Vector2 displacement = gesture.GetDisplacement(); |
| 642 | - Vector2 rotation { | |
| 642 | + Vector2 rotation{ | |
| 643 | 643 | -displacement.y / X_ROTATION_DISPLACEMENT_FACTOR, // Y displacement rotates around X axis |
| 644 | - displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR // X displacement rotates around Y axis | |
| 644 | + displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR // X displacement rotates around Y axis | |
| 645 | 645 | }; |
| 646 | 646 | |
| 647 | - Quaternion q = Quaternion(Radian(rotation.x), Radian(rotation.y), Radian(0.f)); | |
| 647 | + Quaternion q = Quaternion(Radian(rotation.x), Radian(rotation.y), Radian(0.f)); | |
| 648 | 648 | Quaternion q0 = mModel.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>(); |
| 649 | 649 | |
| 650 | 650 | mModel.SetProperty(Actor::Property::ORIENTATION, q * q0); |
| ... | ... | @@ -698,7 +698,7 @@ private: |
| 698 | 698 | PanGestureDetector mPanGestureDetector; ///< Detects pan gestures for rotation of the model. |
| 699 | 699 | Animation mRotationAnimation; ///< Automatically rotates the model, unless it is being panned. |
| 700 | 700 | |
| 701 | - Vector4 mColor; ///< Color to set all shapes. | |
| 701 | + Vector4 mColor; ///< Color to set all shapes. | |
| 702 | 702 | }; |
| 703 | 703 | |
| 704 | 704 | int DALI_EXPORT_API main(int argc, char** argv) | ... | ... |
examples/reflection-demo/gltf-scene.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -68,6 +68,7 @@ struct JsonResult |
| 68 | 68 | { |
| 69 | 69 | bool success; |
| 70 | 70 | T result; |
| 71 | + | |
| 71 | 72 | operator T() const |
| 72 | 73 | { |
| 73 | 74 | return static_cast<T>(result); | ... | ... |
examples/reflection-demo/gltf-scene.h
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | #define GLTF_SCENE_H |
| 3 | 3 | |
| 4 | 4 | /* |
| 5 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 5 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 6 | 6 | * |
| 7 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | 8 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -18,10 +18,9 @@ |
| 18 | 18 | * |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | - | |
| 22 | 21 | // EXTERNAL INCLUDES |
| 23 | -#include <string> | |
| 24 | 22 | #include <dali/integration-api/debug.h> |
| 23 | +#include <string> | |
| 25 | 24 | |
| 26 | 25 | // INTERNAL INCLUDES |
| 27 | 26 | #include "third-party/pico-json.h" | ... | ... |
examples/reflection-demo/reflection-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -21,19 +21,18 @@ |
| 21 | 21 | |
| 22 | 22 | #include <map> |
| 23 | 23 | |
| 24 | -#include "gltf-scene.h" | |
| 25 | -#include "generated/reflection-vert.h" | |
| 26 | 24 | #include "generated/reflection-frag.h" |
| 27 | -#include "generated/reflection-simple-frag.h" | |
| 28 | -#include "generated/reflection-textured-frag.h" | |
| 29 | 25 | #include "generated/reflection-plasma-frag.h" |
| 26 | +#include "generated/reflection-simple-frag.h" | |
| 30 | 27 | #include "generated/reflection-tex-frag.h" |
| 28 | +#include "generated/reflection-textured-frag.h" | |
| 29 | +#include "generated/reflection-vert.h" | |
| 30 | +#include "gltf-scene.h" | |
| 31 | 31 | |
| 32 | 32 | using namespace Dali; |
| 33 | 33 | |
| 34 | 34 | namespace |
| 35 | 35 | { |
| 36 | - | |
| 37 | 36 | struct Model |
| 38 | 37 | { |
| 39 | 38 | Shader shader; |
| ... | ... | @@ -467,10 +466,7 @@ private: |
| 467 | 466 | void OnPan(Actor actor, const PanGesture& panGesture) |
| 468 | 467 | { |
| 469 | 468 | Vector2 displacement = panGesture.GetScreenDisplacement(); |
| 470 | - Vector2 rotation{ | |
| 471 | - displacement.y * -0.1f, | |
| 472 | - displacement.x * 0.1f | |
| 473 | - }; | |
| 469 | + Vector2 rotation{displacement.y * -0.1f, displacement.x * 0.1f}; | |
| 474 | 470 | |
| 475 | 471 | Quaternion q(Degree(0.f), Degree(rotation.y), Degree(rotation.x)); |
| 476 | 472 | Quaternion q0 = mCenterActor.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>(); | ... | ... |
examples/refraction-effect/refraction-effect-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -26,12 +26,12 @@ |
| 26 | 26 | #include <sstream> |
| 27 | 27 | |
| 28 | 28 | // INTERNAL INCLUDES |
| 29 | -#include "shared/utility.h" | |
| 30 | -#include "shared/view.h" | |
| 31 | -#include "generated/refraction-effect-flat-vert.h" | |
| 32 | 29 | #include "generated/refraction-effect-flat-frag.h" |
| 33 | -#include "generated/refraction-effect-refraction-vert.h" | |
| 30 | +#include "generated/refraction-effect-flat-vert.h" | |
| 34 | 31 | #include "generated/refraction-effect-refraction-frag.h" |
| 32 | +#include "generated/refraction-effect-refraction-vert.h" | |
| 33 | +#include "shared/utility.h" | |
| 34 | +#include "shared/view.h" | |
| 35 | 35 | |
| 36 | 36 | using namespace Dali; |
| 37 | 37 | ... | ... |
examples/renderer-stencil/renderer-stencil-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -16,16 +16,16 @@ |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | // EXTERNAL INCLUDES |
| 19 | -#include <dali/public-api/rendering/shader.h> | |
| 20 | 19 | #include <dali-toolkit/dali-toolkit.h> |
| 20 | +#include <dali/public-api/rendering/shader.h> | |
| 21 | 21 | |
| 22 | 22 | // INTERNAL INCLUDES |
| 23 | -#include "shared/utility.h" | |
| 24 | -#include "shared/view.h" | |
| 25 | -#include "generated/render-stencil-vert.h" | |
| 26 | 23 | #include "generated/render-stencil-frag.h" |
| 27 | -#include "generated/render-stencil-textured-vert.h" | |
| 28 | 24 | #include "generated/render-stencil-textured-frag.h" |
| 25 | +#include "generated/render-stencil-textured-vert.h" | |
| 26 | +#include "generated/render-stencil-vert.h" | |
| 27 | +#include "shared/utility.h" | |
| 28 | +#include "shared/view.h" | |
| 29 | 29 | |
| 30 | 30 | using namespace Dali; |
| 31 | 31 | ... | ... |
examples/rendering-basic-light/rendering-basic-light-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali/dali.h> |
| 20 | 20 | |
| 21 | -#include "generated/rendering-basic-light-vert.h" | |
| 22 | 21 | #include "generated/rendering-basic-light-frag.h" |
| 22 | +#include "generated/rendering-basic-light-vert.h" | |
| 23 | 23 | |
| 24 | 24 | using namespace Dali; |
| 25 | 25 | using namespace Toolkit; | ... | ... |
examples/rendering-basic-pbr/ktx-loader.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * 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 |
| 94 | 94 | bool LoadCubeMapFromKtxFile(const std::string& path, CubeData& cubedata) |
| 95 | 95 | { |
| 96 | 96 | Dali::FileStream daliFileStream(path); |
| 97 | - FILE* fp(daliFileStream.GetFile()); | |
| 97 | + FILE* fp(daliFileStream.GetFile()); | |
| 98 | 98 | if(!fp) |
| 99 | 99 | { |
| 100 | 100 | return false; | ... | ... |
examples/rendering-basic-pbr/model-skybox.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -24,9 +24,9 @@ |
| 24 | 24 | #include <cstdio> |
| 25 | 25 | |
| 26 | 26 | // INTERNAL INCLUDES |
| 27 | -#include "obj-loader.h" | |
| 28 | -#include "generated/skybox-vert.h" | |
| 29 | 27 | #include "generated/skybox-frag.h" |
| 28 | +#include "generated/skybox-vert.h" | |
| 29 | +#include "obj-loader.h" | |
| 30 | 30 | |
| 31 | 31 | ModelSkybox::ModelSkybox() |
| 32 | 32 | { | ... | ... |
examples/rendering-cube/rendering-cube.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali/dali.h> |
| 20 | 20 | |
| 21 | -#include "generated/rendering-cube-vert.h" | |
| 22 | 21 | #include "generated/rendering-cube-frag.h" |
| 22 | +#include "generated/rendering-cube-vert.h" | |
| 23 | 23 | |
| 24 | 24 | using namespace Dali; |
| 25 | 25 | using namespace Toolkit; | ... | ... |
examples/rendering-line/rendering-line.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali/dali.h> |
| 20 | 20 | |
| 21 | -#include "generated/rendering-line-vert.h" | |
| 22 | 21 | #include "generated/rendering-line-frag.h" |
| 22 | +#include "generated/rendering-line-vert.h" | |
| 23 | 23 | |
| 24 | 24 | using namespace Dali; |
| 25 | 25 | using namespace Toolkit; | ... | ... |
examples/rendering-radial-progress/radial-progress.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -18,10 +18,10 @@ |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali/dali.h> |
| 20 | 20 | |
| 21 | -#include "generated/radial-progress-basic-vert.h" | |
| 22 | 21 | #include "generated/radial-progress-basic-frag.h" |
| 23 | -#include "generated/radial-progress-textured-vert.h" | |
| 22 | +#include "generated/radial-progress-basic-vert.h" | |
| 24 | 23 | #include "generated/radial-progress-textured-frag.h" |
| 24 | +#include "generated/radial-progress-textured-vert.h" | |
| 25 | 25 | |
| 26 | 26 | using namespace Dali; |
| 27 | 27 | ... | ... |
examples/rendering-skybox/rendering-skybox.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -18,18 +18,17 @@ |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali/dali.h> |
| 20 | 20 | |
| 21 | -#include "look-camera.h" | |
| 22 | -#include "generated/rendering-skybox-vert.h" | |
| 23 | -#include "generated/rendering-skybox-frag.h" | |
| 24 | -#include "generated/rendering-skybox-cube-vert.h" | |
| 25 | 21 | #include "generated/rendering-skybox-cube-frag.h" |
| 22 | +#include "generated/rendering-skybox-cube-vert.h" | |
| 23 | +#include "generated/rendering-skybox-frag.h" | |
| 24 | +#include "generated/rendering-skybox-vert.h" | |
| 25 | +#include "look-camera.h" | |
| 26 | 26 | |
| 27 | 27 | using namespace Dali; |
| 28 | 28 | using namespace Toolkit; |
| 29 | 29 | |
| 30 | 30 | namespace |
| 31 | 31 | { |
| 32 | - | |
| 33 | 32 | const float CAMERA_DEFAULT_FOV(60.0f); |
| 34 | 33 | const float CAMERA_DEFAULT_NEAR(0.1f); |
| 35 | 34 | const float CAMERA_DEFAULT_FAR(1000.0f); | ... | ... |
examples/rendering-textured-cube/rendering-textured-cube.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -18,15 +18,14 @@ |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali/dali.h> |
| 20 | 20 | |
| 21 | -#include "generated/rendering-textured-cube-vert.h" | |
| 22 | 21 | #include "generated/rendering-textured-cube-frag.h" |
| 22 | +#include "generated/rendering-textured-cube-vert.h" | |
| 23 | 23 | |
| 24 | 24 | using namespace Dali; |
| 25 | 25 | using namespace Toolkit; |
| 26 | 26 | |
| 27 | 27 | namespace |
| 28 | 28 | { |
| 29 | - | |
| 30 | 29 | const char* TEXTURE_URL = DEMO_IMAGE_DIR "wood.png"; |
| 31 | 30 | |
| 32 | 31 | } // namespace | ... | ... |
examples/rendering-triangle/rendering-triangle.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | #include <dali/dali.h> |
| 20 | 20 | |
| 21 | -#include "generated/rendering-triangle-vert.h" | |
| 22 | 21 | #include "generated/rendering-triangle-frag.h" |
| 22 | +#include "generated/rendering-triangle-vert.h" | |
| 23 | 23 | |
| 24 | 24 | using namespace Dali; |
| 25 | 25 | using namespace Toolkit; | ... | ... |
examples/scene-loader/main.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -22,7 +22,7 @@ using namespace Dali; |
| 22 | 22 | |
| 23 | 23 | int DALI_EXPORT_API main(int argc, char** argv) |
| 24 | 24 | { |
| 25 | - auto app = Application::New(&argc, &argv, DEMO_THEME_PATH); | |
| 25 | + auto app = Application::New(&argc, &argv, DEMO_THEME_PATH); | |
| 26 | 26 | SceneLoaderExample sceneLoader(app); |
| 27 | 27 | app.MainLoop(); |
| 28 | 28 | return 0; | ... | ... |
examples/scene-loader/scene-loader-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -15,23 +15,23 @@ |
| 15 | 15 | * |
| 16 | 16 | */ |
| 17 | 17 | #include "scene-loader-example.h" |
| 18 | +#include <dirent.h> | |
| 19 | +#include <cstring> | |
| 20 | +#include <string_view> | |
| 21 | +#include "dali-scene-loader/public-api/dli-loader.h" | |
| 18 | 22 | #include "dali-scene-loader/public-api/gltf2-loader.h" |
| 19 | -#include "dali-scene-loader/public-api/shader-definition-factory.h" | |
| 20 | 23 | #include "dali-scene-loader/public-api/light-parameters.h" |
| 21 | -#include "dali-scene-loader/public-api/dli-loader.h" | |
| 22 | 24 | #include "dali-scene-loader/public-api/load-result.h" |
| 23 | -#include "dali/public-api/adaptor-framework/key.h" | |
| 24 | -#include "dali/public-api/events/key-event.h" | |
| 25 | -#include "dali/public-api/actors/layer.h" | |
| 26 | -#include "dali/public-api/render-tasks/render-task-list.h" | |
| 27 | -#include "dali/public-api/object/property-array.h" | |
| 28 | -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h" | |
| 25 | +#include "dali-scene-loader/public-api/shader-definition-factory.h" | |
| 29 | 26 | #include "dali-toolkit/public-api/controls/scrollable/item-view/default-item-layout.h" |
| 27 | +#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h" | |
| 30 | 28 | #include "dali-toolkit/public-api/controls/text-controls/text-label.h" |
| 31 | 29 | #include "dali-toolkit/public-api/visuals/gradient-visual-properties.h" |
| 32 | -#include <string_view> | |
| 33 | -#include <cstring> | |
| 34 | -#include <dirent.h> | |
| 30 | +#include "dali/public-api/actors/layer.h" | |
| 31 | +#include "dali/public-api/adaptor-framework/key.h" | |
| 32 | +#include "dali/public-api/events/key-event.h" | |
| 33 | +#include "dali/public-api/object/property-array.h" | |
| 34 | +#include "dali/public-api/render-tasks/render-task-list.h" | |
| 35 | 35 | |
| 36 | 36 | using namespace Dali; |
| 37 | 37 | using namespace Dali::Toolkit; |
| ... | ... | @@ -39,14 +39,13 @@ using namespace Dali::SceneLoader; |
| 39 | 39 | |
| 40 | 40 | namespace |
| 41 | 41 | { |
| 42 | - | |
| 43 | 42 | const float ROTATION_SCALE = 180.f; // the amount of rotation that a swipe whose length is the width of the screen, causes, in degrees. |
| 44 | 43 | |
| 45 | 44 | const float ITEM_HEIGHT = 50.f; |
| 46 | 45 | |
| 47 | 46 | const Vector3 CAMERA_DEFAULT_POSITION(0.0f, 0.0f, 3.5f); |
| 48 | 47 | |
| 49 | -const std::string_view DLI_EXTENSION = ".dli"; | |
| 48 | +const std::string_view DLI_EXTENSION = ".dli"; | |
| 50 | 49 | const std::string_view GLTF_EXTENSION = ".gltf"; |
| 51 | 50 | |
| 52 | 51 | const std::string RESOURCE_TYPE_DIRS[]{ |
| ... | ... | @@ -58,18 +57,19 @@ const std::string RESOURCE_TYPE_DIRS[]{ |
| 58 | 57 | |
| 59 | 58 | using StringVector = std::vector<std::string>; |
| 60 | 59 | |
| 61 | -StringVector ListFiles(const std::string& path, bool(*predicate)(const char*) = [](const char*) { return true; }) | |
| 60 | +StringVector ListFiles( | |
| 61 | + const std::string& path, bool (*predicate)(const char*) = [](const char*) { return true; }) | |
| 62 | 62 | { |
| 63 | 63 | StringVector results; |
| 64 | 64 | |
| 65 | - if (auto dirp = opendir(path.c_str())) | |
| 65 | + if(auto dirp = opendir(path.c_str())) | |
| 66 | 66 | { |
| 67 | - std::unique_ptr<DIR, int(*)(DIR*)> dir(dirp, closedir); | |
| 67 | + std::unique_ptr<DIR, int (*)(DIR*)> dir(dirp, closedir); | |
| 68 | 68 | |
| 69 | 69 | struct dirent* ent; |
| 70 | - while ((ent = readdir(dir.get())) != nullptr) | |
| 70 | + while((ent = readdir(dir.get())) != nullptr) | |
| 71 | 71 | { |
| 72 | - if (ent->d_type == DT_REG && predicate(ent->d_name)) | |
| 72 | + if(ent->d_type == DT_REG && predicate(ent->d_name)) | |
| 73 | 73 | { |
| 74 | 74 | results.push_back(ent->d_name); |
| 75 | 75 | } |
| ... | ... | @@ -91,12 +91,13 @@ TextLabel MakeLabel(std::string msg) |
| 91 | 91 | struct ItemFactoryImpl : Dali::Toolkit::ItemFactory |
| 92 | 92 | { |
| 93 | 93 | const std::vector<std::string>& mSceneNames; |
| 94 | - TapGestureDetector mTapDetector; | |
| 94 | + TapGestureDetector mTapDetector; | |
| 95 | 95 | |
| 96 | 96 | ItemFactoryImpl(const std::vector<std::string>& sceneNames, TapGestureDetector tapDetector) |
| 97 | 97 | : mSceneNames(sceneNames), |
| 98 | 98 | mTapDetector(tapDetector) |
| 99 | - {} | |
| 99 | + { | |
| 100 | + } | |
| 100 | 101 | |
| 101 | 102 | unsigned int GetNumberOfItems() override |
| 102 | 103 | { |
| ... | ... | @@ -122,7 +123,7 @@ Actor CreateErrorMessage(std::string msg) |
| 122 | 123 | |
| 123 | 124 | void ConfigureCamera(const CameraParameters& params, CameraActor camera) |
| 124 | 125 | { |
| 125 | - if (params.isPerspective) | |
| 126 | + if(params.isPerspective) | |
| 126 | 127 | { |
| 127 | 128 | camera.SetProjectionMode(Camera::PERSPECTIVE_PROJECTION); |
| 128 | 129 | camera.SetNearClippingPlane(params.zNear); |
| ... | ... | @@ -133,16 +134,16 @@ void ConfigureCamera(const CameraParameters& params, CameraActor camera) |
| 133 | 134 | { |
| 134 | 135 | camera.SetProjectionMode(Camera::ORTHOGRAPHIC_PROJECTION); |
| 135 | 136 | camera.SetOrthographicProjection(params.orthographicSize.x, |
| 136 | - params.orthographicSize.y, | |
| 137 | - params.orthographicSize.z, | |
| 138 | - params.orthographicSize.w, | |
| 139 | - params.zNear, | |
| 140 | - params.zFar); | |
| 137 | + params.orthographicSize.y, | |
| 138 | + params.orthographicSize.z, | |
| 139 | + params.orthographicSize.w, | |
| 140 | + params.zNear, | |
| 141 | + params.zFar); | |
| 141 | 142 | } |
| 142 | 143 | |
| 143 | 144 | // model |
| 144 | - Vector3 camTranslation; | |
| 145 | - Vector3 camScale; | |
| 145 | + Vector3 camTranslation; | |
| 146 | + Vector3 camScale; | |
| 146 | 147 | Quaternion camOrientation; |
| 147 | 148 | params.CalculateTransformComponents(camTranslation, camOrientation, camScale); |
| 148 | 149 | |
| ... | ... | @@ -155,17 +156,16 @@ void ConfigureCamera(const CameraParameters& params, CameraActor camera) |
| 155 | 156 | camOrientation.Conjugate(); |
| 156 | 157 | } |
| 157 | 158 | |
| 158 | -void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root, | |
| 159 | - std::vector<BlendshapeShaderConfigurationRequest>&& requests) | |
| 159 | +void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root, std::vector<BlendshapeShaderConfigurationRequest>&& requests) | |
| 160 | 160 | { |
| 161 | 161 | std::vector<std::string> errors; |
| 162 | - auto onError = [&errors](const std::string& msg) { | |
| 162 | + auto onError = [&errors](const std::string& msg) { | |
| 163 | 163 | errors.push_back(msg); |
| 164 | 164 | }; |
| 165 | - if (!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError)) | |
| 165 | + if(!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError)) | |
| 166 | 166 | { |
| 167 | 167 | ExceptionFlinger flinger(ASSERT_LOCATION); |
| 168 | - for (auto& msg : errors) | |
| 168 | + for(auto& msg : errors) | |
| 169 | 169 | { |
| 170 | 170 | flinger << msg << '\n'; |
| 171 | 171 | } |
| ... | ... | @@ -180,12 +180,12 @@ Actor LoadScene(std::string sceneName, CameraActor camera) |
| 180 | 180 | |
| 181 | 181 | auto path = pathProvider(ResourceType::Mesh) + sceneName; |
| 182 | 182 | |
| 183 | - ResourceBundle resources; | |
| 184 | - SceneDefinition scene; | |
| 183 | + ResourceBundle resources; | |
| 184 | + SceneDefinition scene; | |
| 185 | 185 | std::vector<AnimationGroupDefinition> animGroups; |
| 186 | - std::vector<CameraParameters> cameraParameters; | |
| 187 | - std::vector<LightParameters> lights; | |
| 188 | - std::vector<AnimationDefinition> animations; | |
| 186 | + std::vector<CameraParameters> cameraParameters; | |
| 187 | + std::vector<LightParameters> lights; | |
| 188 | + std::vector<AnimationDefinition> animations; | |
| 189 | 189 | |
| 190 | 190 | LoadResult output{ |
| 191 | 191 | resources, |
| ... | ... | @@ -193,12 +193,11 @@ Actor LoadScene(std::string sceneName, CameraActor camera) |
| 193 | 193 | animations, |
| 194 | 194 | animGroups, |
| 195 | 195 | cameraParameters, |
| 196 | - lights | |
| 197 | - }; | |
| 196 | + lights}; | |
| 198 | 197 | |
| 199 | - if (sceneName.rfind(DLI_EXTENSION) == sceneName.size() - DLI_EXTENSION.size()) | |
| 198 | + if(sceneName.rfind(DLI_EXTENSION) == sceneName.size() - DLI_EXTENSION.size()) | |
| 200 | 199 | { |
| 201 | - DliLoader loader; | |
| 200 | + DliLoader loader; | |
| 202 | 201 | DliLoader::InputParams input{ |
| 203 | 202 | pathProvider(ResourceType::Mesh), |
| 204 | 203 | nullptr, |
| ... | ... | @@ -206,8 +205,8 @@ Actor LoadScene(std::string sceneName, CameraActor camera) |
| 206 | 205 | {}, |
| 207 | 206 | nullptr, |
| 208 | 207 | }; |
| 209 | - DliLoader::LoadParams loadParams{ input, output }; | |
| 210 | - if (!loader.LoadScene(path, loadParams)) | |
| 208 | + DliLoader::LoadParams loadParams{input, output}; | |
| 209 | + if(!loader.LoadScene(path, loadParams)) | |
| 211 | 210 | { |
| 212 | 211 | ExceptionFlinger(ASSERT_LOCATION) << "Failed to load scene from '" << path << "': " << loader.GetParseError(); |
| 213 | 212 | } |
| ... | ... | @@ -221,7 +220,7 @@ Actor LoadScene(std::string sceneName, CameraActor camera) |
| 221 | 220 | resources.mEnvironmentMaps.push_back({}); |
| 222 | 221 | } |
| 223 | 222 | |
| 224 | - if (cameraParameters.empty()) | |
| 223 | + if(cameraParameters.empty()) | |
| 225 | 224 | { |
| 226 | 225 | cameraParameters.push_back(CameraParameters()); |
| 227 | 226 | cameraParameters[0].matrix.SetTranslation(CAMERA_DEFAULT_POSITION); |
| ... | ... | @@ -229,20 +228,18 @@ Actor LoadScene(std::string sceneName, CameraActor camera) |
| 229 | 228 | ConfigureCamera(cameraParameters[0], camera); |
| 230 | 229 | |
| 231 | 230 | ViewProjection viewProjection = cameraParameters[0].GetViewProjection(); |
| 232 | - Transforms xforms{ | |
| 231 | + Transforms xforms{ | |
| 233 | 232 | MatrixStack{}, |
| 234 | - viewProjection | |
| 235 | - }; | |
| 233 | + viewProjection}; | |
| 236 | 234 | NodeDefinition::CreateParams nodeParams{ |
| 237 | 235 | resources, |
| 238 | - xforms | |
| 239 | - }; | |
| 236 | + xforms}; | |
| 240 | 237 | Customization::Choices choices; |
| 241 | 238 | |
| 242 | 239 | Actor root = Actor::New(); |
| 243 | 240 | SetActorCentered(root); |
| 244 | 241 | |
| 245 | - for (auto iRoot : scene.GetRoots()) | |
| 242 | + for(auto iRoot : scene.GetRoots()) | |
| 246 | 243 | { |
| 247 | 244 | auto resourceRefs = resources.CreateRefCounter(); |
| 248 | 245 | scene.CountResourceRefs(iRoot, choices, resourceRefs); |
| ... | ... | @@ -250,7 +247,7 @@ Actor LoadScene(std::string sceneName, CameraActor camera) |
| 250 | 247 | |
| 251 | 248 | resources.LoadResources(resourceRefs, pathProvider); |
| 252 | 249 | |
| 253 | - if (auto actor = scene.CreateNodes(iRoot, choices, nodeParams)) | |
| 250 | + if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams)) | |
| 254 | 251 | { |
| 255 | 252 | scene.ConfigureSkeletonJoints(iRoot, resources.mSkeletons, actor); |
| 256 | 253 | scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables)); |
| ... | ... | @@ -262,7 +259,7 @@ Actor LoadScene(std::string sceneName, CameraActor camera) |
| 262 | 259 | } |
| 263 | 260 | } |
| 264 | 261 | |
| 265 | - if (!animations.empty()) | |
| 262 | + if(!animations.empty()) | |
| 266 | 263 | { |
| 267 | 264 | auto getActor = [&root](const std::string& name) { |
| 268 | 265 | return root.FindChildByName(name); |
| ... | ... | @@ -274,14 +271,14 @@ Actor LoadScene(std::string sceneName, CameraActor camera) |
| 274 | 271 | return root; |
| 275 | 272 | } |
| 276 | 273 | |
| 277 | -} // nonamespace | |
| 274 | +} // namespace | |
| 278 | 275 | |
| 279 | 276 | SceneLoaderExample::SceneLoaderExample(Dali::Application& app) |
| 280 | 277 | : mApp(app) |
| 281 | 278 | { |
| 282 | - if (!std::getenv("DALI_APPLICATION_PACKAGE")) | |
| 279 | + if(!std::getenv("DALI_APPLICATION_PACKAGE")) | |
| 283 | 280 | { |
| 284 | - if (auto desktopPrefix = std::getenv("DESKTOP_PREFIX")) | |
| 281 | + if(auto desktopPrefix = std::getenv("DESKTOP_PREFIX")) | |
| 285 | 282 | { |
| 286 | 283 | std::stringstream sstr; |
| 287 | 284 | sstr << desktopPrefix << "/share/com.samsung.dali-demo/res/"; |
| ... | ... | @@ -298,14 +295,14 @@ SceneLoaderExample::SceneLoaderExample(Dali::Application& app) |
| 298 | 295 | void SceneLoaderExample::OnInit(Application& app) |
| 299 | 296 | { |
| 300 | 297 | // get scenes |
| 301 | - auto resPath = Application::GetResourcePath(); | |
| 302 | - auto scenePath = resPath + RESOURCE_TYPE_DIRS[ResourceType::Mesh]; | |
| 298 | + auto resPath = Application::GetResourcePath(); | |
| 299 | + auto scenePath = resPath + RESOURCE_TYPE_DIRS[ResourceType::Mesh]; | |
| 303 | 300 | auto sceneNames = ListFiles(scenePath, [](const char* name) { |
| 304 | 301 | auto len = strlen(name); |
| 305 | 302 | return (len > DLI_EXTENSION.size() && DLI_EXTENSION.compare(name + (len - DLI_EXTENSION.size())) == 0) || |
| 306 | - (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0); | |
| 303 | + (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0); | |
| 307 | 304 | }); |
| 308 | - mSceneNames = sceneNames; | |
| 305 | + mSceneNames = sceneNames; | |
| 309 | 306 | |
| 310 | 307 | // create Dali objects |
| 311 | 308 | auto window = app.GetWindow(); |
| ... | ... | @@ -324,13 +321,14 @@ void SceneLoaderExample::OnInit(Application& app) |
| 324 | 321 | stopColors.PushBack(Vector4(0.45f, 0.7f, 0.8f, 1.f)); // Medium bright, pastel blue |
| 325 | 322 | const float percentageWindowHeight = window.GetSize().GetHeight() * 0.6f; |
| 326 | 323 | |
| 327 | - navigationView.SetProperty(Toolkit::Control::Property::BACKGROUND, Dali::Property::Map(). | |
| 328 | - Add(Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::GRADIENT). | |
| 329 | - Add(Toolkit::GradientVisual::Property::STOP_OFFSET, stopOffsets). | |
| 330 | - Add(Toolkit::GradientVisual::Property::STOP_COLOR, stopColors). | |
| 331 | - Add(Toolkit::GradientVisual::Property::START_POSITION, Vector2(0.f, -percentageWindowHeight)). | |
| 332 | - Add(Toolkit::GradientVisual::Property::END_POSITION, Vector2(0.f, percentageWindowHeight)). | |
| 333 | - Add(Toolkit::GradientVisual::Property::UNITS, Toolkit::GradientVisual::Units::USER_SPACE)); | |
| 324 | + navigationView.SetProperty(Toolkit::Control::Property::BACKGROUND, | |
| 325 | + Dali::Property::Map() | |
| 326 | + .Add(Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::GRADIENT) | |
| 327 | + .Add(Toolkit::GradientVisual::Property::STOP_OFFSET, stopOffsets) | |
| 328 | + .Add(Toolkit::GradientVisual::Property::STOP_COLOR, stopColors) | |
| 329 | + .Add(Toolkit::GradientVisual::Property::START_POSITION, Vector2(0.f, -percentageWindowHeight)) | |
| 330 | + .Add(Toolkit::GradientVisual::Property::END_POSITION, Vector2(0.f, percentageWindowHeight)) | |
| 331 | + .Add(Toolkit::GradientVisual::Property::UNITS, Toolkit::GradientVisual::Units::USER_SPACE)); | |
| 334 | 332 | window.Add(navigationView); |
| 335 | 333 | mNavigationView = navigationView; |
| 336 | 334 | |
| ... | ... | @@ -344,13 +342,13 @@ void SceneLoaderExample::OnInit(Application& app) |
| 344 | 342 | items.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true); |
| 345 | 343 | |
| 346 | 344 | Vector3 windowSize(window.GetSize()); |
| 347 | - auto itemLayout = DefaultItemLayout::New(DefaultItemLayout::LIST); | |
| 345 | + auto itemLayout = DefaultItemLayout::New(DefaultItemLayout::LIST); | |
| 348 | 346 | itemLayout->SetItemSize(Vector3(windowSize.x, ITEM_HEIGHT, 1.f)); |
| 349 | 347 | items.AddLayout(*itemLayout); |
| 350 | 348 | navigationView.Push(items); |
| 351 | 349 | |
| 352 | 350 | mItemLayout = itemLayout; |
| 353 | - mItemView = items; | |
| 351 | + mItemView = items; | |
| 354 | 352 | |
| 355 | 353 | // camera |
| 356 | 354 | auto camera = CameraActor::New(); |
| ... | ... | @@ -373,7 +371,7 @@ void SceneLoaderExample::OnTerminate(Application& app) |
| 373 | 371 | mTapDetector.Reset(); |
| 374 | 372 | mPanDetector.Reset(); |
| 375 | 373 | |
| 376 | - auto window = app.GetWindow(); | |
| 374 | + auto window = app.GetWindow(); | |
| 377 | 375 | auto renderTasks = window.GetRenderTaskList(); |
| 378 | 376 | renderTasks.RemoveTask(mSceneRender); |
| 379 | 377 | mSceneRender.Reset(); |
| ... | ... | @@ -386,11 +384,11 @@ void SceneLoaderExample::OnTerminate(Application& app) |
| 386 | 384 | |
| 387 | 385 | void SceneLoaderExample::OnKey(const KeyEvent& e) |
| 388 | 386 | { |
| 389 | - if (e.GetState() == KeyEvent::UP) | |
| 387 | + if(e.GetState() == KeyEvent::UP) | |
| 390 | 388 | { |
| 391 | - if (IsKey(e, DALI_KEY_ESCAPE) || IsKey(e, DALI_KEY_BACK)) | |
| 389 | + if(IsKey(e, DALI_KEY_ESCAPE) || IsKey(e, DALI_KEY_BACK)) | |
| 392 | 390 | { |
| 393 | - if (mScene) | |
| 391 | + if(mScene) | |
| 394 | 392 | { |
| 395 | 393 | mPanDetector.Reset(); |
| 396 | 394 | |
| ... | ... | @@ -407,15 +405,15 @@ void SceneLoaderExample::OnKey(const KeyEvent& e) |
| 407 | 405 | |
| 408 | 406 | void SceneLoaderExample::OnPan(Actor actor, const PanGesture& pan) |
| 409 | 407 | { |
| 410 | - auto windowSize = mApp.GetWindow().GetSize(); | |
| 411 | - Vector2 size{ float(windowSize.GetWidth()), float(windowSize.GetHeight()) }; | |
| 412 | - float aspect = size.y / size.x; | |
| 408 | + auto windowSize = mApp.GetWindow().GetSize(); | |
| 409 | + Vector2 size{float(windowSize.GetWidth()), float(windowSize.GetHeight())}; | |
| 410 | + float aspect = size.y / size.x; | |
| 413 | 411 | |
| 414 | 412 | size /= ROTATION_SCALE; |
| 415 | 413 | |
| 416 | - Vector2 rotation{ pan.GetDisplacement().x / size.x, pan.GetDisplacement().y / size.y * aspect }; | |
| 414 | + Vector2 rotation{pan.GetDisplacement().x / size.x, pan.GetDisplacement().y / size.y * aspect}; | |
| 417 | 415 | |
| 418 | - Quaternion q = Quaternion(Radian(Degree(rotation.y)), Radian(Degree(rotation.x)), Radian(0.f)); | |
| 416 | + Quaternion q = Quaternion(Radian(Degree(rotation.y)), Radian(Degree(rotation.x)), Radian(0.f)); | |
| 419 | 417 | Quaternion q0 = mScene.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>(); |
| 420 | 418 | |
| 421 | 419 | mScene.SetProperty(Actor::Property::ORIENTATION, q * q0); |
| ... | ... | @@ -427,7 +425,7 @@ void SceneLoaderExample::OnTap(Dali::Actor actor, const Dali::TapGesture& tap) |
| 427 | 425 | |
| 428 | 426 | try |
| 429 | 427 | { |
| 430 | - auto window = mApp.GetWindow(); | |
| 428 | + auto window = mApp.GetWindow(); | |
| 431 | 429 | auto renderTasks = window.GetRenderTaskList(); |
| 432 | 430 | renderTasks.RemoveTask(mSceneRender); |
| 433 | 431 | |
| ... | ... | @@ -438,14 +436,14 @@ void SceneLoaderExample::OnTap(Dali::Actor actor, const Dali::TapGesture& tap) |
| 438 | 436 | sceneRender.SetSourceActor(scene); |
| 439 | 437 | sceneRender.SetExclusive(true); |
| 440 | 438 | |
| 441 | - mScene = scene; | |
| 439 | + mScene = scene; | |
| 442 | 440 | mSceneRender = sceneRender; |
| 443 | 441 | |
| 444 | 442 | mPanDetector = PanGestureDetector::New(); |
| 445 | 443 | mPanDetector.DetectedSignal().Connect(this, &SceneLoaderExample::OnPan); |
| 446 | 444 | mPanDetector.Attach(mNavigationView); |
| 447 | 445 | } |
| 448 | - catch (const DaliException& e) | |
| 446 | + catch(const DaliException& e) | |
| 449 | 447 | { |
| 450 | 448 | mScene = CreateErrorMessage(e.condition); |
| 451 | 449 | } | ... | ... |
examples/scene-loader/scene-loader-example.h
| 1 | 1 | #ifndef SCENE_LAUNCHER_H_ |
| 2 | 2 | #define SCENE_LAUNCHER_H_ |
| 3 | 3 | /* |
| 4 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 4 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 5 | 5 | * |
| 6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | 7 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -17,19 +17,19 @@ |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | 19 | #include "dali-scene-loader/public-api/animation-definition.h" |
| 20 | -#include "dali-scene-loader/public-api/scene-definition.h" | |
| 21 | -#include "dali-scene-loader/public-api/node-definition.h" | |
| 22 | 20 | #include "dali-scene-loader/public-api/camera-parameters.h" |
| 21 | +#include "dali-scene-loader/public-api/node-definition.h" | |
| 22 | +#include "dali-scene-loader/public-api/scene-definition.h" | |
| 23 | +#include "dali-toolkit/devel-api/controls/navigation-view/navigation-view.h" | |
| 24 | +#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h" | |
| 25 | +#include "dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h" | |
| 26 | +#include "dali-toolkit/public-api/controls/scrollable/item-view/item-view.h" | |
| 27 | +#include "dali/public-api/actors/camera-actor.h" | |
| 28 | +#include "dali/public-api/adaptor-framework/application.h" | |
| 23 | 29 | #include "dali/public-api/common/vector-wrapper.h" |
| 24 | 30 | #include "dali/public-api/events/pan-gesture-detector.h" |
| 25 | -#include "dali/public-api/actors/camera-actor.h" | |
| 26 | 31 | #include "dali/public-api/render-tasks/render-task.h" |
| 27 | 32 | #include "dali/public-api/signals/connection-tracker.h" |
| 28 | -#include "dali/public-api/adaptor-framework/application.h" | |
| 29 | -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-view.h" | |
| 30 | -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h" | |
| 31 | -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h" | |
| 32 | -#include "dali-toolkit/devel-api/controls/navigation-view/navigation-view.h" | |
| 33 | 33 | |
| 34 | 34 | class SceneLoaderExample : public Dali::ConnectionTracker |
| 35 | 35 | { |
| ... | ... | @@ -37,7 +37,7 @@ public: |
| 37 | 37 | SceneLoaderExample(Dali::Application& app); |
| 38 | 38 | ~SceneLoaderExample() = default; |
| 39 | 39 | |
| 40 | -private: // data | |
| 40 | +private: // data | |
| 41 | 41 | Dali::Application& mApp; |
| 42 | 42 | |
| 43 | 43 | std::vector<std::string> mSceneNames; |
| ... | ... | @@ -45,19 +45,19 @@ private: // data |
| 45 | 45 | Dali::Toolkit::NavigationView mNavigationView; |
| 46 | 46 | |
| 47 | 47 | std::unique_ptr<Dali::Toolkit::ItemFactory> mItemFactory; |
| 48 | - Dali::Toolkit::ItemLayoutPtr mItemLayout; | |
| 49 | - Dali::Toolkit::ItemView mItemView; | |
| 48 | + Dali::Toolkit::ItemLayoutPtr mItemLayout; | |
| 49 | + Dali::Toolkit::ItemView mItemView; | |
| 50 | 50 | |
| 51 | 51 | Dali::CameraActor mSceneCamera; |
| 52 | - Dali::RenderTask mSceneRender; | |
| 53 | - Dali::Actor mScene; | |
| 52 | + Dali::RenderTask mSceneRender; | |
| 53 | + Dali::Actor mScene; | |
| 54 | 54 | |
| 55 | 55 | Dali::Quaternion mCameraOrientationInv; |
| 56 | 56 | |
| 57 | 57 | Dali::TapGestureDetector mTapDetector; |
| 58 | - Dali::PanGestureDetector mPanDetector; | |
| 58 | + Dali::PanGestureDetector mPanDetector; | |
| 59 | 59 | |
| 60 | -private: // methods | |
| 60 | +private: // methods | |
| 61 | 61 | void OnInit(Dali::Application& app); |
| 62 | 62 | void OnTerminate(Dali::Application& app); |
| 63 | 63 | |
| ... | ... | @@ -66,4 +66,4 @@ private: // methods |
| 66 | 66 | void OnTap(Dali::Actor actor, const Dali::TapGesture& tap); |
| 67 | 67 | }; |
| 68 | 68 | |
| 69 | -#endif //SCENE_LAUNCHER_H_ | |
| 69 | +#endif //SCENE_LAUNCHER_H_ | ... | ... |
examples/simple-text-field/simple-text-field.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -65,7 +65,7 @@ public: |
| 65 | 65 | mTextField.SetProperty(TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Enter folder name."); |
| 66 | 66 | |
| 67 | 67 | mButtonSelectionStart = PushButton::New(); |
| 68 | - mButtonSelectionEnd = PushButton::New(); | |
| 68 | + mButtonSelectionEnd = PushButton::New(); | |
| 69 | 69 | |
| 70 | 70 | mButtonSelectionStart.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); |
| 71 | 71 | mButtonSelectionStart.SetProperty(Actor::Property::SIZE, Vector2(140.f, 50.f)); |
| ... | ... | @@ -100,7 +100,7 @@ public: |
| 100 | 100 | if(button == mButtonSelectionStart) |
| 101 | 101 | { |
| 102 | 102 | int iStart = mTextField.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get<int>() - 1; |
| 103 | - if (iStart < 0) | |
| 103 | + if(iStart < 0) | |
| 104 | 104 | { |
| 105 | 105 | iStart = 0; |
| 106 | 106 | } |
| ... | ... | @@ -108,22 +108,22 @@ public: |
| 108 | 108 | } |
| 109 | 109 | else if(button == mButtonSelectionEnd) |
| 110 | 110 | { |
| 111 | - mTextField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END , mTextField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>() + 1); | |
| 111 | + mTextField.SetProperty(DevelTextField::Property::SELECTED_TEXT_END, mTextField.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get<int>() + 1); | |
| 112 | 112 | } |
| 113 | - else if (mBtnEditable == button) | |
| 113 | + else if(mBtnEditable == button) | |
| 114 | 114 | { |
| 115 | - bool bEditable = !mTextField.GetProperty( DevelTextField::Property::ENABLE_EDITING).Get<int>(); | |
| 116 | - mTextField.SetProperty( DevelTextField::Property::ENABLE_EDITING , bEditable); | |
| 117 | - if (bEditable) | |
| 118 | - { | |
| 119 | - mBtnEditable.SetProperty(Button::Property::LABEL, "Non-editable"); | |
| 120 | - mBtnEditable.SetBackgroundColor(Color::RED); | |
| 121 | - } | |
| 115 | + bool bEditable = !mTextField.GetProperty(DevelTextField::Property::ENABLE_EDITING).Get<int>(); | |
| 116 | + mTextField.SetProperty(DevelTextField::Property::ENABLE_EDITING, bEditable); | |
| 117 | + if(bEditable) | |
| 118 | + { | |
| 119 | + mBtnEditable.SetProperty(Button::Property::LABEL, "Non-editable"); | |
| 120 | + mBtnEditable.SetBackgroundColor(Color::RED); | |
| 121 | + } | |
| 122 | 122 | else |
| 123 | - { | |
| 124 | - mBtnEditable.SetProperty(Button::Property::LABEL, "editable"); | |
| 125 | - mBtnEditable.SetBackgroundColor(Color::GREEN); | |
| 126 | - } | |
| 123 | + { | |
| 124 | + mBtnEditable.SetProperty(Button::Property::LABEL, "editable"); | |
| 125 | + mBtnEditable.SetBackgroundColor(Color::GREEN); | |
| 126 | + } | |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | return true; |
| ... | ... | @@ -145,10 +145,10 @@ public: |
| 145 | 145 | |
| 146 | 146 | private: |
| 147 | 147 | Application& mApplication; |
| 148 | - TextField mTextField; | |
| 149 | - PushButton mButtonSelectionStart; | |
| 150 | - PushButton mButtonSelectionEnd; | |
| 151 | - PushButton mBtnEditable; | |
| 148 | + TextField mTextField; | |
| 149 | + PushButton mButtonSelectionStart; | |
| 150 | + PushButton mButtonSelectionEnd; | |
| 151 | + PushButton mBtnEditable; | |
| 152 | 152 | }; |
| 153 | 153 | |
| 154 | 154 | void RunTest(Application& application) | ... | ... |
examples/simple-text-renderer/simple-text-renderer-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -27,8 +27,8 @@ |
| 27 | 27 | #include <dali/devel-api/adaptor-framework/pixel-buffer.h> |
| 28 | 28 | |
| 29 | 29 | // INTERNAL INCLUDES |
| 30 | -#include "generated/simple-text-renderer-vert.h" | |
| 31 | 30 | #include "generated/simple-text-renderer-frag.h" |
| 31 | +#include "generated/simple-text-renderer-vert.h" | |
| 32 | 32 | |
| 33 | 33 | using namespace std; |
| 34 | 34 | using namespace Dali; | ... | ... |
examples/sparkle/sparkle-effect.h
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | #define DALI_SPARKLE_EFFECT_H |
| 3 | 3 | |
| 4 | 4 | /* |
| 5 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 5 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 6 | 6 | * |
| 7 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | 8 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -21,8 +21,8 @@ |
| 21 | 21 | #include <dali-toolkit/dali-toolkit.h> |
| 22 | 22 | #include <dali/dali.h> |
| 23 | 23 | |
| 24 | -#include "generated/sparkle-effect-vert.h" | |
| 25 | 24 | #include "generated/sparkle-effect-frag.h" |
| 25 | +#include "generated/sparkle-effect-vert.h" | |
| 26 | 26 | |
| 27 | 27 | using namespace Dali; |
| 28 | 28 | using Dali::Toolkit::ImageView; | ... | ... |
examples/styling/image-channel-control-impl.cpp
examples/textured-mesh/textured-mesh-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -19,10 +19,10 @@ |
| 19 | 19 | #include <dali-toolkit/dali-toolkit.h> |
| 20 | 20 | |
| 21 | 21 | // INTERNAL INCLUDES |
| 22 | +#include "generated/textured-mesh-frag.h" | |
| 23 | +#include "generated/textured-mesh-vert.h" | |
| 22 | 24 | #include "shared/utility.h" |
| 23 | 25 | #include "shared/view.h" |
| 24 | -#include "generated/textured-mesh-vert.h" | |
| 25 | -#include "generated/textured-mesh-frag.h" | |
| 26 | 26 | |
| 27 | 27 | using namespace Dali; |
| 28 | 28 | ... | ... |
examples/waves/utils.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -15,8 +15,8 @@ |
| 15 | 15 | * |
| 16 | 16 | */ |
| 17 | 17 | #include "utils.h" |
| 18 | -#include "dali-toolkit/dali-toolkit.h" | |
| 19 | 18 | #include <fstream> |
| 19 | +#include "dali-toolkit/dali-toolkit.h" | |
| 20 | 20 | |
| 21 | 21 | using namespace Dali; |
| 22 | 22 | using namespace Dali::Toolkit; |
| ... | ... | @@ -27,10 +27,10 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) |
| 27 | 27 | float max = std::max(rgb.r, std::max(rgb.g, rgb.b)); |
| 28 | 28 | |
| 29 | 29 | Vector3 hsl(max - min, 0.f, (max + min) * .5f); |
| 30 | - if (hsl.x * hsl.x > .0f) | |
| 30 | + if(hsl.x * hsl.x > .0f) | |
| 31 | 31 | { |
| 32 | 32 | hsl.y = hsl.x / max; |
| 33 | - if (max == rgb.r) | |
| 33 | + if(max == rgb.r) | |
| 34 | 34 | { |
| 35 | 35 | hsl.x = (rgb.g - rgb.b) / hsl.x; |
| 36 | 36 | } |
| ... | ... | @@ -43,7 +43,7 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) |
| 43 | 43 | hsl.x = 4.f + (rgb.r - rgb.g) / hsl.x; |
| 44 | 44 | } |
| 45 | 45 | hsl.x *= 60.f; |
| 46 | - if (hsl.x < 0.f) | |
| 46 | + if(hsl.x < 0.f) | |
| 47 | 47 | { |
| 48 | 48 | hsl.x += 360.f; |
| 49 | 49 | } |
| ... | ... | @@ -59,7 +59,7 @@ Vector3 ToHueSaturationLightness(Vector3 rgb) |
| 59 | 59 | Vector3 FromHueSaturationLightness(Vector3 hsl) |
| 60 | 60 | { |
| 61 | 61 | Vector3 rgb; |
| 62 | - if (hsl.y * hsl.y > 0.f) | |
| 62 | + if(hsl.y * hsl.y > 0.f) | |
| 63 | 63 | { |
| 64 | 64 | if(hsl.x >= 360.f) |
| 65 | 65 | { |
| ... | ... | @@ -67,50 +67,50 @@ Vector3 FromHueSaturationLightness(Vector3 hsl) |
| 67 | 67 | } |
| 68 | 68 | hsl.x /= 60.f; |
| 69 | 69 | |
| 70 | - int i = FastFloor(hsl.x); | |
| 70 | + int i = FastFloor(hsl.x); | |
| 71 | 71 | float ff = hsl.x - i; |
| 72 | - float p = hsl.z * (1.0 - hsl.y); | |
| 73 | - float q = hsl.z * (1.0 - (hsl.y * ff)); | |
| 74 | - float t = hsl.z * (1.0 - (hsl.y * (1.f - ff))); | |
| 72 | + float p = hsl.z * (1.0 - hsl.y); | |
| 73 | + float q = hsl.z * (1.0 - (hsl.y * ff)); | |
| 74 | + float t = hsl.z * (1.0 - (hsl.y * (1.f - ff))); | |
| 75 | 75 | |
| 76 | - switch (i) | |
| 76 | + switch(i) | |
| 77 | 77 | { |
| 78 | - case 0: | |
| 79 | - rgb.r = hsl.z; | |
| 80 | - rgb.g = t; | |
| 81 | - rgb.b = p; | |
| 82 | - break; | |
| 83 | - | |
| 84 | - case 1: | |
| 85 | - rgb.r = q; | |
| 86 | - rgb.g = hsl.z; | |
| 87 | - rgb.b = p; | |
| 88 | - break; | |
| 89 | - | |
| 90 | - case 2: | |
| 91 | - rgb.r = p; | |
| 92 | - rgb.g = hsl.z; | |
| 93 | - rgb.b = t; | |
| 94 | - break; | |
| 95 | - | |
| 96 | - case 3: | |
| 97 | - rgb.r = p; | |
| 98 | - rgb.g = q; | |
| 99 | - rgb.b = hsl.z; | |
| 100 | - break; | |
| 101 | - | |
| 102 | - case 4: | |
| 103 | - rgb.r = t; | |
| 104 | - rgb.g = p; | |
| 105 | - rgb.b = hsl.z; | |
| 106 | - break; | |
| 107 | - | |
| 108 | - case 5: | |
| 109 | - default: | |
| 110 | - rgb.r = hsl.z; | |
| 111 | - rgb.g = p; | |
| 112 | - rgb.b = q; | |
| 113 | - break; | |
| 78 | + case 0: | |
| 79 | + rgb.r = hsl.z; | |
| 80 | + rgb.g = t; | |
| 81 | + rgb.b = p; | |
| 82 | + break; | |
| 83 | + | |
| 84 | + case 1: | |
| 85 | + rgb.r = q; | |
| 86 | + rgb.g = hsl.z; | |
| 87 | + rgb.b = p; | |
| 88 | + break; | |
| 89 | + | |
| 90 | + case 2: | |
| 91 | + rgb.r = p; | |
| 92 | + rgb.g = hsl.z; | |
| 93 | + rgb.b = t; | |
| 94 | + break; | |
| 95 | + | |
| 96 | + case 3: | |
| 97 | + rgb.r = p; | |
| 98 | + rgb.g = q; | |
| 99 | + rgb.b = hsl.z; | |
| 100 | + break; | |
| 101 | + | |
| 102 | + case 4: | |
| 103 | + rgb.r = t; | |
| 104 | + rgb.g = p; | |
| 105 | + rgb.b = hsl.z; | |
| 106 | + break; | |
| 107 | + | |
| 108 | + case 5: | |
| 109 | + default: | |
| 110 | + rgb.r = hsl.z; | |
| 111 | + rgb.g = p; | |
| 112 | + rgb.b = q; | |
| 113 | + break; | |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | else |
| ... | ... | @@ -121,8 +121,7 @@ Vector3 FromHueSaturationLightness(Vector3 hsl) |
| 121 | 121 | return rgb; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | -Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts, | |
| 125 | - Vector2 scale, VertexFn positionFn, VertexFn texCoordFn) | |
| 124 | +Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts, Vector2 scale, VertexFn positionFn, VertexFn texCoordFn) | |
| 126 | 125 | { |
| 127 | 126 | DALI_ASSERT_DEBUG(xVerts > 1 && yVerts > 1); |
| 128 | 127 | int numVerts = xVerts * yVerts; |
| ... | ... | @@ -132,40 +131,40 @@ Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts, |
| 132 | 131 | Vector2 aTexCoord; |
| 133 | 132 | }; |
| 134 | 133 | std::vector<Vertex> vertices; |
| 135 | - vertices.reserve( numVerts); | |
| 134 | + vertices.reserve(numVerts); | |
| 136 | 135 | |
| 137 | 136 | float dx = 1.f / (xVerts - 1); |
| 138 | 137 | float dz = 1.f / (yVerts - 1); |
| 139 | 138 | |
| 140 | - Vector2 pos{ 0.f, 0.f }; | |
| 141 | - for (unsigned int i = 0; i < yVerts; ++i) | |
| 139 | + Vector2 pos{0.f, 0.f}; | |
| 140 | + for(unsigned int i = 0; i < yVerts; ++i) | |
| 142 | 141 | { |
| 143 | 142 | pos.x = float(int((i & 1) * 2) - 1) * dx * .25f; |
| 144 | - for (unsigned int j = 0; j < xVerts; ++j) | |
| 143 | + for(unsigned int j = 0; j < xVerts; ++j) | |
| 145 | 144 | { |
| 146 | - auto vPos = pos + Vector2{ -.5f, -.5f }; | |
| 147 | - vertices.push_back(Vertex{ (positionFn ? positionFn(vPos) : vPos) * scale, | |
| 148 | - texCoordFn ? texCoordFn(pos) : pos }); | |
| 145 | + auto vPos = pos + Vector2{-.5f, -.5f}; | |
| 146 | + vertices.push_back(Vertex{(positionFn ? positionFn(vPos) : vPos) * scale, | |
| 147 | + texCoordFn ? texCoordFn(pos) : pos}); | |
| 149 | 148 | pos.x += dx; |
| 150 | 149 | } |
| 151 | 150 | |
| 152 | 151 | pos.y += dz; |
| 153 | 152 | } |
| 154 | 153 | |
| 155 | - VertexBuffer vertexBuffer = VertexBuffer::New( Property::Map() | |
| 156 | - .Add( "aPosition", Property::VECTOR2 ) | |
| 157 | - .Add( "aTexCoord", Property::VECTOR2 )); | |
| 154 | + VertexBuffer vertexBuffer = VertexBuffer::New(Property::Map() | |
| 155 | + .Add("aPosition", Property::VECTOR2) | |
| 156 | + .Add("aTexCoord", Property::VECTOR2)); | |
| 158 | 157 | vertexBuffer.SetData(vertices.data(), vertices.size()); |
| 159 | 158 | |
| 160 | - int numInds = (xVerts - 1) * (yVerts - 1) * 6; | |
| 159 | + int numInds = (xVerts - 1) * (yVerts - 1) * 6; | |
| 161 | 160 | std::vector<uint16_t> indices; |
| 162 | 161 | indices.reserve(numInds); |
| 163 | 162 | |
| 164 | - for (unsigned int i = 1; i < yVerts; ++i) | |
| 163 | + for(unsigned int i = 1; i < yVerts; ++i) | |
| 165 | 164 | { |
| 166 | - if ((i & 1) == 0) | |
| 165 | + if((i & 1) == 0) | |
| 167 | 166 | { |
| 168 | - for (unsigned int j = 1; j < xVerts; ++j) | |
| 167 | + for(unsigned int j = 1; j < xVerts; ++j) | |
| 169 | 168 | { |
| 170 | 169 | int iBase = i * xVerts + j; |
| 171 | 170 | indices.push_back(iBase); |
| ... | ... | @@ -178,7 +177,7 @@ Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts, |
| 178 | 177 | } |
| 179 | 178 | else |
| 180 | 179 | { |
| 181 | - for (unsigned int j = 1; j < xVerts; ++j) | |
| 180 | + for(unsigned int j = 1; j < xVerts; ++j) | |
| 182 | 181 | { |
| 183 | 182 | int iBase = i * xVerts + j; |
| 184 | 183 | indices.push_back(iBase); |
| ... | ... | @@ -201,8 +200,7 @@ Texture LoadTexture(const std::string& path) |
| 201 | 200 | { |
| 202 | 201 | PixelData pixelData = SyncImageLoader::Load(path); |
| 203 | 202 | |
| 204 | - Texture texture = Texture::New(TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), | |
| 205 | - pixelData.GetWidth(), pixelData.GetHeight()); | |
| 203 | + Texture texture = Texture::New(TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight()); | |
| 206 | 204 | texture.Upload(pixelData); |
| 207 | 205 | return texture; |
| 208 | 206 | } |
| ... | ... | @@ -211,14 +209,14 @@ Renderer CreateRenderer(TextureSet textures, Geometry geometry, Shader shader, u |
| 211 | 209 | { |
| 212 | 210 | Renderer renderer = Renderer::New(geometry, shader); |
| 213 | 211 | renderer.SetProperty(Renderer::Property::BLEND_MODE, |
| 214 | - (options & OPTION_BLEND) ? BlendMode::ON : BlendMode::OFF); | |
| 212 | + (options & OPTION_BLEND) ? BlendMode::ON : BlendMode::OFF); | |
| 215 | 213 | renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE, |
| 216 | - (options & OPTION_DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF); | |
| 214 | + (options & OPTION_DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF); | |
| 217 | 215 | renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, |
| 218 | - (options & OPTION_DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF); | |
| 216 | + (options & OPTION_DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF); | |
| 219 | 217 | renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK); |
| 220 | 218 | |
| 221 | - if (!textures) | |
| 219 | + if(!textures) | |
| 222 | 220 | { |
| 223 | 221 | textures = TextureSet::New(); |
| 224 | 222 | } |
| ... | ... | @@ -242,15 +240,15 @@ Actor CreateActor() |
| 242 | 240 | |
| 243 | 241 | Renderer CloneRenderer(Renderer original) |
| 244 | 242 | { |
| 245 | - Geometry geom = original.GetGeometry(); | |
| 246 | - Shader shader = original.GetShader(); | |
| 247 | - Renderer clone = Renderer::New(geom, shader); | |
| 243 | + Geometry geom = original.GetGeometry(); | |
| 244 | + Shader shader = original.GetShader(); | |
| 245 | + Renderer clone = Renderer::New(geom, shader); | |
| 248 | 246 | |
| 249 | 247 | // Copy properties. |
| 250 | 248 | Property::IndexContainer indices; |
| 251 | 249 | original.GetPropertyIndices(indices); |
| 252 | 250 | |
| 253 | - for (auto& i: indices) | |
| 251 | + for(auto& i : indices) | |
| 254 | 252 | { |
| 255 | 253 | auto actualIndex = Dali::PropertyRanges::DEFAULT_RENDERER_PROPERTY_START_INDEX + i; |
| 256 | 254 | clone.SetProperty(actualIndex, original.GetProperty(actualIndex)); |
| ... | ... | @@ -274,17 +272,17 @@ Actor CloneActor(Actor original) |
| 274 | 272 | // Don't copy every single one of them. |
| 275 | 273 | // Definitely don't copy resize policy related things, which will internally enable |
| 276 | 274 | // relayout, which in turn will result in losing the ability to set Z size. |
| 277 | - for (auto i : { | |
| 278 | - Actor::Property::PARENT_ORIGIN, | |
| 279 | - Actor::Property::ANCHOR_POINT, | |
| 280 | - Actor::Property::SIZE, | |
| 281 | - Actor::Property::POSITION, | |
| 282 | - Actor::Property::ORIENTATION, | |
| 283 | - Actor::Property::SCALE, | |
| 284 | - Actor::Property::VISIBLE, | |
| 285 | - Actor::Property::COLOR, | |
| 286 | - Actor::Property::NAME, | |
| 287 | - }) | |
| 275 | + for(auto i : { | |
| 276 | + Actor::Property::PARENT_ORIGIN, | |
| 277 | + Actor::Property::ANCHOR_POINT, | |
| 278 | + Actor::Property::SIZE, | |
| 279 | + Actor::Property::POSITION, | |
| 280 | + Actor::Property::ORIENTATION, | |
| 281 | + Actor::Property::SCALE, | |
| 282 | + Actor::Property::VISIBLE, | |
| 283 | + Actor::Property::COLOR, | |
| 284 | + Actor::Property::NAME, | |
| 285 | + }) | |
| 288 | 286 | { |
| 289 | 287 | clone.SetProperty(i, original.GetProperty(i)); |
| 290 | 288 | } | ... | ... |
examples/waves/utils.h
| 1 | 1 | #ifndef WAVES_UTILS_H_ |
| 2 | 2 | #define WAVES_UTILS_H_ |
| 3 | 3 | /* |
| 4 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 4 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 5 | 5 | * |
| 6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | 7 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -16,38 +16,37 @@ |
| 16 | 16 | * limitations under the License. |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | +#include <cmath> | |
| 19 | 20 | #include "dali/public-api/actors/actor.h" |
| 21 | +#include "dali/public-api/math/vector3.h" | |
| 20 | 22 | #include "dali/public-api/rendering/geometry.h" |
| 21 | 23 | #include "dali/public-api/rendering/renderer.h" |
| 22 | 24 | #include "dali/public-api/rendering/shader.h" |
| 23 | 25 | #include "dali/public-api/rendering/texture.h" |
| 24 | -#include "dali/public-api/math/vector3.h" | |
| 25 | -#include <cmath> | |
| 26 | 26 | |
| 27 | 27 | // |
| 28 | 28 | // Maths |
| 29 | 29 | // |
| 30 | -inline | |
| 31 | -float FastFloor(float x) | |
| 30 | +inline float FastFloor(float x) | |
| 32 | 31 | { |
| 33 | 32 | return static_cast<int>(x) - static_cast<int>(x < 0); |
| 34 | 33 | } |
| 35 | 34 | |
| 36 | -inline | |
| 37 | -float Sign(float x) | |
| 35 | +inline float Sign(float x) | |
| 38 | 36 | { |
| 39 | 37 | return float(x > 0.f) - float(x < .0f); |
| 40 | 38 | } |
| 41 | 39 | |
| 42 | -template <typename T> | |
| 40 | +template<typename T> | |
| 43 | 41 | inline |
| 44 | -typename std::decay<T>::type Lerp( | |
| 42 | + typename std::decay<T>::type | |
| 43 | + Lerp( | |
| 45 | 44 | const T& min, const T& max, float alpha) |
| 46 | 45 | { |
| 47 | 46 | return min + (max - min) * alpha; |
| 48 | 47 | } |
| 49 | 48 | |
| 50 | -template <typename T> | |
| 49 | +template<typename T> | |
| 51 | 50 | T Normalized(T v) |
| 52 | 51 | { |
| 53 | 52 | v.Normalize(); |
| ... | ... | @@ -68,22 +67,21 @@ Dali::Vector3 FromHueSaturationLightness(Dali::Vector3 hsl); |
| 68 | 67 | // |
| 69 | 68 | // Dali entities |
| 70 | 69 | // |
| 71 | -using VertexFn = Dali::Vector2(*)(const Dali::Vector2&); | |
| 70 | +using VertexFn = Dali::Vector2 (*)(const Dali::Vector2&); | |
| 72 | 71 | |
| 73 | 72 | ///@brief Creates a tesselated quad with @a xVerts vertices horizontally and @a yVerts |
| 74 | 73 | /// vertices vertically. Allows the use of an optional @a shaderFn, which can be used to |
| 75 | 74 | /// modify the vertex positions - these will be in the [{ 0.f, 0.f}, { 1.f, 1.f}] range. |
| 76 | 75 | /// After returning from the shader, they're transformed |
| 77 | -Dali::Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts, | |
| 78 | - Dali::Vector2 scale, VertexFn positionFn = nullptr, VertexFn texCoordFn = nullptr); | |
| 76 | +Dali::Geometry CreateTesselatedQuad(unsigned int xVerts, unsigned int yVerts, Dali::Vector2 scale, VertexFn positionFn = nullptr, VertexFn texCoordFn = nullptr); | |
| 79 | 77 | |
| 80 | 78 | Dali::Texture LoadTexture(const std::string& path); |
| 81 | 79 | |
| 82 | 80 | enum RendererOptions |
| 83 | 81 | { |
| 84 | - OPTION_NONE = 0x0, | |
| 85 | - OPTION_BLEND = 0x01, | |
| 86 | - OPTION_DEPTH_TEST = 0x02, | |
| 82 | + OPTION_NONE = 0x0, | |
| 83 | + OPTION_BLEND = 0x01, | |
| 84 | + OPTION_DEPTH_TEST = 0x02, | |
| 87 | 85 | OPTION_DEPTH_WRITE = 0x04 |
| 88 | 86 | }; |
| 89 | 87 | |
| ... | ... | @@ -91,8 +89,7 @@ enum RendererOptions |
| 91 | 89 | /// and @a options from above. |
| 92 | 90 | ///@note Back face culling is on. |
| 93 | 91 | ///@note If textures is not a valid handle, an empty texture set will be created. |
| 94 | -Dali::Renderer CreateRenderer(Dali::TextureSet textures, Dali::Geometry geometry, | |
| 95 | - Dali::Shader shader, uint32_t options = OPTION_NONE); | |
| 92 | +Dali::Renderer CreateRenderer(Dali::TextureSet textures, Dali::Geometry geometry, Dali::Shader shader, uint32_t options = OPTION_NONE); | |
| 96 | 93 | |
| 97 | 94 | ///@brief Sets @a actor's anchor point and parent origin to center. |
| 98 | 95 | void CenterActor(Dali::Actor actor); | ... | ... |
examples/waves/waves-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 ( "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -16,59 +16,58 @@ |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | // INTERNAL INCLUDES |
| 19 | -#include "utils.h" | |
| 19 | +#include <fstream> | |
| 20 | +#include <iostream> | |
| 21 | +#include <numeric> | |
| 20 | 22 | #include "dali/devel-api/adaptor-framework/tilt-sensor.h" |
| 23 | +#include "dali/public-api/actors/camera-actor.h" | |
| 24 | +#include "dali/public-api/actors/layer.h" | |
| 21 | 25 | #include "dali/public-api/adaptor-framework/application.h" |
| 22 | 26 | #include "dali/public-api/adaptor-framework/key.h" |
| 23 | 27 | #include "dali/public-api/animation/animation.h" |
| 28 | +#include "dali/public-api/events/key-event.h" | |
| 24 | 29 | #include "dali/public-api/events/pan-gesture-detector.h" |
| 25 | 30 | #include "dali/public-api/events/tap-gesture-detector.h" |
| 26 | -#include "dali/public-api/events/key-event.h" | |
| 27 | -#include "dali/public-api/actors/camera-actor.h" | |
| 28 | -#include "dali/public-api/actors/layer.h" | |
| 29 | -#include "dali/public-api/render-tasks/render-task.h" | |
| 30 | 31 | #include "dali/public-api/render-tasks/render-task-list.h" |
| 31 | -#include <fstream> | |
| 32 | -#include <iostream> | |
| 33 | -#include <numeric> | |
| 32 | +#include "dali/public-api/render-tasks/render-task.h" | |
| 33 | +#include "utils.h" | |
| 34 | 34 | |
| 35 | -#include "generated/waves-vert.h" | |
| 36 | 35 | #include "generated/waves-frag.h" |
| 36 | +#include "generated/waves-vert.h" | |
| 37 | 37 | |
| 38 | 38 | using namespace Dali; |
| 39 | 39 | |
| 40 | 40 | namespace |
| 41 | 41 | { |
| 42 | - | |
| 43 | 42 | const float TIME_STEP = 0.0952664626; |
| 44 | 43 | |
| 45 | -const std::string UNIFORM_LIGHT_COLOR_SQR = "uLightColorSqr"; | |
| 46 | -const std::string UNIFORM_AMBIENT_COLOR = "uAmbientColor"; | |
| 47 | -const std::string UNIFORM_INV_LIGHT_DIR = "uInvLightDir"; | |
| 48 | -const std::string UNIFORM_SCROLL_SCALE = "uScrollScale"; | |
| 49 | -const std::string UNIFORM_WAVE_RATE = "uWaveRate"; | |
| 50 | -const std::string UNIFORM_WAVE_AMPLITUDE = "uWaveAmplitude"; | |
| 44 | +const std::string UNIFORM_LIGHT_COLOR_SQR = "uLightColorSqr"; | |
| 45 | +const std::string UNIFORM_AMBIENT_COLOR = "uAmbientColor"; | |
| 46 | +const std::string UNIFORM_INV_LIGHT_DIR = "uInvLightDir"; | |
| 47 | +const std::string UNIFORM_SCROLL_SCALE = "uScrollScale"; | |
| 48 | +const std::string UNIFORM_WAVE_RATE = "uWaveRate"; | |
| 49 | +const std::string UNIFORM_WAVE_AMPLITUDE = "uWaveAmplitude"; | |
| 51 | 50 | const std::string UNIFORM_NORMAL_MAP_WEIGHT = "uNormalMapWeight"; |
| 52 | -const std::string UNIFORM_SPECULARITY = "uSpecularity"; | |
| 53 | -const std::string UNIFORM_PARALLAX_AMOUNT = "uParallaxAmount"; | |
| 54 | -const std::string UNIFORM_TIME = "uTime"; | |
| 51 | +const std::string UNIFORM_SPECULARITY = "uSpecularity"; | |
| 52 | +const std::string UNIFORM_PARALLAX_AMOUNT = "uParallaxAmount"; | |
| 53 | +const std::string UNIFORM_TIME = "uTime"; | |
| 55 | 54 | |
| 56 | -const Vector3 WAVES_COLOR { .78f, .64f, .26f }; | |
| 57 | -const Vector3 LIGHT_COLOR { 1.0f, 0.91f, 0.6f }; | |
| 58 | -const Vector3 AMBIENT_COLOR { .002f, .001f, .001f }; | |
| 55 | +const Vector3 WAVES_COLOR{.78f, .64f, .26f}; | |
| 56 | +const Vector3 LIGHT_COLOR{1.0f, 0.91f, 0.6f}; | |
| 57 | +const Vector3 AMBIENT_COLOR{.002f, .001f, .001f}; | |
| 59 | 58 | |
| 60 | -const Vector3 INV_LIGHT_DIR = Normalized(Vector3{ .125f, .8f, -.55f }); | |
| 59 | +const Vector3 INV_LIGHT_DIR = Normalized(Vector3{.125f, .8f, -.55f}); | |
| 61 | 60 | |
| 62 | -const Vector2 SCROLL_SCALE{ 1.f, 3.5f }; | |
| 63 | -const float WAVE_RATE = 12.17f; | |
| 64 | -const float WAVE_AMPLITUDE = 1.f; | |
| 65 | -const float NORMAL_MAP_WEIGHT = 0.05f; | |
| 66 | -const float SPECULARITY = 512.f; | |
| 67 | -const float PARALLAX_AMOUNT = .25f; | |
| 61 | +const Vector2 SCROLL_SCALE{1.f, 3.5f}; | |
| 62 | +const float WAVE_RATE = 12.17f; | |
| 63 | +const float WAVE_AMPLITUDE = 1.f; | |
| 64 | +const float NORMAL_MAP_WEIGHT = 0.05f; | |
| 65 | +const float SPECULARITY = 512.f; | |
| 66 | +const float PARALLAX_AMOUNT = .25f; | |
| 68 | 67 | |
| 69 | 68 | const float TILT_RANGE_DEGREES = 30.f; |
| 70 | 69 | |
| 71 | -const float TRANSITION_DURATION = 1.2f; | |
| 70 | +const float TRANSITION_DURATION = 1.2f; | |
| 72 | 71 | const float TRANSITION_TIME_SCALE = 6.f; |
| 73 | 72 | |
| 74 | 73 | const std::string_view NORMAL_MAP_NAME = "noise512.png"; |
| ... | ... | @@ -92,7 +91,7 @@ public: |
| 92 | 91 | void Add(Dali::Vector2 tilt) |
| 93 | 92 | { |
| 94 | 93 | mTiltSamples[mIdxNextSample] = tilt; |
| 95 | - mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE; | |
| 94 | + mIdxNextSample = (mIdxNextSample + 1) % FILTER_SIZE; | |
| 96 | 95 | } |
| 97 | 96 | |
| 98 | 97 | Dali::Vector2 Filter() const |
| ... | ... | @@ -101,22 +100,25 @@ public: |
| 101 | 100 | } |
| 102 | 101 | |
| 103 | 102 | private: |
| 104 | - enum { FILTER_SIZE = 8u }; | |
| 103 | + enum | |
| 104 | + { | |
| 105 | + FILTER_SIZE = 8u | |
| 106 | + }; | |
| 105 | 107 | |
| 106 | 108 | Dali::Vector2 mTiltSamples[FILTER_SIZE]; |
| 107 | - size_t mIdxNextSample = 0; | |
| 109 | + size_t mIdxNextSample = 0; | |
| 108 | 110 | }; |
| 109 | 111 | |
| 110 | -} // nonamespace | |
| 112 | +} // namespace | |
| 111 | 113 | |
| 112 | 114 | class WavesExample : public ConnectionTracker |
| 113 | 115 | { |
| 114 | 116 | public: |
| 115 | - WavesExample( Application& app ) | |
| 116 | - : mApp( app ) | |
| 117 | + WavesExample(Application& app) | |
| 118 | + : mApp(app) | |
| 117 | 119 | { |
| 118 | - mApp.InitSignal().Connect( this, &WavesExample::Create ); | |
| 119 | - mApp.TerminateSignal().Connect( this, &WavesExample::Destroy ); | |
| 120 | + mApp.InitSignal().Connect(this, &WavesExample::Create); | |
| 121 | + mApp.TerminateSignal().Connect(this, &WavesExample::Destroy); | |
| 120 | 122 | } |
| 121 | 123 | |
| 122 | 124 | ~WavesExample() = default; |
| ... | ... | @@ -124,9 +126,9 @@ public: |
| 124 | 126 | private: |
| 125 | 127 | Application& mApp; |
| 126 | 128 | |
| 127 | - CameraActor mCamera; // no ownership | |
| 129 | + CameraActor mCamera; // no ownership | |
| 128 | 130 | |
| 129 | - Actor mWaves; | |
| 131 | + Actor mWaves; | |
| 130 | 132 | Shader mWaveShader; |
| 131 | 133 | |
| 132 | 134 | Property::Index mUInvLightDir{Property::INVALID_INDEX}; |
| ... | ... | @@ -150,37 +152,35 @@ private: |
| 150 | 152 | Animation mTimeAnim; |
| 151 | 153 | Animation mTransitionAnim; |
| 152 | 154 | |
| 153 | - void Create( Application& application ) | |
| 155 | + void Create(Application& application) | |
| 154 | 156 | { |
| 155 | - Window window = application.GetWindow(); | |
| 156 | - auto rootLayer = window.GetRootLayer(); | |
| 157 | + Window window = application.GetWindow(); | |
| 158 | + auto rootLayer = window.GetRootLayer(); | |
| 157 | 159 | |
| 158 | 160 | window.SetBackgroundColor(Vector4(WAVES_COLOR * .5f)); |
| 159 | 161 | |
| 160 | 162 | // Get camera |
| 161 | - RenderTaskList tasks = window.GetRenderTaskList(); | |
| 162 | - RenderTask mainPass = tasks.GetTask(0); | |
| 163 | - CameraActor camera = mainPass.GetCameraActor(); | |
| 164 | - mCamera = camera; | |
| 163 | + RenderTaskList tasks = window.GetRenderTaskList(); | |
| 164 | + RenderTask mainPass = tasks.GetTask(0); | |
| 165 | + CameraActor camera = mainPass.GetCameraActor(); | |
| 166 | + mCamera = camera; | |
| 165 | 167 | |
| 166 | 168 | // NOTE: watchface doesn't tolerate modification of the camera well; |
| 167 | 169 | /// we're better off rotating the world. |
| 168 | - Quaternion baseOrientation (Radian(Degree(-150.f)), Radian(M_PI), Radian(0.f)); | |
| 170 | + Quaternion baseOrientation(Radian(Degree(-150.f)), Radian(M_PI), Radian(0.f)); | |
| 169 | 171 | |
| 170 | 172 | auto shader = CreateShader(); |
| 171 | 173 | |
| 172 | 174 | // Create geometry |
| 173 | - Geometry geom = CreateTesselatedQuad(16, 64, Vector2{ .25f, 3.8f }, [](const Vector2& v) { | |
| 175 | + Geometry geom = CreateTesselatedQuad( | |
| 176 | + 16, 64, Vector2{.25f, 3.8f}, [](const Vector2& v) { | |
| 174 | 177 | float y = v.y + .5f; // 0..1 |
| 175 | 178 | y = std::sqrt(y) - .5f; // perspective correction - increase vertex density closer to viewer |
| 176 | 179 | |
| 177 | 180 | float x = v.x + v.x * (1.f - y) * 5.5f; |
| 178 | 181 | |
| 179 | 182 | y -= .24f; // further translation |
| 180 | - return Vector2{ x, y }; | |
| 181 | - }, [](const Vector2& v) { | |
| 182 | - return Vector2{ v.x, std::sqrt(v.y) }; | |
| 183 | - }); | |
| 183 | + return Vector2{ x, y }; }, [](const Vector2& v) { return Vector2{v.x, std::sqrt(v.y)}; }); | |
| 184 | 184 | |
| 185 | 185 | // Create texture |
| 186 | 186 | auto normalMap = LoadTexture(std::string(DEMO_IMAGE_DIR) + NORMAL_MAP_NAME.data()); |
| ... | ... | @@ -197,7 +197,7 @@ private: |
| 197 | 197 | Renderer renderer = CreateRenderer(textures, geom, shader, OPTION_DEPTH_TEST | OPTION_DEPTH_WRITE); |
| 198 | 198 | |
| 199 | 199 | auto waves = CreateActor(); |
| 200 | - auto size = Vector2(window.GetSize()); | |
| 200 | + auto size = Vector2(window.GetSize()); | |
| 201 | 201 | waves.SetProperty(Actor::Property::SIZE, Vector3(size.x, 100.f, size.y)); |
| 202 | 202 | waves.SetProperty(Actor::Property::ORIENTATION, baseOrientation); |
| 203 | 203 | waves.SetProperty(Actor::Property::COLOR, WAVES_COLOR); |
| ... | ... | @@ -206,7 +206,7 @@ private: |
| 206 | 206 | window.Add(waves); |
| 207 | 207 | mWaves = waves; |
| 208 | 208 | |
| 209 | - window.KeyEventSignal().Connect( this, &WavesExample::OnKeyEvent ); | |
| 209 | + window.KeyEventSignal().Connect(this, &WavesExample::OnKeyEvent); | |
| 210 | 210 | |
| 211 | 211 | // Setup double tap detector for color change |
| 212 | 212 | mDoubleTapGesture = TapGestureDetector::New(2); |
| ... | ... | @@ -215,10 +215,10 @@ private: |
| 215 | 215 | |
| 216 | 216 | // Touch controls |
| 217 | 217 | mTiltSensor = TiltSensor::Get(); |
| 218 | - if ( mTiltSensor.Start() ) | |
| 218 | + if(mTiltSensor.Start()) | |
| 219 | 219 | { |
| 220 | 220 | // Get notifications when the device is tilted |
| 221 | - mTiltSensor.TiltedSignal().Connect( this, &WavesExample::OnTilted ); | |
| 221 | + mTiltSensor.TiltedSignal().Connect(this, &WavesExample::OnTilted); | |
| 222 | 222 | } |
| 223 | 223 | else |
| 224 | 224 | { |
| ... | ... | @@ -239,7 +239,7 @@ private: |
| 239 | 239 | mTimeAnim = animTime; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - void Destroy( Application& app) | |
| 242 | + void Destroy(Application& app) | |
| 243 | 243 | { |
| 244 | 244 | mCamera.Reset(); |
| 245 | 245 | |
| ... | ... | @@ -251,38 +251,38 @@ private: |
| 251 | 251 | |
| 252 | 252 | Shader CreateShader() |
| 253 | 253 | { |
| 254 | - Vector3 lightColorSqr{ LIGHT_COLOR }; | |
| 255 | - Vector3 ambientColor = AMBIENT_COLOR; | |
| 256 | - Vector3 invLightDir = INV_LIGHT_DIR; | |
| 257 | - Vector2 scrollScale = SCROLL_SCALE; | |
| 258 | - float waveRate = WAVE_RATE; | |
| 259 | - float waveAmp = WAVE_AMPLITUDE; | |
| 260 | - float normalMapWeight = NORMAL_MAP_WEIGHT; | |
| 261 | - float specularity = SPECULARITY; | |
| 262 | - float parallaxAmount = PARALLAX_AMOUNT; | |
| 263 | - if (mWaveShader) | |
| 254 | + Vector3 lightColorSqr{LIGHT_COLOR}; | |
| 255 | + Vector3 ambientColor = AMBIENT_COLOR; | |
| 256 | + Vector3 invLightDir = INV_LIGHT_DIR; | |
| 257 | + Vector2 scrollScale = SCROLL_SCALE; | |
| 258 | + float waveRate = WAVE_RATE; | |
| 259 | + float waveAmp = WAVE_AMPLITUDE; | |
| 260 | + float normalMapWeight = NORMAL_MAP_WEIGHT; | |
| 261 | + float specularity = SPECULARITY; | |
| 262 | + float parallaxAmount = PARALLAX_AMOUNT; | |
| 263 | + if(mWaveShader) | |
| 264 | 264 | { |
| 265 | - lightColorSqr = mWaveShader.GetProperty(mULightColorSqr).Get<Vector3>(); | |
| 266 | - ambientColor = mWaveShader.GetProperty(mUAmbientColor).Get<Vector3>(); | |
| 267 | - invLightDir = mWaveShader.GetProperty(mUInvLightDir).Get<Vector3>(); | |
| 268 | - scrollScale = mWaveShader.GetProperty(mUScrollScale).Get<Vector2>(); | |
| 269 | - waveRate = mWaveShader.GetProperty(mUWaveRate).Get<float>(); | |
| 270 | - waveAmp = mWaveShader.GetProperty(mUWaveAmplitude).Get<float>(); | |
| 265 | + lightColorSqr = mWaveShader.GetProperty(mULightColorSqr).Get<Vector3>(); | |
| 266 | + ambientColor = mWaveShader.GetProperty(mUAmbientColor).Get<Vector3>(); | |
| 267 | + invLightDir = mWaveShader.GetProperty(mUInvLightDir).Get<Vector3>(); | |
| 268 | + scrollScale = mWaveShader.GetProperty(mUScrollScale).Get<Vector2>(); | |
| 269 | + waveRate = mWaveShader.GetProperty(mUWaveRate).Get<float>(); | |
| 270 | + waveAmp = mWaveShader.GetProperty(mUWaveAmplitude).Get<float>(); | |
| 271 | 271 | normalMapWeight = mWaveShader.GetProperty(mUNormalMapWeight).Get<float>(); |
| 272 | - specularity = mWaveShader.GetProperty(mUSpecularity).Get<float>(); | |
| 272 | + specularity = mWaveShader.GetProperty(mUSpecularity).Get<float>(); | |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - Shader shader = Shader::New(SHADER_WAVES_VERT, SHADER_WAVES_FRAG, Shader::Hint::MODIFIES_GEOMETRY); | |
| 276 | - mULightColorSqr = shader.RegisterProperty(UNIFORM_LIGHT_COLOR_SQR, lightColorSqr); | |
| 277 | - mUAmbientColor = shader.RegisterProperty(UNIFORM_AMBIENT_COLOR, ambientColor); | |
| 278 | - mUInvLightDir = shader.RegisterProperty(UNIFORM_INV_LIGHT_DIR, invLightDir); | |
| 279 | - mUScrollScale = shader.RegisterProperty(UNIFORM_SCROLL_SCALE, scrollScale); | |
| 280 | - mUWaveRate = shader.RegisterProperty(UNIFORM_WAVE_RATE, waveRate); | |
| 281 | - mUWaveAmplitude = shader.RegisterProperty(UNIFORM_WAVE_AMPLITUDE, waveAmp); | |
| 275 | + Shader shader = Shader::New(SHADER_WAVES_VERT, SHADER_WAVES_FRAG, Shader::Hint::MODIFIES_GEOMETRY); | |
| 276 | + mULightColorSqr = shader.RegisterProperty(UNIFORM_LIGHT_COLOR_SQR, lightColorSqr); | |
| 277 | + mUAmbientColor = shader.RegisterProperty(UNIFORM_AMBIENT_COLOR, ambientColor); | |
| 278 | + mUInvLightDir = shader.RegisterProperty(UNIFORM_INV_LIGHT_DIR, invLightDir); | |
| 279 | + mUScrollScale = shader.RegisterProperty(UNIFORM_SCROLL_SCALE, scrollScale); | |
| 280 | + mUWaveRate = shader.RegisterProperty(UNIFORM_WAVE_RATE, waveRate); | |
| 281 | + mUWaveAmplitude = shader.RegisterProperty(UNIFORM_WAVE_AMPLITUDE, waveAmp); | |
| 282 | 282 | mUNormalMapWeight = shader.RegisterProperty(UNIFORM_NORMAL_MAP_WEIGHT, normalMapWeight); |
| 283 | - mUSpecularity = shader.RegisterProperty(UNIFORM_SPECULARITY, specularity); | |
| 284 | - mUParallaxAmount = shader.RegisterProperty(UNIFORM_PARALLAX_AMOUNT, parallaxAmount); | |
| 285 | - mUTime = shader.RegisterProperty(UNIFORM_TIME, 0.f); | |
| 283 | + mUSpecularity = shader.RegisterProperty(UNIFORM_SPECULARITY, specularity); | |
| 284 | + mUParallaxAmount = shader.RegisterProperty(UNIFORM_PARALLAX_AMOUNT, parallaxAmount); | |
| 285 | + mUTime = shader.RegisterProperty(UNIFORM_TIME, 0.f); | |
| 286 | 286 | |
| 287 | 287 | auto window = mApp.GetWindow(); |
| 288 | 288 | shader.RegisterProperty("uScreenHalfSize", Vector2(window.GetSize()) * .5f); |
| ... | ... | @@ -293,7 +293,7 @@ private: |
| 293 | 293 | |
| 294 | 294 | void TriggerColorTransition(Vector3 wavesColor, Vector3 lightColor) |
| 295 | 295 | { |
| 296 | - if (mTransitionAnim) | |
| 296 | + if(mTransitionAnim) | |
| 297 | 297 | { |
| 298 | 298 | mTransitionAnim.Stop(); |
| 299 | 299 | } |
| ... | ... | @@ -336,9 +336,9 @@ private: |
| 336 | 336 | |
| 337 | 337 | void OnKeyEvent(const KeyEvent& event) |
| 338 | 338 | { |
| 339 | - if ( event.GetState() == KeyEvent::UP) // single keystrokes | |
| 339 | + if(event.GetState() == KeyEvent::UP) // single keystrokes | |
| 340 | 340 | { |
| 341 | - if( IsKey( event, DALI_KEY_ESCAPE ) || IsKey( event, DALI_KEY_BACK ) ) | |
| 341 | + if(IsKey(event, DALI_KEY_ESCAPE) || IsKey(event, DALI_KEY_BACK)) | |
| 342 | 342 | { |
| 343 | 343 | mApp.Quit(); |
| 344 | 344 | } |
| ... | ... | @@ -354,24 +354,24 @@ private: |
| 354 | 354 | void OnPan(Actor actor, const PanGesture& gesture) |
| 355 | 355 | { |
| 356 | 356 | auto tilt = gesture.GetDisplacement() / Vector2(mApp.GetWindow().GetSize()); |
| 357 | - switch (gesture.GetState()) | |
| 357 | + switch(gesture.GetState()) | |
| 358 | 358 | { |
| 359 | - case GestureState::STARTED: | |
| 360 | - mTiltFilter.Add(tilt); | |
| 361 | - break; | |
| 359 | + case GestureState::STARTED: | |
| 360 | + mTiltFilter.Add(tilt); | |
| 361 | + break; | |
| 362 | 362 | |
| 363 | - case GestureState::CONTINUING: | |
| 364 | - mTiltFilter.Add(mTiltFilter.Filter() + tilt); | |
| 365 | - break; | |
| 363 | + case GestureState::CONTINUING: | |
| 364 | + mTiltFilter.Add(mTiltFilter.Filter() + tilt); | |
| 365 | + break; | |
| 366 | 366 | |
| 367 | - default: | |
| 368 | - break; | |
| 367 | + default: | |
| 368 | + break; | |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | UpdateLightDirection(); |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - void OnTilted( const TiltSensor& sensor) | |
| 374 | + void OnTilted(const TiltSensor& sensor) | |
| 375 | 375 | { |
| 376 | 376 | mTiltFilter.Add(Vector2(sensor.GetPitch(), sensor.GetRoll())); |
| 377 | 377 | |
| ... | ... | @@ -380,17 +380,17 @@ private: |
| 380 | 380 | |
| 381 | 381 | void UpdateLightDirection() |
| 382 | 382 | { |
| 383 | - Vector2 tilt = mTiltFilter.Filter(); | |
| 383 | + Vector2 tilt = mTiltFilter.Filter(); | |
| 384 | 384 | Quaternion q(Radian(tilt.y), Radian(-tilt.x), Radian(0.f)); |
| 385 | - Vector3 lightDir = q.Rotate(INV_LIGHT_DIR); | |
| 385 | + Vector3 lightDir = q.Rotate(INV_LIGHT_DIR); | |
| 386 | 386 | mWaveShader.SetProperty(mUInvLightDir, lightDir); |
| 387 | 387 | } |
| 388 | 388 | }; |
| 389 | 389 | |
| 390 | -int DALI_EXPORT_API main( int argc, char **argv ) | |
| 390 | +int DALI_EXPORT_API main(int argc, char** argv) | |
| 391 | 391 | { |
| 392 | - Application application = Application::New( &argc, &argv, DEMO_THEME_PATH ); | |
| 393 | - WavesExample example( application); | |
| 392 | + Application application = Application::New(&argc, &argv, DEMO_THEME_PATH); | |
| 393 | + WavesExample example(application); | |
| 394 | 394 | application.MainLoop(); |
| 395 | 395 | return 0; |
| 396 | 396 | } | ... | ... |
shared/bubble-animator.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -18,13 +18,13 @@ |
| 18 | 18 | // CLASS HEADER |
| 19 | 19 | #include "bubble-animator.h" |
| 20 | 20 | |
| 21 | -#include <dali/public-api/animation/constraint.h> | |
| 22 | -#include <dali/public-api/math/random.h> | |
| 23 | -#include <dali/public-api/rendering/shader.h> | |
| 21 | +#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h> | |
| 24 | 22 | #include <dali-toolkit/public-api/controls/image-view/image-view.h> |
| 25 | 23 | #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h> |
| 26 | 24 | #include <dali-toolkit/public-api/visuals/image-visual-properties.h> |
| 27 | -#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h> | |
| 25 | +#include <dali/public-api/animation/constraint.h> | |
| 26 | +#include <dali/public-api/math/random.h> | |
| 27 | +#include <dali/public-api/rendering/shader.h> | |
| 28 | 28 | |
| 29 | 29 | using namespace Dali; |
| 30 | 30 | using namespace Dali::Toolkit; |
| ... | ... | @@ -32,19 +32,17 @@ using namespace Dali::Toolkit; |
| 32 | 32 | namespace |
| 33 | 33 | { |
| 34 | 34 | const char* const BUBBLE_COLOR_STYLE_NAME[] = |
| 35 | -{ | |
| 36 | - "BubbleColor1", | |
| 37 | - "BubbleColor2", | |
| 38 | - "BubbleColor3", | |
| 39 | - "BubbleColor4" | |
| 40 | -}; | |
| 35 | + { | |
| 36 | + "BubbleColor1", | |
| 37 | + "BubbleColor2", | |
| 38 | + "BubbleColor3", | |
| 39 | + "BubbleColor4"}; | |
| 41 | 40 | constexpr int NUMBER_OF_BUBBLE_COLORS(sizeof(BUBBLE_COLOR_STYLE_NAME) / sizeof(BUBBLE_COLOR_STYLE_NAME[0])); |
| 42 | 41 | |
| 43 | 42 | const char* const SHAPE_IMAGE_TABLE[] = |
| 44 | -{ | |
| 45 | - DEMO_IMAGE_DIR "shape-circle.png", | |
| 46 | - DEMO_IMAGE_DIR "shape-bubble.png" | |
| 47 | -}; | |
| 43 | + { | |
| 44 | + DEMO_IMAGE_DIR "shape-circle.png", | |
| 45 | + DEMO_IMAGE_DIR "shape-bubble.png"}; | |
| 48 | 46 | constexpr int NUMBER_OF_SHAPE_IMAGES(sizeof(SHAPE_IMAGE_TABLE) / sizeof(SHAPE_IMAGE_TABLE[0])); |
| 49 | 47 | |
| 50 | 48 | constexpr int NUM_BACKGROUND_IMAGES = 18; |
| ... | ... | @@ -157,7 +155,7 @@ void BubbleAnimator::InitializeBackgroundActors(Dali::Actor actor) |
| 157 | 155 | |
| 158 | 156 | // Define bubble horizontal parallax and vertical wrapping |
| 159 | 157 | Actor scrollView = mScrollView.GetHandle(); |
| 160 | - if( scrollView ) | |
| 158 | + if(scrollView) | |
| 161 | 159 | { |
| 162 | 160 | Constraint animConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, AnimateBubbleConstraint(childPos, Random::Range(-0.85f, 0.25f))); |
| 163 | 161 | animConstraint.AddSource(Source(scrollView, ScrollView::Property::SCROLL_POSITION)); |
| ... | ... | @@ -174,7 +172,6 @@ void BubbleAnimator::InitializeBackgroundActors(Dali::Actor actor) |
| 174 | 172 | animation.Play(); |
| 175 | 173 | mBackgroundAnimations.push_back(animation); |
| 176 | 174 | } |
| 177 | - | |
| 178 | 175 | } |
| 179 | 176 | |
| 180 | 177 | void BubbleAnimator::AddBackgroundActors(Actor layer, int count) | ... | ... |
shared/bubble-animator.h
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | #define DALI_DEMO_BUBBLE_ANIMATOR_H |
| 3 | 3 | |
| 4 | 4 | /* |
| 5 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 5 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 6 | 6 | * |
| 7 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | 8 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -19,12 +19,12 @@ |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | // EXTERNAL INCLUDES |
| 22 | -#include <vector> | |
| 23 | 22 | #include <dali/public-api/actors/actor.h> |
| 24 | 23 | #include <dali/public-api/adaptor-framework/timer.h> |
| 25 | 24 | #include <dali/public-api/animation/animation.h> |
| 26 | 25 | #include <dali/public-api/object/weak-handle.h> |
| 27 | 26 | #include <dali/public-api/signals/connection-tracker.h> |
| 27 | +#include <vector> | |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Creates and animates random sized bubbles |
| ... | ... | @@ -32,7 +32,6 @@ |
| 32 | 32 | class BubbleAnimator : public Dali::ConnectionTracker |
| 33 | 33 | { |
| 34 | 34 | public: |
| 35 | - | |
| 36 | 35 | /** |
| 37 | 36 | * @brief Initilizes the bubble background |
| 38 | 37 | * |
| ... | ... | @@ -47,7 +46,6 @@ public: |
| 47 | 46 | void PlayAnimation(); |
| 48 | 47 | |
| 49 | 48 | private: |
| 50 | - | |
| 51 | 49 | /** |
| 52 | 50 | * @brief Used by the timer to pause the animation |
| 53 | 51 | * |
| ... | ... | @@ -71,13 +69,12 @@ private: |
| 71 | 69 | void AddBackgroundActors(Dali::Actor layer, int count); |
| 72 | 70 | |
| 73 | 71 | private: |
| 74 | - | |
| 75 | 72 | using AnimationList = std::vector<Dali::Animation>; |
| 76 | 73 | |
| 77 | - Dali::WeakHandle<Dali::Actor> mScrollView; ///< Weak handle to the scroll view used to apply a parallax effect when scrolling. | |
| 78 | - AnimationList mBackgroundAnimations; ///< List of background bubble animations. | |
| 79 | - Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period. | |
| 80 | - bool mBackgroundAnimsPlaying{false}; ///< Are background animations playing. | |
| 74 | + Dali::WeakHandle<Dali::Actor> mScrollView; ///< Weak handle to the scroll view used to apply a parallax effect when scrolling. | |
| 75 | + AnimationList mBackgroundAnimations; ///< List of background bubble animations. | |
| 76 | + Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period. | |
| 77 | + bool mBackgroundAnimsPlaying{false}; ///< Are background animations playing. | |
| 81 | 78 | }; |
| 82 | 79 | |
| 83 | 80 | #endif // DALI_DEMO_BUBBLE_ANIMATOR_H | ... | ... |
shared/dali-table-view.cpp
100755 โ 100644
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -19,13 +19,9 @@ |
| 19 | 19 | #include "dali-table-view.h" |
| 20 | 20 | |
| 21 | 21 | // EXTERNAL INCLUDES |
| 22 | -#include <dali/devel-api/actors/actor-devel.h> | |
| 23 | -#include <dali/devel-api/images/distance-field.h> | |
| 24 | -#include <dali-toolkit/devel-api/controls/control-devel.h> | |
| 25 | -#include <dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h> | |
| 26 | -#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h> | |
| 27 | 22 | #include <dali-toolkit/dali-toolkit.h> |
| 28 | 23 | #include <dali-toolkit/devel-api/accessibility-manager/accessibility-manager.h> |
| 24 | +#include <dali-toolkit/devel-api/controls/control-devel.h> | |
| 29 | 25 | #include <dali-toolkit/devel-api/controls/table-view/table-view.h> |
| 30 | 26 | #include <dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h> |
| 31 | 27 | #include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h> |
| ... | ... | @@ -65,7 +61,7 @@ const float BUTTON_PRESS_ANIMATION_TIME = 0.35f; ///< Time to perform button s |
| 65 | 61 | const int EXAMPLES_PER_ROW = 3; |
| 66 | 62 | const int ROWS_PER_PAGE = 3; |
| 67 | 63 | const int EXAMPLES_PER_PAGE = EXAMPLES_PER_ROW * ROWS_PER_PAGE; |
| 68 | -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. | |
| 64 | +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. | |
| 69 | 65 | |
| 70 | 66 | const char* const DEMO_BUILD_DATE = __DATE__ " " __TIME__; |
| 71 | 67 | |
| ... | ... | @@ -159,8 +155,7 @@ Dali::Toolkit::Popup CreateVersionPopup(Application& application, ConnectionTrac |
| 159 | 155 | // Hide the popup when touched outside |
| 160 | 156 | popup.OutsideTouchedSignal().Connect( |
| 161 | 157 | &connectionTracker, |
| 162 | - [popup]() mutable | |
| 163 | - { | |
| 158 | + [popup]() mutable { | |
| 164 | 159 | if(popup && (popup.GetDisplayState() == Toolkit::Popup::SHOWN)) |
| 165 | 160 | { |
| 166 | 161 | popup.SetDisplayState(Popup::HIDDEN); |
| ... | ... | @@ -399,7 +394,7 @@ void DaliTableView::Populate() |
| 399 | 394 | { |
| 400 | 395 | if(mSortAlphabetically) |
| 401 | 396 | { |
| 402 | - sort(mExampleList.begin(), mExampleList.end(), [](auto& lhs, auto& rhs)->bool { return lhs.title < rhs.title; } ); | |
| 397 | + sort(mExampleList.begin(), mExampleList.end(), [](auto& lhs, auto& rhs) -> bool { return lhs.title < rhs.title; }); | |
| 403 | 398 | } |
| 404 | 399 | |
| 405 | 400 | unsigned int exampleCount = 0; |
| ... | ... | @@ -501,7 +496,7 @@ Actor DaliTableView::CreateTile(const std::string& name, const std::string& titl |
| 501 | 496 | focusableTile.TouchedSignal().Connect(this, &DaliTableView::OnTilePressed); |
| 502 | 497 | focusableTile.HoveredSignal().Connect(this, &DaliTableView::OnTileHovered); |
| 503 | 498 | focusableTile.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::PUSH_BUTTON); |
| 504 | - DevelControl::AccessibilityActivateSignal(focusableTile).Connect(this, [=](){ | |
| 499 | + DevelControl::AccessibilityActivateSignal(focusableTile).Connect(this, [=]() { | |
| 505 | 500 | DoTilePress(focusableTile, PointState::DOWN); |
| 506 | 501 | DoTilePress(focusableTile, PointState::UP); |
| 507 | 502 | }); |
| ... | ... | @@ -532,7 +527,7 @@ bool DaliTableView::DoTilePress(Actor actor, PointState::Type pointState) |
| 532 | 527 | // ignore Example button presses when scrolling or button animating. |
| 533 | 528 | if((!mScrolling) && (!mPressedAnimation)) |
| 534 | 529 | { |
| 535 | - std::string name = actor.GetProperty<std::string>(Dali::Actor::Property::NAME); | |
| 530 | + std::string name = actor.GetProperty<std::string>(Dali::Actor::Property::NAME); | |
| 536 | 531 | for(Example& example : mExampleList) |
| 537 | 532 | { |
| 538 | 533 | if(example.name == name) | ... | ... |
shared/dali-table-view.h
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | #define DALI_DEMO_TABLEVIEW_H |
| 3 | 3 | |
| 4 | 4 | /* |
| 5 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 5 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 6 | 6 | * |
| 7 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | 8 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -33,7 +33,6 @@ |
| 33 | 33 | class DaliTableView : public Dali::ConnectionTracker |
| 34 | 34 | { |
| 35 | 35 | public: |
| 36 | - | |
| 37 | 36 | /** |
| 38 | 37 | * Constructor |
| 39 | 38 | * |
| ... | ... | @@ -66,7 +65,7 @@ public: |
| 66 | 65 | */ |
| 67 | 66 | void SortAlphabetically(bool sortAlphabetically); |
| 68 | 67 | |
| 69 | -private: // Application callbacks & implementation | |
| 68 | +private: // Application callbacks & implementation | |
| 70 | 69 | static constexpr unsigned int FOCUS_ANIMATION_ACTOR_NUMBER = 2; ///< The number of elements used to form the custom focus effect |
| 71 | 70 | |
| 72 | 71 | /** |
| ... | ... | @@ -239,14 +238,14 @@ private: |
| 239 | 238 | }; |
| 240 | 239 | FocusEffect mFocusEffect[FOCUS_ANIMATION_ACTOR_NUMBER]; ///< The elements used to create the custom focus effect |
| 241 | 240 | |
| 242 | - std::vector<Dali::Actor> mPages; ///< List of pages. | |
| 243 | - ExampleList mExampleList; ///< List of examples. | |
| 241 | + std::vector<Dali::Actor> mPages; ///< List of pages. | |
| 242 | + ExampleList mExampleList; ///< List of examples. | |
| 244 | 243 | |
| 245 | 244 | float mPageWidth; ///< The width of a page within the scroll-view, used to calculate the domain |
| 246 | 245 | int mTotalPages; ///< Total pages within scrollview. |
| 247 | 246 | |
| 248 | - bool mScrolling : 1; ///< Flag indicating whether view is currently being scrolled | |
| 249 | - bool mSortAlphabetically : 1; ///< Sort examples alphabetically. | |
| 247 | + bool mScrolling : 1; ///< Flag indicating whether view is currently being scrolled | |
| 248 | + bool mSortAlphabetically : 1; ///< Sort examples alphabetically. | |
| 250 | 249 | }; |
| 251 | 250 | |
| 252 | 251 | #endif // DALI_DEMO_TABLEVIEW_H | ... | ... |
shared/example.h
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | #define DALI_DEMO_EXAMPLE_H |
| 3 | 3 | |
| 4 | 4 | /* |
| 5 | - * Copyright (c) 2020 Samsung Electronics Co., Ltd. | |
| 5 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | |
| 6 | 6 | * |
| 7 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | 8 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -49,7 +49,7 @@ struct Example |
| 49 | 49 | std::string title; ///< title (caption) of example to appear on tile button. |
| 50 | 50 | }; |
| 51 | 51 | |
| 52 | -using ExampleList = std::vector<Example>; | |
| 52 | +using ExampleList = std::vector<Example>; | |
| 53 | 53 | using ExampleListConstIter = ExampleList::const_iterator; |
| 54 | 54 | |
| 55 | 55 | #endif // DALI_DEMO_SHARED_EXAMPLE_H | ... | ... |