/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
#include <dali/integration-api/events/key-event-integ.h>
+// for Internal::StyleManager
+#include <dali-toolkit/internal/styling/style-manager-impl.h>
+
using namespace Dali;
using namespace Dali::Toolkit;
END_TEST;
}
+
+
+int UtcDaliStyleManagerNewWithAdditionalBehavior(void)
+{
+ ToolkitTestApplication application;
+
+ Toolkit::StyleManager styleManager = StyleManager::Get();
+ Toolkit::Internal::StyleManager& styleManagerImpl = GetImpl(styleManager);
+
+ auto checkup = [&styleManagerImpl](int enableStyleChangeSignal, const Control& control){
+ DALI_TEST_EQUALS( enableStyleChangeSignal, styleManagerImpl.ControlStyleChangeSignal().GetConnectionCount(), TEST_LOCATION );
+ };
+
+ // Default New
+ tet_infoline( "Check whether ControlStyleChangeSignal connected in default New\n");
+ checkup(1, Control::New());
+ checkup(1, ImageView::New());
+ checkup(1, ImageView::New("url"));
+ checkup(1, ImageView::New("url", Dali::ImageDimensions(32u, 32u)));
+ checkup(1, TextLabel::New());
+ checkup(1, TextLabel::New("text"));
+
+ // New with additional behaviour, but enable style change signals
+ tet_infoline( "Check whether ControlStyleChangeSignal connected in non-disable style change signals\n");
+ checkup(1, Control::New(Toolkit::Control::ControlBehaviour::CONTROL_BEHAVIOUR_DEFAULT));
+ checkup(1, Control::New(Toolkit::Control::ControlBehaviour::DISABLE_SIZE_NEGOTIATION));
+ checkup(1, Control::New(Toolkit::Control::ControlBehaviour::REQUIRES_KEYBOARD_NAVIGATION_SUPPORT));
+ checkup(1, ImageView::New(Toolkit::Control::ControlBehaviour::CONTROL_BEHAVIOUR_DEFAULT));
+ checkup(1, ImageView::New(Toolkit::Control::ControlBehaviour::CONTROL_BEHAVIOUR_DEFAULT, "url"));
+ checkup(1, ImageView::New(Toolkit::Control::ControlBehaviour::CONTROL_BEHAVIOUR_DEFAULT, "url", Dali::ImageDimensions(32u, 32u)));
+ checkup(1, ImageView::New(Toolkit::Control::ControlBehaviour::DISABLE_SIZE_NEGOTIATION));
+ checkup(1, ImageView::New(Toolkit::Control::ControlBehaviour::DISABLE_SIZE_NEGOTIATION, "url"));
+ checkup(1, ImageView::New(Toolkit::Control::ControlBehaviour::DISABLE_SIZE_NEGOTIATION, "url", Dali::ImageDimensions(32u, 32u)));
+ checkup(1, TextLabel::New(Toolkit::Control::ControlBehaviour::CONTROL_BEHAVIOUR_DEFAULT));
+ checkup(1, TextLabel::New(Toolkit::Control::ControlBehaviour::CONTROL_BEHAVIOUR_DEFAULT, "text"));
+ checkup(1, TextLabel::New(Toolkit::Control::ControlBehaviour::DISABLE_SIZE_NEGOTIATION));
+ checkup(1, TextLabel::New(Toolkit::Control::ControlBehaviour::DISABLE_SIZE_NEGOTIATION, "text"));
+
+ // New with additional behaviour, so disable style change signals
+ tet_infoline( "Check whether ControlStyleChangeSignal did not connected\n");
+ checkup(0, Control::New(Toolkit::Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS));
+ checkup(0, Control::New(Toolkit::Control::ControlBehaviour(Toolkit::Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS | Toolkit::Control::ControlBehaviour::DISABLE_SIZE_NEGOTIATION)));
+ checkup(0, ImageView::New(Toolkit::Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS));
+ checkup(0, ImageView::New(Toolkit::Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS, "url"));
+ checkup(0, ImageView::New(Toolkit::Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS, "url", Dali::ImageDimensions(32u, 32u)));
+ checkup(0, TextLabel::New(Toolkit::Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS));
+ checkup(0, TextLabel::New(Toolkit::Control::ControlBehaviour::DISABLE_STYLE_CHANGE_SIGNALS, "text"));
+
+ END_TEST;
+}
using namespace Dali;
-ImageView::ImageView()
-: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
+ImageView::ImageView(ControlBehaviour additionalBehaviour)
+: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehaviour)),
mImageSize(),
mImageVisualPaddingSetByTransform(false),
mImageViewPixelAreaSetByFittingMode(false)
{
}
-Toolkit::ImageView ImageView::New()
+Toolkit::ImageView ImageView::New(ControlBehaviour additionalBehaviour)
{
- ImageView* impl = new ImageView();
+ ImageView* impl = new ImageView(additionalBehaviour);
Toolkit::ImageView handle = Toolkit::ImageView(*impl);
protected:
/**
* Construct a new ImageView.
+ *
+ * @param[in] additionalBehaviour additional behaviour flags for this ImageView
*/
- ImageView();
+ ImageView(ControlBehaviour additionalBehaviour);
/**
* A reference counted object may only be deleted by calling Unreference()
public:
/**
* Create a new ImageView.
+ *
+ * @param[in] additionalBehaviour custom behavior flags for this ImageView. Default is CONTROL_BEHAVIOUR_DEFAULT
* @return A smart-pointer to the newly allocated ImageView.
*/
- static Toolkit::ImageView New();
+ static Toolkit::ImageView New(ControlBehaviour additionalBehaviour = ControlBehaviour::CONTROL_BEHAVIOUR_DEFAULT);
/**
* @brief Sets this ImageView from an Dali::Property::Map
} // namespace
-Toolkit::TextLabel TextLabel::New()
+Toolkit::TextLabel TextLabel::New(ControlBehaviour additionalBehaviour)
{
// Create the implementation, temporarily owned by this handle on stack
- IntrusivePtr<TextLabel> impl = new TextLabel();
+ IntrusivePtr<TextLabel> impl = new TextLabel(additionalBehaviour);
// Pass ownership to CustomActor handle
Toolkit::TextLabel handle(*impl);
CommonTextUtils::SynchronizeTextAnchorsInParent(Self(), mController, mAnchorActors);
}
-TextLabel::TextLabel()
-: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
+TextLabel::TextLabel(ControlBehaviour additionalBehavior)
+: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehavior)),
mRenderingBackend(DEFAULT_RENDERING_BACKEND),
mTextUpdateNeeded(false)
{
#define DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
public:
/**
* @copydoc Dali::Toollkit::TextLabel::New()
+ * @param[in] additionalBehaviour custom behavior flags for this TextLabel. Default is CONTROL_BEHAVIOUR_DEFAULT
*/
- static Toolkit::TextLabel New();
+ static Toolkit::TextLabel New(ControlBehaviour additionalBehaviour = ControlBehaviour::CONTROL_BEHAVIOUR_DEFAULT);
// Properties
private: // Implementation
/**
* Construct a new TextLabel.
+ *
+ * @param[in] additionalBehaviour additional behaviour flags for this TextLabel
*/
- TextLabel();
+ TextLabel(ControlBehaviour additionalBehaviour);
/**
* A reference counted object may only be deleted by calling Unreference()
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
Toolkit::Control Control::New()
{
+ return New(ControlBehaviour::CONTROL_BEHAVIOUR_DEFAULT);
+}
+
+Toolkit::Control Control::New(ControlBehaviour additionalBehaviour)
+{
// Create the implementation, temporarily owned on stack
- IntrusivePtr<Control> controlImpl = new Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT));
+ IntrusivePtr<Control> controlImpl = new Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehaviour));
// Pass ownership to handle
Toolkit::Control handle(*controlImpl);
#define DALI_TOOLKIT_CONTROL_IMPL_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
class Extension; ///< Forward declare future extension interface
// Creation & Destruction
-
/**
* @brief Creates a new ControlImpl instance that does not require touch by default.
*
*/
void OnLayoutNegotiated(float size, Dimension::Type dimension) override;
-protected: // Helpers for deriving classes
- // Construction
+public: // Helpers for deriving classes
/**
* @brief Flags for the constructor.
static const int CONTROL_BEHAVIOUR_FLAG_COUNT = Log<LAST_CONTROL_BEHAVIOUR_FLAG - 1>::value + 1; ///< Total count of flags
/**
+ * @brief Creates a new ControlImpl instance that does not require touch by default.
+ *
+ * If touch is required, then the user can connect to this class' touch signal.
+ * @SINCE_2_1.8
+ * @param[in] additionalBehaviour Additional control behaviour.
+ * @return A handle to the ControlImpl instance
+ */
+ static Toolkit::Control New(ControlBehaviour additionalBehaviour);
+
+protected:
+ // Construction
+
+ /**
* @brief Control constructor.
*
* @SINCE_1_0.0
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
{
Control Control::New()
{
- return Internal::Control::New();
+ return Toolkit::Internal::Control::New();
+}
+
+Control Control::New(ControlBehaviour additionalBehaviour)
+{
+ return Toolkit::Internal::Control::New(static_cast<Toolkit::Internal::Control::ControlBehaviour>(additionalBehaviour));
}
Control::Control()
#define DALI_TOOLKIT_CONTROL_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
typedef Signal<void(Control)> ResourceReadySignalType;
public: // Creation & Destruction
+
+ /**
+ * @brief Additional control behaviour flags for the control constructor.
+ * @note TODO : Currunt code is hard-coded. We Should sync type values as
+ * CustomActorImpl::ActorFlag and Internal::Control::ControlBehaviour in future.
+ * @SINCE_2_1.8
+ */
+ enum ControlBehaviour
+ {
+ CONTROL_BEHAVIOUR_DEFAULT = 0, ///< Default behaviour: Size negotiation is enabled & listens to Style Change signal, but doesn't receive event callbacks. @SINCE_1_2_10
+ DISABLE_SIZE_NEGOTIATION = 1 << (0 + 0), ///< True if control does not need size negotiation, i.e. it can be skipped in the algorithm @SINCE_1_0.0
+ REQUIRES_KEYBOARD_NAVIGATION_SUPPORT = 1 << (4 + 1), ///< True if needs to support keyboard navigation @SINCE_1_0.0
+ DISABLE_STYLE_CHANGE_SIGNALS = 1 << (4 + 2), ///< True if control should not monitor style change signals @SINCE_1_2_10
+ };
+
/**
* @brief Creates a new instance of a Control.
*
static Control New();
/**
+ * @brief Creates a new instance of a Control with additional behaviour.
+ *
+ * @SINCE_2_1.8
+ * @param[in] additionalBehaviour Additional control behaviour
+ * @return A handle to a new Control
+ */
+ static Control New(ControlBehaviour additionalBehaviour);
+
+ /**
* @brief Creates an uninitialized Control handle.
*
* Only derived versions can be instantiated. Calling member
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
ImageView ImageView::New()
{
- return Internal::ImageView::New();
+ return Toolkit::Internal::ImageView::New();
}
ImageView ImageView::New(const std::string& url)
return imageView;
}
+ImageView ImageView::New(ControlBehaviour additionalBehaviour)
+{
+ return Toolkit::Internal::ImageView::New(static_cast<Toolkit::Internal::Control::ControlBehaviour>(additionalBehaviour));
+}
+
+ImageView ImageView::New(ControlBehaviour additionalBehaviour, const std::string& url)
+{
+ ImageView imageView = Internal::ImageView::New(static_cast<Toolkit::Internal::Control::ControlBehaviour>(additionalBehaviour));
+ imageView.SetImage(url, ImageDimensions());
+ return imageView;
+}
+
+ImageView ImageView::New(ControlBehaviour additionalBehaviour, const std::string& url, ImageDimensions size)
+{
+ ImageView imageView = Internal::ImageView::New(static_cast<Toolkit::Internal::Control::ControlBehaviour>(additionalBehaviour));
+ imageView.SetImage(url, size);
+ return imageView;
+}
+
ImageView ImageView::DownCast(BaseHandle handle)
{
return Control::DownCast<ImageView, Internal::ImageView>(handle);
#define DALI_TOOLKIT_IMAGE_VIEW_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
static ImageView New(const std::string& url, ImageDimensions size);
/**
+ * @brief Create an initialized ImageView with additional behaviour.
+ *
+ * @SINCE_2_1.8
+ * @param[in] additionalBehaviour Additional control behaviour
+ * @return A handle to a newly allocated Dali ImageView
+ *
+ * @note ImageView will not display anything.
+ */
+ static ImageView New(ControlBehaviour additionalBehaviour);
+
+ /**
+ * @brief Creates an initialized ImageView from an URL to an image resource with additional behaviour.
+ *
+ * If the string is empty, ImageView will not display anything.
+ *
+ * @SINCE_2_1.8
+ * @REMARK_INTERNET
+ * @REMARK_STORAGE
+ * @param[in] additionalBehaviour Additional control behaviour
+ * @param[in] url The url of the image resource to display
+ * @return A handle to a newly allocated ImageView
+ */
+ static ImageView New(ControlBehaviour additionalBehaviour, const std::string& url);
+
+ /**
+ * @brief Creates an initialized ImageView from a URL to an image resource with additional behaviour.
+ *
+ * If the string is empty, ImageView will not display anything.
+ *
+ * @SINCE_2_1.8
+ * @REMARK_INTERNET
+ * @REMARK_STORAGE
+ * @param[in] additionalBehaviour Additional control behaviour
+ * @param[in] url The url of the image resource to display
+ * @param[in] size The width and height to which to fit the loaded image
+ * @return A handle to a newly allocated ImageView
+ * @note A valid size is preferable for efficiency.
+ * However, do not set a size that is bigger than the actual image size, as up-scaling is not available.
+ * The content of the area not covered by the actual image is undefined and will not be cleared.
+ */
+ static ImageView New(ControlBehaviour additionalBehaviour, const std::string& url, ImageDimensions size);
+
+ /**
* @brief Destructor.
*
* This is non-virtual since derived Handle types must not contain data or virtual methods.
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
return label;
}
+TextLabel TextLabel::New(ControlBehaviour additionalBehaviour)
+{
+ return Internal::TextLabel::New(static_cast<Toolkit::Internal::Control::ControlBehaviour>(additionalBehaviour));
+}
+
+TextLabel TextLabel::New(ControlBehaviour additionalBehaviour, const std::string& text)
+{
+ TextLabel label = Internal::TextLabel::New(static_cast<Toolkit::Internal::Control::ControlBehaviour>(additionalBehaviour));
+ label.SetProperty(TextLabel::Property::TEXT, text);
+
+ return label;
+}
+
TextLabel::TextLabel()
{
}
#define DALI_TOOLKIT_TEXT_LABEL_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
static TextLabel New(const std::string& text);
/**
+ * @brief Creates the TextLabel control with additional behavior.
+ *
+ * @SINCE_2_1.8
+ * @param[in] additionalBehaviour Additional control behaviour
+ * @return A handle to the TextLabel control
+ */
+ static TextLabel New(ControlBehaviour additionalBehaviour);
+
+ /**
+ * @brief Creates the TextLabel control with additional behavior.
+ *
+ * @SINCE_2_1.8
+ * @param[in] additionalBehaviour Additional control behaviour
+ * @param[in] text The text to display
+ * @return A handle to the TextLabel control
+ */
+ static TextLabel New(ControlBehaviour additionalBehaviour, const std::string& text);
+
+ /**
* @brief Creates an empty handle.
* @SINCE_1_0.0
*/