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.
5 #ifndef UI_BASE_LAYOUT_H_
6 #define UI_BASE_LAYOUT_H_
10 #include "build/build_config.h"
11 #include "ui/base/ui_export.h"
12 #include "ui/gfx/native_widget_types.h"
17 // The typical layout for e.g. Windows, Mac and Linux.
20 // Layout optimized for touch. Used e.g. for Windows 8 Metro mode.
24 // Returns the display layout that should be used. This could be used
25 // e.g. to tweak hard-coded padding that's layout specific, or choose
26 // the .pak file of theme resources to load.
27 // WARNING: this is deprecated and will be nuked as soon as aura is the default
29 UI_EXPORT DisplayLayout
GetDisplayLayout();
31 // Supported UI scale factors for the platform. This is used as an index
32 // into the array |kScaleFactorScales| which maps the enum value to a float.
33 // SCALE_FACTOR_NONE is used for density independent resources such as
34 // string, html/js files or an image that can be used for any scale factors
35 // (such as wallpapers).
37 SCALE_FACTOR_NONE
= 0,
45 NUM_SCALE_FACTORS
// This always appears last.
48 // Returns the float scale value for |scale_factor|.
49 UI_EXPORT
float GetScaleFactorScale(ScaleFactor scale_factor
);
51 // Returns the supported ScaleFactor which most closely matches |scale|.
52 // Converting from float to ScaleFactor is inefficient and should be done as
53 // little as possible.
54 // TODO(oshima): Make ScaleFactor a class and remove this.
55 UI_EXPORT ScaleFactor
GetScaleFactorFromScale(float scale
);
57 // Returns the ScaleFactor used by |view|.
58 UI_EXPORT ScaleFactor
GetScaleFactorForNativeView(gfx::NativeView view
);
60 // Returns the maximum device scale factor supported by this platform.
61 UI_EXPORT ScaleFactor
GetMaxScaleFactor();
63 // Returns a vector with the scale factors which are supported by this
64 // platform, in ascending order.
65 UI_EXPORT
std::vector
<ScaleFactor
> GetSupportedScaleFactors();
67 // Returns true if |scale_factor| is supported by this platform.
68 UI_EXPORT
bool IsScaleFactorSupported(ScaleFactor scale_factor
);
72 // Changes the value of GetSupportedScaleFactors() to |scale_factors|.
73 // Use ScopedSetSupportedScaleFactors for unit tests as not to affect the
74 // state of other tests.
75 UI_EXPORT
void SetSupportedScaleFactors(
76 const std::vector
<ScaleFactor
>& scale_factors
);
78 // Class which changes the value of GetSupportedScaleFactors() to
79 // |new_scale_factors| for the duration of its lifetime.
80 class UI_EXPORT ScopedSetSupportedScaleFactors
{
82 explicit ScopedSetSupportedScaleFactors(
83 const std::vector
<ui::ScaleFactor
>& new_scale_factors
);
84 ~ScopedSetSupportedScaleFactors();
87 const std::vector
<ui::ScaleFactor
> original_scale_factors_
;
89 DISALLOW_COPY_AND_ASSIGN(ScopedSetSupportedScaleFactors
);
96 #endif // UI_BASE_LAYOUT_H_