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_base_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_BASE_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,
47 NUM_SCALE_FACTORS
// This always appears last.
50 // Changes the value of GetSupportedScaleFactors() to |scale_factors|.
51 // Use ScopedSetSupportedScaleFactors for unit tests as not to affect the
52 // state of other tests.
53 UI_BASE_EXPORT
void SetSupportedScaleFactors(
54 const std::vector
<ScaleFactor
>& scale_factors
);
56 // Returns a vector with the scale factors which are supported by this
57 // platform, in ascending order.
58 UI_BASE_EXPORT
const std::vector
<ScaleFactor
>& GetSupportedScaleFactors();
60 // Returns the float scale value for |scale_factor|.
61 UI_BASE_EXPORT
float GetImageScale(ScaleFactor scale_factor
);
63 // Returns the supported ScaleFactor which most closely matches |scale|.
64 // Converting from float to ScaleFactor is inefficient and should be done as
65 // little as possible.
66 // TODO(oshima): Make ScaleFactor a class and remove this.
67 UI_BASE_EXPORT ScaleFactor
GetSupportedScaleFactor(float image_scale
);
69 // Returns the ScaleFactor used by |view|.
70 UI_BASE_EXPORT ScaleFactor
GetScaleFactorForNativeView(gfx::NativeView view
);
72 // Returns true if |scale_factor| is supported by this platform.
73 UI_BASE_EXPORT
bool IsScaleFactorSupported(ScaleFactor scale_factor
);
75 // Returns the scale factor closest to |scale| from the full list of factors.
76 // Note that it does NOT rely on the list of supported scale factors.
77 // Finding the closest match is inefficient and shouldn't be done frequently.
78 UI_BASE_EXPORT ScaleFactor
FindClosestScaleFactorUnsafe(float scale
);
81 // Class which changes the value of GetSupportedScaleFactors() to
82 // |new_scale_factors| for the duration of its lifetime.
83 class UI_BASE_EXPORT ScopedSetSupportedScaleFactors
{
85 explicit ScopedSetSupportedScaleFactors(
86 const std::vector
<ui::ScaleFactor
>& new_scale_factors
);
87 ~ScopedSetSupportedScaleFactors();
90 std::vector
<ui::ScaleFactor
>* original_scale_factors_
;
92 DISALLOW_COPY_AND_ASSIGN(ScopedSetSupportedScaleFactors
);
99 #endif // UI_BASE_LAYOUT_H_