OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 UI_AURA_MONITOR_H_ | 5 #ifndef UI_AURA_MONITOR_H_ |
6 #define UI_AURA_MONITOR_H_ | 6 #define UI_AURA_MONITOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "ui/aura/aura_export.h" | 10 #include "ui/aura/aura_export.h" |
11 #include "ui/gfx/insets.h" | 11 #include "ui/gfx/insets.h" |
12 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
13 | 13 |
14 namespace gfx { | |
15 class Monitor; | |
16 } | |
17 | |
14 namespace aura { | 18 namespace aura { |
15 | 19 |
16 // Note: The screen and monitor currently uses pixels coordinate | 20 class AURA_EXPORT MonitorAura { |
Ben Goodger (Google)
2012/04/13 19:57:19
What's the purpose of this class when you have gfx
oshima
2012/04/13 21:18:41
WorkArea is computed from bounds and insets on Aur
| |
17 // system. ENABLE_DIP macro (which is enabled with enable_dip=1 gyp | |
18 // flag) will make this inconsistent with views' coordinate system | |
19 // because views will use DIP coordinate system, which uses | |
20 // (1.0/device_scale_factor) scale of the pixel coordinate system. | |
21 // TODO(oshima): Change aura/screen to DIP coordinate system and | |
22 // update this comment. | |
23 class AURA_EXPORT Monitor { | |
24 public: | 21 public: |
25 Monitor(); | 22 MonitorAura(); |
26 ~Monitor(); | 23 explicit MonitorAura(const gfx::Rect& bounds); |
24 virtual ~MonitorAura(); | |
27 | 25 |
28 // Sets/gets monitor's bounds in |gfx::screen|'s coordinates, | 26 // Sets/gets monitor's bounds in |gfx::screen|'s coordinates, |
29 // which is relative to the primary screen's origin. | 27 // which is relative to the primary screen's origin. |
30 void set_bounds(const gfx::Rect& bounds) { bounds_ = bounds;} | 28 void set_bounds(const gfx::Rect& bounds) { bounds_ = bounds;} |
31 const gfx::Rect& bounds() const { return bounds_; }; | 29 const gfx::Rect& bounds() const { return bounds_; }; |
32 | 30 |
33 // Sets/gets monitor's size. | 31 // Sets/gets monitor's size. |
34 void set_size(const gfx::Size& size) { bounds_.set_size(size); } | 32 void set_size(const gfx::Size& size) { bounds_.set_size(size); } |
35 const gfx::Size& size() const { return bounds_.size(); } | 33 const gfx::Size& size() const { return bounds_.size(); } |
36 | 34 |
37 // Sets/gets monitor's workarea insets. | 35 // Sets/gets monitor's workarea insets. |
38 void set_work_area_insets(const gfx::Insets& insets) { | 36 void set_work_area_insets(const gfx::Insets& insets) { |
39 work_area_insets_ = insets; | 37 work_area_insets_ = insets; |
40 } | 38 } |
41 const gfx::Insets& work_area_insets() const { return work_area_insets_; } | 39 const gfx::Insets& work_area_insets() const { return work_area_insets_; } |
42 | 40 |
43 // Output device's pixel scale factor. This specifies how much the | 41 // Sets the device scale factor. |
44 // UI should be scaled when the actual output has more pixels than | |
45 // standard monitors (which is around 100~120dpi.) For aura, this | |
46 // value is either 1.0 or 2.0, but may return different values on | |
47 // other platforms. | |
48 float GetDeviceScaleFactor() const { | |
49 return device_scale_factor_; | |
50 } | |
51 | |
52 void set_device_scale_factor(float scale) { | 42 void set_device_scale_factor(float scale) { |
53 device_scale_factor_ = scale; | 43 device_scale_factor_ = scale; |
54 } | 44 } |
55 | 45 |
56 // Returns the monitor's work area. | 46 // Copy the monitor info into |monitor_out|. |
57 gfx::Rect GetWorkAreaBounds() const; | 47 void CopyTo(gfx::Monitor* monitor_out) const; |
58 | 48 |
59 private: | 49 private: |
60 // Insets for the work area. | 50 // Insets for the work area. |
61 gfx::Insets work_area_insets_; | 51 gfx::Insets work_area_insets_; |
62 | 52 |
63 gfx::Rect bounds_; | 53 gfx::Rect bounds_; |
64 | 54 |
65 float device_scale_factor_; | 55 float device_scale_factor_; |
66 | 56 |
67 DISALLOW_COPY_AND_ASSIGN(Monitor); | 57 DISALLOW_COPY_AND_ASSIGN(MonitorAura); |
68 }; | 58 }; |
69 | 59 |
70 } // namespace aura | 60 } // namespace aura |
71 | 61 |
72 #endif // UI_AURA_MONITOR_H_ | 62 #endif // UI_AURA_MONITOR_H_ |
OLD | NEW |