blob: ab838780c25b278d8c2611f372255892c030126d [file] [log] [blame]
[email protected]cef15da2012-04-26 13:38:101// 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_BASE_LAYOUT_H_
6#define UI_BASE_LAYOUT_H_
[email protected]cef15da2012-04-26 13:38:107
[email protected]b1a99302012-06-25 17:43:318#include <vector>
9
[email protected]2cd6edd92012-06-25 19:45:4810#include "build/build_config.h"
[email protected]9552c2d2014-01-06 02:05:3211#include "ui/base/ui_base_export.h"
[email protected]509e5aa2012-08-03 01:35:5512#include "ui/gfx/native_widget_types.h"
[email protected]cef15da2012-04-26 13:38:1013
14namespace ui {
15
[email protected]c49201a2012-05-24 11:04:5716// Supported UI scale factors for the platform. This is used as an index
17// into the array |kScaleFactorScales| which maps the enum value to a float.
[email protected]0a4cf452012-11-14 07:28:4018// SCALE_FACTOR_NONE is used for density independent resources such as
19// string, html/js files or an image that can be used for any scale factors
20// (such as wallpapers).
thakisb8fbe312014-10-29 01:30:4221enum ScaleFactor : int {
[email protected]0a4cf452012-11-14 07:28:4022 SCALE_FACTOR_NONE = 0,
23 SCALE_FACTOR_100P,
[email protected]07d694672013-08-23 11:53:1424 SCALE_FACTOR_125P,
[email protected]3e594582013-02-04 21:03:3625 SCALE_FACTOR_133P,
[email protected]a27ef622012-09-10 17:52:0226 SCALE_FACTOR_140P,
[email protected]276e8a322013-01-24 01:50:1127 SCALE_FACTOR_150P,
[email protected]a27ef622012-09-10 17:52:0228 SCALE_FACTOR_180P,
[email protected]c49201a2012-05-24 11:04:5729 SCALE_FACTOR_200P,
[email protected]e416a9b2014-06-12 06:42:2430 SCALE_FACTOR_250P,
[email protected]f9ff27b2013-12-10 21:53:4631 SCALE_FACTOR_300P,
[email protected]a27ef622012-09-10 17:52:0232
33 NUM_SCALE_FACTORS // This always appears last.
[email protected]c49201a2012-05-24 11:04:5734};
35
[email protected]421ce19f2013-01-31 18:06:4136// Changes the value of GetSupportedScaleFactors() to |scale_factors|.
37// Use ScopedSetSupportedScaleFactors for unit tests as not to affect the
38// state of other tests.
[email protected]9552c2d2014-01-06 02:05:3239UI_BASE_EXPORT void SetSupportedScaleFactors(
[email protected]b1a99302012-06-25 17:43:3140 const std::vector<ScaleFactor>& scale_factors);
41
[email protected]50b66262013-09-24 03:25:4842// Returns a vector with the scale factors which are supported by this
43// platform, in ascending order.
[email protected]9552c2d2014-01-06 02:05:3244UI_BASE_EXPORT const std::vector<ScaleFactor>& GetSupportedScaleFactors();
[email protected]50b66262013-09-24 03:25:4845
[email protected]50b66262013-09-24 03:25:4846// Returns the supported ScaleFactor which most closely matches |scale|.
47// Converting from float to ScaleFactor is inefficient and should be done as
48// little as possible.
[email protected]9552c2d2014-01-06 02:05:3249UI_BASE_EXPORT ScaleFactor GetSupportedScaleFactor(float image_scale);
[email protected]50b66262013-09-24 03:25:4850
51// Returns the ScaleFactor used by |view|.
[email protected]1e76b502014-05-20 06:25:2952UI_BASE_EXPORT float GetScaleFactorForNativeView(gfx::NativeView view);
[email protected]50b66262013-09-24 03:25:4853
[email protected]b82b38f72014-03-28 20:16:2754// Returns the image scale for the scale factor passed in.
55UI_BASE_EXPORT float GetScaleForScaleFactor(ScaleFactor scale_factor);
56
[email protected]50b66262013-09-24 03:25:4857namespace test {
[email protected]421ce19f2013-01-31 18:06:4158// Class which changes the value of GetSupportedScaleFactors() to
59// |new_scale_factors| for the duration of its lifetime.
[email protected]9552c2d2014-01-06 02:05:3260class UI_BASE_EXPORT ScopedSetSupportedScaleFactors {
[email protected]421ce19f2013-01-31 18:06:4161 public:
62 explicit ScopedSetSupportedScaleFactors(
63 const std::vector<ui::ScaleFactor>& new_scale_factors);
64 ~ScopedSetSupportedScaleFactors();
65
66 private:
[email protected]50b66262013-09-24 03:25:4867 std::vector<ui::ScaleFactor>* original_scale_factors_;
[email protected]421ce19f2013-01-31 18:06:4168
69 DISALLOW_COPY_AND_ASSIGN(ScopedSetSupportedScaleFactors);
70};
71
[email protected]b1a99302012-06-25 17:43:3172} // namespace test
73
[email protected]cef15da2012-04-26 13:38:1074} // namespace ui
75
76#endif // UI_BASE_LAYOUT_H_