Image Policies Example suite 82/158282/13
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Wed, 25 Oct 2017 11:24:22 +0000 (12:24 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Tue, 7 Nov 2017 14:09:27 +0000 (14:09 +0000)
Collection of examples demonstrating Image polices:
LoadPolicy
ReleasePolicy
and EXIF orientation.

Designed to step the user through each example and explaining what should occur.

Change-Id: If4452712a805b40e86ac29ae591592711d7ee09a

13 files changed:
com.samsung.dali-demo.xml
examples-reel/dali-examples-reel.cpp
examples/image-policies/image-policies-example.cpp [new file with mode: 0644]
examples/image-view/image-view-example.cpp
resources/images/DarkStyleDisabledArrowButton.png [new file with mode: 0644]
resources/images/DarkStyleGreenArrowButton.png [new file with mode: 0755]
resources/images/DarkStyleGreyArrowButton.png [new file with mode: 0755]
resources/images/animatedLoading.gif [new file with mode: 0644]
resources/images/keyboard-Landscape.jpg [new file with mode: 0644]
resources/images/keyboard-LandscapeCopy.jpg [new file with mode: 0644]
resources/po/en_GB.po
resources/po/en_US.po
shared/dali-demo-strings.h

index 7dcb04c23832a9e7f894e5b1e3a31369e5db286d..43f0ac19b1227619350c1805518757fde2e8630c 100644 (file)
        <ui-application appid="property-notification.example" exec="/usr/apps/com.samsung.dali-demo/bin/property-notification.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Property Notification</label>
        </ui-application>
+       <ui-application appid="image-policies.example" exec="/usr/apps/com.samsung.dali-demo/bin/image-policies.example" nodisplay="true" multiple="false" taskmanage="true" type="c++app">
+               <label>Image Policies</label></ui-application>
        <privileges>
                <privilege>http://tizen.org/privilege/mediastorage</privilege>
                <privilege>http://tizen.org/privilege/externalstorage</privilege>
index ee7a9d77e8f1961d00a87d9255253762db0f2613..a90d8f0898606469a522a60aa077bb7b76444833 100644 (file)
@@ -48,6 +48,7 @@ int DALI_EXPORT_API main(int argc, char **argv)
   demo.AddExample(Example("flex-container.example", DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND));
   demo.AddExample(Example("focus-integration.example", DALI_DEMO_STR_TITLE_FOCUS_INTEGRATION));
   demo.AddExample(Example("gradients.example", DALI_DEMO_STR_TITLE_COLOR_GRADIENT));
+  demo.AddExample(Example("image-policies.example", DALI_DEMO_STR_TITLE_IMAGE_POLICIES));
   demo.AddExample(Example("image-scaling-and-filtering.example", DALI_DEMO_STR_TITLE_IMAGE_FITTING_SAMPLING));
   demo.AddExample(Example("image-scaling-irregular-grid.example", DALI_DEMO_STR_TITLE_IMAGE_SCALING));
   demo.AddExample(Example("image-view.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW));
diff --git a/examples/image-policies/image-policies-example.cpp b/examples/image-policies/image-policies-example.cpp
new file mode 100644 (file)
index 0000000..7f7acc8
--- /dev/null
@@ -0,0 +1,551 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <string>
+#include "shared/view.h"
+#include <dali/dali.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+namespace
+{
+const char* NEXT_BUTTON_IMAGE( DEMO_IMAGE_DIR "DarkStyleGreenArrowButton.png" );
+const char* NEXT_BUTTON_PRESSED_IMAGE( DEMO_IMAGE_DIR "DarkStyleGreyArrowButton.png" );
+const char* NEXT_BUTTON_DISABLED_IMAGE( DEMO_IMAGE_DIR "DarkStyleDisabledArrowButton.png" );
+const char* OK_IMAGE_IMAGE( DEMO_IMAGE_DIR "FontStyleButton_OK_02.png" );
+const char* LOADING_IMAGE( DEMO_IMAGE_DIR "animatedLoading.gif" );
+
+const char* IMAGE_PATH[] = {
+    DEMO_IMAGE_DIR "gallery-small-23.jpg",
+    DEMO_IMAGE_DIR "woodEffect.jpg",
+    DEMO_IMAGE_DIR "heartsframe.9.png",
+    DEMO_IMAGE_DIR "keyboard-Landscape.jpg",
+    DEMO_IMAGE_DIR "keyboard-LandscapeCopy.jpg",
+};
+
+/**
+ * Enums that refer to the row in the main table view.
+ * Aids in placement of content so easy to see which type of content belongs to each row.
+ */
+enum TableRowPlacement
+{
+  TITLE,
+  INSTRUCTIONS,
+  IMAGE,
+  NEXT_BUTTON,
+  LOADING_STATUS,
+  NUMBER_OF_ROWS
+};
+
+}  // namespace
+
+/**
+ * Examples showing the various polices of ImageVisual in use.
+ * image release polcy, image loading policy and exif data are currently demonstrated.
+ * Large images are used to cause loading time to be long enough to show differences.
+ * If hardware causes loading time improve then remote images or larger images may be required in future.
+ */
+class ImagePolicies: public ConnectionTracker
+{
+ public:
+
+  /**
+   * Constructor
+   */
+  ImagePolicies( Application& application )
+    : mApplication( application ),
+      mExampleIndex( 0 )
+  {
+    // Connect to the Application's Init signal
+    mApplication.InitSignal().Connect( this, &ImagePolicies::Create );
+  }
+
+  /**
+   * To prevent the next button being pressed before an Image has loaded the Button can br disabled.
+   * This function allows the control (Image view in this case) to attached to the Image loading signal
+   * and re-enable the button after Image has loaded.
+   */
+  void ResourceReadySignal( Control control )
+  {
+    mNextButton.SetProperty( Button::Property::DISABLED, false );
+  }
+
+  /**
+   * Helper function to create ImageViews used by this example, preventing the duplication of code.
+   * param[in] correctionEnabled  Set true if Exif orientation correction should be applied.
+   * param[in] loadPolicy Which LoadPolicy to use.
+   * param[in] releasePolicy Which ReleasePolicy to use
+   * param[in] synchronousLoading If the Image should be loaded synchronously
+   * param[in] imageFilenameId Which image to load, referring to the array of filenames for this example.
+   */
+  ImageView CreateImageView( bool correctionEnabled, DevelImageVisual::LoadPolicy::Type loadPolicy, DevelImageVisual::ReleasePolicy::Type releasePolicy, bool synchronousLoading, unsigned int imageFilenameId )
+  {
+    ImageView imageView = ImageView::New( );
+    Property::Map imagePropertyMap;
+    imagePropertyMap.Insert( Visual::Property::TYPE,  Visual::IMAGE );
+    imagePropertyMap.Insert( ImageVisual::Property::URL,  IMAGE_PATH[imageFilenameId ]  );
+    imagePropertyMap.Insert( DevelImageVisual::Property::ORIENTATION_CORRECTION, correctionEnabled  );
+    imagePropertyMap.Insert( DevelImageVisual::Property::LOAD_POLICY,  loadPolicy  );
+    imagePropertyMap.Insert( DevelImageVisual::Property::RELEASE_POLICY,  releasePolicy  );
+    if( synchronousLoading )
+    {
+      imagePropertyMap.Insert( DevelImageVisual::Property::SYNCHRONOUS_LOADING,  true  );
+    }
+    imageView.SetProperty(ImageView::Property::IMAGE , imagePropertyMap );
+
+    imageView.SetParentOrigin( ParentOrigin::CENTER );
+    imageView.SetAnchorPoint( AnchorPoint::CENTER );
+    imageView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+    return imageView;
+  }
+
+  /**
+   * To prevent the next button being pressed before an Image has loaded the Button can br disabled.
+   * This function will disable the next button.
+   * Connecting to the ResourceReady signal with ( ResourceReadySignal( Control control ) ) will allow enabling of the button again.
+   */
+
+  void DisableButtonWhilstLoading()
+  {
+    mNextButton.SetProperty( Button::Property::DISABLED, true );
+  }
+
+  /**
+   * Example shows loading an Image with exif orientation data but not applying automatic orientation correction
+   */
+  void OrientationCorrectionExampleNoCorrection()
+  {
+
+    mTitle.SetProperty( Toolkit::TextLabel::Property::TEXT,  "Orientation Correction" );
+    mInstructions.SetProperty( TextLabel::Property::TEXT, "Orientation Correction not applied");
+    mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+    DisableButtonWhilstLoading();
+    ImageView imageView01 = CreateImageView( false, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
+
+    mTable.AddChild( imageView01, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+  }
+
+  /**
+   * Example shows loading an Image with exif orientation data and automatically correcting the orientation to match the exif data.
+   */
+  void OrientationCorrectionExampleWithCorrection()
+  {
+    mInstructions.SetProperty( TextLabel::Property::TEXT, "Orientation Correction applied based on Exif data, now shown in landscape");
+    mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+    DisableButtonWhilstLoading();
+    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
+    mTable.AddChild( imageView01, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+  }
+
+  /**
+   * Part One of the Immediate loading example, displays instructions on what will be shown and starts loading of the Immediate image before it
+   * is staged.
+   */
+  void LoadPolicyImmediateExampleInstructions()
+  {
+    mTitle.SetProperty( Toolkit::TextLabel::Property::TEXT,  "Immediate Loading Policy");
+    mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+    mInstructions.SetProperty( TextLabel::Property::TEXT, "Loading Image before staging, press next to see it in right column");
+    TableView dualImageViewTable = TableView::New( 1, 2 );
+    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
+    dualImageViewTable.SetName("dualTable");
+    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+    dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
+    TextLabel attached = TextLabel::New("ATTACHED loaded image \nWill appear here");
+    attached.SetProperty( TextLabel::Property::MULTI_LINE, true );
+    TextLabel immediate = TextLabel::New("IMMEDIATE loaded image \nWill appear here");
+    immediate.SetProperty( TextLabel::Property::MULTI_LINE, true );
+
+    dualImageViewTable.AddChild( attached, TableView::CellPosition( 0, 0 ) );
+    dualImageViewTable.AddChild( immediate, TableView::CellPosition( 0, 1 ) );
+    mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+
+    mPersistantImageView = CreateImageView( true, DevelImageVisual::LoadPolicy::IMMEDIATE, DevelImageVisual::ReleasePolicy::DESTROYED, false, 4 );
+  }
+
+  /**
+   * Part Two of the Immediate loading example and here the Image is staged, shown to be instant (if previously step gave enough time to load).
+   */
+  void LoadPolicyImmediateExample()
+  {
+    mInstructions.SetProperty( TextLabel::Property::TEXT, "Immediate loading policy on only second column hence image load was almost instant.");
+    DisableButtonWhilstLoading();
+    mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+
+    TableView dualImageViewTable = TableView::New( 2, 2 );
+    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
+    dualImageViewTable.SetName("dualTable");
+    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+    dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
+
+    TextLabel attached = TextLabel::New("ATTACHED");
+    TextLabel immediate = TextLabel::New("IMMEDIATE");
+    dualImageViewTable.AddChild( attached, TableView::CellPosition( 1, 0 ) );
+    dualImageViewTable.AddChild( immediate, TableView::CellPosition( 1, 1 ) );
+    dualImageViewTable.SetFitHeight( 1 );
+
+    mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+
+    ImageView imageView02 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    imageView02.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
+    dualImageViewTable.AddChild( imageView02, TableView::CellPosition( 0, 0 ) );
+    dualImageViewTable.AddChild( mPersistantImageView, TableView::CellPosition( 0, 1 ) );
+  }
+
+  /**
+   * Part one of an example of loading time when an Image is destroyed with the ReleasePolicy DESTROYED.
+   */
+  void LoadPolicyDestroyedExample()
+  {
+    mTitle.SetProperty( Toolkit::TextLabel::Property::TEXT, "Release Policy DESTROYED");
+    mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+    mPersistantImageView.Reset();
+    mInstructions.SetProperty( TextLabel::Property::TEXT, "ReleasePolicy::DESTROYED shown in first column, press next to destroy it.");
+    DisableButtonWhilstLoading();
+    TableView dualImageViewTable = TableView::New( 1, 2 );
+    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
+    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+    dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
+
+    mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+
+    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
+
+    dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 0 ) );
+  }
+
+  /**
+   * Part two of the Destroyed example, the image is staged again but to the second column, it shows the loading takes the same amount of time as
+   * when first loaded.
+   */
+  void LoadPolicyDestroyedExample02()
+  {
+    mInstructions.SetProperty( TextLabel::Property::TEXT, "Destroyed first image and reloaded in second column (loading took some time)");
+    mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+    DisableButtonWhilstLoading();
+    TableView dualImageViewTable = TableView::New( 1, 2 );
+    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
+    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+    dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
+
+    mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+
+    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
+
+    dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 1 ) );
+  }
+
+  /**
+   * Part one the second Release policy example showing detachment of a visual with the Destroyed policy and loading instantly when re-used.
+   */
+  void ReleasePolicyDestroyedExample03()
+  {
+    mTitle.SetProperty( Toolkit::TextLabel::Property::TEXT, "Detaching with DESTROYED Policy");
+    mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+    mInstructions.SetProperty( TextLabel::Property::TEXT, "Image with ReleasePolicy::DESTROYED shown in first column, Image will be detached, reusing it will be fast");
+    DisableButtonWhilstLoading();
+    TableView dualImageViewTable = TableView::New( 1, 2 );
+    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
+    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+    dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
+
+    mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+
+    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
+
+    dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 0 ) );
+  }
+
+  /**
+   * Second part of the second Release policy example, the detached visual is used again in the second column and shown nearly instantly.
+   */
+  void ReleasePolicyDestroyedExample04()
+  {
+    mInstructions.SetProperty( TextLabel::Property::TEXT, "Detached first image and reloaded in second column, loading should have seemed instant");
+    DisableButtonWhilstLoading();
+    TableView dualImageViewTable = TableView::DownCast( mTable.GetChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) ) );
+    ImageView imageViewDetached = ImageView::DownCast( dualImageViewTable.GetChildAt( TableView::CellPosition( 0, 0 ) ) );
+    dualImageViewTable.RemoveChildAt( TableView::CellPosition( 0, 0 ) );
+
+    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
+
+    dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 1 ) );
+  }
+
+  /**
+   * Part one of an example of loading time when an Image is detached with the ReleasePolicy Detached.
+   */
+  void ReleasePolicyDestroyedExample05()
+  {
+    mTitle.SetProperty( Toolkit::TextLabel::Property::TEXT, "Detaching with DETACHED Policy");
+    mTable.RemoveChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+    mInstructions.SetProperty( TextLabel::Property::TEXT, "Image with ReleasePolicy::DETACHED shown in first column, will be detached and reloaded");
+    DisableButtonWhilstLoading();
+    TableView dualImageViewTable = TableView::New( 1, 2 );
+    dualImageViewTable.SetAnchorPoint( AnchorPoint::CENTER );
+    dualImageViewTable.SetParentOrigin( ParentOrigin::CENTER );
+    dualImageViewTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+    dualImageViewTable.SetCellPadding( Vector2( 6.0f, 0.0f ) );
+
+    mTable.AddChild( dualImageViewTable, TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) );
+
+    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DETACHED, false, 3 );
+    imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
+
+    dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 0 ) );
+  }
+
+  /**
+   * Part two of the Detached example, the image is staged again but to the second column, it shows the loading takes the same amount of time as
+   * when first loaded.
+   */
+  void ReleasePolicyDestroyedExample06()
+  {
+    mInstructions.SetProperty( TextLabel::Property::TEXT, "Detached first image and reloaded in second column, loading took some time");
+    DisableButtonWhilstLoading();
+    TableView dualImageViewTable = TableView::DownCast( mTable.GetChildAt( TableView::CellPosition( TableRowPlacement::IMAGE, 0 ) ) );
+    ImageView imageViewDetached = ImageView::DownCast( dualImageViewTable.GetChildAt( TableView::CellPosition( 0, 0 ) ) );
+    dualImageViewTable.RemoveChildAt( TableView::CellPosition( 0, 0 ) );
+
+    ImageView imageView01 = CreateImageView( true, DevelImageVisual::LoadPolicy::ATTACHED, DevelImageVisual::ReleasePolicy::DESTROYED, false, 3 );
+    imageView01.ResourceReadySignal().Connect( this, &ImagePolicies::ResourceReadySignal );
+
+    dualImageViewTable.AddChild( imageView01, TableView::CellPosition( 0, 1 ) );
+  }
+
+  /**
+   * Created a gradient property map that will produce a Gradient Visual
+   * param[out] gradientMap the output property map
+   */
+  void CreateGradient( Property::Map& gradientMap )
+  {
+    gradientMap.Insert( Toolkit::Visual::Property::TYPE,  Visual::GRADIENT );
+
+    Property::Array stopOffsets;
+    stopOffsets.PushBack( 0.0f );
+    stopOffsets.PushBack( 0.6f );
+    stopOffsets.PushBack( 1.0f );
+    gradientMap.Insert( GradientVisual::Property::STOP_OFFSET, stopOffsets );
+
+    Property::Array stopColors;
+    stopColors.PushBack( Vector4( 54.f, 140.f, 207.f, 223.f )/255.f );
+    stopColors.PushBack( Vector4( 54.f, 170.f, 207.f, 123.f )/255.f );
+    stopColors.PushBack( Vector4( 54.f, 189.f, 207.f, 123.f )/255.f );
+    gradientMap.Insert( GradientVisual::Property::STOP_COLOR, stopColors );
+
+    gradientMap.Insert( GradientVisual::Property::START_POSITION, Vector2(  0.5f,  0.5f ) );
+    gradientMap.Insert( GradientVisual::Property::END_POSITION,  Vector2( -0.5f, -0.5f ) );
+  }
+
+  /**
+   * Start of this example, called once when the application is initiated
+   */
+  void Create( Application& application )
+  {
+    Property::Map gradientBackground;
+    CreateGradient( gradientBackground );
+
+    // Get a handle to the stage
+    Stage stage = Stage::GetCurrent();
+
+    // Create default View.
+    Toolkit::Control view = Toolkit::Control::New();
+    view.SetAnchorPoint( Dali::AnchorPoint::CENTER );
+    view.SetParentOrigin( Dali::ParentOrigin::CENTER );
+    view.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS );
+    view.SetProperty( Toolkit::Control::Property::BACKGROUND , gradientBackground );
+    stage.Add( view );
+
+    // Create a table view to show a pair of buttons above each image.
+    mTable = TableView::New( TableRowPlacement::NUMBER_OF_ROWS, 1 );
+    mTable.SetAnchorPoint( AnchorPoint::CENTER );
+    mTable.SetParentOrigin( ParentOrigin::CENTER );
+    mTable.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
+    Vector3 offset( 0.9f, 0.90f, 0.0f );
+    mTable.SetSizeModeFactor( offset );
+    mTable.SetFitHeight( TableRowPlacement::NEXT_BUTTON );
+    mTable.SetFitHeight( TableRowPlacement::LOADING_STATUS );
+    view.Add( mTable );
+
+    // Create Next button
+    mNextButton = PushButton::New();
+    Property::Map imagePropertyMap;
+    imagePropertyMap.Insert( Visual::Property::TYPE,  Visual::IMAGE );
+    imagePropertyMap.Insert( ImageVisual::Property::URL, NEXT_BUTTON_IMAGE );
+    mNextButton.SetProperty( DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, imagePropertyMap );
+    imagePropertyMap.Clear();
+    imagePropertyMap.Insert( Visual::Property::TYPE,  Visual::IMAGE );
+    imagePropertyMap.Insert( ImageVisual::Property::URL, NEXT_BUTTON_PRESSED_IMAGE );
+    mNextButton.SetProperty( DevelButton::Property::SELECTED_BACKGROUND_VISUAL, imagePropertyMap );
+    mNextButton.SetProperty( DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL, LOADING_IMAGE );
+    mNextButton.SetProperty( DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL, NEXT_BUTTON_DISABLED_IMAGE );
+    mNextButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+    mNextButton.SetY( -50.0f );
+    mNextButton.SetSize( 100.0f, 100.0f );
+    mNextButton.ClickedSignal().Connect( this, &ImagePolicies::ChangeImageClicked );
+    mTable.AddChild( mNextButton, TableView::CellPosition( TableRowPlacement::NEXT_BUTTON, 0 ) );
+    mTable.SetCellPadding( Vector2( 2.0f, 2.0f ) );
+
+    Stage::GetCurrent().KeyEventSignal().Connect(this, &ImagePolicies::OnKeyEvent);
+
+    // Outline Map for Labels
+    Property::Map outlineMap;
+    outlineMap["color"] = Color::BLACK;
+    outlineMap["width"] = 1.0f;
+
+    // Create Title Label
+    mTitle  = TextLabel::New("Image Polices");
+    mTitle.SetProperty( TextLabel::Property::TEXT_COLOR, Color::CYAN );
+    mTable.AddChild( mTitle, TableView::CellPosition( TableRowPlacement::TITLE, 0 ) );
+    mTable.SetFitHeight( TableRowPlacement::TITLE );
+
+    // Create Instructions label
+    mInstructions = TextLabel::New("This is an explaination of each example");
+    mInstructions.SetProperty( TextLabel::Property::MULTI_LINE, true );
+    mInstructions.SetProperty( TextLabel::Property::TEXT_COLOR, Color::WHITE );
+    mInstructions.SetProperty( TextLabel::Property::OUTLINE, outlineMap );
+    mInstructions.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+    mTable.AddChild( mInstructions, TableView::CellPosition( TableRowPlacement::INSTRUCTIONS, 0 ) );
+    float value = mInstructions.GetProperty<float>( TextLabel::Property::PIXEL_SIZE );
+    mTable.SetFixedHeight( TableRowPlacement::INSTRUCTIONS, value * 5 ); // Space allocated for example instructions
+
+    ChangeImageClicked( mNextButton );  // Start examples ( 0 )
+  }
+
+private:
+
+  /**
+   * Callback to the button clicked signal and starts the next example.
+   */
+  bool ChangeImageClicked( Button button )
+  {
+    switch ( mExampleIndex++ )
+    {
+      case 0 :
+      {
+        OrientationCorrectionExampleNoCorrection();
+        break;
+      }
+      case 1 :
+      {
+        OrientationCorrectionExampleWithCorrection();
+        break;
+      }
+      case 2 :
+      {
+        LoadPolicyImmediateExampleInstructions();
+        break;
+      }
+      case 3 :
+      {
+        LoadPolicyImmediateExample();
+        break;
+      }
+      case 4 :
+      {
+        LoadPolicyDestroyedExample();
+        break;
+      }
+      case 5 :
+      {
+        LoadPolicyDestroyedExample02();
+        break;
+      }
+      case 6 :
+      {
+        ReleasePolicyDestroyedExample03();
+        break;
+      }
+      case 7 :
+      {
+        ReleasePolicyDestroyedExample04();
+        break;
+      }
+      case 8 :
+      {
+        ReleasePolicyDestroyedExample05();
+        break;
+      }
+      case 9 :
+      {
+        ReleasePolicyDestroyedExample06();
+        // Change Next button to complete button ( will quit app once pressed )
+        button.SetProperty( DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, OK_IMAGE_IMAGE );
+        button.SetProperty( DevelButton::Property::SELECTED_BACKGROUND_VISUAL, OK_IMAGE_IMAGE );
+        break;
+      }
+      default:
+      {
+        mApplication.Quit();
+        break;
+      }
+    }
+    return true;
+  }
+
+  /**
+   * Main key event handler
+   */
+  void OnKeyEvent(const KeyEvent& event)
+  {
+    if(event.state == KeyEvent::Down)
+    {
+      if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) )
+      {
+        mApplication.Quit();
+      }
+    }
+  }
+
+private:
+  Application& mApplication;
+
+  TableView    mTable;
+  TextLabel    mInstructions;
+  TextLabel    mTitle;
+  PushButton   mNextButton;
+  ImageView    mPersistantImageView;
+
+  unsigned int mExampleIndex;
+};
+
+int DALI_EXPORT_API main( int argc, char **argv )
+{
+  Application application = Application::New( &argc, &argv, DEMO_THEME_PATH );
+  ImagePolicies test( application );
+  application.MainLoop();
+  return 0;
+}
index d057aa78f13af266376a34b0ab61cf80f8abac6a..afb3fe1fbf6cc06851ec59ee191440eba4d8c054 100644 (file)
@@ -19,6 +19,8 @@
 #include "shared/view.h"
 #include <dali/dali.h>
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 
 using namespace Dali;
 
@@ -142,7 +144,13 @@ class ImageViewController: public ConnectionTracker
       button2.SetName( s );
       mTable.AddChild( button2, Toolkit::TableView::CellPosition( CellPlacement::LOWER_BUTTON, x )  );
 
-      mImageViews[x] = Toolkit::ImageView::New( IMAGE_PATH[ 0 ] );
+      mImageViews[x] = Toolkit::ImageView::New( );
+      Property::Map imagePropertyMap;
+      imagePropertyMap.Insert( Toolkit::Visual::Property::TYPE,  Toolkit::Visual::IMAGE );
+      imagePropertyMap.Insert( Toolkit::ImageVisual::Property::URL,  IMAGE_PATH[ 0 ]  );
+      mImageViews[x].SetProperty(Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
+
+
       mImageViews[x].SetParentOrigin( ParentOrigin::CENTER );
       mImageViews[x].SetAnchorPoint( AnchorPoint::CENTER );
       mImageViews[x].SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
@@ -158,6 +166,15 @@ class ImageViewController: public ConnectionTracker
 
 private:
 
+  void ImmediateLoadImage( const char* urlToLoad )
+  {
+    Property::Map imagePropertyMap;
+    imagePropertyMap.Insert( Toolkit::Visual::Property::TYPE,  Toolkit::Visual::IMAGE );
+    imagePropertyMap.Insert( Toolkit::ImageVisual::Property::URL, urlToLoad );
+    Toolkit::Visual::Base visual =  Toolkit::VisualFactory::Get().CreateVisual( imagePropertyMap );
+    visual.Reset();
+  }
+
   bool ToggleImageOnStage( Toolkit::Button button )
   {
     unsigned int buttonIndex = GetButtonIndex( button );
@@ -184,7 +201,10 @@ private:
 
     if (  mImageViews[buttonIndex].OnStage() )
     {
-      mImageViews[buttonIndex].SetImage( IMAGE_PATH[ mImageViewImageIndexStatus[buttonIndex] ] );
+      Property::Map imagePropertyMap;
+      imagePropertyMap.Insert( Toolkit::Visual::Property::TYPE,  Toolkit::Visual::IMAGE );
+      imagePropertyMap.Insert( Toolkit::ImageVisual::Property::URL,  IMAGE_PATH[ mImageViewImageIndexStatus[buttonIndex] ]  );
+      mImageViews[buttonIndex].SetProperty(Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
 
       ++mImageViewImageIndexStatus[buttonIndex];
 
diff --git a/resources/images/DarkStyleDisabledArrowButton.png b/resources/images/DarkStyleDisabledArrowButton.png
new file mode 100644 (file)
index 0000000..7d7d271
Binary files /dev/null and b/resources/images/DarkStyleDisabledArrowButton.png differ
diff --git a/resources/images/DarkStyleGreenArrowButton.png b/resources/images/DarkStyleGreenArrowButton.png
new file mode 100755 (executable)
index 0000000..4149109
Binary files /dev/null and b/resources/images/DarkStyleGreenArrowButton.png differ
diff --git a/resources/images/DarkStyleGreyArrowButton.png b/resources/images/DarkStyleGreyArrowButton.png
new file mode 100755 (executable)
index 0000000..204f3ec
Binary files /dev/null and b/resources/images/DarkStyleGreyArrowButton.png differ
diff --git a/resources/images/animatedLoading.gif b/resources/images/animatedLoading.gif
new file mode 100644 (file)
index 0000000..48f65ad
Binary files /dev/null and b/resources/images/animatedLoading.gif differ
diff --git a/resources/images/keyboard-Landscape.jpg b/resources/images/keyboard-Landscape.jpg
new file mode 100644 (file)
index 0000000..47e7e3d
Binary files /dev/null and b/resources/images/keyboard-Landscape.jpg differ
diff --git a/resources/images/keyboard-LandscapeCopy.jpg b/resources/images/keyboard-LandscapeCopy.jpg
new file mode 100644 (file)
index 0000000..c90d87d
Binary files /dev/null and b/resources/images/keyboard-LandscapeCopy.jpg differ
index 5d30473b94a57d38c3ddfde98a592d76907f9496..4664da669d22510e4928cba67b0fb067511baa75 100755 (executable)
@@ -49,6 +49,9 @@ msgstr "Flexbox Playground"
 msgid "DALI_DEMO_STR_TITLE_IMAGE_FITTING_SAMPLING"
 msgstr "Image Fitting and Sampling"
 
+msgid "DALI_DEMO_STR_TITLE_IMAGE_POLICIES"
+msgstr "Image Policies"
+
 msgid "DALI_DEMO_STR_TITLE_IMAGE_SCALING"
 msgstr "Image Scaling Grid"
 
index 1296053fb71728c3a7a141859eb21c58739502bb..604da3a1224823593133e783108af5744b62fa18 100755 (executable)
@@ -46,6 +46,9 @@ msgstr "Emoji Text"
 msgid "DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND"
 msgstr "Flexbox Playground"
 
+msgid "DALI_DEMO_STR_TITLE_IMAGE_POLICIES"
+msgstr "Image Policies"
+
 msgid "DALI_DEMO_STR_TITLE_IMAGE_FITTING_SAMPLING"
 msgstr "Image Fitting and Sampling"
 
index 7ce01828f8293b3ff11f124a55fe02ced1ea4ae6..b73ac73f1ece6bce4a445b35bca45ea539821b0b 100644 (file)
@@ -50,6 +50,7 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_FPP_GAME                    dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_FPP_GAME")
 #define DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND          dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND")
 #define DALI_DEMO_STR_TITLE_FOCUS_INTEGRATION           dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_FOCUS_INTEGRATION")
+#define DALI_DEMO_STR_TITLE_IMAGE_POLICIES              dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_IMAGE_POLICIES")
 #define DALI_DEMO_STR_TITLE_IMAGE_FITTING_SAMPLING      dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_IMAGE_FITTING_SAMPLING")
 #define DALI_DEMO_STR_TITLE_IMAGE_SCALING               dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_IMAGE_SCALING")
 #define DALI_DEMO_STR_TITLE_IMAGE_VIEW                  dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_IMAGE_VIEW")
@@ -120,6 +121,7 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_FPP_GAME                    "First Person Game"
 #define DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND          "Flexbox Playground"
 #define DALI_DEMO_STR_TITLE_FOCUS_INTEGRATION           "Focus Integration"
+#define DALI_DEMO_STR_TITLE_IMAGE_POLICIES              "Image Policies"
 #define DALI_DEMO_STR_TITLE_IMAGE_FITTING_SAMPLING      "Image Fitting and Sampling"
 #define DALI_DEMO_STR_TITLE_IMAGE_SCALING               "Image Scaling Grid"
 #define DALI_DEMO_STR_TITLE_IMAGE_VIEW                  "Image View"