| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_DISPLAY_DISPLAY_LAYOUT_H_ | 5 #ifndef ASH_DISPLAY_DISPLAY_LAYOUT_H_ |
| 6 #define ASH_DISPLAY_DISPLAY_LAYOUT_H_ | 6 #define ASH_DISPLAY_DISPLAY_LAYOUT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "ash/ash_export.h" | 13 #include "ash/ash_export.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
| 17 | 17 #include "base/strings/string_piece.h" |
| 18 namespace gfx { | |
| 19 class Display; | |
| 20 } | |
| 21 | 18 |
| 22 namespace base { | 19 namespace base { |
| 23 class Value; | 20 class Value; |
| 24 template <typename T> class JSONValueConverter; | 21 template <typename T> class JSONValueConverter; |
| 25 } | 22 } |
| 26 | 23 |
| 24 namespace gfx { |
| 25 class Display; |
| 26 } |
| 27 |
| 27 namespace ash { | 28 namespace ash { |
| 28 | 29 |
| 29 // An identifier used to manage display layout in DisplayManager / | 30 // An identifier used to manage display layout in DisplayManager / |
| 30 // DisplayLayoutStore. | 31 // DisplayLayoutStore. |
| 31 using DisplayIdList = std::vector<int64_t>; | 32 using DisplayIdList = std::vector<int64_t>; |
| 32 | 33 |
| 33 using DisplayList = std::vector<gfx::Display>; | 34 using DisplayList = std::vector<gfx::Display>; |
| 34 | 35 |
| 35 // DisplayPlacement specifies where the display (D) is placed relative | 36 // DisplayPlacement specifies where the display (D) is placed relative |
| 36 // to parent (P) display. In the following example, the display (D) | 37 // to parent (P) display. In the following example, the display (D) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 61 int offset; | 62 int offset; |
| 62 | 63 |
| 63 explicit DisplayPlacement(const DisplayPlacement& placement); | 64 explicit DisplayPlacement(const DisplayPlacement& placement); |
| 64 DisplayPlacement(Position position, int offset); | 65 DisplayPlacement(Position position, int offset); |
| 65 DisplayPlacement(); | 66 DisplayPlacement(); |
| 66 | 67 |
| 67 DisplayPlacement& Swap(); | 68 DisplayPlacement& Swap(); |
| 68 | 69 |
| 69 std::string ToString() const; | 70 std::string ToString() const; |
| 70 | 71 |
| 71 // Used by JSONValueConverter to generate DisplayPlacement from a | 72 static std::string PositionToString(Position position); |
| 72 // JSON value. See json_value_converter.h. | 73 static bool StringToPosition(const base::StringPiece& string, |
| 73 static void RegisterJSONConverter( | 74 Position* position); |
| 74 base::JSONValueConverter<DisplayPlacement>* converter); | |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 class ASH_EXPORT DisplayLayout final { | 77 class ASH_EXPORT DisplayLayout final { |
| 78 public: | 78 public: |
| 79 DisplayLayout(); | 79 DisplayLayout(); |
| 80 ~DisplayLayout(); | 80 ~DisplayLayout(); |
| 81 | 81 |
| 82 // Converter functions to/from base::Value. | |
| 83 static bool ConvertFromValue(const base::Value& value, DisplayLayout* layout); | |
| 84 static bool ConvertToValue(const DisplayLayout& layout, base::Value* value); | |
| 85 | |
| 86 // Used by JSONValueConverter to generate DisplayLayout from a | |
| 87 // JSON value. See json_value_converter.h. | |
| 88 static void RegisterJSONConverter( | |
| 89 base::JSONValueConverter<DisplayLayout>* converter); | |
| 90 | |
| 91 // Validates the layout object. | 82 // Validates the layout object. |
| 92 static bool Validate(const DisplayIdList& list, const DisplayLayout& layout); | 83 static bool Validate(const DisplayIdList& list, const DisplayLayout& layout); |
| 93 | 84 |
| 94 ScopedVector<DisplayPlacement> placement_list; | 85 ScopedVector<DisplayPlacement> placement_list; |
| 95 | 86 |
| 96 // True if displays are mirrored. | 87 // True if displays are mirrored. |
| 97 bool mirrored; | 88 bool mirrored; |
| 98 | 89 |
| 99 // True if multi displays should default to unified mode. | 90 // True if multi displays should default to unified mode. |
| 100 bool default_unified; | 91 bool default_unified; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 115 // |display_id| if it exists, otherwise returns nullptr. | 106 // |display_id| if it exists, otherwise returns nullptr. |
| 116 const DisplayPlacement* FindPlacementById(int64_t display_id) const; | 107 const DisplayPlacement* FindPlacementById(int64_t display_id) const; |
| 117 | 108 |
| 118 private: | 109 private: |
| 119 DISALLOW_COPY_AND_ASSIGN(DisplayLayout); | 110 DISALLOW_COPY_AND_ASSIGN(DisplayLayout); |
| 120 }; | 111 }; |
| 121 | 112 |
| 122 } // namespace ash | 113 } // namespace ash |
| 123 | 114 |
| 124 #endif | 115 #endif |
| OLD | NEW |