Use a pre-target handler in RootView to open keyboard-generated context menus
[chromium-blink-merge.git] / ash / display / display_layout.h
blobdc322087c2f1bb92d4198dae7d707ca427679bea
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_DISPLAY_DISPLAY_LAYOUT_H_
6 #define ASH_DISPLAY_DISPLAY_LAYOUT_H_
8 #include <map>
9 #include <string>
11 #include "ash/ash_export.h"
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
15 namespace base {
16 class Value;
17 template <typename T> class JSONValueConverter;
20 namespace ash {
22 typedef std::pair<int64, int64> DisplayIdPair;
24 struct ASH_EXPORT DisplayLayout {
25 // Layout options where the secondary display should be positioned.
26 enum Position {
27 TOP,
28 RIGHT,
29 BOTTOM,
30 LEFT
33 // Factory method to create DisplayLayout from ints. The |mirrored| is
34 // set to false and |primary_id| is set to gfx::Display::kInvalidDisplayId.
35 // Used for persistence and webui.
36 static DisplayLayout FromInts(int position, int offsets);
38 DisplayLayout();
39 DisplayLayout(Position position, int offset);
41 // Returns an inverted display layout.
42 DisplayLayout Invert() const WARN_UNUSED_RESULT;
44 // Converter functions to/from base::Value.
45 static bool ConvertFromValue(const base::Value& value, DisplayLayout* layout);
46 static bool ConvertToValue(const DisplayLayout& layout, base::Value* value);
48 // This method is used by base::JSONValueConverter, you don't need to call
49 // this directly. Instead consider using converter functions above.
50 static void RegisterJSONConverter(
51 base::JSONValueConverter<DisplayLayout>* converter);
53 Position position;
55 // The offset of the position of the secondary display. The offset is
56 // based on the top/left edge of the primary display.
57 int offset;
59 // True if displays are mirrored.
60 bool mirrored;
62 // The id of the display used as a primary display.
63 int64 primary_id;
65 // Returns string representation of the layout for debugging/testing.
66 std::string ToString() const;
69 } // namespace ash
71 #endif