• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 #include "mouse_event.h"
17 namespace OHOS {
Initialize(MultimodalProperty & multiProperty,MouseProperty & mouseProperty)18 void MouseEvent::Initialize(MultimodalProperty &multiProperty, MouseProperty &mouseProperty)
19 {
20     MultimodalEvent::Initialize(multiProperty);
21     mouseProperty_.action = mouseProperty.action;
22     mouseProperty_.actionButton = mouseProperty.actionButton;
23     mouseProperty_.pressedButtons = mouseProperty.pressedButtons;
24     mouseProperty_.mmiPoint = mouseProperty.mmiPoint;
25     mouseProperty_.xOffset = mouseProperty.xOffset;
26     mouseProperty_.yOffset = mouseProperty.yOffset;
27     mouseProperty_.cursorDelta = mouseProperty.cursorDelta;
28     mouseProperty_.scrollingDelta = mouseProperty.scrollingDelta;
29 }
30 
Marshalling(Parcel & parcel) const31 bool MouseEvent::Marshalling(Parcel &parcel) const
32 {
33     return false;
34 }
35 
Unmarshalling(Parcel & parcel)36 MouseEvent *MouseEvent::Unmarshalling(Parcel &parcel)
37 {
38     MouseEvent *event = new (std::nothrow) MouseEvent();
39     if (event == nullptr) {
40         return nullptr;
41     }
42     return event;
43 }
44 
GetAction()45 int MouseEvent::GetAction()
46 {
47     return mouseProperty_.action;
48 }
49 
GetActionButton()50 int MouseEvent::GetActionButton()
51 {
52     return mouseProperty_.actionButton;
53 }
54 
GetPressedButtons()55 int MouseEvent::GetPressedButtons()
56 {
57     return mouseProperty_.pressedButtons;
58 }
59 
GetCursor()60 MmiPoint MouseEvent::GetCursor()
61 {
62     return mouseProperty_.mmiPoint;
63 }
64 
SetCursorOffset(float offsetX,float offsetY)65 void MouseEvent::SetCursorOffset(float offsetX, float offsetY)
66 {
67     mouseProperty_.xOffset = offsetX;
68     mouseProperty_.yOffset = offsetY;
69 }
70 
GetCursorDelta(int axis)71 float MouseEvent::GetCursorDelta(int axis)
72 {
73     return mouseProperty_.cursorDelta;
74 }
75 
GetScrollingDelta(int axis)76 float MouseEvent::GetScrollingDelta(int axis)
77 {
78     return mouseProperty_.scrollingDelta;
79 }
80 }