| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #ifndef SKY_ENGINE_PLATFORM_PLATFORMEVENT_H_ | |
| 27 #define SKY_ENGINE_PLATFORM_PLATFORMEVENT_H_ | |
| 28 | |
| 29 namespace blink { | |
| 30 | |
| 31 class PlatformEvent { | |
| 32 public: | |
| 33 enum Type { | |
| 34 NoType = 0, | |
| 35 }; | |
| 36 | |
| 37 enum Modifiers { | |
| 38 AltKey = 1 << 0, | |
| 39 CtrlKey = 1 << 1, | |
| 40 MetaKey = 1 << 2, | |
| 41 ShiftKey = 1 << 3, | |
| 42 }; | |
| 43 | |
| 44 Type type() const { return static_cast<Type>(m_type); } | |
| 45 | |
| 46 bool shiftKey() const { return m_modifiers & ShiftKey; } | |
| 47 bool ctrlKey() const { return m_modifiers & CtrlKey; } | |
| 48 bool altKey() const { return m_modifiers & AltKey; } | |
| 49 bool metaKey() const { return m_modifiers & MetaKey; } | |
| 50 | |
| 51 unsigned modifiers() const { return m_modifiers; } | |
| 52 | |
| 53 double timestamp() const { return m_timestamp; } | |
| 54 | |
| 55 protected: | |
| 56 PlatformEvent() | |
| 57 : m_type(NoType) | |
| 58 , m_modifiers(0) | |
| 59 , m_timestamp(0) | |
| 60 { | |
| 61 } | |
| 62 | |
| 63 explicit PlatformEvent(Type type) | |
| 64 : m_type(type) | |
| 65 , m_modifiers(0) | |
| 66 , m_timestamp(0) | |
| 67 { | |
| 68 } | |
| 69 | |
| 70 PlatformEvent(Type type, Modifiers modifiers, double timestamp) | |
| 71 : m_type(type) | |
| 72 , m_modifiers(modifiers) | |
| 73 , m_timestamp(timestamp) | |
| 74 { | |
| 75 } | |
| 76 | |
| 77 PlatformEvent(Type type, bool shiftKey, bool ctrlKey, bool altKey, bool meta
Key, double timestamp) | |
| 78 : m_type(type) | |
| 79 , m_modifiers(0) | |
| 80 , m_timestamp(timestamp) | |
| 81 { | |
| 82 if (shiftKey) | |
| 83 m_modifiers |= ShiftKey; | |
| 84 if (ctrlKey) | |
| 85 m_modifiers |= CtrlKey; | |
| 86 if (altKey) | |
| 87 m_modifiers |= AltKey; | |
| 88 if (metaKey) | |
| 89 m_modifiers |= MetaKey; | |
| 90 } | |
| 91 | |
| 92 // Explicit protected destructor so that people don't accidentally | |
| 93 // delete a PlatformEvent. | |
| 94 ~PlatformEvent() | |
| 95 { | |
| 96 } | |
| 97 | |
| 98 unsigned m_type; | |
| 99 unsigned m_modifiers; | |
| 100 double m_timestamp; | |
| 101 }; | |
| 102 | |
| 103 } // namespace blink | |
| 104 | |
| 105 #endif // SKY_ENGINE_PLATFORM_PLATFORMEVENT_H_ | |
| OLD | NEW |