• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_IMAGE_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_IMAGE_H
18 
19 #include "frameworks/bridge/declarative_frontend/jsview/js_interactable_view.h"
20 #include "frameworks/bridge/declarative_frontend/jsview/js_utils.h"
21 #include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h"
22 
23 namespace OHOS::Ace::Framework {
24 class JSImage : public JSViewAbstract, public JSInteractableView {
25 public:
26     static void Create(const JSCallbackInfo& info);
27     static void HandleLoadImageSuccess(const BaseEventInfo& param);
28     static void HandleLoadImageFail(const BaseEventInfo& param);
29     static void SetAlt(const JSCallbackInfo& args);
30     static void SetMatchTextDirection(bool value);
31     static void SetFitOriginalSize(bool value);
32     static void SetSourceSize(const JSCallbackInfo& info);
33     static void SetObjectFit(int32_t value);
34     static void SetImageFill(const JSCallbackInfo& info);
35     static void SetImageInterpolation(int32_t imageInterpolation);
36     static void SetImageRenderMode(int32_t imageRenderMode);
37     static void SetImageRepeat(int32_t imageRepeat);
38     static void JSBind(BindingTarget globalObj);
39     static void OnComplete(const JSCallbackInfo& args);
40     static void OnError(const JSCallbackInfo& args);
41     static void OnFinish(const JSCallbackInfo& info);
42     static void SetSyncLoad(const JSCallbackInfo& info);
43     static void SetColorFilter(const JSCallbackInfo& info);
44 
45     static void JsBorder(const JSCallbackInfo& info);
46     static void JsBorderRadius(const JSCallbackInfo& info);
47     static void SetLeftBorderWidth(const CalcDimension& value);
48     static void SetTopBorderWidth(const CalcDimension& value);
49     static void SetRightBorderWidth(const CalcDimension& value);
50     static void SetBottomBorderWidth(const CalcDimension& value);
51     static void SetBorderRadius(const CalcDimension& value);
52     static void JsOpacity(const JSCallbackInfo& info);
53     static void JsBlur(const JSCallbackInfo& info);
54     static void JsTransition(const JSCallbackInfo& info);
55     static void JsSetDraggable(bool draggable);
56     static void JsOnDragStart(const JSCallbackInfo& info);
57     static void SetCopyOption(const JSCallbackInfo& info);
58 
59 protected:
60     static void SetBorder(const Border& border);
61     static void SetAutoResize(bool autoResize);
62 
63     static bool IsDrawable(const JSRef<JSVal>& jsValue);
64 };
65 
66 class JSColorFilter : public AceType {
67     DECLARE_ACE_TYPE(JSColorFilter, AceType);
68 
69 public:
70     JSColorFilter() = default;
71     ~JSColorFilter() override = default;
72     static void ConstructorCallback(const JSCallbackInfo& info);
73     static void DestructorCallback(JSColorFilter* obj);
74 
SetColorFilterMatrix(const std::vector<float> && matrix)75     void SetColorFilterMatrix(const std::vector<float>&& matrix)
76     {
77         colorfiltermatrix_ = std::move(matrix);
78     }
79 
GetColorFilterMatrix()80     const std::vector<float>& GetColorFilterMatrix() const
81     {
82         return colorfiltermatrix_;
83     }
84 
85 private:
86     std::vector<float> colorfiltermatrix_;
87 };
88 
89 } // namespace OHOS::Ace::Framework
90 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_IMAGE_H
91