| 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" | |
| 17 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
| 18 | 17 |
| 19 namespace base { | 18 namespace base { |
| 20 class Value; | 19 class Value; |
| 21 template <typename T> class JSONValueConverter; | 20 template <typename T> class JSONValueConverter; |
| 22 } | 21 } |
| 23 | 22 |
| 24 namespace gfx { | 23 namespace gfx { |
| 25 class Display; | 24 class Display; |
| 26 } | 25 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 54 int64_t parent_display_id; | 53 int64_t parent_display_id; |
| 55 | 54 |
| 56 // To which side the parent display the display is positioned. | 55 // To which side the parent display the display is positioned. |
| 57 enum Position { TOP, RIGHT, BOTTOM, LEFT }; | 56 enum Position { TOP, RIGHT, BOTTOM, LEFT }; |
| 58 Position position; | 57 Position position; |
| 59 | 58 |
| 60 // The offset of the position of the secondary display. The offset is | 59 // The offset of the position of the secondary display. The offset is |
| 61 // based on the top/left edge of the primary display. | 60 // based on the top/left edge of the primary display. |
| 62 int offset; | 61 int offset; |
| 63 | 62 |
| 64 explicit DisplayPlacement(const DisplayPlacement& placement); | |
| 65 DisplayPlacement(Position position, int offset); | 63 DisplayPlacement(Position position, int offset); |
| 66 DisplayPlacement(); | 64 DisplayPlacement(); |
| 65 DisplayPlacement(const DisplayPlacement& placement); |
| 67 | 66 |
| 68 DisplayPlacement& Swap(); | 67 DisplayPlacement& Swap(); |
| 69 | 68 |
| 70 std::string ToString() const; | 69 std::string ToString() const; |
| 71 | 70 |
| 72 static std::string PositionToString(Position position); | 71 static std::string PositionToString(Position position); |
| 73 static bool StringToPosition(const base::StringPiece& string, | 72 static bool StringToPosition(const base::StringPiece& string, |
| 74 Position* position); | 73 Position* position); |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 class ASH_EXPORT DisplayLayout final { | 76 class ASH_EXPORT DisplayLayout final { |
| 78 public: | 77 public: |
| 79 DisplayLayout(); | 78 DisplayLayout(); |
| 80 ~DisplayLayout(); | 79 ~DisplayLayout(); |
| 81 | 80 |
| 82 // Validates the layout object. | 81 // Validates the layout object. |
| 83 static bool Validate(const DisplayIdList& list, const DisplayLayout& layout); | 82 static bool Validate(const DisplayIdList& list, const DisplayLayout& layout); |
| 84 | 83 |
| 85 ScopedVector<DisplayPlacement> placement_list; | 84 std::vector<DisplayPlacement> placement_list; |
| 86 | 85 |
| 87 // True if displays are mirrored. | 86 // True if displays are mirrored. |
| 88 bool mirrored; | 87 bool mirrored; |
| 89 | 88 |
| 90 // True if multi displays should default to unified mode. | 89 // True if multi displays should default to unified mode. |
| 91 bool default_unified; | 90 bool default_unified; |
| 92 | 91 |
| 93 // The id of the display used as a primary display. | 92 // The id of the display used as a primary display. |
| 94 int64_t primary_id; | 93 int64_t primary_id; |
| 95 | 94 |
| 96 scoped_ptr<DisplayLayout> Copy() const; | 95 scoped_ptr<DisplayLayout> Copy() const; |
| 97 | 96 |
| 98 // Test if the |layout| has the same placement list. Other fields such | 97 // Test if the |layout| has the same placement list. Other fields such |
| 99 // as mirrored, primary_id are ignored. | 98 // as mirrored, primary_id are ignored. |
| 100 bool HasSamePlacementList(const DisplayLayout& layout) const; | 99 bool HasSamePlacementList(const DisplayLayout& layout) const; |
| 101 | 100 |
| 102 // Returns string representation of the layout for debugging/testing. | 101 // Returns string representation of the layout for debugging/testing. |
| 103 std::string ToString() const; | 102 std::string ToString() const; |
| 104 | 103 |
| 105 // Returns the DisplayPlacement entry in |placement_list| matching | 104 // Returns the DisplayPlacement entry matching |display_id| if it exists, |
| 106 // |display_id| if it exists, otherwise returns nullptr. | 105 // otherwise returns a DisplayPlacement with an invalid display id. |
| 107 const DisplayPlacement* FindPlacementById(int64_t display_id) const; | 106 DisplayPlacement FindPlacementById(int64_t display_id) const; |
| 108 | 107 |
| 109 private: | 108 private: |
| 110 DISALLOW_COPY_AND_ASSIGN(DisplayLayout); | 109 DISALLOW_COPY_AND_ASSIGN(DisplayLayout); |
| 111 }; | 110 }; |
| 112 | 111 |
| 113 } // namespace ash | 112 } // namespace ash |
| 114 | 113 |
| 115 #endif | 114 #endif |
| OLD | NEW |