utc-Dali-KeyboardFocusManager.cpp
utc-Dali-Magnifier.cpp
utc-Dali-Popup.cpp
+ utc-Dali-ProgressBar.cpp
utc-Dali-PushButton.cpp
utc-Dali-RadioButton.cpp
utc-Dali-ScrollViewEffect.cpp
--- /dev/null
+/*
+ * Copyright (c) 2016 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 <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/progress-bar/progress-bar.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+using Dali::Toolkit::ProgressBar;
+
+
+void utc_dali_toolkit_progressbar_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_toolkit_progressbar_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+namespace
+{
+
+static bool gObjectCreatedCallBackCalled;
+
+static void TestCallback(BaseHandle handle)
+{
+ gObjectCreatedCallBackCalled = true;
+}
+
+}
+
+int UtcDaliProgressBarNew(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliProgressBarNew");
+
+ // Create the ProgressBar actor
+ ProgressBar progressBar;
+
+ DALI_TEST_CHECK( !progressBar );
+
+ progressBar = ProgressBar::New();
+
+ DALI_TEST_CHECK( progressBar );
+
+ ProgressBar progressBar2(progressBar);
+
+ DALI_TEST_CHECK( progressBar2 == progressBar );
+
+ ProgressBar progressBar3;
+ progressBar3 = progressBar2;
+
+ DALI_TEST_CHECK( progressBar3 == progressBar2 );
+
+ //Additional check to ensure object is created by checking if it's registered
+ ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
+ DALI_TEST_CHECK( registry );
+
+ gObjectCreatedCallBackCalled = false;
+ registry.ObjectCreatedSignal().Connect( &TestCallback );
+ {
+ ProgressBar progressBar = ProgressBar::New();
+ }
+ DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
+ END_TEST;
+}
+
+int UtcDaliProgressBarDestructor(void)
+{
+ ToolkitTestApplication application;
+
+ ProgressBar* progressBar = new ProgressBar();
+ delete progressBar;
+
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliProgressBarDownCast(void)
+{
+ ToolkitTestApplication application;
+
+ Handle handle = ProgressBar::New();
+
+ ProgressBar progressBar = ProgressBar::DownCast( handle );
+
+ DALI_TEST_CHECK( progressBar == handle );
+ END_TEST;
+}
+
+static bool gProgressBarValueChangedCallBackCalled = false;
+
+static void OnProgressBarValueChanged( ProgressBar progressBar, float value )
+{
+ gProgressBarValueChangedCallBackCalled = true;
+}
+
+int UtcDaliProgressBarSignals(void)
+{
+ ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
+ tet_infoline(" UtcDaliProgressBarSignals");
+
+ // Create the ProgressBar actor
+ ProgressBar progressBar = ProgressBar::New();
+ Stage::GetCurrent().Add( progressBar );
+ progressBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ progressBar.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+ progressBar.SetSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
+ progressBar.SetPosition( 0.0f, 0.0f );
+
+ progressBar.ValueChangedSignal().Connect( &OnProgressBarValueChanged );
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.2f);
+
+ application.SendNotification();
+ application.Render();
+
+ //gProgressBarValueChangedCallBackCalled = false;
+
+ DALI_TEST_CHECK(gProgressBarValueChangedCallBackCalled);
+ END_TEST;
+}
+
+int UtcDaliProgressBarSetPropertyP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliProgressBarSetPropertyP" );
+
+ ProgressBar progressBar = ProgressBar::New();
+ progressBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ progressBar.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+ progressBar.SetSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
+ progressBar.SetPosition( 0.0f, 0.0f );
+
+ Stage::GetCurrent().Add(progressBar);
+ application.SendNotification();
+ application.Render();
+
+ float val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.0f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.2f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.2f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.8f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.8f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.4f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.4f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.0f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 1.0f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 1.0f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, -1.0f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 1.0f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.9f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.9f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 1.1f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.9f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 2.0f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.9f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.0f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.9f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.9f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.09f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.09f, TEST_LOCATION);
+
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.1f);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.1f, TEST_LOCATION);
+
+ {
+ Property::Map map;
+ map["rendererType"] = "image";
+ map["size"] = Vector2(200, 200);
+ map["url"] = "track2.png";
+ progressBar.SetProperty(ProgressBar::Property::TRACK_VISUAL, map);
+ map["url"] = "progress2.png";
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VISUAL, map);
+
+ Property::Value value = progressBar.GetProperty(ProgressBar::Property::TRACK_VISUAL);
+ Property::Map* resultMap = value.GetMap();
+ DALI_TEST_CHECK( resultMap );
+ Property::Value* url = resultMap->Find("url");
+ DALI_TEST_CHECK( url ) ;
+ DALI_TEST_EQUALS( *url, "track2.png", TEST_LOCATION );
+
+ value = progressBar.GetProperty(ProgressBar::Property::PROGRESS_VISUAL);
+ resultMap = value.GetMap();
+ DALI_TEST_CHECK( resultMap );
+ url = resultMap->Find("url");
+ DALI_TEST_CHECK( url ) ;
+ DALI_TEST_EQUALS( *url, "progress2.png", TEST_LOCATION );
+
+ }
+
+ END_TEST;
+}
+
+int UtcDaliProgressBarSetPropertyP1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliProgressBarSetPropertyP1" );
+
+ ProgressBar progressBar = ProgressBar::New();
+ progressBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ progressBar.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+ progressBar.SetSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
+ progressBar.SetPosition( 0.0f, 0.0f );
+
+ Stage::GetCurrent().Add(progressBar);
+ application.SendNotification();
+ application.Render();
+
+ float val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, 0.0f, TEST_LOCATION);
+
+ // test to download a file of 100k in chunks
+ float lowerBound = 0, upperBound = 100, progressValue = 0, chunkValue = 0;
+
+ while( chunkValue <= upperBound )
+ {
+ progressValue = (chunkValue - lowerBound ) / ( upperBound - lowerBound );
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, progressValue);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, progressValue, TEST_LOCATION);
+ chunkValue = chunkValue + 10;
+ }
+
+ // test to download a file of 1000k in chunks
+ lowerBound = 0, upperBound = 1000, progressValue = 0, chunkValue = 0;
+
+ while( chunkValue <= upperBound )
+ {
+ progressValue = (chunkValue - lowerBound ) / ( upperBound - lowerBound );
+ progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, progressValue);
+ val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+ DALI_TEST_EQUALS(val, progressValue, TEST_LOCATION);
+ chunkValue = chunkValue + 100;
+ }
+
+ END_TEST;
+}
+
develapieffectsviewdir = $(develapicontrolsdir)/effects-view
develapimagnifierdir = $(develapicontrolsdir)/magnifier
develapipopupdir = $(develapicontrolsdir)/popup
+develapiprogressbardir = $(develapicontrolsdir)/progress-bar
develapishadowviewdir = $(develapicontrolsdir)/shadow-view
develapisuperblurviewdir = $(develapicontrolsdir)/super-blur-view
develapifocusmanagerdir = $(develapidir)/focus-manager
develapiimageatlas_HEADERS = $(devel_api_image_atlas_header_files)
develapimagnifier_HEADERS = $(devel_api_magnifier_header_files)
develapipopup_HEADERS = $(devel_api_popup_header_files)
+develapiprogressbar_HEADERS = $(devel_api_progress_bar_header_files)
develapivisualfactory_HEADERS = $(devel_api_visual_factory_header_files)
develapiscripting_HEADERS = $(devel_api_scripting_header_files)
develapishadowview_HEADERS = $(devel_api_shadow_view_header_files)
--- /dev/null
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/progress-bar/progress-bar.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/progress-bar/progress-bar-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+ProgressBar::ProgressBar()
+{
+}
+
+ProgressBar::ProgressBar( const ProgressBar& handle )
+: Control( handle )
+{
+}
+
+ProgressBar& ProgressBar::operator=( const ProgressBar& handle )
+{
+ if( &handle != this )
+ {
+ Control::operator=( handle );
+ }
+ return *this;
+}
+
+ProgressBar::ProgressBar(Internal::ProgressBar& implementation)
+: Control(implementation)
+{
+}
+
+ProgressBar::ProgressBar( Dali::Internal::CustomActor* internal )
+: Control( internal )
+{
+ VerifyCustomActorPointer<Internal::ProgressBar>(internal);
+}
+
+ProgressBar ProgressBar::New()
+{
+ return Internal::ProgressBar::New();
+}
+
+ProgressBar::~ProgressBar()
+{
+}
+
+ProgressBar::ValueChangedSignalType& ProgressBar::ValueChangedSignal()
+{
+ return GetImpl( *this ).ValueChangedSignal();
+}
+
+ProgressBar ProgressBar::DownCast( BaseHandle handle )
+{
+ return Control::DownCast<ProgressBar, Internal::ProgressBar>(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_PROGRESS_BAR_H
+#define DALI_TOOLKIT_PROGRESS_BAR_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class ProgressBar;
+}
+
+/**
+ * @brief ProgressBar is a control to give the user an indication of the progress of an operation.
+ *
+ * Also progress value percentage is shown as text inside the progress bar.
+ *
+ * Signals
+ * | %Signal Name | Method |
+ * |-------------------|-------------------------------|
+ * | valueChanged | @ref ValueChangedSignal() |
+ */
+class DALI_IMPORT_API ProgressBar : public Control
+{
+public:
+
+ // Properties
+
+ /**
+ * @brief The start and end property ranges for this control.
+ */
+ enum PropertyRange
+ {
+ PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< Start Index
+ PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
+ };
+
+ /**
+ * @brief An enumeration of properties belonging to the ProgressBar class.
+ */
+ struct Property
+ {
+ enum
+ {
+
+ /**
+ * @brief The progress value of progress bar, progress runs form 0 to 1.
+ * @details Name "progressValue", type Property::FLOAT.
+ * @note Optional. If not supplied, the default is 0.
+ * @note Value should be between 0 to 1.
+ * @note If Value is set to 0, progress bar will be set to beginning.
+ * @note If Value is set to 1, progress bar will be set to end.
+ * @note Any Value outside of the range is ignored.
+ */
+ PROGRESS_VALUE = PROPERTY_START_INDEX,
+
+ /**
+ * @brief The track Visual value of progress bar, it's a full progress area and it's shown behind PROGRESS_VISUAL.
+ * @details Name "trackVisual", type Property::STRING if it is a url, map otherwise.
+ * @note Optional. If not supplied, the default track visual will be shown.
+ */
+ TRACK_VISUAL,
+
+ /**
+ * @brief The progress Visual value of progress bar, size of the progress visual is changed based on PROGRESS_VALUE.
+ * @details Name "progressVisual", type Property::STRING if it is a url, map otherwise.
+ * @note Optional. If not supplied, the default progress visual will be shown.
+ */
+ PROGRESS_VISUAL,
+ };
+ };
+
+public:
+
+ /**
+ * @brief Creates the ProgressBar control.
+ * @return A handle to the ProgressBar control
+ */
+ static ProgressBar New();
+
+ /**
+ * @brief Creates an empty ProgressBar handle.
+ */
+ ProgressBar();
+
+ /**
+ * @brief Copy constructor.
+ *
+ * Creates another handle that points to the same real object.
+ */
+ ProgressBar( const ProgressBar& handle );
+
+ /**
+ * @brief Assignment operator.
+ *
+ * Changes this handle to point to another real object.
+ */
+ ProgressBar& operator=( const ProgressBar& handle );
+
+ /**
+ * @brief Destructor.
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~ProgressBar();
+
+ /**
+ * @brief Downcast an Object handle to ProgressBar.
+ *
+ * If handle points to a ProgressBar the
+ * downcast produces valid handle. If not the returned handle is left uninitialized.
+ * @param[in] handle Handle to an object
+ * @return handle to a ProgressBar or an uninitialized handle
+ */
+ static ProgressBar DownCast( BaseHandle handle );
+
+public: // Signals
+
+ /**
+ * @brief Value changed signal type.
+ */
+ typedef Signal< void ( ProgressBar, float ) > ValueChangedSignalType;
+
+ /**
+ * @brief Signal emitted when the ProgressBar value changes.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName( ProgressBar progressBar, float value );
+ * @endcode
+ * @return The signal to connect to
+ */
+ ValueChangedSignalType& ValueChangedSignal();
+
+public: // Not intended for application developers
+
+ /// @cond internal
+ /**
+ * @brief Creates a handle using the Toolkit::Internal implementation.
+ * @param[in] implementation The Control implementation
+ */
+ DALI_INTERNAL ProgressBar(Internal::ProgressBar& implementation);
+
+ /**
+ * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
+ * @param[in] internal A pointer to the internal CustomActor
+ */
+ explicit DALI_INTERNAL ProgressBar( Dali::Internal::CustomActor* internal );
+ /// @endcond
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_PROGRESS_BAR_H
$(devel_api_src_dir)/controls/magnifier/magnifier.cpp \
$(devel_api_src_dir)/controls/popup/confirmation-popup.cpp \
$(devel_api_src_dir)/controls/popup/popup.cpp \
+ $(devel_api_src_dir)/controls/progress-bar/progress-bar.cpp \
$(devel_api_src_dir)/controls/shadow-view/shadow-view.cpp \
$(devel_api_src_dir)/controls/super-blur-view/super-blur-view.cpp \
$(devel_api_src_dir)/controls/text-controls/text-selection-popup.cpp \
$(devel_api_src_dir)/controls/popup/confirmation-popup.h \
$(devel_api_src_dir)/controls/popup/popup.h
+devel_api_progress_bar_header_files = \
+ $(devel_api_src_dir)/controls/progress-bar/progress-bar.h
+
devel_api_visual_factory_header_files = \
$(devel_api_src_dir)/visual-factory/visual-factory.h \
$(devel_api_src_dir)/visual-factory/visual-base.h
--- /dev/null
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/controls/progress-bar/progress-bar-impl.h>
+
+// EXTERNAL INCLUDES
+#include <cstring> // for strcmp
+#include <sstream>
+#include <algorithm>
+#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
+#include <dali/public-api/math/math-utils.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace // Unnamed namespace
+{
+
+BaseHandle Create()
+{
+ return Dali::Toolkit::ProgressBar::New();
+}
+
+// Setup properties, signals and actions using the type-registry.
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ProgressBar, Toolkit::Control, Create )
+
+DALI_PROPERTY_REGISTRATION( Toolkit, ProgressBar, "progressValue", FLOAT, PROGRESS_VALUE )
+DALI_PROPERTY_REGISTRATION( Toolkit, ProgressBar, "trackVisual", MAP, TRACK_VISUAL )
+DALI_PROPERTY_REGISTRATION( Toolkit, ProgressBar, "progressVisual", MAP, PROGRESS_VISUAL )
+DALI_SIGNAL_REGISTRATION( Toolkit, ProgressBar, "valueChanged", SIGNAL_VALUE_CHANGED )
+
+DALI_TYPE_REGISTRATION_END()
+
+const char* SKINNED_TRACK_VISUAL = DALI_IMAGE_DIR "slider-skin.9.png";
+const char* SKINNED_PROGRESS_VISUAL = DALI_IMAGE_DIR "slider-skin-progress.9.png";
+
+float DEFAULT_VALUE = 0.0f;
+float DEFAULT_LOWER_BOUND = 0.0f;
+float DEFAULT_UPPER_BOUND = 1.0f;
+float DEFAULT_PADDING = 24.0f;
+
+} // Unnamed namespace
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// ProgressBar
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+Dali::Toolkit::ProgressBar ProgressBar::New()
+{
+ // Create the implementation
+ ProgressBarPtr progressBar( new ProgressBar() );
+
+ // Pass ownership to CustomActor via derived handle
+ Dali::Toolkit::ProgressBar handle( *progressBar );
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ progressBar->Initialize();
+
+ return handle;
+}
+
+ProgressBar::ProgressBar()
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+ mTrackVisual(""),
+ mProgressVisual(""),
+ mTrackMap(),
+ mTrackVisualSize(),
+ mProgressVisualSize(),
+ mValue( DEFAULT_VALUE )
+{
+}
+
+ProgressBar::~ProgressBar()
+{
+}
+
+void ProgressBar::OnInitialize()
+{
+ // Setup
+ CreateChildren();
+
+ // Properties
+ SetTrackVisual( SKINNED_TRACK_VISUAL );
+ SetProgressVisual( SKINNED_PROGRESS_VISUAL );
+
+ DisplayValue( mValue, false ); // Run this last to display the correct value
+}
+
+void ProgressBar::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+ Vector2 trackSize( size );
+ trackSize.width = std::max( 0.0f, size.width - DEFAULT_PADDING ); // Ensure we don't go negative
+
+ // Track
+ if( mTrack )
+ {
+ container.Add( mTrack, trackSize );
+
+ // mValueTextLabel will have its relayout method called automatically as it's a child of mTrack,
+ // which is added to the container
+ }
+
+ // Progress bar
+ if( mProgress )
+ {
+ mDomain = CalcDomain( trackSize );
+
+ Vector2 progressSize( trackSize );
+
+ // If no progress, then we do not want a n-patch image shown incorrectly
+ progressSize.width = std::max( mProgressVisualSize.width, mDomain.from.x + mValue * ( mDomain.to.x - mDomain.from.x ) );
+ progressSize.width = std::min( progressSize.width, trackSize.width ); // We should not exceed given size
+
+ container.Add( mProgress, progressSize );
+ }
+}
+
+Vector3 ProgressBar::GetNaturalSize()
+{
+ // Return the maximum width/height combinations of our visuals
+
+ Vector3 naturalSize;
+ naturalSize.width = std::max( mTrackVisualSize.width, mProgressVisualSize.width );
+ naturalSize.height = std::max( mTrackVisualSize.height, mProgressVisualSize.height );
+ return naturalSize;
+}
+
+ProgressBar::Domain ProgressBar::CalcDomain( const Vector2& currentSize )
+{
+ return Domain( Vector2( 0.0f, 0.0f ), currentSize );
+}
+
+void ProgressBar::DisplayValue( float value, bool raiseSignals )
+{
+ // Signals
+ if( raiseSignals )
+ {
+ Toolkit::ProgressBar self = Toolkit::ProgressBar::DownCast( Self() );
+ mValueChangedSignal.Emit( self, value );
+ }
+
+ // Change the value of the text label
+ if( mValueTextLabel )
+ {
+ std::stringstream ss;
+ ss.precision( 0 );
+ ss << std::fixed << ( value * 100 ) << "%";
+
+ std::string label = mValueTextLabel.GetProperty<std::string>( Toolkit::TextLabel::Property::TEXT );
+ if( label.compare(ss.str()) )
+ {
+ mValueTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, ss.str() );
+ }
+ }
+}
+
+Toolkit::ImageView ProgressBar::CreateTrack()
+{
+ Toolkit::ImageView track = Toolkit::ImageView::New();
+ track.SetParentOrigin( ParentOrigin::CENTER );
+ track.SetAnchorPoint( AnchorPoint::CENTER );
+ track.SetResizePolicy(ResizePolicy::USE_ASSIGNED_SIZE, Dimension::ALL_DIMENSIONS );
+
+ return track;
+}
+
+void ProgressBar::SetTrackVisual( const std::string& filename )
+{
+ if( mTrack && filename.size() > 0 )
+ {
+ mTrack.SetImage( filename );
+ mTrackVisual = filename;
+ mTrackVisualSize = Vector2::ZERO;
+ RelayoutRequest();
+ }
+}
+
+void ProgressBar::SetTrackVisual( Property::Map map )
+{
+ bool relayoutRequired = false;
+
+ Property::Value* imageValue = map.Find( "url" );
+ if( imageValue )
+ {
+ mTrackVisual.clear();
+ std::string filename;
+ if( imageValue->Get( filename ) )
+ {
+ if( mTrack && ( filename.size() > 0 ) )
+ {
+ mTrack.SetImage( filename );
+ mTrackMap = map;
+ relayoutRequired = true;
+ }
+ }
+ }
+
+ Property::Value* sizeValue = map.Find( "size" );
+ if( sizeValue )
+ {
+ Vector2 size;
+ if( sizeValue->Get( size ) )
+ {
+ mTrackVisualSize = size;
+ relayoutRequired = true;
+ }
+ }
+
+ // Visual and/or visual size changed so we need to relayout
+ if( relayoutRequired )
+ {
+ RelayoutRequest();
+ }
+}
+
+std::string ProgressBar::GetTrackVisual()
+{
+ return mTrackVisual;
+}
+
+Toolkit::ImageView ProgressBar::CreateProgress()
+{
+ Toolkit::ImageView progress = Toolkit::ImageView::New();
+ progress.SetParentOrigin( ParentOrigin::CENTER_LEFT );
+ progress.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+ progress.SetResizePolicy(ResizePolicy::USE_ASSIGNED_SIZE, Dimension::ALL_DIMENSIONS );
+
+ return progress;
+}
+
+void ProgressBar::SetProgressVisual( const std::string& filename )
+{
+ if( mProgress && ( filename.size() > 0 ) )
+ {
+ mProgress.SetImage( filename );
+ mProgressVisual = filename;
+ mProgressVisualSize = Vector2::ZERO;
+ RelayoutRequest();
+ }
+}
+
+void ProgressBar::SetProgressVisual( Property::Map map )
+{
+ bool relayoutRequired = false;
+
+ Property::Value* imageValue = map.Find( "url" );
+ if( imageValue )
+ {
+ mProgressVisual.clear();
+ std::string filename;
+ if( imageValue->Get( filename ) )
+ {
+ if( mProgress && ( filename.size() > 0 ) )
+ {
+ mProgress.SetImage( filename );
+ mProgressMap = map;
+ relayoutRequired = true;
+ }
+ }
+ }
+
+ Property::Value* sizeValue = map.Find( "size" );
+ if( sizeValue )
+ {
+ Vector2 size;
+ if( sizeValue->Get( size ) )
+ {
+ mProgressVisualSize = size;
+ relayoutRequired = true;
+ }
+ }
+
+ // Visual and/or visual size changed so we need to relayout
+ if( relayoutRequired )
+ {
+ RelayoutRequest();
+ }
+}
+
+std::string ProgressBar::GetProgressVisual()
+{
+ return mProgressVisual;
+}
+
+Toolkit::ProgressBar::ValueChangedSignalType& ProgressBar::ValueChangedSignal()
+{
+ return mValueChangedSignal;
+}
+
+void ProgressBar::CreateChildren()
+{
+ Actor self = Self();
+
+ // Track
+ mTrack = CreateTrack();
+ self.Add( mTrack ); // Needs to be a direct child as we want to manipulate its size
+
+ // Progress bar
+ mProgress = CreateProgress();
+ self.Add( mProgress ); // Needs to be a direct child as we want to manipulate its size
+
+ // Value Text
+ mValueTextLabel = Toolkit::TextLabel::New();
+ mValueTextLabel.SetName( "ProgressBarValueTextLabel" );
+ mValueTextLabel.SetStyleName( "ProgressBarValueTextLabel" );
+ mValueTextLabel.SetParentOrigin( ParentOrigin::CENTER );
+ mValueTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
+ mValueTextLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ mValueTextLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+ mTrack.Add( mValueTextLabel ); // Add to mTrack and let it automatically set its size
+}
+
+void ProgressBar::SetProgressValue( float value )
+{
+ // update the progress bar value (taking float precision errors into account)
+ if( ( mValue != value ) &&
+ ( ( value >= DEFAULT_LOWER_BOUND ) || ( Equals( value, DEFAULT_LOWER_BOUND ) ) ) &&
+ ( ( value <= DEFAULT_UPPER_BOUND ) || ( Equals( value, DEFAULT_UPPER_BOUND ) ) ) )
+ {
+ mValue = Clamp( value, DEFAULT_LOWER_BOUND, DEFAULT_UPPER_BOUND );
+ DisplayValue( mValue, true );
+ RelayoutRequest();
+ }
+}
+
+float ProgressBar::GetProgressValue() const
+{
+ return mValue;
+}
+
+// Static class method to support script connecting signals
+bool ProgressBar::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+{
+ Dali::BaseHandle handle( object );
+
+ bool connected = true;
+ Toolkit::ProgressBar ProgressBar = Toolkit::ProgressBar::DownCast( handle );
+
+ if( 0 == strcmp( signalName.c_str(), SIGNAL_VALUE_CHANGED ) )
+ {
+ ProgressBar.ValueChangedSignal().Connect( tracker, functor );
+ }
+ else
+ {
+ // signalName does not match any signal
+ connected = false;
+ }
+
+ return connected;
+}
+
+void ProgressBar::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
+{
+ Toolkit::ProgressBar progressBar = Toolkit::ProgressBar::DownCast( Dali::BaseHandle( object ) );
+
+ if ( progressBar )
+ {
+ ProgressBar& progressBarImpl( GetImpl( progressBar ) );
+
+ switch ( propertyIndex )
+ {
+ case Toolkit::ProgressBar::Property::PROGRESS_VALUE:
+ {
+ progressBarImpl.SetProgressValue( value.Get< float >() );
+ break;
+ }
+
+ case Toolkit::ProgressBar::Property::TRACK_VISUAL:
+ {
+ Property::Map map;
+ if( value.Get( map ) )
+ {
+ progressBarImpl.SetTrackVisual( map );
+ }
+ break;
+ }
+
+ case Toolkit::ProgressBar::Property::PROGRESS_VISUAL:
+ {
+ Property::Map map;
+ if( value.Get( map ) )
+ {
+ progressBarImpl.SetProgressVisual( map );
+ }
+ break;
+ }
+ }
+ }
+}
+
+Property::Value ProgressBar::GetProperty( BaseObject* object, Property::Index propertyIndex )
+{
+ Property::Value value;
+
+ Toolkit::ProgressBar progressBar = Toolkit::ProgressBar::DownCast( Dali::BaseHandle( object ) );
+
+ if ( progressBar )
+ {
+ ProgressBar& progressBarImpl( GetImpl( progressBar ) );
+
+ switch ( propertyIndex )
+ {
+ case Toolkit::ProgressBar::Property::PROGRESS_VALUE:
+ {
+ value = progressBarImpl.GetProgressValue();
+ break;
+ }
+
+ case Toolkit::ProgressBar::Property::TRACK_VISUAL:
+ {
+ if( !progressBarImpl.mTrackVisual.empty() )
+ {
+ value = progressBarImpl.GetTrackVisual();
+ }
+ else if( !progressBarImpl.mTrackMap.Empty() )
+ {
+ value = progressBarImpl.mTrackMap;
+ }
+ break;
+ }
+
+ case Toolkit::ProgressBar::Property::PROGRESS_VISUAL:
+ {
+ if( !progressBarImpl.mProgressVisual.empty() )
+ {
+ value = progressBarImpl.GetProgressVisual();
+ }
+ else if( !progressBarImpl.mProgressMap.Empty() )
+ {
+ value = progressBarImpl.mProgressMap;
+ }
+ break;
+ }
+ }
+ }
+
+ return value;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H
+#define DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/property-map.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/devel-api/controls/progress-bar/progress-bar.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+class ProgressBar;
+
+typedef Dali::IntrusivePtr< ProgressBar > ProgressBarPtr;
+
+/**
+ * @copydoc Toolkit::ProgressBar
+ */
+class ProgressBar : public Control
+{
+public:
+
+ /**
+ * Create a new ProgressBar.
+ *
+ * @return A public handle to the newly allocated ProgressBar.
+ */
+ static Dali::Toolkit::ProgressBar New();
+
+public:
+
+ // Properties
+
+ /**
+ * Set the value of the ProgressBar
+ *
+ * @param[in] value The value to set. Will be clamped to [lowerBound .. upperBound]
+ */
+
+ void SetProgressValue( float value );
+
+ /**
+ * Get the value of the ProgressBar
+ *
+ * @return The current value of the ProgressBar
+ */
+ float GetProgressValue() const;
+
+public:
+ //Signals
+
+ /**
+ * @copydoc Toolkit::ProgressBar::ValueChangedSignal()
+ */
+ Toolkit::ProgressBar::ValueChangedSignalType& ValueChangedSignal();
+
+ /**
+ * Connects a callback function with the object's signals.
+ * @param[in] object The object providing the signal.
+ * @param[in] tracker Used to disconnect the signal.
+ * @param[in] signalName The signal to connect to.
+ * @param[in] functor A newly allocated FunctorDelegate.
+ * @return True if the signal was connected.
+ * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+ */
+ static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName,
+ FunctorDelegate* functor );
+
+ // Properties
+
+ /**
+ * Called when a property of an object of this type is set.
+ * @param[in] object The object whose property is set.
+ * @param[in] index The property index.
+ * @param[in] value The new property value.
+ */
+ static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+
+ /**
+ * Called to retrieve a property of an object of this type.
+ * @param[in] object The object whose property is to be retrieved.
+ * @param[in] index The property index.
+ * @return The current value of the property.
+ */
+ static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
+
+protected:
+
+ /**
+ * Construct a new ProgressBar.
+ */
+ ProgressBar();
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~ProgressBar();
+
+ /**
+ * @copydoc CustomActorImpl::OnRelayout()
+ */
+ virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+ /**
+ * @copydoc CustomActorImpl::GetNaturalSize()
+ */
+ virtual Vector3 GetNaturalSize();
+
+private:
+
+ /**
+ * Domain is a from/to pair
+ */
+ struct Domain
+ {
+ Vector2 from;
+ Vector2 to;
+
+ Domain()
+ {
+ }
+ Domain( Vector2 fromVal, Vector2 toVal )
+ : from( fromVal ), to( toVal )
+ {
+ }
+ };
+
+private:
+
+ /**
+ * @copydoc Toolkit::Control::OnInitialize()
+ */
+ virtual void OnInitialize();
+
+ /**
+ * Get the range of the valid values the ProgressBar handle can move between
+ *
+ * @param[in] currentSize The current size of the ProgressBar
+ * @return The range as a domain pair
+ */
+ Domain CalcDomain( const Vector2& currentSize );
+
+ /**
+ * Create the track for the ProgressBar
+ *
+ * @return The track actor
+ */
+ Toolkit::ImageView CreateTrack();
+
+ /**
+ * Create the progress track for the ProgressBar
+ *
+ * @return The track actor
+ */
+ Toolkit::ImageView CreateProgress();
+
+ /**
+ * Create all the children
+ */
+ void CreateChildren();
+
+ /**
+ * Set value choosing whether to fire signals or not
+ *
+ * @paramp[in] value The value to set
+ * @param[in] raiseSignals Configure signals to be raised or not.
+ */
+ void DisplayValue( float value, bool raiseSignals );
+
+ /**
+ * Create the image for the track
+ *
+ * @param[in] filename The track image
+ */
+ void SetTrackVisual( const std::string& filename );
+
+ /**
+ * @brief Set the track visual from an Dali::Property::Map
+ *
+ * @param[in] map The Dali::Property::Map to use for to display
+ */
+ void SetTrackVisual( Dali::Property::Map map );
+
+ /**
+ * @brief Return the track image.
+ *
+ * @return The track image.
+ */
+ std::string GetTrackVisual();
+
+ /**
+ * Create the image for the progress bar
+ *
+ * @param[in] filename The progress bar image
+ */
+ void SetProgressVisual( const std::string& filename );
+
+ /**
+ * @brief Set the progress visual from an Dali::Property::Map
+ *
+ * @param[in] map The Dali::Property::Map to use for to display
+ */
+ void SetProgressVisual( Dali::Property::Map map );
+
+ /**
+ * @brief Return the progress bar image.
+ *
+ * @return The progress bar image if it exists.
+ */
+ std::string GetProgressVisual();
+
+private:
+
+ // Undefined
+ ProgressBar( const ProgressBar& );
+
+ // Undefined
+ ProgressBar& operator=( const ProgressBar& rhs );
+
+private:
+
+ Domain mDomain; ///< Current domain of the handle
+
+ Toolkit::ImageView mTrack; ///< Track image
+ Toolkit::ImageView mProgress; ///< Progress bar
+ Toolkit::TextLabel mValueTextLabel; ///< Text value to show progress percentage
+ Toolkit::ProgressBar::ValueChangedSignalType mValueChangedSignal; ///< Signal emitted when the value is changed
+
+ std::string mTrackVisual; ///< Image for track image
+ std::string mProgressVisual; ///< Image for progress bar image
+
+ Property::Map mTrackMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise
+ Property::Map mProgressMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise
+
+ Vector2 mTrackVisualSize; ///< Size of the track image used
+ Vector2 mProgressVisualSize; ///< Size of progress image used
+
+ float mValue; ///< Current value of ProgressBar
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Toolkit::Internal::ProgressBar& GetImpl( Toolkit::ProgressBar& pub )
+{
+ DALI_ASSERT_ALWAYS( pub );
+
+ Dali::RefObject& handle = pub.GetImplementation();
+
+ return static_cast< Toolkit::Internal::ProgressBar& >( handle );
+}
+
+inline const Toolkit::Internal::ProgressBar& GetImpl( const Toolkit::ProgressBar& pub )
+{
+ DALI_ASSERT_ALWAYS( pub );
+
+ const Dali::RefObject& handle = pub.GetImplementation();
+
+ return static_cast< const Toolkit::Internal::ProgressBar& >( handle );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H
$(toolkit_src_dir)/controls/page-turn-view/page-turn-effect.cpp \
$(toolkit_src_dir)/controls/page-turn-view/page-turn-landscape-view-impl.cpp \
$(toolkit_src_dir)/controls/page-turn-view/page-turn-view-impl.cpp \
+ $(toolkit_src_dir)/controls/progress-bar/progress-bar-impl.cpp \
$(toolkit_src_dir)/controls/scroll-bar/scroll-bar-impl.cpp \
$(toolkit_src_dir)/controls/scrollable/bouncing-effect-actor.cpp \
$(toolkit_src_dir)/controls/scrollable/item-view/depth-layout.cpp \
"grabHandleImage" : "{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png",
"selectionHandleImageLeft" : {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png" },
"selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
+ },
+ "ProgressBar":
+ {
+ "progressValue": 0,
+ "trackVisual":{
+ "url":"{DALI_IMAGE_DIR}slider-skin.9.png",
+ "size":[24,24]
+ },
+ "progressVisual":{
+ "url":"{DALI_IMAGE_DIR}slider-skin-progress.9.png",
+ "size":[24,24]
+ }
+ },
+ "ProgressBarValueTextLabel":
+ {
+ "textColor":[0.8,0.8,1,1]
}
}
}
"SliderHandleTextLabel":
{
"textColor":[0.8,0.8,1,1]
+ },
+ "ProgressBar":
+ {
+ "progressValue": 0,
+ "trackVisual":{
+ "url":"{DALI_IMAGE_DIR}slider-skin.9.png",
+ "size":[24,24]
+ },
+ "progressVisual":{
+ "url":"{DALI_IMAGE_DIR}slider-skin-progress.9.png",
+ "size":[24,24]
+ }
+ },
+ "ProgressBarValueTextLabel":
+ {
+ "textColor":[0.8,0.8,1,1]
}
}
}
"SliderHandleTextLabel":
{
"textColor":[0.8,0.8,1,1]
+ },
+ "ProgressBar":
+ {
+ "progressValue": 0,
+ "trackVisual":{
+ "url":"{DALI_IMAGE_DIR}slider-skin.9.png",
+ "size":[24,24]
+ },
+ "progressVisual":{
+ "url":"{DALI_IMAGE_DIR}slider-skin-progress.9.png",
+ "size":[24,24]
+ }
+ },
+ "ProgressBarValueTextLabel":
+ {
+ "textColor":[0.8,0.8,1,1]
}
}
}