[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / hidden-text.h
1 #ifndef DALI_HIDDEN_TEXT_H
2 #define DALI_HIDDEN_TEXT_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/adaptor-framework/timer.h>
23 #include <dali/public-api/object/property-map.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/internal/text/text-definitions.h>
27 #include <dali-toolkit/public-api/controls/text-controls/hidden-input-properties.h>
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace Text
34 {
35
36 static constexpr const uint32_t STAR = 0x2A; // Set default substitute character as '*'
37
38 /**
39  * Class to handle the hidden text
40  */
41 class HiddenText : public ConnectionTracker
42 {
43 public:
44   class Observer
45   {
46   public:
47     /**
48      * @brief Invoked when the time to show last character is expired
49      */
50     virtual void DisplayTimeExpired() = 0;
51   };
52
53   /**
54    * @brief Constructor
55    * @param[in] observer The Observer pointer.
56    */
57   HiddenText(Observer* observer);
58
59 public: // Intended for internal use
60   /**
61    * @brief Used to set options of hidden text
62    * @param[in] map The property map describing the option
63    */
64   void SetProperties(const Property::Map& map);
65
66   /**
67    * @brief Retrieve property map of hidden text options
68    * @param[out] map The hidden text option
69    */
70   void GetProperties(Property::Map& map);
71
72   /**
73    * @brief Convert source text to destination text according to current option
74    * @param[in] source The original text
75    * @param[out] destination The applied text
76    */
77   void Substitute(const Vector<Character>& source, Vector<Character>& destination);
78
79   /**
80    * @brief Invoked when the timer is expired
81    */
82   bool OnTick();
83
84 private:
85   Timer     mTimer;
86   Observer* mObserver;
87   int       mHideMode;
88   int       mSubstituteText;
89   int       mDisplayDuration;
90   int       mSubstituteCount;
91   Length    mPreviousTextCount;
92 };
93
94 } // namespace Text
95
96 } // namespace Toolkit
97
98 } // namespace Dali
99
100 #endif // DALI_HIDDEN_TEXT_H