[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / controller / text-controller-event-handler.h
1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_EVENT_HANDLER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_EVENT_HANDLER_H
3
4 /*
5  * Copyright (c) 2022 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/devel-api/adaptor-framework/input-method-context.h>
23 #include <dali/public-api/events/gesture-enumerations.h>
24 #include <dali/public-api/events/key-event.h>
25 #include <dali/public-api/math/vector2.h>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
29 #include <dali-toolkit/internal/text/controller/text-controller.h>
30 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
31
32 namespace Dali
33 {
34 namespace Toolkit
35 {
36 namespace Text
37 {
38 struct Controller::EventHandler
39 {
40   /// @copydoc Text::Controller::KeyboardFocusGainEvent
41   /// @param[in] controller A reference to the controller class
42   static void KeyboardFocusGainEvent(Controller& controller);
43
44   /// @copydoc Text::Controller::KeyboardFocusLostEvent
45   /// @param[in] controller A reference to the controller class
46   static void KeyboardFocusLostEvent(Controller& controller);
47
48   /// @copydoc Text::Controller::KeyEvent
49   /// @param[in] controller A reference to the controller class
50   static bool KeyEvent(Controller& controller, const Dali::KeyEvent& keyEvent);
51
52   /// @copydoc Text::Controller::AnchorEvent
53   /// @param[in] controller A reference to the controller class
54   static void AnchorEvent(Controller& controller, float x, float y);
55
56   /// @copydoc Text::Controller::TapEvent
57   /// @param[in] controller A reference to the controller class
58   static void TapEvent(Controller& controller, unsigned int tapCount, float x, float y);
59
60   /// @copydoc Text::Controller::PanEvent
61   /// @param[in] controller A reference to the controller class
62   static void PanEvent(Controller& controller, GestureState state, const Vector2& displacement);
63
64   /// @copydoc Text::Controller::LongPressEvent
65   /// @param[in] controller A reference to the controller class
66   static void LongPressEvent(Controller& controller, GestureState state, float x, float y);
67
68   /// @copydoc Text::Controller::SelectEvent
69   /// @param[in] controller A reference to the controller class
70   static void SelectEvent(Controller& controller, float x, float y, SelectionType selectType);
71
72   /**
73    * @brief Creates a selection event with a selection index.
74    *
75    * It could be called from the SelectText().
76    * The start and end parameters are passed through the event.
77    *
78    * @param[in] controller A reference to the controller class
79    * @param[in] start The start selection position.
80    * @param[in] end The end selection position.
81    * @param[in] selection type like the range.
82    */
83   static void SelectEvent(Controller& controller, const uint32_t start, const uint32_t end, SelectionType selectType);
84
85   /**
86    * @brief Process queued events which modify the model.
87    * @param[in] controller A reference to the controller class
88    */
89   static void ProcessModifyEvents(Controller& controller);
90
91   /**
92    * @brief Used to process an event queued from SetText()
93    * @param[in] controller A reference to the controller class
94    */
95   static void TextReplacedEvent(Controller& controller);
96
97   /**
98    * @brief Used to process an event queued from key events etc.
99    * @param[in] controller A reference to the controller class
100    */
101   static void TextInsertedEvent(Controller& controller);
102
103   /**
104    * @brief Used to process an event queued from backspace key etc.
105    * @param[in] controller A reference to the controller class
106    */
107   static void TextDeletedEvent(Controller& controller);
108
109   /**
110    * @brief Helper to KeyEvent() to handle the backspace or delete key case.
111    *
112    * @param[in] controller A reference to the controller class
113    * @param[in] keyCode The keycode for the key pressed
114    * @return True if a character was deleted.
115    */
116   static bool DeleteEvent(Controller& controller, int keyCode);
117
118   /// @copydoc Text::Controller::OnInputMethodContextEvent
119   /// @param[in] controller A reference to the controller class
120   static InputMethodContext::CallbackData OnInputMethodContextEvent(Controller&                          controller,
121                                                                     InputMethodContext&                  inputMethodContext,
122                                                                     const InputMethodContext::EventData& inputMethodContextEvent);
123
124   /**
125    * @brief This function executes the actual text update when a clipboard paste event occurs.
126    *
127    * @param[in] controller A reference to the controller class.
128    * @param[in] text The text data to be pasted into the text controller.
129    */
130   static void PasteClipboardItemEvent(Controller& controller, const std::string& text);
131
132   /// @copydoc Text::Controller::DecorationEvent
133   /// @param[in] controller A reference to the controller class
134   static void DecorationEvent(Controller& controller, HandleType handleType, HandleState state, float x, float y);
135
136   /// @copydoc Text::Controller::TextPopupButtonTouched
137   /// @param[in] controller A reference to the controller class
138   static void TextPopupButtonTouched(Controller& controller, Dali::Toolkit::TextSelectionPopup::Buttons button);
139 };
140
141 } // namespace Text
142
143 } // namespace Toolkit
144
145 } // namespace Dali
146
147 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_EVENT_HANDLER_H