| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 UI_GFX_MONITOR_H_ | |
| 6 #define UI_GFX_MONITOR_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "ui/base/ui_export.h" | |
| 12 #include "ui/gfx/rect.h" | |
| 13 | |
| 14 namespace gfx { | |
| 15 | |
| 16 // Note: The screen and monitor currently uses pixel coordinate | |
| 17 // system. For platforms that support DIP (density independent pixel), | |
| 18 // |bounds()| and |work_area| will return values in DIP coordinate | |
| 19 // system, not in backing pixels. | |
| 20 class UI_EXPORT Monitor { | |
| 21 public: | |
| 22 // Returns the default value for the device scale factor, which is | |
| 23 // given by "--default-device-scale-factor". | |
| 24 static float GetDefaultDeviceScaleFactor(); | |
| 25 | |
| 26 // Creates a monitor with invalid id(-1) as default. | |
| 27 Monitor(); | |
| 28 explicit Monitor(int id); | |
| 29 Monitor(int id, const Rect& bounds); | |
| 30 ~Monitor(); | |
| 31 | |
| 32 // Sets/Gets unique identifier associated with the monitor. | |
| 33 int id() const { return id_; } | |
| 34 void set_id(int id) { id_ = id; } | |
| 35 | |
| 36 // Gets/Sets the monitor's bounds in gfx::Screen's coordinates. | |
| 37 // -1 means invalid monitor and it doesn't not exit. | |
| 38 const Rect& bounds() const { return bounds_; } | |
| 39 void set_bounds(const Rect& bounds) { bounds_ = bounds; } | |
| 40 | |
| 41 // Gets/Sets the monitor's work area in gfx::Screen's coordinates. | |
| 42 const Rect& work_area() const { return work_area_; } | |
| 43 void set_work_area(const Rect& work_area) { work_area_ = work_area; } | |
| 44 | |
| 45 // Output device's pixel scale factor. This specifies how much the | |
| 46 // UI should be scaled when the actual output has more pixels than | |
| 47 // standard monitors (which is around 100~120dpi.) The potential return | |
| 48 // values depend on each platforms. | |
| 49 float device_scale_factor() const { return device_scale_factor_; } | |
| 50 void set_device_scale_factor(float scale) { device_scale_factor_ = scale; } | |
| 51 | |
| 52 // Utility functions that just return the size of monitor and | |
| 53 // work area. | |
| 54 const Size& size() const { return bounds_.size(); } | |
| 55 const Size& work_area_size() const { return work_area_.size(); } | |
| 56 | |
| 57 // Returns the work area insets. | |
| 58 Insets GetWorkAreaInsets() const; | |
| 59 | |
| 60 // Sets the device scale factor and monitor bounds in pixel. This | |
| 61 // updates the work are using the same insets between old bounds and | |
| 62 // work area. | |
| 63 void SetScaleAndBounds(float device_scale_factor, | |
| 64 const gfx::Rect& bounds_in_pixel); | |
| 65 | |
| 66 // Sets the monitor's size. This updates the work area using the same insets | |
| 67 // between old bounds and work area. | |
| 68 void SetSize(const gfx::Size& size_in_pixel); | |
| 69 | |
| 70 // Computes and updates the monitor's work are using | |
| 71 // |work_area_insets| and the bounds. | |
| 72 void UpdateWorkAreaFromInsets(const gfx::Insets& work_area_insets); | |
| 73 | |
| 74 // Returns the monitor's size in pixel coordinates. | |
| 75 gfx::Size GetSizeInPixel() const; | |
| 76 | |
| 77 #if defined(USE_AURA) | |
| 78 // TODO(oshima): |bounds()| on ash is not screen's coordinate and | |
| 79 // this is an workaround for this. This will be removed when ash | |
| 80 // has true multi monitor support. crbug.com/119268. | |
| 81 // Returns the monitor's bounds in pixel coordinates. | |
| 82 const Rect& bounds_in_pixel() const { return bounds_in_pixel_; } | |
| 83 #endif | |
| 84 | |
| 85 // Returns a string representation of the monitor; | |
| 86 std::string ToString() const; | |
| 87 | |
| 88 private: | |
| 89 int id_; | |
| 90 Rect bounds_; | |
| 91 Rect work_area_; | |
| 92 #if defined(USE_AURA) | |
| 93 Rect bounds_in_pixel_; | |
| 94 #endif | |
| 95 float device_scale_factor_; | |
| 96 }; | |
| 97 | |
| 98 } // namespace gfx | |
| 99 | |
| 100 #endif // UI_GFX_MONITOR_H_ | |
| OLD | NEW |