| OLD | NEW |
| (Empty) |
| 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 <stdint.h> | |
| 9 | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "ash/ash_export.h" | |
| 14 #include "base/macros.h" | |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/strings/string_piece.h" | |
| 17 | |
| 18 namespace base { | |
| 19 class Value; | |
| 20 template <typename T> class JSONValueConverter; | |
| 21 } | |
| 22 | |
| 23 namespace gfx { | |
| 24 class Display; | |
| 25 } | |
| 26 | |
| 27 namespace ash { | |
| 28 | |
| 29 // An identifier used to manage display layout in DisplayManager / | |
| 30 // DisplayLayoutStore. | |
| 31 using DisplayIdList = std::vector<int64_t>; | |
| 32 | |
| 33 using DisplayList = std::vector<gfx::Display>; | |
| 34 | |
| 35 // DisplayPlacement specifies where the display (D) is placed relative | |
| 36 // to parent (P) display. In the following example, the display (D) | |
| 37 // given by |display_id| is placed at the left side of the parent | |
| 38 // display (P) given by |parent_display_id|, with a negative offset. | |
| 39 // | |
| 40 // + +--------+ | |
| 41 // offset | | | | |
| 42 // + | D +--------+ | |
| 43 // | | | | |
| 44 // +--------+ P | | |
| 45 // | | | |
| 46 // +--------+ | |
| 47 // | |
| 48 struct ASH_EXPORT DisplayPlacement { | |
| 49 // The id of the display this placement will be applied to. | |
| 50 int64_t display_id; | |
| 51 | |
| 52 // The parent display id to which the above display is placed. | |
| 53 int64_t parent_display_id; | |
| 54 | |
| 55 // To which side the parent display the display is positioned. | |
| 56 enum Position { TOP, RIGHT, BOTTOM, LEFT }; | |
| 57 Position position; | |
| 58 | |
| 59 // The offset of the position of the secondary display. The offset is | |
| 60 // based on the top/left edge of the primary display. | |
| 61 int offset; | |
| 62 | |
| 63 DisplayPlacement(Position position, int offset); | |
| 64 DisplayPlacement(); | |
| 65 DisplayPlacement(const DisplayPlacement& placement); | |
| 66 | |
| 67 DisplayPlacement& Swap(); | |
| 68 | |
| 69 std::string ToString() const; | |
| 70 | |
| 71 static std::string PositionToString(Position position); | |
| 72 static bool StringToPosition(const base::StringPiece& string, | |
| 73 Position* position); | |
| 74 }; | |
| 75 | |
| 76 class ASH_EXPORT DisplayLayout final { | |
| 77 public: | |
| 78 DisplayLayout(); | |
| 79 ~DisplayLayout(); | |
| 80 | |
| 81 // Validates the layout object. | |
| 82 static bool Validate(const DisplayIdList& list, const DisplayLayout& layout); | |
| 83 | |
| 84 std::vector<DisplayPlacement> placement_list; | |
| 85 | |
| 86 // True if displays are mirrored. | |
| 87 bool mirrored; | |
| 88 | |
| 89 // True if multi displays should default to unified mode. | |
| 90 bool default_unified; | |
| 91 | |
| 92 // The id of the display used as a primary display. | |
| 93 int64_t primary_id; | |
| 94 | |
| 95 scoped_ptr<DisplayLayout> Copy() const; | |
| 96 | |
| 97 // Test if the |layout| has the same placement list. Other fields such | |
| 98 // as mirrored, primary_id are ignored. | |
| 99 bool HasSamePlacementList(const DisplayLayout& layout) const; | |
| 100 | |
| 101 // Returns string representation of the layout for debugging/testing. | |
| 102 std::string ToString() const; | |
| 103 | |
| 104 // Returns the DisplayPlacement entry matching |display_id| if it exists, | |
| 105 // otherwise returns a DisplayPlacement with an invalid display id. | |
| 106 DisplayPlacement FindPlacementById(int64_t display_id) const; | |
| 107 | |
| 108 private: | |
| 109 DISALLOW_COPY_AND_ASSIGN(DisplayLayout); | |
| 110 }; | |
| 111 | |
| 112 } // namespace ash | |
| 113 | |
| 114 #endif | |
| OLD | NEW |