Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: ui/gfx/monitor.h

Issue 9960042: Refactor screen/monitor so that gfx::Screen returns monitor object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix command line Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/monitor.h
diff --git a/ui/gfx/monitor.h b/ui/gfx/monitor.h
new file mode 100644
index 0000000000000000000000000000000000000000..d1b5c723113eef8978733678f2171f0fa4ae7dfd
--- /dev/null
+++ b/ui/gfx/monitor.h
@@ -0,0 +1,67 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_MONITOR_H_
+#define UI_GFX_MONITOR_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ui/base/ui_export.h"
+#include "ui/gfx/rect.h"
+
+namespace gfx {
+
+class UI_EXPORT Monitor {
+ public:
+ Monitor();
+ virtual ~Monitor();
+
+ // Returns the monitor's bounds in gfx::Screen's coordinates.
+ virtual Rect GetBounds() const = 0;
+
+ // Returns the monitor's work area in gfx::Screen's coordinates.
+ virtual Rect GetWorkArea() const = 0;
+
+ // Output device's pixel scale factor. This specifies how much the
+ // UI should be scaled when the actual output has more pixels than
+ // standard monitors (which is around 100~120dpi.) For aura, this
Ben Goodger (Google) 2012/04/10 16:37:20 don't mention aura here, just note that the return
oshima 2012/04/10 21:31:46 Done.
+ // value is either 1.0 or 2.0, but may return different values on
+ // other platforms.
+ virtual float GetDeviceScaleFactor() const = 0;
+
+ // Utility functions that just return the size of monitor and
+ // work area.
+ Size GetSize() const;
+ Size GetWorkAreaSize() const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Monitor);
+};
+
+// Simple monitor class that stores bounds and workarea.
+class UI_EXPORT SimpleMonitor : public Monitor {
+ public:
+ SimpleMonitor();
+ explicit SimpleMonitor(const gfx::Rect& bounds);
+ virtual ~SimpleMonitor();
+
+ void set_bounds(const Rect& bounds) { bounds_ = bounds; }
+ void set_work_area(const Rect& work_area) { work_area_ = work_area; }
+
+ // Monitor overrides:
+ virtual Rect GetBounds() const OVERRIDE;
+ virtual Rect GetWorkArea() const OVERRIDE;
+ virtual float GetDeviceScaleFactor() const OVERRIDE;
+
+ private:
+ Rect bounds_;
+ Rect work_area_;
+
+ DISALLOW_COPY_AND_ASSIGN(SimpleMonitor);
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_MONITOR_H_

Powered by Google App Engine
This is Rietveld 408576698