TizenRT Public API  v2.0 M2
FocusManager.h
Go to the documentation of this file.
1 /* ****************************************************************
2  *
3  * Copyright 2018 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  ******************************************************************/
18 
29 #ifndef __MEDIA_FOCUSMANAGER_H
30 #define __MEDIA_FOCUSMANAGER_H
31 
32 #include <list>
33 #include <memory>
34 #include <mutex>
35 #include <string>
36 
37 #include <media/FocusRequest.h>
38 
39 namespace media {
40 
41 static const int FOCUS_REQUEST_SUCCESS = 0;
42 static const int FOCUS_REQUEST_FAIL = -1;
43 
51 {
52 public:
59  static FocusManager &getFocusManager();
67  int abandonFocus(std::shared_ptr<FocusRequest> focusRequest);
75  int requestFocus(std::shared_ptr<FocusRequest> focusRequest);
76 
77 private:
78  class FocusRequester
79  {
80  public:
81  FocusRequester(std::string id, std::shared_ptr<FocusChangeListener> listener);
82  bool hasSameId(std::string id);
83  void notify(int focusChange);
84 
85  private:
86  std::string mId;
87  std::shared_ptr<FocusChangeListener> mListener;
88  };
89 
90  FocusManager() = default;
91  virtual ~FocusManager() = default;
92  void removeFocusElement(std::string id);
93  std::list<std::shared_ptr<FocusRequester>> mFocusList;
94  std::mutex mFocusLock;
95 };
96 } // namespace media
97 
98 #endif
99  // end of MEDIA group
Media FocusRequest APIs.
static FocusManager & getFocusManager()
Get FocusManager Instance.
int requestFocus(std::shared_ptr< FocusRequest > focusRequest)
Request Focus.
int abandonFocus(std::shared_ptr< FocusRequest > focusRequest)
Abandon Focus.