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;
+}
+
application.SendNotification();
application.Render();
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ // renderer is not added to actor until the rasterization is completed.
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
EventThreadCallback* eventTrigger = EventThreadCallback::Get();
CallbackBase* callback = eventTrigger->GetCallback();
eventTrigger->WaitingForTrigger( 1 );// waiting until the svg image is rasterized.
CallbackBase::Execute( *callback );
+ // renderer is added to actor
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
// waiting for the resource uploading
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
float GetDepthIndex() const;
/**
- * @brief Visual needs to know when when the control is put on to the stage to add the renderer.
+ * @brief Visual needs to know when the control is put on to the stage to add the renderer.
*
* This function should be called when the control is put on to the stage.
*
void SetOnStage( Actor& actor );
/**
- * @brief Visual needs to know when when the control is removed from the stage to remove the renderer.
+ * @brief Visual needs to know when the control is removed from the stage to remove the renderer.
*
* This function should be called when the control is removed from the stage
*
visual = visualFactory.CreateVisual( map );
RegisterVisual( visualIndex, placementActor, visual );
- visual.SetOnStage( placementActor );
SetupContent( *contentActor, placementActor ); //
contentActor->SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
mImage = image;
Actor self( Self() );
- InitializeVisual( self, mVisual, image );
+ mVisual = Toolkit::VisualFactory::Get().CreateVisual( image );
+ RegisterVisual( Toolkit::ImageView::Property::IMAGE, self, mVisual );
mImageSize = image ? ImageDimensions( image.GetWidth(), image.GetHeight() ) : ImageDimensions( 0, 0 );
RelayoutRequest();
mPropertyMap = map;
Actor self( Self() );
- InitializeVisual( self, mVisual, mPropertyMap );
+ mVisual = Toolkit::VisualFactory::Get().CreateVisual( mPropertyMap );
+ RegisterVisual( Toolkit::ImageView::Property::IMAGE, self, mVisual );
Property::Value* widthValue = mPropertyMap.Find( "width" );
if( widthValue )
}
Actor self( Self() );
- InitializeVisual( self, mVisual, url, size );
+ mVisual = Toolkit::VisualFactory::Get().CreateVisual( url, size );
+ RegisterVisual( Toolkit::ImageView::Property::IMAGE, self, mVisual );
mVisual.SetSize( mSizeSet );
// Private methods
//
-void ImageView::OnStageConnection( int depth )
-{
- Control::OnStageConnection( depth );
-
- if( mVisual )
- {
- CustomActor self = Self();
- mVisual.SetOnStage( self );
- }
-}
-
-void ImageView::OnStageDisconnection()
-{
- if( mVisual )
- {
- CustomActor self = Self();
- mVisual.SetOffStage( self );
- }
-
- Control::OnStageDisconnection();
-}
-
void ImageView::OnSizeSet( const Vector3& targetSize )
{
Control::OnSizeSet( targetSize );
private: // From Control
/**
- * @copydoc Toolkit::Control::OnStageConnect()
- */
- virtual void OnStageConnection( int depth );
-
- /**
- * @copydoc Toolkit::Control::OnStageDisconnection()
- */
- virtual void OnStageDisconnection();
-
- /**
* @copydoc Toolkit::Control::OnSizeSet()
*/
virtual void OnSizeSet( const Vector3& targetSize );
--- /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 \
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
}
mBorderSizeIndex = (mImpl->mRenderer).RegisterProperty( Toolkit::BorderVisual::Property::SIZE, SIZE_NAME, mBorderSize );
+
+ actor.AddRenderer( mImpl->mRenderer );
}
void BorderVisual::DoCreatePropertyMap( Property::Map& map ) const
protected:
/**
- * @copydoc Visual::DoInitialize
+ * @copydoc Visual::Base::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc Visual::DoSetOnStage
+ * @copydoc Visual::Base::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
/**
- * @copydoc Visual::CreatePropertyMap
+ * @copydoc Visual::Base::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
void ColorVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
+
+ actor.AddRenderer( mImpl->mRenderer );
}
void ColorVisual::DoCreatePropertyMap( Property::Map& map ) const
public: // from Visual
/**
- * @copydoc Visual::SetSize
+ * @copydoc Visual::Base::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc Visual::CreatePropertyMap
+ * @copydoc Visual::Base::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc Visual::DoInitialize
+ * @copydoc Visual::Base::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc Visual::DoSetOnStage
+ * @copydoc Visual::Base::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
void GradientVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
+
+ actor.AddRenderer( mImpl->mRenderer );
}
void GradientVisual::DoCreatePropertyMap( Property::Map& map ) const
public: // from Visual
/**
- * @copydoc Visual::SetSize
+ * @copydoc Visual::Base::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc Visual::CreatePropertyMap
+ * @copydoc Visual::Base::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc Visual::DoInitialize
+ * @copydoc Visual::Base::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc Visual::DoSetOnStage
+ * @copydoc Visual::Base::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
}
// Turn batching on, to send message it must be on stage
mImpl->mRenderer.SetProperty( Dali::Renderer::Property::BATCHING_ENABLED, true );
+
+ actor.AddRenderer( mImpl->mRenderer );
}
void BatchImageVisual::DoSetOffStage( Actor& actor )
{
mImpl->mRenderer.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, mPixelArea );
}
+
+ actor.AddRenderer( mImpl->mRenderer );
}
void ImageVisual::DoSetOffStage( Actor& actor )
public: // from Visual
/**
- * @copydoc Visual::GetNaturalSize
+ * @copydoc Visual::Base::GetNaturalSize
*/
virtual void GetNaturalSize( Vector2& naturalSize ) const;
/**
- * @copydoc Visual::CreatePropertyMap
+ * @copydoc Visual::Base::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc Visual::DoInitialize
+ * @copydoc Visual::Base::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc Visual::DoSetOnStage
+ * @copydoc Visual::Base::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
/**
- * @copydoc Visual::DoSetOffStage
+ * @copydoc Visual::Base::DoSetOffStage
*/
virtual void DoSetOffStage( Actor& actor );
void MeshVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
+
+ actor.AddRenderer( mImpl->mRenderer );
}
void MeshVisual::DoCreatePropertyMap( Property::Map& map ) const
public: // from Visual
/**
- * @copydoc Visual::SetSize
+ * @copydoc Visual::Base::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc Visual::CreatePropertyMap
+ * @copydoc Visual::Base::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc Visual::DoInitialize
+ * @copydoc Visual::Base::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc Visual::DoSetOnStage
+ * @copydoc Visual::Base::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
{
ApplyImageToSampler();
}
+
+ actor.AddRenderer( mImpl->mRenderer );
}
void NPatchVisual::DoSetOffStage( Actor& actor )
public: // from Visual
/**
- * @copydoc Visual::GetNaturalSize
+ * @copydoc Visual::Base::GetNaturalSize
*/
virtual void GetNaturalSize( Vector2& naturalSize ) const;
/**
- * @copydoc Visual::CreatePropertyMap
+ * @copydoc Visual::Base::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc Visual::DoInitialize
+ * @copydoc Visual::Base::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc Visual::DoSetOnStage
+ * @copydoc Visual::Base::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
/**
- * @copydoc Visual::DoSetOffStage
+ * @copydoc Visual::Base::DoSetOffStage
*/
virtual void DoSetOffStage( Actor& actor );
void PrimitiveVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
+
+ actor.AddRenderer( mImpl->mRenderer );
}
void PrimitiveVisual::DoCreatePropertyMap( Property::Map& map ) const
public: // from Visual
/**
- * @copydoc Visual::SetSize
+ * @copydoc Visual::Base::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc Visual::GetNaturalSize
+ * @copydoc Visual::Base::GetNaturalSize
*/
virtual void GetNaturalSize( Vector2& naturalSize ) const;
/**
- * @copydoc Visual::CreatePropertyMap
+ * @copydoc Visual::Base::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc Visual::DoInitialize
+ * @copydoc Visual::Base::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc Visual::DoSetOnStage
+ * @copydoc Visual::Base::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
{
AddRasterizationTask( mImpl->mSize );
}
+
+ // Hold the weak handle of the placement actor and delay the adding of renderer until the svg rasterization is finished.
+ mPlacementActor = actor;
}
void SvgVisual::DoSetOffStage( Actor& actor )
actor.RemoveRenderer( mImpl->mRenderer );
mImpl->mRenderer.Reset();
+ mPlacementActor.Reset();
}
void SvgVisual::GetNaturalSize( Vector2& naturalSize ) const
TextureSetImage( textureSet, 0u, texture );
}
}
+
+ // Rasterized pixels are uploaded to texture. If weak handle is holding a placement actor, it is the time to add the renderer to actor.
+ Actor actor = mPlacementActor.GetHandle();
+ if( actor )
+ {
+ actor.AddRenderer( mImpl->mRenderer );
+ // reset the weak handle so that the renderer only get added to actor once
+ mPlacementActor.Reset();
+ }
}
}
-
} // namespace Internal
} // namespace Toolkit
*
*/
+//EXTERNAL INCLUDES
+#include <dali/devel-api/object/weak-handle.h>
+
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
public: // from Visual
/**
- * @copydoc Visual::GetNaturalSize
+ * @copydoc Visual::Base::GetNaturalSize
*/
virtual void GetNaturalSize( Vector2& naturalSize ) const;
/**
- * @copydoc Visual::SetSize
+ * @copydoc Visual::Base::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc Visual::CreatePropertyMap
+ * @copydoc Visual::Base::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc Visual::DoInitialize
+ * @copydoc Visual::Base::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc Visual::DoSetOnStage
+ * @copydoc Visual::Base::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
/**
- * @copydoc Visual::DoSetOffStage
+ * @copydoc Visual::Base::DoSetOffStage
*/
virtual void DoSetOffStage( Actor& actor );
Vector4 mAtlasRect;
std::string mImageUrl;
NSVGimage* mParsedImage;
+ WeakHandle<Actor> mPlacementActor;
};
void Visual::Base::SetOnStage( Actor& actor )
{
+ // To display the actor correctly, renderer should not be added to actor until all required resources are ready.
+ // Thus the calling of actor.AddRenderer() should happen inside derived class as base class does not know the exact timing.
DoSetOnStage( actor );
mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
- actor.AddRenderer( mImpl->mRenderer );
-
mImpl->mFlags |= Impl::IS_ON_STAGE;
}
return mImpl->mFlags & Impl::IS_PREMULTIPLIED_ALPHA;
}
-void Visual::Base::DoSetOnStage( Actor& actor )
-{
-}
-
void Visual::Base::DoSetOffStage( Actor& actor )
{
actor.RemoveRenderer( mImpl->mRenderer );
/**
* @brief Called by SetOnStage() allowing sub classes to respond to the SetOnStage event
*
+ * @note The derived class is required to create the renderer, and add it to the actor when all the resources are in place.
+ *
* @param[in] actor The actor applying this visual.
*/
- virtual void DoSetOnStage( Actor& actor );
+ virtual void DoSetOnStage( Actor& actor )=0;
/**
* @brief Called by SetOffStage() allowing sub classes to respond to the SetOffStage event
void WireframeVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
+
+ actor.AddRenderer( mImpl->mRenderer );
}
void WireframeVisual::DoCreatePropertyMap( Property::Map& map ) const
protected:
/**
- * @copydoc Visual::DoSetOnStage
+ * @copydoc Visual::Base::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
/**
- * @copydoc Visual::CreatePropertyMap
+ * @copydoc Visual::Base::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/rendering/renderer.h>
#include <dali/public-api/size-negotiation/relayout-container.h>
+#include <dali/devel-api/common/owner-container.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
RegisteredVisual( Property::Index aIndex, Toolkit::Visual::Base &aVisual, Actor &aPlacementActor) : index(aIndex), visual(aVisual), placementActor(aPlacementActor) {}
};
+typedef Dali::OwnerContainer< RegisteredVisual* > RegisteredVisuals;
+
/**
* Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
*/
-bool FindVisual( Property::Index targetIndex, std::vector<RegisteredVisual>& visuals, std::vector<RegisteredVisual>::iterator& iter )
+bool FindVisual( Property::Index targetIndex, RegisteredVisuals& visuals, RegisteredVisuals::Iterator& iter )
{
- for ( iter = visuals.begin(); iter != visuals.end(); iter++ )
+ for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
{
- if ( (*iter).index == targetIndex )
+ if ( (*iter)->index == targetIndex )
{
return true;
}
// Data
Control& mControlImpl;
- std::vector<RegisteredVisual> mVisuals; // Stores visuals needed by the control, non trivial type so std::vector used.
+ RegisteredVisuals mVisuals; // Stores visuals needed by the control, non trivial type so std::vector used.
std::string mStyleName;
Toolkit::Visual::Base mBackgroundVisual; ///< The visual to render the background
Vector4 mBackgroundColor; ///< The color of the background visual
Property::Map map;
map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR;
map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
- InitializeVisual( self, mImpl->mBackgroundVisual, map );
+ mImpl->mBackgroundVisual = Toolkit::VisualFactory::Get().CreateVisual( map );
+ RegisterVisual( Toolkit::Control::Property::BACKGROUND, self, mImpl->mBackgroundVisual );
if( mImpl->mBackgroundVisual )
{
mImpl->mBackgroundVisual.SetDepthIndex( DepthIndex::BACKGROUND );
void Control::SetBackground( const Property::Map& map )
{
Actor self( Self() );
- InitializeVisual( self, mImpl->mBackgroundVisual, map );
+ mImpl->mBackgroundVisual = Toolkit::VisualFactory::Get().CreateVisual( map );
+ RegisterVisual( Toolkit::Control::Property::BACKGROUND, self, mImpl->mBackgroundVisual );
if( mImpl->mBackgroundVisual )
{
mImpl->mBackgroundVisual.SetDepthIndex( DepthIndex::BACKGROUND );
void Control::SetBackgroundImage( Image image )
{
Actor self( Self() );
- InitializeVisual( self, mImpl->mBackgroundVisual, image );
+ mImpl->mBackgroundVisual = Toolkit::VisualFactory::Get().CreateVisual( image );
+ RegisterVisual( Toolkit::Control::Property::BACKGROUND, self, mImpl->mBackgroundVisual );
if( mImpl->mBackgroundVisual )
{
mImpl->mBackgroundVisual.SetDepthIndex( DepthIndex::BACKGROUND );
OnKeyboardEnter();
}
-void Control::RegisterVisual( Property::Index index, Actor placementActor, Toolkit::Visual::Base visual )
+void Control::RegisterVisual( Property::Index index, Actor& placementActor, Toolkit::Visual::Base& visual )
{
bool visualReplaced ( false );
Actor actorToRegister; // Null actor, replaced if placement actor not Self
+ Actor self = Self();
- if ( placementActor != Self() ) // Prevent increasing ref count if actor self
+ if ( placementActor != self ) // Prevent increasing ref count if actor self
{
actorToRegister = placementActor;
}
- if ( !mImpl->mVisuals.empty() )
+ if ( !mImpl->mVisuals.Empty() )
{
- std::vector<RegisteredVisual>::iterator iter;
+ RegisteredVisuals::Iterator iter;
// Check if visual (index) is already registered. Replace if so.
if ( FindVisual( index, mImpl->mVisuals, iter ) )
{
- (*iter).visual = visual;
- (*iter).placementActor = actorToRegister;
+ if( (*iter)->visual && self.OnStage() )
+ {
+ if( (*iter)->placementActor )
+ {
+ (*iter)->visual.SetOffStage( (*iter)->placementActor );
+ }
+ else
+ {
+ (*iter)->visual.SetOffStage( self );
+ }
+ }
+ (*iter)->visual = visual;
+ (*iter)->placementActor = actorToRegister;
visualReplaced = true;
}
}
if ( !visualReplaced ) // New registration entry
{
- RegisteredVisual newVisual = RegisteredVisual( index, visual, actorToRegister );
- mImpl->mVisuals.push_back( newVisual );
+ mImpl->mVisuals.PushBack( new RegisteredVisual( index, visual, actorToRegister ) );
+ }
+
+ if( visual && self.OnStage() )
+ {
+ visual.SetOnStage( placementActor );
}
}
void Control::UnregisterVisual( Property::Index index )
{
- std::vector< RegisteredVisual >::iterator iter;
+ RegisteredVisuals::Iterator iter;
if ( FindVisual( index, mImpl->mVisuals, iter ) )
{
- mImpl->mVisuals.erase( iter );
+ mImpl->mVisuals.Erase( iter );
}
}
-Toolkit::Visual::Base Control::GetVisual( Property::Index index )
+Toolkit::Visual::Base Control::GetVisual( Property::Index index ) const
{
- std::vector< RegisteredVisual >::iterator iter;
+ RegisteredVisuals::Iterator iter;
if ( FindVisual( index, mImpl->mVisuals, iter ) )
{
- return (*iter).visual;
+ return (*iter)->visual;
}
return Toolkit::Visual::Base();
}
-Actor Control::GetPlacementActor( Property::Index index )
+Actor Control::GetPlacementActor( Property::Index index ) const
{
- std::vector< RegisteredVisual >::iterator iter;
+ RegisteredVisuals::Iterator iter;
if ( FindVisual( index, mImpl->mVisuals, iter ) )
{
- if( (*iter).placementActor )
+ if( (*iter)->placementActor )
{
- return (*iter).placementActor;
+ return (*iter)->placementActor;
}
else
{
void Control::OnStageConnection( int depth )
{
- if( mImpl->mBackgroundVisual)
+ for(RegisteredVisuals::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++)
{
- Actor self( Self() );
- mImpl->mBackgroundVisual.SetOnStage( self );
+ // Check whether the visual is empty, as it is allowed to register a placement actor without visual.
+ if( (*iter)->visual )
+ {
+ if( (*iter)->placementActor )
+ {
+ (*iter)->visual.SetOnStage( (*iter)->placementActor );
+ }
+ else
+ {
+ Actor self( Self() );
+ (*iter)->visual.SetOnStage( self );
+ }
+ }
}
}
void Control::OnStageDisconnection()
{
- if( mImpl->mBackgroundVisual )
+ for(RegisteredVisuals::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++)
{
- Actor self( Self() );
- mImpl->mBackgroundVisual.SetOffStage( self );
+ // Check whether the visual is empty, as it is allowed to register a placement actor without visual.
+ if( (*iter)->visual )
+ {
+ if( (*iter)->placementActor )
+ {
+ (*iter)->visual.SetOffStage( (*iter)->placementActor );
+ }
+ else
+ {
+ Actor self( Self() );
+ (*iter)->visual.SetOffStage( self );
+ }
+ }
}
}
* @param[in] index The Property index of the visual, used to reference visual
* @param[in] placementActor The actor used to by the visual.
* @param[in] visual The visual to register
+ * @note Derived class must NOT call visual.SetOnStage(placementActor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
*/
- void RegisterVisual( Property::Index index, Actor placementActor, Toolkit::Visual::Base visual );
+ void RegisterVisual( Property::Index index, Actor& placementActor, Toolkit::Visual::Base& visual );
/**
* @brief Erase the entry matching the given index from the list of registered visuals
* @return The registered visual if exist, otherwise empty handle.
* @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
*/
- Toolkit::Visual::Base GetVisual( Property::Index index );
+ Toolkit::Visual::Base GetVisual( Property::Index index ) const;
/**
* @brief Retrieve the placement actor associated with the given index.
* @return Then placement actor if exist, otherwise empty handle.
* @note For managing object life-cycle, do not store the returned placement actor as a member which increments its reference count.
*/
- Actor GetPlacementActor( Property::Index index );
+ Actor GetPlacementActor( Property::Index index ) const;
/**
* @brief Emits KeyInputFocusGained signal if true else emits KeyInputFocusLost signal
"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]
}
}
}