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. 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 UI_EXPORT Monitor { |
| 24 public: |
| 25 // Creates a monitor with invalid id(-1) as default. |
| 26 Monitor(); |
| 27 explicit Monitor(int id); |
| 28 Monitor(int id, const Rect& bounds); |
| 29 ~Monitor(); |
| 30 |
| 31 // Sets/Gets unique identifier associated with the monitor. |
| 32 int id() const { return id_; } |
| 33 void set_id(int id) { id_ = id; } |
| 34 |
| 35 // Gets/Sets the monitor's bounds in gfx::Screen's coordinates. |
| 36 // -1 means invalid monitor and it doesn't not exit. |
| 37 const Rect& bounds() const { return bounds_; } |
| 38 void set_bounds(const Rect& bounds) { bounds_ = bounds; } |
| 39 |
| 40 // Gets/Sets the monitor's work area in gfx::Screen's coordinates. |
| 41 const Rect& work_area() const { return work_area_; } |
| 42 void set_work_area(const Rect& work_area) { work_area_ = work_area; } |
| 43 |
| 44 // Output device's pixel scale factor. This specifies how much the |
| 45 // UI should be scaled when the actual output has more pixels than |
| 46 // standard monitors (which is around 100~120dpi.) The potential return |
| 47 // values depend on each platforms. |
| 48 float device_scale_factor() const { return device_scale_factor_; } |
| 49 void set_device_scale_factor(float scale) { device_scale_factor_ = scale; } |
| 50 |
| 51 // Utility functions that just return the size of monitor and |
| 52 // work area. |
| 53 const Size& size() const { return bounds_.size(); } |
| 54 const Size& work_area_size() const { return work_area_.size(); } |
| 55 |
| 56 // Sets the monitor bounds and updates the work are using the same insets |
| 57 // between old bounds and work area. |
| 58 void SetBoundsAndUpdateWorkArea(const gfx::Rect& bounds); |
| 59 |
| 60 // Sets the monitor size and updates the work are using the same insets |
| 61 // between old bounds and work area. |
| 62 void SetSizeAndUpdateWorkArea(const gfx::Size& size); |
| 63 |
| 64 // Computes and updates the monitor's work are using insets and the bounds. |
| 65 void UpdateWorkAreaWithInsets(const gfx::Insets& work_area_insets); |
| 66 |
| 67 private: |
| 68 int id_; |
| 69 Rect bounds_; |
| 70 Rect work_area_; |
| 71 float device_scale_factor_; |
| 72 }; |
| 73 |
| 74 } // namespace gfx |
| 75 |
| 76 #endif // UI_GFX_MONITOR_H_ |
OLD | NEW |