• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_ROSEN_UI_EFFECT_CONTROLLER_H
17 #define OHOS_ROSEN_UI_EFFECT_CONTROLLER_H
18 #include <functional>
19 
20 #include "ui_effect_controller_stub.h"
21 
22 namespace OHOS::Rosen {
23 class UIEffectControllerClientDeath final : public IRemoteObject::DeathRecipient {
24 public:
25     using EraseUIEffectFunc = std::function<void()>;
UIEffectControllerClientDeath(const EraseUIEffectFunc & func)26     explicit UIEffectControllerClientDeath(const EraseUIEffectFunc& func): eraseFunc_(func) {};
27     void OnRemoteDied(const wptr<IRemoteObject>& remote) override;
28 
29 private:
30     EraseUIEffectFunc eraseFunc_;
31 };
32 
33 class UIEffectController : public UIEffectControllerStub {
34 public:
35     using SetParamsFunc = std::function<void(int32_t, sptr<UIEffectParams>)>;
36     using AnimateToFunc = std::function<void(int32_t, sptr<UIEffectParams>, sptr<WindowAnimationOption>,
37         sptr<WindowAnimationOption>)>;
38     UIEffectController(int32_t id, const SetParamsFunc& paramCallback, const AnimateToFunc& animateCallback);
39     WMError SetParams(const sptr<UIEffectParams>& params) override;
40     WMError AnimateTo(const sptr<UIEffectParams>& params, const sptr<WindowAnimationOption>& config,
41         const sptr<WindowAnimationOption>& interruptOption) override;
SetIsAliveInUI(bool state)42     void SetIsAliveInUI(bool state) { isAliveInUI_ = state; }
43 
44 private:
45     SetParamsFunc setParamsCallback_ = nullptr;
46     AnimateToFunc animateToCallback_ = nullptr;
47     // unique id of ui effect controller
48     int32_t id_;
49     std::atomic<bool> isAliveInUI_ = false;
50 };
51 } // namespace OHOS::Rosen
52 #endif