diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-26 13:38:10 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-26 13:38:10 +0000 |
commit | cef15da9b534f5bd07bdf64cc959a7104341278d (patch) | |
tree | 8e2a752e4beb256f4f9395ceb560b940f9769d2b /ui/base | |
parent | 3349b59b789b2cd6c7c9164ed62fe7613878403b (diff) | |
download | chromium_src-cef15da9b534f5bd07bdf64cc959a7104341278d.zip chromium_src-cef15da9b534f5bd07bdf64cc959a7104341278d.tar.gz chromium_src-cef15da9b534f5bd07bdf64cc959a7104341278d.tar.bz2 |
Set toolbar padding to something appropriate for Metro icons.
Prepare to handle different sizes of Metro icons, and move now-common
code to ui/base/scale.h and .cc
BUG=114311
TEST=When launched from Metro, Chrome uses larger icons in the tab strip and they fit in a reasonably balanced way.
Review URL: http://codereview.chromium.org/10115029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r-- | ui/base/layout.cc | 38 | ||||
-rw-r--r-- | ui/base/layout.h | 32 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle_win.cc | 41 |
3 files changed, 89 insertions, 22 deletions
diff --git a/ui/base/layout.cc b/ui/base/layout.cc new file mode 100644 index 0000000..9dff5c2 --- /dev/null +++ b/ui/base/layout.cc @@ -0,0 +1,38 @@ +// 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. + +#include "ui/base/layout.h" + +#include "base/basictypes.h" +#include "build/build_config.h" + +#if defined(OS_WIN) +#include "base/win/metro.h" +#include <Windows.h> +#endif // defined(OS_WIN) + +namespace ui { + +// Note that this function should be extended to select +// LAYOUT_TOUCH when appropriate on more platforms than just +// Windows. +DisplayLayout GetDisplayLayout() { +#if defined(USE_ASH) + return LAYOUT_ASH; +#elif !defined(OS_WIN) + return LAYOUT_DESKTOP; +#else // On Windows. + bool use_touch = false; +#if defined(ENABLE_METRO) + use_touch = base::win::GetMetroModule() != NULL; +#endif // defined(ENABLE_METRO) + if (use_touch) { + return LAYOUT_TOUCH; + } else { + return LAYOUT_DESKTOP; + } +#endif // On Windows. +} + +} // namespace ui diff --git a/ui/base/layout.h b/ui/base/layout.h new file mode 100644 index 0000000..be65e6e --- /dev/null +++ b/ui/base/layout.h @@ -0,0 +1,32 @@ +// 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_BASE_LAYOUT_H_ +#define UI_BASE_LAYOUT_H_ +#pragma once + +#include "ui/base/ui_export.h" + +namespace ui { + +enum DisplayLayout { + // Layout optimized for ASH. This enum value should go away as soon as + // LAYOUT_DESKTOP and LAYOUT_ASH are the same. + LAYOUT_ASH, + + // The typical layout for e.g. Windows, Mac and Linux. + LAYOUT_DESKTOP, + + // Layout optimized for touch. Used e.g. for Windows 8 Metro mode. + LAYOUT_TOUCH, +}; + +// Returns the display layout that should be used. This could be used +// e.g. to tweak hard-coded padding that's layout specific, or choose +// the .pak file of theme resources to load. +UI_EXPORT DisplayLayout GetDisplayLayout(); + +} // namespace ui + +#endif // UI_BASE_LAYOUT_H_ diff --git a/ui/base/resource/resource_bundle_win.cc b/ui/base/resource/resource_bundle_win.cc index 6558e45..7890002 100644 --- a/ui/base/resource/resource_bundle_win.cc +++ b/ui/base/resource/resource_bundle_win.cc @@ -6,7 +6,7 @@ #include "base/logging.h" #include "base/path_service.h" -#include "base/win/metro.h" +#include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_data_dll_win.h" #include "ui/base/win/dpi.h" @@ -36,30 +36,27 @@ void ResourceBundle::LoadCommonResources() { // As a convenience, add the current resource module as a data packs. data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); - bool use_hidpi_pak = false; + bool use_hidpi = false; #if defined(ENABLE_HIDPI) - // If we're running in HiDPI mode then use the 2x resource for DPI greater - // than 1.5. Otherwise use the 1x resource. - use_hidpi_pak = ui::GetDPIScale() > 1.5; + // If we're running in HiDPI mode at a scale larger than 150%, we switch + // to 2x resources for desktop layouts. + use_hidpi = ui::GetDPIScale() > 1.5; #endif - bool use_metro_pak = false; -#if defined(ENABLE_METRO) - use_metro_pak = base::win::GetMetroModule() != NULL; -#endif - - if (use_metro_pak) { - AddDataPack(GetResourcesPakFilePath("theme_resources_metro_1x.pak")); - } else if (use_hidpi_pak) { - AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak")); - } else { - AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak")); - } - - if (use_hidpi_pak) { - AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak")); - } else { - AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak")); + switch (ui::GetDisplayLayout()) { + case ui::LAYOUT_TOUCH: + AddDataPack(GetResourcesPakFilePath("theme_resources_metro_1x.pak")); + AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak")); + break; + default: + if (use_hidpi) { + AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak")); + AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak")); + } else { + AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak")); + AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak")); + } + break; } } |