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.
4
5#ifndef ASH_DISPLAY_DISPLAY_LAYOUT_H_
6#define ASH_DISPLAY_DISPLAY_LAYOUT_H_
7
8#include <map>
9#include <string>
10
11#include "ash/ash_export.h"
12#include "base/basictypes.h"
13#include "base/compiler_specific.h"
14
15namespace base {
16class Value;
17template <typename T> class JSONValueConverter;
18}
19
20namespace ash {
21
22typedef std::pair<int64, int64> DisplayIdPair;
23
24struct ASH_EXPORT DisplayLayout {
25  // Layout options where the secondary display should be positioned.
26  enum Position {
27    TOP,
28    RIGHT,
29    BOTTOM,
30    LEFT
31  };
32
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);
37
38  DisplayLayout();
39  DisplayLayout(Position position, int offset);
40
41  // Returns an inverted display layout.
42  DisplayLayout Invert() const WARN_UNUSED_RESULT;
43
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);
47
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);
52
53  Position position;
54
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;
58
59  // True if displays are mirrored.
60  bool mirrored;
61
62  // The id of the display used as a primary display.
63  int64 primary_id;
64
65  // Returns string representation of the layout for debugging/testing.
66  std::string ToString() const;
67};
68
69}  // namespace ash
70
71#endif
72