X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-base-data-impl.h;h=16d7a76f88e3ef0356f456d88ca98e1bb2ec52c8;hb=HEAD;hp=524057e52efd96bfeb7762b31446dcf3dbe52d9f;hpb=92a400c3857fbf6c1e63693f22c94dcffe50e522;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/visual-base-data-impl.h b/dali-toolkit/internal/visuals/visual-base-data-impl.h index 524057e..d8e7f34 100644 --- a/dali-toolkit/internal/visuals/visual-base-data-impl.h +++ b/dali-toolkit/internal/visuals/visual-base-data-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_VISUAL_BASE_DATA_IMPL_H /* - * Copyright (c) 2016 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. @@ -20,56 +20,245 @@ // EXTERNAL INCLUDES #include -#include +#include // INTERNAL INCLUDES +#include #include +#include +#include +#include namespace Dali { - namespace Toolkit { - namespace Internal { - namespace Visual { - struct Base::Impl { + /** + * Constructor + * @param [in] fittingMode that the derived class prefers + * @param [in] type The type of the this visual + */ + Impl(FittingMode fittingMode, Toolkit::Visual::Type type); + + /** + * Destructor + */ + ~Impl(); + enum Flags { - IS_ON_STAGE = 1, - IS_FROM_CACHE = 1 << 1, - IS_ATLASING_APPLIED = 1<<2, - IS_PREMULTIPLIED_ALPHA = 1 << 3, - IS_SYNCHRONOUS_RESOURCE_LOADING = 1 << 4 + IS_ON_SCENE = 1, + IS_ATLASING_APPLIED = 1 << 1, + IS_PREMULTIPLIED_ALPHA = 1 << 2, + IS_SYNCHRONOUS_RESOURCE_LOADING = 1 << 3, }; struct CustomShader { - std::string mVertexShader; - std::string mFragmentShader; - Dali::ImageDimensions mGridSize; + CustomShader(const Property::Map& map); + void SetPropertyMap(const Property::Map& map); + void CreatePropertyMap(Property::Map& map) const; + + std::string mVertexShader; + std::string mFragmentShader; + Dali::ImageDimensions mGridSize; Dali::Shader::Hint::Value mHints; //(bitfield) values from enum Shader::Hint + }; + + struct Transform + { + /** + * Default constructor ensures the visual fills the control + */ + Transform(); + + /** + * Use the property map to set zero or more of the transform + * attributes, and sets the remaining attributes to their default + * values. + */ + void SetPropertyMap(const Property::Map& map); + + /** + * Add the transform attributes to the map (using integer keys) + */ + void GetPropertyMap(Property::Map& map) const; + + /** + * Update zero or more attributes from the property map. + */ + void UpdatePropertyMap(const Property::Map& map); + + /** + * Set the uniform properties onto the renderer + */ + void SetUniforms(VisualRenderer renderer, Toolkit::Direction::Type direction); - CustomShader( const Property::Map& map ); - void SetPropertyMap( const Property::Map& map ); - void CreatePropertyMap( Property::Map& map ) const; + /** + * Convert the control size and the transform attributes into the actual + * size of the visual. + */ + Vector2 GetVisualSize(const Vector2& controlSize); + + Vector2 mOffset; + Vector2 mSize; + Vector2 mExtraSize; + Vector4 mOffsetSizeMode; + Toolkit::Align::Type mOrigin; + Toolkit::Align::Type mAnchorPoint; }; - Renderer mRenderer; + struct DecorationData + { + // Default constructor + DecorationData() + : mBorderlineColor(Color::BLACK), + mCornerRadius(Vector4::ZERO), + mBorderlineWidth(0.0f), + mBorderlineOffset(0.0f), + mCornerRadiusPolicy(static_cast(Toolkit::Visual::Transform::Policy::ABSOLUTE)) + { + } + Vector4 mBorderlineColor; + Vector4 mCornerRadius; + float mBorderlineWidth; + float mBorderlineOffset; + int mCornerRadiusPolicy; + }; - CustomShader* mCustomShader; + DecorationData* EnsureDecorationData() + { + if(mDecorationData == nullptr) + { + mDecorationData = new DecorationData(); + } + return mDecorationData; + } - Vector2 mSize; - float mDepthIndex; - int mFlags; + /** + * @brief Get decoration data value : borderline width + * + * Keep these API as inline function due to the performance. + */ + float GetBorderlineWidth() + { + return mDecorationData ? mDecorationData->mBorderlineWidth : 0.0f; + } - Impl(); - ~Impl(); + /** + * @brief Set decoration data value : borderline width + * + * Keep these API as inline function due to the performance. + */ + void SetBorderlineWidth(float value) + { + EnsureDecorationData()->mBorderlineWidth = value; + } + + /** + * @brief Get decoration data value : borderline color + * + * Keep these API as inline function due to the performance. + */ + Vector4 GetBorderlineColor() + { + return mDecorationData ? mDecorationData->mBorderlineColor : Color::BLACK; + } + + /** + * @brief Set decoration data value : borderline color + * + * Keep these API as inline function due to the performance. + */ + void SetBorderlineColor(Vector4 value) + { + EnsureDecorationData()->mBorderlineColor = value; + } + + /** + * @brief Get decoration data value : borderline offset + * + * Keep these API as inline function due to the performance. + */ + float GetBorderlineOffset() + { + return mDecorationData ? mDecorationData->mBorderlineOffset : 0.0f; + } + + /** + * @brief Set decoration data value : borderline offset + * + * Keep these API as inline function due to the performance. + */ + void SetBorderlineOffset(float value) + { + EnsureDecorationData()->mBorderlineOffset = value; + } + + /** + * @brief Get decoration data value : corner radius + * + * Keep these API as inline function due to the performance. + */ + Vector4 GetCornerRadius() + { + return mDecorationData ? mDecorationData->mCornerRadius : Vector4::ZERO; + } + + /** + * @brief Set decoration data value : corner radius + * + * Keep these API as inline function due to the performance. + */ + void SetCornerRadius(Vector4 value) + { + EnsureDecorationData()->mCornerRadius = value; + } + + /** + * @brief Get decoration data value : corner radius policy + * + * Keep these API as inline function due to the performance. + */ + int GetCornerRadiusPolicy() + { + return mDecorationData ? mDecorationData->mCornerRadiusPolicy : static_cast(Toolkit::Visual::Transform::Policy::ABSOLUTE); + } + + /** + * @brief Set decoration data value : corner radius policy + * + * Keep these API as inline function due to the performance. + */ + void SetCornerRadiusPolicy(int value) + { + EnsureDecorationData()->mCornerRadiusPolicy = value; + } + + VisualRenderer mRenderer; + CustomShader* mCustomShader; + EventObserver* mEventObserver; ///< Allows controls to observe when the visual has events to notify + std::string mName; + Transform mTransform; + Vector4 mMixColor; + Size mControlSize; + DecorationData* mDecorationData; + int mDepthIndex; + FittingMode mFittingMode; ///< How the contents should fit the view + int mFlags; + Toolkit::Visual::ResourceStatus mResourceStatus; + const Toolkit::Visual::Type mType; + bool mAlwaysUsingBorderline : 1; ///< Whether we need the borderline in shader always. + bool mAlwaysUsingCornerRadius : 1; ///< Whether we need the corner radius in shader always. + bool mIgnoreFittingMode : 1; ///< Whether we need to ignore fitting mode. + bool mPixelAreaSetByFittingMode : 1; ///< Whether the pixel area is set for fitting mode. + bool mTransformMapSetForFittingMode :1; ///< Whether the transformMap is set for fitting mode. }; } // namespace Visual