Commit 888de069f8cb0dd95e90994474c488cfd8f5bbb0
[dali_1.4.28] Merge branch 'devel/master'
Change-Id: I3c15f334aad8a541c0e5228a5ea41fbf58684c1d
Showing
19 changed files
with
633 additions
and
38 deletions
builder/dali-builder.cpp
| ... | ... | @@ -27,6 +27,7 @@ |
| 27 | 27 | //------------------------------------------------------------------------------ |
| 28 | 28 | |
| 29 | 29 | #include <dali/dali.h> |
| 30 | +#include <dali/devel-api/adaptor-framework/file-loader.h> | |
| 30 | 31 | #include <dali-toolkit/dali-toolkit.h> |
| 31 | 32 | #include <dali-toolkit/devel-api/builder/builder.h> |
| 32 | 33 | #include <dali-toolkit/devel-api/builder/tree-node.h> |
| ... | ... | @@ -102,10 +103,16 @@ private: |
| 102 | 103 | std::time_t mLastTime; |
| 103 | 104 | std::string mstringPath; |
| 104 | 105 | |
| 105 | - std::string GetFileContents(const std::string &fn) | |
| 106 | + std::string GetFileContents(const std::string &filename) | |
| 106 | 107 | { |
| 107 | - std::ifstream t(fn.c_str()); | |
| 108 | - return std::string((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>()); | |
| 108 | + std::streampos bufferSize = 0; | |
| 109 | + Dali::Vector<char> fileBuffer; | |
| 110 | + if( !Dali::FileLoader::ReadFile( filename, bufferSize, fileBuffer, FileLoader::FileType::BINARY ) ) | |
| 111 | + { | |
| 112 | + return std::string(); | |
| 113 | + } | |
| 114 | + | |
| 115 | + return std::string( &fileBuffer[0], bufferSize ); | |
| 109 | 116 | }; |
| 110 | 117 | }; |
| 111 | 118 | ... | ... |
com.samsung.dali-demo.xml
| ... | ... | @@ -296,6 +296,15 @@ |
| 296 | 296 | <ui-application appid="gestures.example" exec="/usr/apps/com.samsung.dali-demo/bin/gestures.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 297 | 297 | <label>Gestures</label> |
| 298 | 298 | </ui-application> |
| 299 | + <ui-application appid="visual-fitting-mode.example" exec="/usr/apps/com.samsung.dali-demo/bin/visual-fitting-mode.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 300 | + <label>Visual Fitting Mode</label> | |
| 301 | + </ui-application> | |
| 302 | + <ui-application appid="gaussian-blur-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/gaussian-blur-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 303 | + <label>Gaussian Blur</label> | |
| 304 | + </ui-application> | |
| 305 | + <ui-application appid="super-blur-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/super-blur-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 306 | + <label>Super Blur</label> | |
| 307 | + </ui-application> | |
| 299 | 308 | |
| 300 | 309 | <privileges> |
| 301 | 310 | <privilege>http://tizen.org/privilege/mediastorage</privilege> | ... | ... |
examples-reel/dali-examples-reel.cpp
| ... | ... | @@ -50,6 +50,7 @@ int DALI_EXPORT_API main(int argc, char **argv) |
| 50 | 50 | demo.AddExample(Example("flex-container.example", DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND)); |
| 51 | 51 | demo.AddExample(Example("frame-callback.example", DALI_DEMO_STR_TITLE_FRAME_CALLBACK)); |
| 52 | 52 | demo.AddExample(Example("focus-integration.example", DALI_DEMO_STR_TITLE_FOCUS_INTEGRATION)); |
| 53 | + demo.AddExample(Example("gaussian-blur-view.example", DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW)); | |
| 53 | 54 | demo.AddExample(Example("gestures.example", DALI_DEMO_STR_TITLE_GESTURES)); |
| 54 | 55 | demo.AddExample(Example("gradients.example", DALI_DEMO_STR_TITLE_COLOR_GRADIENT)); |
| 55 | 56 | demo.AddExample(Example("hello-world.example", DALI_DEMO_STR_TITLE_HELLO_WORLD)); |
| ... | ... | @@ -80,6 +81,7 @@ int DALI_EXPORT_API main(int argc, char **argv) |
| 80 | 81 | demo.AddExample(Example("scroll-view.example", DALI_DEMO_STR_TITLE_SCROLL_VIEW)); |
| 81 | 82 | demo.AddExample(Example("size-negotiation.example", DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE)); |
| 82 | 83 | demo.AddExample(Example("styling.example", DALI_DEMO_STR_TITLE_STYLING)); |
| 84 | + demo.AddExample(Example("super-blur-view.example", DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW)); | |
| 83 | 85 | demo.AddExample(Example("text-editor.example", DALI_DEMO_STR_TITLE_TEXT_EDITOR)); |
| 84 | 86 | demo.AddExample(Example("text-field.example", DALI_DEMO_STR_TITLE_TEXT_FIELD)); |
| 85 | 87 | demo.AddExample(Example("text-label.example", DALI_DEMO_STR_TITLE_TEXT_LABEL)); | ... | ... |
examples/builder/examples.cpp
| ... | ... | @@ -43,6 +43,7 @@ |
| 43 | 43 | #include <cstring> |
| 44 | 44 | |
| 45 | 45 | #include <dali/integration-api/debug.h> |
| 46 | +#include <dali/devel-api/adaptor-framework/file-loader.h> | |
| 46 | 47 | #include "shared/view.h" |
| 47 | 48 | |
| 48 | 49 | #define TOKEN_STRING(x) #x |
| ... | ... | @@ -86,9 +87,14 @@ std::string ReplaceQuotes(const std::string &single_quoted) |
| 86 | 87 | |
| 87 | 88 | std::string GetFileContents(const std::string &fn) |
| 88 | 89 | { |
| 89 | - std::ifstream t(fn.c_str()); | |
| 90 | - return std::string((std::istreambuf_iterator<char>(t)), | |
| 91 | - std::istreambuf_iterator<char>()); | |
| 90 | + std::streampos bufferSize = 0; | |
| 91 | + Dali::Vector<char> fileBuffer; | |
| 92 | + if( !Dali::FileLoader::ReadFile( fn, bufferSize, fileBuffer, FileLoader::FileType::BINARY ) ) | |
| 93 | + { | |
| 94 | + return std::string(); | |
| 95 | + } | |
| 96 | + | |
| 97 | + return std::string( &fileBuffer[0], bufferSize ); | |
| 92 | 98 | }; |
| 93 | 99 | |
| 94 | 100 | typedef std::vector<std::string> FileList; | ... | ... |
examples/fpp-game/game-utils.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2016 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2019 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,6 +17,8 @@ |
| 17 | 17 | |
| 18 | 18 | #include <inttypes.h> |
| 19 | 19 | #include <stdio.h> |
| 20 | +#include <dali/integration-api/debug.h> | |
| 21 | +#include <dali/devel-api/adaptor-framework/file-stream.h> | |
| 20 | 22 | |
| 21 | 23 | #include "game-utils.h" |
| 22 | 24 | |
| ... | ... | @@ -24,25 +26,25 @@ namespace GameUtils |
| 24 | 26 | { |
| 25 | 27 | bool LoadFile( const char* filename, ByteArray& bytes ) |
| 26 | 28 | { |
| 27 | - FILE* fin = fopen( filename, "rb" ); | |
| 29 | + Dali::FileStream fileStream( filename, Dali::FileStream::READ | Dali::FileStream::BINARY ); | |
| 30 | + FILE* fin = fileStream.GetFile(); | |
| 31 | + | |
| 28 | 32 | if( fin ) |
| 29 | 33 | { |
| 30 | 34 | if( fseek( fin, 0, SEEK_END ) ) |
| 31 | 35 | { |
| 32 | - fclose(fin); | |
| 33 | 36 | return false; |
| 34 | 37 | } |
| 35 | 38 | bytes.resize( ftell( fin ) ); |
| 36 | 39 | std::fill( bytes.begin(), bytes.end(), 0 ); |
| 37 | 40 | if( fseek( fin, 0, SEEK_SET ) ) |
| 38 | 41 | { |
| 39 | - fclose( fin ); | |
| 40 | 42 | return false; |
| 41 | 43 | } |
| 42 | 44 | size_t result = fread( bytes.data(), 1, bytes.size(), fin ); |
| 43 | - fclose( fin ); | |
| 44 | 45 | return ( result != 0 ); |
| 45 | 46 | } |
| 47 | + | |
| 46 | 48 | return false; |
| 47 | 49 | } |
| 48 | 50 | ... | ... |
examples/gaussian-blur-view/gaussian-blur-view-example.cpp
0 โ 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2019 Samsung Electronics Co., Ltd. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + * | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#include <algorithm> | |
| 19 | + | |
| 20 | +#include <dali-toolkit/dali-toolkit.h> | |
| 21 | +#include <dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h> | |
| 22 | + | |
| 23 | +using namespace Dali; | |
| 24 | +using Dali::Toolkit::TextLabel; | |
| 25 | +using Dali::Toolkit::GaussianBlurView; | |
| 26 | + | |
| 27 | +namespace | |
| 28 | +{ | |
| 29 | + | |
| 30 | +const char* const BACKGROUND_IMAGE( DEMO_IMAGE_DIR "lake_front.jpg" ); | |
| 31 | +const float BACKGROUND_IMAGE_WIDTH = 2048.0f; | |
| 32 | + | |
| 33 | +} | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * This example shows a scrolling background image which can be blurred (on/off) by tapping the screen | |
| 37 | + */ | |
| 38 | +class GaussianBlurViewExample : public ConnectionTracker | |
| 39 | +{ | |
| 40 | +public: | |
| 41 | + | |
| 42 | + GaussianBlurViewExample( Application& application ) | |
| 43 | + : mApplication( application ), | |
| 44 | + mExcessWidth( 0.0f ), | |
| 45 | + mStrength( 1.0f ) | |
| 46 | + { | |
| 47 | + mApplication.InitSignal().Connect( this, &GaussianBlurViewExample::Create ); | |
| 48 | + } | |
| 49 | + | |
| 50 | + ~GaussianBlurViewExample() = default; | |
| 51 | + | |
| 52 | +private: | |
| 53 | + | |
| 54 | + void Create( Application& application ) | |
| 55 | + { | |
| 56 | + Stage stage = Stage::GetCurrent(); | |
| 57 | + Vector2 stageSize = stage.GetSize(); | |
| 58 | + stage.KeyEventSignal().Connect(this, &GaussianBlurViewExample::OnKeyEvent); | |
| 59 | + | |
| 60 | + mImageView = Toolkit::ImageView::New( BACKGROUND_IMAGE ); | |
| 61 | + mImageView.SetParentOrigin( ParentOrigin::CENTER ); | |
| 62 | + mImageView.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 63 | + | |
| 64 | + stage.Add( mImageView ); | |
| 65 | + | |
| 66 | + float excessWidth = std::max( 0.0f, (BACKGROUND_IMAGE_WIDTH - stageSize.width) * 0.5f ); | |
| 67 | + | |
| 68 | + if( excessWidth > 0.0f ) | |
| 69 | + { | |
| 70 | + // Move background image to show GaussianBlurView activity | |
| 71 | + | |
| 72 | + float pixelsPerSecond = 10.0f; | |
| 73 | + float duration = excessWidth / pixelsPerSecond; | |
| 74 | + float qDuration = duration * 0.25f; | |
| 75 | + | |
| 76 | + mAnimation = Animation::New( duration ); | |
| 77 | + mAnimation.AnimateTo( Property(mImageView, Actor::Property::POSITION_X), excessWidth, TimePeriod(0.0f , qDuration) ); | |
| 78 | + mAnimation.AnimateTo( Property(mImageView, Actor::Property::POSITION_X), 0.0f, TimePeriod(qDuration , qDuration) ); | |
| 79 | + mAnimation.AnimateTo( Property(mImageView, Actor::Property::POSITION_X), -excessWidth, TimePeriod(2.0f*qDuration, qDuration) ); | |
| 80 | + mAnimation.AnimateTo( Property(mImageView, Actor::Property::POSITION_X), 0.0f, TimePeriod(3.0f*qDuration, qDuration) ); | |
| 81 | + | |
| 82 | + mAnimation.SetLooping( true ); | |
| 83 | + mAnimation.Play(); | |
| 84 | + } | |
| 85 | + | |
| 86 | + Layer onTop = Layer::New(); | |
| 87 | + onTop.SetParentOrigin( ParentOrigin::CENTER ); | |
| 88 | + onTop.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 89 | + onTop.SetSize( stageSize ); | |
| 90 | + stage.Add( onTop ); | |
| 91 | + onTop.RaiseToTop(); | |
| 92 | + | |
| 93 | + mOnLabel = TextLabel::New( "Blur ON" ); | |
| 94 | + mOnLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 95 | + mOnLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN ); | |
| 96 | + mOnLabel.SetVisible( false ); | |
| 97 | + onTop.Add( mOnLabel ); | |
| 98 | + | |
| 99 | + mOffLabel = TextLabel::New( "Blur OFF" ); | |
| 100 | + mOffLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 101 | + mOffLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::WHITE ); | |
| 102 | + mOffLabel.SetVisible( true ); | |
| 103 | + onTop.Add( mOffLabel ); | |
| 104 | + | |
| 105 | + stage.GetRootLayer().TouchSignal().Connect( this, &GaussianBlurViewExample::OnTouch ); | |
| 106 | + } | |
| 107 | + | |
| 108 | + bool OnTouch( Actor actor, const TouchData& touch ) | |
| 109 | + { | |
| 110 | + const PointState::Type state = touch.GetState( 0 ); | |
| 111 | + | |
| 112 | + if( PointState::DOWN == state ) | |
| 113 | + { | |
| 114 | + Stage stage = Stage::GetCurrent(); | |
| 115 | + | |
| 116 | + // Enable/disable blur effect | |
| 117 | + | |
| 118 | + if( !mGaussianBlurView ) | |
| 119 | + { | |
| 120 | + mGaussianBlurView = GaussianBlurView::New( 30, 8.0f, Pixel::RGBA8888, 0.5f, 0.5f, false ); | |
| 121 | + mGaussianBlurView.SetParentOrigin( ParentOrigin::CENTER ); | |
| 122 | + mGaussianBlurView.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 123 | + mGaussianBlurView.SetSize( stage.GetSize() ); | |
| 124 | + stage.Add( mGaussianBlurView ); | |
| 125 | + | |
| 126 | + mGaussianBlurView.Add( mImageView ); | |
| 127 | + mGaussianBlurView.Activate(); | |
| 128 | + | |
| 129 | + mGaussianBlurView.SetProperty( mGaussianBlurView.GetBlurStrengthPropertyIndex(), mStrength ); | |
| 130 | + | |
| 131 | + mOnLabel.SetVisible( true ); | |
| 132 | + mOffLabel.SetVisible( false ); | |
| 133 | + } | |
| 134 | + else | |
| 135 | + { | |
| 136 | + stage.Add( mImageView ); | |
| 137 | + | |
| 138 | + UnparentAndReset( mGaussianBlurView ); | |
| 139 | + | |
| 140 | + mOnLabel.SetVisible( false ); | |
| 141 | + mOffLabel.SetVisible( true ); | |
| 142 | + } | |
| 143 | + | |
| 144 | + } | |
| 145 | + | |
| 146 | + return true; | |
| 147 | + } | |
| 148 | + | |
| 149 | + void OnKeyEvent(const KeyEvent& event) | |
| 150 | + { | |
| 151 | + if(event.state == KeyEvent::Down) | |
| 152 | + { | |
| 153 | + if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) | |
| 154 | + { | |
| 155 | + mApplication.Quit(); | |
| 156 | + } | |
| 157 | + } | |
| 158 | + } | |
| 159 | + | |
| 160 | +private: | |
| 161 | + | |
| 162 | + Application& mApplication; | |
| 163 | + | |
| 164 | + Toolkit::ImageView mImageView; | |
| 165 | + | |
| 166 | + Animation mAnimation; | |
| 167 | + | |
| 168 | + TextLabel mOnLabel; | |
| 169 | + TextLabel mOffLabel; | |
| 170 | + | |
| 171 | + GaussianBlurView mGaussianBlurView; | |
| 172 | + | |
| 173 | + float mExcessWidth; | |
| 174 | + float mStrength; | |
| 175 | +}; | |
| 176 | + | |
| 177 | +int DALI_EXPORT_API main( int argc, char **argv ) | |
| 178 | +{ | |
| 179 | + Application application = Application::New( &argc, &argv ); | |
| 180 | + | |
| 181 | + GaussianBlurViewExample test( application ); | |
| 182 | + | |
| 183 | + application.MainLoop(); | |
| 184 | + | |
| 185 | + return 0; | |
| 186 | +} | ... | ... |
examples/ray-marching/ray-marching-example.cpp
| ... | ... | @@ -20,6 +20,8 @@ |
| 20 | 20 | #include "shared/view.h" |
| 21 | 21 | #include "shared/utility.h" |
| 22 | 22 | #include <stdio.h> |
| 23 | +#include <dali/integration-api/debug.h> | |
| 24 | +#include <dali/devel-api/adaptor-framework/file-stream.h> | |
| 23 | 25 | |
| 24 | 26 | using namespace Dali; |
| 25 | 27 | using Dali::Toolkit::TextLabel; |
| ... | ... | @@ -41,14 +43,16 @@ bool LoadShaderCode( const char* path, const char* filename, std::vector<char>& |
| 41 | 43 | { |
| 42 | 44 | std::string fullpath( path ); |
| 43 | 45 | fullpath += filename; |
| 44 | - FILE* file = fopen( fullpath.c_str(), "rb" ); | |
| 45 | - if( ! file ) | |
| 46 | + | |
| 47 | + Dali::FileStream fileStream( fullpath, Dali::FileStream::READ | Dali::FileStream::BINARY ); | |
| 48 | + FILE* file = fileStream.GetFile(); | |
| 49 | + if( !file ) | |
| 46 | 50 | { |
| 47 | 51 | return false; |
| 48 | 52 | } |
| 49 | 53 | |
| 50 | 54 | bool retValue = false; |
| 51 | - if( ! fseek( file, 0, SEEK_END ) ) | |
| 55 | + if( !fseek( file, 0, SEEK_END ) ) | |
| 52 | 56 | { |
| 53 | 57 | long int size = ftell( file ); |
| 54 | 58 | |
| ... | ... | @@ -63,7 +67,6 @@ bool LoadShaderCode( const char* path, const char* filename, std::vector<char>& |
| 63 | 67 | } |
| 64 | 68 | } |
| 65 | 69 | |
| 66 | - fclose( file ); | |
| 67 | 70 | return retValue; |
| 68 | 71 | } |
| 69 | 72 | ... | ... |
examples/refraction-effect/refraction-effect-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2017 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2019 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,9 @@ |
| 19 | 19 | #include <dali/dali.h> |
| 20 | 20 | #include <dali-toolkit/dali-toolkit.h> |
| 21 | 21 | #include <dali-toolkit/devel-api/controls/buttons/button-devel.h> |
| 22 | +#include <dali/integration-api/debug.h> | |
| 23 | +#include <dali/devel-api/adaptor-framework/file-loader.h> | |
| 22 | 24 | |
| 23 | -#include <fstream> | |
| 24 | 25 | #include <sstream> |
| 25 | 26 | #include <limits> |
| 26 | 27 | |
| ... | ... | @@ -471,14 +472,22 @@ private: |
| 471 | 472 | std::vector<Vector3>& vertexPositions, |
| 472 | 473 | Vector<unsigned int>& faceIndices) |
| 473 | 474 | { |
| 474 | - std::ifstream ifs( objFileName.c_str(), std::ios::in ); | |
| 475 | + std::streampos bufferSize = 0; | |
| 476 | + Dali::Vector<char> fileBuffer; | |
| 477 | + if( !Dali::FileLoader::ReadFile( objFileName, bufferSize, fileBuffer, Dali::FileLoader::FileType::TEXT ) ) | |
| 478 | + { | |
| 479 | + DALI_LOG_WARNING( "file open failed for: \"%s\"", objFileName ); | |
| 480 | + return; | |
| 481 | + } | |
| 482 | + | |
| 483 | + std::stringstream iss( &fileBuffer[0], std::ios::in ); | |
| 475 | 484 | |
| 476 | 485 | boundingBox.Resize( 6 ); |
| 477 | 486 | boundingBox[0]=boundingBox[2]=boundingBox[4] = std::numeric_limits<float>::max(); |
| 478 | 487 | boundingBox[1]=boundingBox[3]=boundingBox[5] = -std::numeric_limits<float>::max(); |
| 479 | 488 | |
| 480 | 489 | std::string line; |
| 481 | - while( std::getline( ifs, line ) ) | |
| 490 | + while( std::getline( iss, line ) ) | |
| 482 | 491 | { |
| 483 | 492 | if( line[0] == 'v' && std::isspace(line[1])) // vertex |
| 484 | 493 | { |
| ... | ... | @@ -518,8 +527,6 @@ private: |
| 518 | 527 | faceIndices.PushBack( indices[2*step]-1 ); |
| 519 | 528 | } |
| 520 | 529 | } |
| 521 | - | |
| 522 | - ifs.close(); | |
| 523 | 530 | } |
| 524 | 531 | |
| 525 | 532 | void ShapeResizeAndTexureCoordinateCalculation( const Vector<float>& boundingBox, | ... | ... |
examples/rendering-basic-pbr/ktx-loader.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2017 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2019 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,6 +22,8 @@ |
| 22 | 22 | #include <memory.h> |
| 23 | 23 | #include <stdio.h> |
| 24 | 24 | #include <stdint.h> |
| 25 | +#include <dali/integration-api/debug.h> | |
| 26 | +#include <dali/devel-api/adaptor-framework/file-stream.h> | |
| 25 | 27 | |
| 26 | 28 | namespace PbrDemo |
| 27 | 29 | { |
| ... | ... | @@ -92,8 +94,8 @@ bool ConvertPixelFormat(const uint32_t ktxPixelFormat, Dali::Pixel::Format& form |
| 92 | 94 | |
| 93 | 95 | bool LoadCubeMapFromKtxFile( const std::string& path, CubeData& cubedata ) |
| 94 | 96 | { |
| 95 | - FILE* fp = fopen(path.c_str(),"rb"); | |
| 96 | - | |
| 97 | + Dali::FileStream fileStream( path, Dali::FileStream::READ | Dali::FileStream::BINARY ); | |
| 98 | + FILE* fp = fileStream.GetFile(); | |
| 97 | 99 | if( NULL == fp ) |
| 98 | 100 | { |
| 99 | 101 | return false; |
| ... | ... | @@ -104,7 +106,6 @@ bool LoadCubeMapFromKtxFile( const std::string& path, CubeData& cubedata ) |
| 104 | 106 | int result = fread(&header,1,sizeof(KtxFileHeader),fp); |
| 105 | 107 | if( 0 == result ) |
| 106 | 108 | { |
| 107 | - fclose( fp ); | |
| 108 | 109 | return false; |
| 109 | 110 | } |
| 110 | 111 | |
| ... | ... | @@ -115,14 +116,12 @@ bool LoadCubeMapFromKtxFile( const std::string& path, CubeData& cubedata ) |
| 115 | 116 | |
| 116 | 117 | if( fseek(fp, imageSizeOffset, SEEK_END) ) |
| 117 | 118 | { |
| 118 | - fclose( fp ); | |
| 119 | 119 | return false; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | lSize = ftell(fp); |
| 123 | 123 | if( lSize == -1L ) |
| 124 | 124 | { |
| 125 | - fclose( fp ); | |
| 126 | 125 | return false; |
| 127 | 126 | } |
| 128 | 127 | |
| ... | ... | @@ -130,7 +129,6 @@ bool LoadCubeMapFromKtxFile( const std::string& path, CubeData& cubedata ) |
| 130 | 129 | |
| 131 | 130 | if( fseek(fp, imageSizeOffset, SEEK_SET) ) |
| 132 | 131 | { |
| 133 | - fclose( fp ); | |
| 134 | 132 | return false; |
| 135 | 133 | } |
| 136 | 134 | ... | ... |
examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2017 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2019 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. |
| ... | ... | @@ -25,6 +25,8 @@ |
| 25 | 25 | #include "ktx-loader.h" |
| 26 | 26 | #include "model-skybox.h" |
| 27 | 27 | #include "model-pbr.h" |
| 28 | +#include <dali/integration-api/debug.h> | |
| 29 | +#include <dali/devel-api/adaptor-framework/file-stream.h> | |
| 28 | 30 | |
| 29 | 31 | using namespace Dali; |
| 30 | 32 | using namespace Toolkit; |
| ... | ... | @@ -390,7 +392,8 @@ public: |
| 390 | 392 | */ |
| 391 | 393 | bool LoadShaderCode( const std::string& fullpath, std::vector<char>& output ) |
| 392 | 394 | { |
| 393 | - FILE* file = fopen( fullpath.c_str(), "rb" ); | |
| 395 | + Dali::FileStream fileStream( fullpath, FileStream::READ | FileStream::BINARY ); | |
| 396 | + FILE* file = fileStream.GetFile(); | |
| 394 | 397 | if( NULL == file ) |
| 395 | 398 | { |
| 396 | 399 | return false; |
| ... | ... | @@ -411,7 +414,7 @@ public: |
| 411 | 414 | retValue = ( result >= 0 ); |
| 412 | 415 | } |
| 413 | 416 | } |
| 414 | - fclose( file ); | |
| 417 | + | |
| 415 | 418 | return retValue; |
| 416 | 419 | } |
| 417 | 420 | ... | ... |
examples/simple-text-renderer/simple-text-renderer-example.cpp
| ... | ... | @@ -26,9 +26,6 @@ |
| 26 | 26 | #include <dali-toolkit/devel-api/text/text-utils-devel.h> |
| 27 | 27 | #include <devel-api/adaptor-framework/image-loading.h> |
| 28 | 28 | |
| 29 | -#include <iostream> | |
| 30 | -#include <fstream> | |
| 31 | - | |
| 32 | 29 | using namespace std; |
| 33 | 30 | using namespace Dali; |
| 34 | 31 | using namespace Dali::Toolkit; | ... | ... |
examples/super-blur-view/super-blur-view-example.cpp
0 โ 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2019 Samsung Electronics Co., Ltd. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + * | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#include <dali/dali.h> | |
| 19 | +#include <dali-toolkit/dali-toolkit.h> | |
| 20 | +#include <dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.h> | |
| 21 | + | |
| 22 | +using namespace Dali; | |
| 23 | +using Dali::Toolkit::Button; | |
| 24 | +using Dali::Toolkit::PushButton; | |
| 25 | +using Dali::Toolkit::SuperBlurView; | |
| 26 | + | |
| 27 | +namespace | |
| 28 | +{ | |
| 29 | + | |
| 30 | +const char* const BACKGROUND_IMAGE( DEMO_IMAGE_DIR "background-4.jpg" ); | |
| 31 | + | |
| 32 | +const unsigned int DEFAULT_BLUR_LEVEL(5u); ///< The default blur level when creating SuperBlurView from the type registry | |
| 33 | + | |
| 34 | +} | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * This example shows a background image which is "super blurred" while the push-button control is pressed. | |
| 38 | + */ | |
| 39 | +class SuperBlurViewExample : public ConnectionTracker | |
| 40 | +{ | |
| 41 | +public: | |
| 42 | + | |
| 43 | + SuperBlurViewExample( Application& application ) | |
| 44 | + : mApplication( application ) | |
| 45 | + { | |
| 46 | + mApplication.InitSignal().Connect( this, &SuperBlurViewExample::Create ); | |
| 47 | + } | |
| 48 | + | |
| 49 | + ~SuperBlurViewExample() = default; | |
| 50 | + | |
| 51 | +private: | |
| 52 | + | |
| 53 | + void Create( Application& application ) | |
| 54 | + { | |
| 55 | + Stage stage = Stage::GetCurrent(); | |
| 56 | + stage.KeyEventSignal().Connect( this, &SuperBlurViewExample::OnKeyEvent ); | |
| 57 | + | |
| 58 | + mSuperBlurView = SuperBlurView::New( DEFAULT_BLUR_LEVEL ); | |
| 59 | + mSuperBlurView.SetParentOrigin( ParentOrigin::CENTER ); | |
| 60 | + mSuperBlurView.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 61 | + mSuperBlurView.SetSize( 800, 1280 ); | |
| 62 | + mSuperBlurView.SetProperty( SuperBlurView::Property::IMAGE_URL, BACKGROUND_IMAGE ); | |
| 63 | + stage.Add( mSuperBlurView ); | |
| 64 | + | |
| 65 | + mBlurAnimation = Animation::New(1.0f); | |
| 66 | + mBlurAnimation.AnimateTo( Property(mSuperBlurView, mSuperBlurView.GetBlurStrengthPropertyIndex()), 1.0f ); | |
| 67 | + | |
| 68 | + mClearAnimation = Animation::New(1.0f); | |
| 69 | + mClearAnimation.AnimateTo( Property(mSuperBlurView, mSuperBlurView.GetBlurStrengthPropertyIndex()), 0.0f ); | |
| 70 | + | |
| 71 | + mPushButton = PushButton::New(); | |
| 72 | + mPushButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); | |
| 73 | + mPushButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | |
| 74 | + mPushButton.SetProperty( Button::Property::LABEL_TEXT, "Blur" ); | |
| 75 | + mPushButton.PressedSignal().Connect( this, &SuperBlurViewExample::OnButtonPressed ); | |
| 76 | + mPushButton.ReleasedSignal().Connect( this, &SuperBlurViewExample::OnButtonReleased ); | |
| 77 | + stage.Add( mPushButton ); | |
| 78 | + } | |
| 79 | + | |
| 80 | + bool OnButtonPressed( Button button ) | |
| 81 | + { | |
| 82 | + mBlurAnimation.Play(); | |
| 83 | + return true; | |
| 84 | + } | |
| 85 | + | |
| 86 | + bool OnButtonReleased( Button button ) | |
| 87 | + { | |
| 88 | + mClearAnimation.Play(); | |
| 89 | + return true; | |
| 90 | + } | |
| 91 | + | |
| 92 | + void OnKeyEvent( const KeyEvent& event ) | |
| 93 | + { | |
| 94 | + if ( event.state == KeyEvent::Down ) | |
| 95 | + { | |
| 96 | + if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) | |
| 97 | + { | |
| 98 | + mApplication.Quit(); | |
| 99 | + } | |
| 100 | + } | |
| 101 | + } | |
| 102 | + | |
| 103 | +private: | |
| 104 | + | |
| 105 | + Application& mApplication; | |
| 106 | + | |
| 107 | + SuperBlurView mSuperBlurView; | |
| 108 | + | |
| 109 | + PushButton mPushButton; | |
| 110 | + | |
| 111 | + Animation mBlurAnimation; | |
| 112 | + Animation mClearAnimation; | |
| 113 | +}; | |
| 114 | + | |
| 115 | +int DALI_EXPORT_API main( int argc, char **argv ) | |
| 116 | +{ | |
| 117 | + Application application = Application::New( &argc, &argv ); | |
| 118 | + | |
| 119 | + SuperBlurViewExample test( application ); | |
| 120 | + | |
| 121 | + application.MainLoop(); | |
| 122 | + | |
| 123 | + return 0; | |
| 124 | +} | ... | ... |
examples/visual-fitting-mode/visual-fitting-mode-example.cpp
0 โ 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2019 Samsung Electronics Co., Ltd. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + * | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#include <dali/devel-api/object/handle-devel.h> | |
| 19 | +#include <dali-toolkit/dali-toolkit.h> | |
| 20 | +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> | |
| 21 | + | |
| 22 | +using namespace Dali; | |
| 23 | +using namespace Dali::Toolkit; | |
| 24 | + | |
| 25 | +namespace | |
| 26 | +{ | |
| 27 | +const char * const IMAGE_NAME = DEMO_IMAGE_DIR "gallery-medium-1.jpg"; ///< The image to use. | |
| 28 | +const Vector3 IMAGE_SIZE = Vector3( 300, 200, 0 ); ///< The size of the image-views. | |
| 29 | + | |
| 30 | +const float BORDER_SIZE = 2.0f; ///< The size of the border. | |
| 31 | +const Property::Value BORDER ///< The border to use for each image-view. | |
| 32 | +{ | |
| 33 | + { Visual::Property::TYPE, Visual::BORDER }, | |
| 34 | + { BorderVisual::Property::COLOR, Color::RED }, | |
| 35 | + { BorderVisual::Property::SIZE, BORDER_SIZE } | |
| 36 | +}; | |
| 37 | +const Extents LARGE_PADDING( 100.0f, 100.0f, 2.0f, 2.0f ); ///< The large padding extents. | |
| 38 | +const Extents BORDER_ONLY_PADDING( BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE ); ///< The border only padding extents. | |
| 39 | + | |
| 40 | +const std::string INSTRUCTIONS_TEXT = "\n(Tap or Key Press To Change)"; ///< Instructions on how to change the padding mode. | |
| 41 | +const std::string LARGE_PADDING_TEXT( "Padding: Left/Right Large" + INSTRUCTIONS_TEXT ); ///< Label to shown when large padding enabled. | |
| 42 | +const std::string BORDER_ONLY_PADDING_TEXT( "Padding: Border Only" + INSTRUCTIONS_TEXT ); ///< Label to shown when border-only padding enabled. | |
| 43 | +const std::string FILL_LABEL( "FILL" ); | |
| 44 | +const std::string FIT_KEEP_ASPECT_LABEL( "FIT\nKEEP ASPECT" ); | |
| 45 | + | |
| 46 | +const Property::Map TEXT_LABEL_PROPERTIES ///< All the properties of the Large Text Label shown in the example. | |
| 47 | +{ | |
| 48 | + { Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER }, | |
| 49 | + { Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER }, | |
| 50 | + { Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT }, | |
| 51 | + { Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT }, | |
| 52 | + { Control::Property::BACKGROUND, | |
| 53 | + { | |
| 54 | + { Toolkit::Visual::Property::TYPE, Visual::GRADIENT }, | |
| 55 | + { GradientVisual::Property::STOP_COLOR, Property::Array{ Vector4( 167.0f, 207.0f, 223.0f, 255.0f ) / 255.0f, | |
| 56 | + Vector4( 0.0f, 64.0f, 137.0f, 255.0f ) / 255.0f } }, | |
| 57 | + { GradientVisual::Property::START_POSITION, Vector2( 0.0f, -0.5f ) }, | |
| 58 | + { GradientVisual::Property::END_POSITION, Vector2( 0.0f, 0.5f ) } | |
| 59 | + } | |
| 60 | + }, | |
| 61 | + { TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::CENTER }, | |
| 62 | + { TextLabel::Property::VERTICAL_ALIGNMENT, VerticalAlignment::CENTER }, | |
| 63 | + { TextLabel::Property::MULTI_LINE, true } | |
| 64 | +}; | |
| 65 | + | |
| 66 | +const Property::Map FILL_IMAGE_PROPERTIES ///< The basic properties of the Fill image view. | |
| 67 | +{ | |
| 68 | + { Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER }, | |
| 69 | + { Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER }, | |
| 70 | + { Actor::Property::SIZE, IMAGE_SIZE }, | |
| 71 | + { Control::Property::BACKGROUND, BORDER } | |
| 72 | +}; | |
| 73 | + | |
| 74 | +const Property::Map FIT_KEEP_ASPECT_RATIO_IMAGE_BASIC_PROPERTIES ///< The basic properties of the Fit Keep Aspect image view. | |
| 75 | +{ | |
| 76 | + { Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER }, | |
| 77 | + { Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER }, | |
| 78 | + { Actor::Property::SIZE, IMAGE_SIZE }, | |
| 79 | + { Control::Property::BACKGROUND, BORDER } | |
| 80 | +}; | |
| 81 | + | |
| 82 | +const Property::Map OVERLAY_LABEL_PROPERTIES ///< The image view overlay label properties | |
| 83 | +{ | |
| 84 | + { TextLabel::Property::TEXT_COLOR, Color::WHITE }, | |
| 85 | + { TextLabel::Property::OUTLINE, { { "color", Color::BLACK }, { "width", 1.0f } } }, | |
| 86 | + { TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::CENTER }, | |
| 87 | + { TextLabel::Property::VERTICAL_ALIGNMENT, VerticalAlignment::CENTER }, | |
| 88 | + { TextLabel::Property::MULTI_LINE, true }, | |
| 89 | +}; | |
| 90 | +} // unnamed namespace | |
| 91 | + | |
| 92 | +/** | |
| 93 | + * @brief This example shows how to use the Dali::Toolkit::DevelVisual::Property::VISUAL_FITTING_MODE property. | |
| 94 | + */ | |
| 95 | +class VisualFittingModeController : public ConnectionTracker | |
| 96 | +{ | |
| 97 | +public: | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * @brief Constructor. | |
| 101 | + * @param[in] application A reference to the Application class. | |
| 102 | + */ | |
| 103 | + VisualFittingModeController( Application& application ) | |
| 104 | + : mApplication( application ), | |
| 105 | + mLargePadding( true ) | |
| 106 | + { | |
| 107 | + // Connect to the Application's Init signal | |
| 108 | + mApplication.InitSignal().Connect( this, &VisualFittingModeController::Create ); | |
| 109 | + } | |
| 110 | + | |
| 111 | +private: | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * @brief Called to initialise the application content | |
| 115 | + * @param[in] application A reference to the Application class. | |
| 116 | + */ | |
| 117 | + void Create( Application& application ) | |
| 118 | + { | |
| 119 | + // Get a handle to the stage | |
| 120 | + Stage stage = Stage::GetCurrent(); | |
| 121 | + stage.SetBackgroundColor( Color::WHITE ); | |
| 122 | + | |
| 123 | + // Text Label filling the entire screen, with a background | |
| 124 | + mTextLabel = DevelHandle::New< TextLabel >( TEXT_LABEL_PROPERTIES ); | |
| 125 | + stage.Add( mTextLabel ); | |
| 126 | + | |
| 127 | + // We want to change the padding when tapping | |
| 128 | + mTapDetector = TapGestureDetector::New(); | |
| 129 | + mTapDetector.Attach( mTextLabel ); | |
| 130 | + mTapDetector.DetectedSignal().Connect( this, &VisualFittingModeController::OnTap ); | |
| 131 | + | |
| 132 | + // Create an ImageView with the default behaviour, i.e. image fills to control size | |
| 133 | + mFillImage = ImageView::New( IMAGE_NAME ); | |
| 134 | + DevelHandle::SetProperties( mFillImage, FILL_IMAGE_PROPERTIES ); | |
| 135 | + stage.Add( mFillImage ); | |
| 136 | + | |
| 137 | + // Create an ImageView that Keeps the aspect ratio while fitting within the given size | |
| 138 | + mFitKeepAspectRatioImage = DevelHandle::New< ImageView >( FIT_KEEP_ASPECT_RATIO_IMAGE_BASIC_PROPERTIES ); | |
| 139 | + mFitKeepAspectRatioImage.SetProperty( ImageView::Property::IMAGE, | |
| 140 | + Property::Map | |
| 141 | + { | |
| 142 | + { Visual::Property::TYPE, Visual::IMAGE }, | |
| 143 | + { ImageVisual::Property::URL, IMAGE_NAME }, | |
| 144 | + { DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FIT_KEEP_ASPECT_RATIO } | |
| 145 | + } ); | |
| 146 | + stage.Add( mFitKeepAspectRatioImage ); | |
| 147 | + | |
| 148 | + // Create an overlay label for fill image | |
| 149 | + Actor fillLabel = TextLabel::New( FILL_LABEL ); | |
| 150 | + DevelHandle::SetProperties( fillLabel, FILL_IMAGE_PROPERTIES ); | |
| 151 | + DevelHandle::SetProperties( fillLabel, OVERLAY_LABEL_PROPERTIES ); | |
| 152 | + stage.Add( fillLabel ); | |
| 153 | + | |
| 154 | + // Create an overlay label for the Fit/Keep Aspect image | |
| 155 | + Actor fitLabel = TextLabel::New( FIT_KEEP_ASPECT_LABEL ); | |
| 156 | + DevelHandle::SetProperties( fitLabel, FIT_KEEP_ASPECT_RATIO_IMAGE_BASIC_PROPERTIES ); | |
| 157 | + DevelHandle::SetProperties( fitLabel, OVERLAY_LABEL_PROPERTIES ); | |
| 158 | + stage.Add( fitLabel ); | |
| 159 | + | |
| 160 | + // Respond to key events, exit if ESC/Back, change the padding if anything else | |
| 161 | + stage.KeyEventSignal().Connect( this, &VisualFittingModeController::OnKeyEvent ); | |
| 162 | + | |
| 163 | + // Set the initial padding | |
| 164 | + ChangePadding(); | |
| 165 | + } | |
| 166 | + | |
| 167 | + /** | |
| 168 | + * @brief Changes the padding of both image-views to show how the VisualFittingMode is applied. | |
| 169 | + */ | |
| 170 | + void ChangePadding() | |
| 171 | + { | |
| 172 | + mLargePadding = !mLargePadding; | |
| 173 | + | |
| 174 | + const Extents padding( mLargePadding ? LARGE_PADDING : BORDER_ONLY_PADDING ); | |
| 175 | + mFitKeepAspectRatioImage.SetProperty( Control::Property::PADDING, padding ); | |
| 176 | + mFillImage.SetProperty( Control::Property::PADDING, padding ); | |
| 177 | + | |
| 178 | + mTextLabel.SetProperty( TextLabel::Property::TEXT, mLargePadding ? LARGE_PADDING_TEXT : BORDER_ONLY_PADDING_TEXT ); | |
| 179 | + } | |
| 180 | + | |
| 181 | + /** | |
| 182 | + * @brief Called when the main text-label is tapped. | |
| 183 | + * | |
| 184 | + * We just want to change the padding when this happens. | |
| 185 | + */ | |
| 186 | + void OnTap( Actor /* actor */, const TapGesture& /* tap */ ) | |
| 187 | + { | |
| 188 | + ChangePadding(); | |
| 189 | + } | |
| 190 | + | |
| 191 | + /** | |
| 192 | + * @brief Called when any key event is received | |
| 193 | + * | |
| 194 | + * Will use this to quit the application if we receive the Back or the Escape key & change | |
| 195 | + * the padding if any other key. | |
| 196 | + * @param[in] event The key event information | |
| 197 | + */ | |
| 198 | + void OnKeyEvent( const KeyEvent& event ) | |
| 199 | + { | |
| 200 | + if( event.state == KeyEvent::Down ) | |
| 201 | + { | |
| 202 | + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) | |
| 203 | + { | |
| 204 | + mApplication.Quit(); | |
| 205 | + } | |
| 206 | + else | |
| 207 | + { | |
| 208 | + ChangePadding(); | |
| 209 | + } | |
| 210 | + } | |
| 211 | + } | |
| 212 | + | |
| 213 | +private: | |
| 214 | + Application& mApplication; ///< Reference to the application class. | |
| 215 | + Actor mFillImage; ///< An image-view that fills to the control size. | |
| 216 | + Actor mFitKeepAspectRatioImage; ///< An image-view that fits within the given size & keeps the aspect ratio. | |
| 217 | + Actor mTextLabel; ///< A text label to show the current padding mode. | |
| 218 | + TapGestureDetector mTapDetector; ///< A tap detector to change the padding mode. | |
| 219 | + bool mLargePadding; ///< If true, the large padding values are used. When false, only the border padding is applied. | |
| 220 | +}; | |
| 221 | + | |
| 222 | +int DALI_EXPORT_API main( int argc, char **argv ) | |
| 223 | +{ | |
| 224 | + Application application = Application::New( &argc, &argv ); | |
| 225 | + VisualFittingModeController visualFittingModeController( application ); | |
| 226 | + application.MainLoop(); | |
| 227 | + return 0; | |
| 228 | +} | ... | ... |
packaging/com.samsung.dali-demo.spec
resources/po/en_GB.po
| ... | ... | @@ -40,6 +40,9 @@ msgstr "Clipping" |
| 40 | 40 | msgid "DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER" |
| 41 | 41 | msgstr "Clipping Draw Order" |
| 42 | 42 | |
| 43 | +msgid "DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW" | |
| 44 | +msgstr "Gaussian Blur" | |
| 45 | + | |
| 43 | 46 | msgid "DALI_DEMO_STR_TITLE_GESTURES" |
| 44 | 47 | msgstr "Gestures" |
| 45 | 48 | |
| ... | ... | @@ -181,6 +184,9 @@ msgstr "Sparkle" |
| 181 | 184 | msgid "DALI_DEMO_STR_TITLE_STYLING" |
| 182 | 185 | msgstr "Styling" |
| 183 | 186 | |
| 187 | +msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW" | |
| 188 | +msgstr "Super Blur" | |
| 189 | + | |
| 184 | 190 | msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH" |
| 185 | 191 | msgstr "Mesh Texture" |
| 186 | 192 | |
| ... | ... | @@ -217,6 +223,9 @@ msgstr "Tooltip" |
| 217 | 223 | msgid "DALI_DEMO_STR_TITLE_FPP_GAME" |
| 218 | 224 | msgstr "FPP Game" |
| 219 | 225 | |
| 226 | +msgid "DALI_DEMO_STR_TITLE_VISUAL_FITTING_MODE" | |
| 227 | +msgstr "Visual Fitting Mode" | |
| 228 | + | |
| 220 | 229 | msgid "DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS" |
| 221 | 230 | msgstr "Visual Transitions" |
| 222 | 231 | ... | ... |
resources/po/en_US.po
| ... | ... | @@ -40,6 +40,9 @@ msgstr "Clipping" |
| 40 | 40 | msgid "DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER" |
| 41 | 41 | msgstr "Clipping Draw Order" |
| 42 | 42 | |
| 43 | +msgid "DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW" | |
| 44 | +msgstr "Gaussian Blur" | |
| 45 | + | |
| 43 | 46 | msgid "DALI_DEMO_STR_TITLE_GESTURES" |
| 44 | 47 | msgstr "Gestures" |
| 45 | 48 | |
| ... | ... | @@ -184,6 +187,9 @@ msgstr "Sparkle" |
| 184 | 187 | msgid "DALI_DEMO_STR_TITLE_STYLING" |
| 185 | 188 | msgstr "Styling" |
| 186 | 189 | |
| 190 | +msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW" | |
| 191 | +msgstr "Super Blur" | |
| 192 | + | |
| 187 | 193 | msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH" |
| 188 | 194 | msgstr "Mesh Texture" |
| 189 | 195 | |
| ... | ... | @@ -220,6 +226,9 @@ msgstr "Tooltip" |
| 220 | 226 | msgid "DALI_DEMO_STR_TITLE_FPP_GAME" |
| 221 | 227 | msgstr "FPP Game" |
| 222 | 228 | |
| 229 | +msgid "DALI_DEMO_STR_TITLE_VISUAL_FITTING_MODE" | |
| 230 | +msgstr "Visual Fitting Mode" | |
| 231 | + | |
| 223 | 232 | msgid "DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS" |
| 224 | 233 | msgstr "Visual Transitions" |
| 225 | 234 | ... | ... |
resources/scripts/super-blur-view.json
| ... | ... | @@ -52,9 +52,7 @@ |
| 52 | 52 | "parentOrigin": "TOP_CENTER", |
| 53 | 53 | "anchorPoint": "TOP_CENTER", |
| 54 | 54 | "size": [800, 1280, 0], |
| 55 | - "image": { | |
| 56 | - "filename": "{DEMO_IMAGE_DIR}background-4.jpg" | |
| 57 | - } | |
| 55 | + "imageUrl": "{DEMO_IMAGE_DIR}background-4.jpg" | |
| 58 | 56 | }, |
| 59 | 57 | |
| 60 | 58 | // Button to blur/clear | ... | ... |
shared/dali-demo-strings.h
| ... | ... | @@ -46,6 +46,7 @@ extern "C" |
| 46 | 46 | #define DALI_DEMO_STR_TITLE_CARD_ACTIVE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_CARD_ACTIVE") |
| 47 | 47 | #define DALI_DEMO_STR_TITLE_CLIPPING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_CLIPPING") |
| 48 | 48 | #define DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER") |
| 49 | +#define DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW") | |
| 49 | 50 | #define DALI_DEMO_STR_TITLE_GESTURES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_GESTURES") |
| 50 | 51 | #define DALI_DEMO_STR_TITLE_COLOR_GRADIENT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_COLOR_GRADIENT") |
| 51 | 52 | #define DALI_DEMO_STR_TITLE_COMPRESSED_TEXTURE_FORMATS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_COMPRESSED_TEXTURE_FORMATS") |
| ... | ... | @@ -105,6 +106,7 @@ extern "C" |
| 105 | 106 | #define DALI_DEMO_STR_TITLE_SKYBOX dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SKYBOX") |
| 106 | 107 | #define DALI_DEMO_STR_TITLE_SPARKLE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SPARKLE") |
| 107 | 108 | #define DALI_DEMO_STR_TITLE_STYLING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_STYLING") |
| 109 | +#define DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW") | |
| 108 | 110 | #define DALI_DEMO_STR_TITLE_TEXTURED_MESH dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXTURED_MESH") |
| 109 | 111 | #define DALI_DEMO_STR_TITLE_TEXT_EDITOR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_EDITOR") |
| 110 | 112 | #define DALI_DEMO_STR_TITLE_TEXT_FIELD dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_FIELD") |
| ... | ... | @@ -116,6 +118,7 @@ extern "C" |
| 116 | 118 | #define DALI_DEMO_STR_TITLE_TEXT_SCROLLING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_SCROLLING") |
| 117 | 119 | #define DALI_DEMO_STR_TITLE_TILT_SENSOR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TILT_SENSOR") |
| 118 | 120 | #define DALI_DEMO_STR_TITLE_TOOLTIP dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TOOLTIP") |
| 121 | +#define DALI_DEMO_STR_TITLE_VISUAL_FITTING_MODE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_VISUAL_FITTING_MODE") | |
| 119 | 122 | #define DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS") |
| 120 | 123 | #define DALI_DEMO_STR_TITLE_WEB_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_WEB_VIEW") |
| 121 | 124 | #define DALI_DEMO_STR_TITLE_TEXT_RENDERER dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_RENDERER") |
| ... | ... | @@ -138,6 +141,7 @@ extern "C" |
| 138 | 141 | #define DALI_DEMO_STR_TITLE_CARD_ACTIVE "Card Active" |
| 139 | 142 | #define DALI_DEMO_STR_TITLE_CLIPPING "Clipping" |
| 140 | 143 | #define DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER "Clipping Draw Order" |
| 144 | +#define DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW "Gaussian Blur" | |
| 141 | 145 | #define DALI_DEMO_STR_TITLE_GESTURES "Gestures" |
| 142 | 146 | #define DALI_DEMO_STR_TITLE_COLOR_GRADIENT "Color Gradient" |
| 143 | 147 | #define DALI_DEMO_STR_TITLE_COMPRESSED_TEXTURE_FORMATS "Compressed Texture Formats" |
| ... | ... | @@ -197,6 +201,7 @@ extern "C" |
| 197 | 201 | #define DALI_DEMO_STR_TITLE_SKYBOX "Skybox" |
| 198 | 202 | #define DALI_DEMO_STR_TITLE_SPARKLE "Sparkle" |
| 199 | 203 | #define DALI_DEMO_STR_TITLE_STYLING "Styling" |
| 204 | +#define DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW "Super Blur" | |
| 200 | 205 | #define DALI_DEMO_STR_TITLE_TEXTURED_MESH "Mesh Texture" |
| 201 | 206 | #define DALI_DEMO_STR_TITLE_TEXT_EDITOR "Text Editor" |
| 202 | 207 | #define DALI_DEMO_STR_TITLE_TEXT_FIELD "Text Field" |
| ... | ... | @@ -208,6 +213,7 @@ extern "C" |
| 208 | 213 | #define DALI_DEMO_STR_TITLE_TEXT_SCROLLING "Text Scrolling" |
| 209 | 214 | #define DALI_DEMO_STR_TITLE_TILT_SENSOR "Tilt Sensor" |
| 210 | 215 | #define DALI_DEMO_STR_TITLE_TOOLTIP "Tooltip" |
| 216 | +#define DALI_DEMO_STR_TITLE_VISUAL_FITTING_MODE "Visual Fitting Mode" | |
| 211 | 217 | #define DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS "Visual Transitions" |
| 212 | 218 | #define DALI_DEMO_STR_TITLE_WEB_VIEW "Web View" |
| 213 | 219 | #define DALI_DEMO_STR_TITLE_TEXT_RENDERER "Text Renderer" | ... | ... |
tests-reel/dali-tests-reel.cpp
| ... | ... | @@ -47,6 +47,7 @@ int DALI_EXPORT_API main(int argc, char **argv) |
| 47 | 47 | demo.AddExample(Example("text-fonts.example", DALI_DEMO_STR_TITLE_TEXT_FONTS)); |
| 48 | 48 | demo.AddExample(Example("text-memory-profiling.example", DALI_DEMO_STR_TITLE_TEXT_MEMORY_PROFILING)); |
| 49 | 49 | demo.AddExample(Example("text-overlap.example", DALI_DEMO_STR_TITLE_TEXT_OVERLAP)); |
| 50 | + demo.AddExample(Example("visual-fitting-mode.example", DALI_DEMO_STR_TITLE_VISUAL_FITTING_MODE)); | |
| 50 | 51 | demo.AddExample(Example("visual-transitions.example", DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS)); |
| 51 | 52 | demo.AddExample(Example("simple-text-label.example", DALI_DEMO_STR_TITLE_TEXT_LABEL)); |
| 52 | 53 | demo.AddExample(Example("simple-text-field.example", DALI_DEMO_STR_TITLE_TEXT_FIELD)); | ... | ... |