Added documentation, restructured the files to fit better with electron's style and fixed a typo in keyboard_util's name.

This commit is contained in:
Heilig Benedek 2016-01-31 02:27:14 +01:00
parent 0c9174bc7c
commit 61e0219e91
12 changed files with 134 additions and 194 deletions

View file

@ -3,7 +3,7 @@
// found in the LICENSE file.
#include <string>
#include "atom/common/keyboad_util.h"
#include "atom/common/keyboard_util.h"
namespace atom {

View file

@ -2,8 +2,8 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_COMMON_KEYBOAD_UTIL_H_
#define ATOM_COMMON_KEYBOAD_UTIL_H_
#ifndef ATOM_COMMON_KEYBOARD_UTIL_H_
#define ATOM_COMMON_KEYBOARD_UTIL_H_
#include <string>
#include "ui/events/keycodes/keyboard_codes.h"
@ -20,4 +20,4 @@ ui::KeyboardCode KeyboardCodeFromKeyIdentifier(const std::string& chr);
} // namespace atom
#endif // ATOM_COMMON_KEYBOAD_UTIL_H_
#endif // ATOM_COMMON_KEYBOARD_UTIL_H_

67
atom/common/mouse_util.cc Normal file
View file

@ -0,0 +1,67 @@
// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include <string>
#include "atom/common/mouse_util.h"
using Cursor = blink::WebCursorInfo::Type;
namespace atom {
std::string CursorTypeToString(const content::WebCursor& cursor) {
content::WebCursor::CursorInfo* info = new content::WebCursor::CursorInfo();
cursor.GetCursorInfo(info);
switch (info->type) {
case Cursor::TypePointer: return "pointer";
case Cursor::TypeCross: return "cross";
case Cursor::TypeHand: return "hand";
case Cursor::TypeIBeam: return "i-beam";
case Cursor::TypeWait: return "wait";
case Cursor::TypeHelp: return "help";
case Cursor::TypeEastResize: return "east-resize";
case Cursor::TypeNorthResize: return "north-resize";
case Cursor::TypeNorthEastResize: return "north-east-resize";
case Cursor::TypeNorthWestResize: return "north-west-resize";
case Cursor::TypeSouthResize: return "south-resize";
case Cursor::TypeSouthEastResize: return "south-east-resize";
case Cursor::TypeSouthWestResize: return "south-west-resize";
case Cursor::TypeWestResize: return "west-resize";
case Cursor::TypeNorthSouthResize: return "north-south-resize";
case Cursor::TypeEastWestResize: return "east-west-resize";
case Cursor::TypeNorthEastSouthWestResize:
return "north-east-south-west-resize";
case Cursor::TypeNorthWestSouthEastResize:
return "north-west-south-east-resize";
case Cursor::TypeColumnResize: return "column-resize";
case Cursor::TypeRowResize: return "row-resize";
case Cursor::TypeMiddlePanning: return "middle-panning";
case Cursor::TypeEastPanning: return "east-panning";
case Cursor::TypeNorthPanning: return "north-panning";
case Cursor::TypeNorthEastPanning: return "north-east-panning";
case Cursor::TypeNorthWestPanning: return "north-west-panning";
case Cursor::TypeSouthPanning: return "south-panning";
case Cursor::TypeSouthEastPanning: return "south-east-panning";
case Cursor::TypeSouthWestPanning: return "south-west-panning";
case Cursor::TypeWestPanning: return "west-panning";
case Cursor::TypeMove: return "move";
case Cursor::TypeVerticalText: return "vertical-text";
case Cursor::TypeCell: return "cell";
case Cursor::TypeContextMenu: return "context-menu";
case Cursor::TypeAlias: return "alias";
case Cursor::TypeProgress: return "progress";
case Cursor::TypeNoDrop: return "nodrop";
case Cursor::TypeCopy: return "copy";
case Cursor::TypeNone: return "none";
case Cursor::TypeNotAllowed: return "not-allowed";
case Cursor::TypeZoomIn: return "zoom-in";
case Cursor::TypeZoomOut: return "zoom-out";
case Cursor::TypeGrab: return "grab";
case Cursor::TypeGrabbing: return "grabbing";
case Cursor::TypeCustom: return "custom";
default: return "pointer";
}
}
} // namespace atom

36
atom/common/mouse_util.h Normal file
View file

@ -0,0 +1,36 @@
// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_COMMON_MOUSE_UTIL_H_
#define ATOM_COMMON_MOUSE_UTIL_H_
#include <string>
#include "content/common/cursors/webcursor.h"
#include "ipc/ipc_message_macros.h"
// IPC macros similar to the already existing ones in the chromium source.
// We need these to listen to the cursor change IPC message while still
// letting chromium handle the actual cursor change by setting handled = false.
#define IPC_MESSAGE_HANDLER_CODE(msg_class, member_func, code) \
IPC_MESSAGE_FORWARD_CODE(msg_class, this, \
_IpcMessageHandlerClass::member_func, code)
#define IPC_MESSAGE_FORWARD_CODE(msg_class, obj, member_func, code) \
case msg_class::ID: { \
TRACK_RUN_IN_THIS_SCOPED_REGION(member_func); \
if (!msg_class::Dispatch(&ipc_message__, obj, this, param__, \
&member_func)) \
ipc_message__.set_dispatch_error(); \
code; \
} \
break;
namespace atom {
// Returns the cursor's type as a string.
std::string CursorTypeToString(const content::WebCursor& cursor);
} // namespace atom
#endif // ATOM_COMMON_MOUSE_UTIL_H_

View file

@ -7,7 +7,7 @@
#include <string>
#include <vector>
#include "atom/common/keyboad_util.h"
#include "atom/common/keyboard_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/native_web_keyboard_event.h"