Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_BASE_LAYOUT_H_ | 5 #ifndef UI_BASE_LAYOUT_H_ |
| 6 #define UI_BASE_LAYOUT_H_ | 6 #define UI_BASE_LAYOUT_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 LAYOUT_TOUCH, | 25 LAYOUT_TOUCH, |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 // Returns the display layout that should be used. This could be used | 28 // Returns the display layout that should be used. This could be used |
| 29 // e.g. to tweak hard-coded padding that's layout specific, or choose | 29 // e.g. to tweak hard-coded padding that's layout specific, or choose |
| 30 // the .pak file of theme resources to load. | 30 // the .pak file of theme resources to load. |
| 31 UI_EXPORT DisplayLayout GetDisplayLayout(); | 31 UI_EXPORT DisplayLayout GetDisplayLayout(); |
| 32 | 32 |
| 33 // Supported UI scale factors for the platform. This is used as an index | 33 // Supported UI scale factors for the platform. This is used as an index |
| 34 // into the array |kScaleFactorScales| which maps the enum value to a float. | 34 // into the array |kScaleFactorScales| which maps the enum value to a float. |
| 35 // SCALE_FACTOR_NONE is used for density independent resources such as | |
| 36 // string, html/js files or an image that can be used for any scales | |
|
pkotwicz
2012/11/07 06:40:44
Nit: /any scale/all scale factors/g
oshima
2012/11/07 22:35:30
Done.
| |
| 37 // (such as wallpapers). | |
| 35 enum ScaleFactor { | 38 enum ScaleFactor { |
| 36 SCALE_FACTOR_100P = 0, | 39 SCALE_FACTOR_NONE = 0, |
| 40 SCALE_FACTOR_100P, | |
| 37 | 41 |
| 38 // The scale factor used for unscaled binary data, the 1x (default) scale | 42 // The scale factor used for unscaled binary data, the 1x (default) scale |
| 39 // factor data packs. | 43 // factor data packs. |
|
pkotwicz
2012/11/07 06:40:44
Nit: remove the comment above as it is stale
oshima
2012/11/07 22:35:30
Done.
| |
| 40 SCALE_FACTOR_NONE = SCALE_FACTOR_100P, | |
| 41 SCALE_FACTOR_140P, | 44 SCALE_FACTOR_140P, |
| 42 SCALE_FACTOR_180P, | 45 SCALE_FACTOR_180P, |
| 43 SCALE_FACTOR_200P, | 46 SCALE_FACTOR_200P, |
| 44 | 47 |
| 45 NUM_SCALE_FACTORS // This always appears last. | 48 NUM_SCALE_FACTORS // This always appears last. |
| 46 }; | 49 }; |
| 47 | 50 |
| 48 // Returns the float scale value for |scale_factor|. | 51 // Returns the float scale value for |scale_factor|. |
| 49 UI_EXPORT float GetScaleFactorScale(ScaleFactor scale_factor); | 52 UI_EXPORT float GetScaleFactorScale(ScaleFactor scale_factor); |
| 50 | 53 |
| 51 // Returns the supported ScaleFactor which most closely matches |scale|. | 54 // Returns the supported ScaleFactor which most closely matches |scale|. |
| 52 // Converting from float to ScaleFactor is inefficient and should be done as | 55 // Converting from float to ScaleFactor is inefficient and should be done as |
| 53 // little as possible. | 56 // little as possible. |
| 57 // TODO(oshima): Make ScaleFactor a class and remove this. | |
| 54 UI_EXPORT ScaleFactor GetScaleFactorFromScale(float scale); | 58 UI_EXPORT ScaleFactor GetScaleFactorFromScale(float scale); |
| 55 | 59 |
| 56 // Returns the ScaleFactor used by |view|. | 60 // Returns the ScaleFactor used by |view|. |
| 57 UI_EXPORT ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view); | 61 UI_EXPORT ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view); |
| 58 | 62 |
| 59 // Returns the maximum device scale factor supported by this platform. | 63 // Returns the maximum device scale factor supported by this platform. |
| 60 UI_EXPORT ScaleFactor GetMaxScaleFactor(); | 64 UI_EXPORT ScaleFactor GetMaxScaleFactor(); |
| 61 | 65 |
| 62 // Returns a vector with the scale factors which are supported by this | 66 // Returns a vector with the scale factors which are supported by this |
| 63 // platform, in ascending order. | 67 // platform, in ascending order. |
| 64 UI_EXPORT std::vector<ScaleFactor> GetSupportedScaleFactors(); | 68 UI_EXPORT std::vector<ScaleFactor> GetSupportedScaleFactors(); |
| 65 | 69 |
| 66 // Returns true if |scale_factor| is supported by this platform. | 70 // Returns true if |scale_factor| is supported by this platform. |
| 67 UI_EXPORT bool IsScaleFactorSupported(ScaleFactor scale_factor); | 71 UI_EXPORT bool IsScaleFactorSupported(ScaleFactor scale_factor); |
| 68 | 72 |
| 69 namespace test { | 73 namespace test { |
| 70 | 74 |
| 71 UI_EXPORT void SetSupportedScaleFactors( | 75 UI_EXPORT void SetSupportedScaleFactors( |
| 72 const std::vector<ScaleFactor>& scale_factors); | 76 const std::vector<ScaleFactor>& scale_factors); |
| 73 | 77 |
| 74 } // namespace test | 78 } // namespace test |
| 75 | 79 |
| 76 } // namespace ui | 80 } // namespace ui |
| 77 | 81 |
| 78 #endif // UI_BASE_LAYOUT_H_ | 82 #endif // UI_BASE_LAYOUT_H_ |
| OLD | NEW |