Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: ui/base/resource/resource_bundle_win.cc

Issue 10115029: Set toolbar padding to something appropriate for Metro icons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Const not OK for Mac build. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/layout.cc ('k') | ui/ui.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/base/resource/resource_bundle_win.h" 5 #include "ui/base/resource/resource_bundle_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/win/metro.h" 9 #include "ui/base/layout.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/base/resource/resource_data_dll_win.h" 11 #include "ui/base/resource/resource_data_dll_win.h"
12 #include "ui/base/win/dpi.h" 12 #include "ui/base/win/dpi.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 namespace { 16 namespace {
17 17
18 HINSTANCE resources_data_dll; 18 HINSTANCE resources_data_dll;
19 19
20 HINSTANCE GetCurrentResourceDLL() { 20 HINSTANCE GetCurrentResourceDLL() {
21 if (resources_data_dll) 21 if (resources_data_dll)
22 return resources_data_dll; 22 return resources_data_dll;
23 return GetModuleHandle(NULL); 23 return GetModuleHandle(NULL);
24 } 24 }
25 25
26 FilePath GetResourcesPakFilePath(const std::string& pak_name) { 26 FilePath GetResourcesPakFilePath(const std::string& pak_name) {
27 FilePath path; 27 FilePath path;
28 if (PathService::Get(base::DIR_MODULE, &path)) 28 if (PathService::Get(base::DIR_MODULE, &path))
29 return path.AppendASCII(pak_name.c_str()); 29 return path.AppendASCII(pak_name.c_str());
30 return FilePath(); 30 return FilePath();
31 } 31 }
32 32
33 } // end anonymous namespace 33 } // end anonymous namespace
34 34
35 void ResourceBundle::LoadCommonResources() { 35 void ResourceBundle::LoadCommonResources() {
36 // As a convenience, add the current resource module as a data packs. 36 // As a convenience, add the current resource module as a data packs.
37 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); 37 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL()));
38 38
39 bool use_hidpi_pak = false; 39 bool use_hidpi = false;
40 #if defined(ENABLE_HIDPI) 40 #if defined(ENABLE_HIDPI)
41 // If we're running in HiDPI mode then use the 2x resource for DPI greater 41 // If we're running in HiDPI mode at a scale larger than 150%, we switch
42 // than 1.5. Otherwise use the 1x resource. 42 // to 2x resources for desktop layouts.
43 use_hidpi_pak = ui::GetDPIScale() > 1.5; 43 use_hidpi = ui::GetDPIScale() > 1.5;
44 #endif 44 #endif
45 45
46 bool use_metro_pak = false; 46 switch (ui::GetDisplayLayout()) {
47 #if defined(ENABLE_METRO) 47 case ui::LAYOUT_TOUCH:
48 use_metro_pak = base::win::GetMetroModule() != NULL; 48 AddDataPack(GetResourcesPakFilePath("theme_resources_metro_1x.pak"));
49 #endif 49 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
50 50 break;
51 if (use_metro_pak) { 51 default:
52 AddDataPack(GetResourcesPakFilePath("theme_resources_metro_1x.pak")); 52 if (use_hidpi) {
53 } else if (use_hidpi_pak) { 53 AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak"));
54 AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak")); 54 AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak"));
55 } else { 55 } else {
56 AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak")); 56 AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"));
57 } 57 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
58 58 }
59 if (use_hidpi_pak) { 59 break;
60 AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak"));
61 } else {
62 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
63 } 60 }
64 } 61 }
65 62
66 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { 63 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
67 // Flipped image is not used on Windows. 64 // Flipped image is not used on Windows.
68 DCHECK_EQ(rtl, RTL_DISABLED); 65 DCHECK_EQ(rtl, RTL_DISABLED);
69 66
70 // Windows only uses SkBitmap for gfx::Image, so this is the same as 67 // Windows only uses SkBitmap for gfx::Image, so this is the same as
71 // GetImageNamed. 68 // GetImageNamed.
72 return GetImageNamed(resource_id); 69 return GetImageNamed(resource_id);
73 } 70 }
74 71
75 void SetResourcesDataDLL(HINSTANCE handle) { 72 void SetResourcesDataDLL(HINSTANCE handle) {
76 resources_data_dll = handle; 73 resources_data_dll = handle;
77 } 74 }
78 75
79 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { 76 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) {
80 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); 77 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id));
81 } 78 }
82 79
83 } // namespace ui; 80 } // namespace ui;
OLDNEW
« no previous file with comments | « ui/base/layout.cc ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698