summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/gtk/custom_button.cc
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 23:41:53 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 23:41:53 +0000
commitec015c8457dd6978ad0d86fd04738aa4a12867a4 (patch)
treeddd3873f745e968db94c1cc7b3dae16ab27545e6 /chrome/browser/ui/gtk/custom_button.cc
parent7ad2d26cf0d1eb496f3372ad02ae21b93778fe78 (diff)
downloadchromium_src-ec015c8457dd6978ad0d86fd04738aa4a12867a4.zip
chromium_src-ec015c8457dd6978ad0d86fd04738aa4a12867a4.tar.gz
chromium_src-ec015c8457dd6978ad0d86fd04738aa4a12867a4.tar.bz2
Metro/HiDPI: Cleanup ResourceBundle
For Metro and HiDPI support we need to conditionally load resource pak files. For example, on Windows I'd like to have something like this: ..ResourceBundle::LoadCommonResources() { ....if (IsMetroMode()) { ......switch (DPIScale()) { ........case 1.0: AddDataPack("theme_resources_metro_1_0x.pak"); break; ........case 1.4: AddDataPack("theme_resources_metro_1_4x.pak"); break; ........case 1.8: AddDataPack("theme_resources_metro_1_8x.pak"); break; ......} ....} else { ......if (DPIScale() < 1.5) ........AddDataPack("theme_resources_desktop_1_0x.pak"); ......else ........AddDataPack("theme_resources_desktop_2_0x.pak"); ....} ..} As a first step this CL does the following: - create a new ResourceHandle abstract class that can be backed by a DLL on Windows. - manage all resource packs through the data_packs_ vector - clean up ResourceBundle interface by removing all the #ifdefs BUG=114311 TEST=Built and ran on Mac, Linux, Windows, Linux Arua. Review URL: http://codereview.chromium.org/10051012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132091 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/gtk/custom_button.cc')
-rw-r--r--chrome/browser/ui/gtk/custom_button.cc25
1 files changed, 16 insertions, 9 deletions
diff --git a/chrome/browser/ui/gtk/custom_button.cc b/chrome/browser/ui/gtk/custom_button.cc
index 9795471..65e3694 100644
--- a/chrome/browser/ui/gtk/custom_button.cc
+++ b/chrome/browser/ui/gtk/custom_button.cc
@@ -17,8 +17,20 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/gtk_util.h"
#include "ui/gfx/image/cairo_cached_surface.h"
+#include "ui/gfx/image/image.h"
#include "ui/gfx/skbitmap_operations.h"
+namespace {
+
+GdkPixbuf* GetImage(int resource_id) {
+ if (!resource_id)
+ return NULL;
+ return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
+ resource_id, ui::ResourceBundle::RTL_ENABLED).ToGdkPixbuf();
+}
+
+} // namespace
+
CustomDrawButtonBase::CustomDrawButtonBase(ThemeServiceGtk* theme_provider,
int normal_id,
int pressed_id,
@@ -46,16 +58,11 @@ CustomDrawButtonBase::CustomDrawButtonBase(ThemeServiceGtk* theme_provider,
content::Source<ThemeService>(theme_provider));
} else {
// Load the button images from the resource bundle.
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- surfaces_[GTK_STATE_NORMAL]->UsePixbuf(
- normal_id_ ? rb.GetRTLEnabledPixbufNamed(normal_id_) : NULL);
- surfaces_[GTK_STATE_ACTIVE]->UsePixbuf(
- pressed_id_ ? rb.GetRTLEnabledPixbufNamed(pressed_id_) : NULL);
- surfaces_[GTK_STATE_PRELIGHT]->UsePixbuf(
- hover_id_ ? rb.GetRTLEnabledPixbufNamed(hover_id_) : NULL);
+ surfaces_[GTK_STATE_NORMAL]->UsePixbuf(GetImage(normal_id_));
+ surfaces_[GTK_STATE_ACTIVE]->UsePixbuf(GetImage(pressed_id_));
+ surfaces_[GTK_STATE_PRELIGHT]->UsePixbuf(GetImage(hover_id_));
surfaces_[GTK_STATE_SELECTED]->UsePixbuf(NULL);
- surfaces_[GTK_STATE_INSENSITIVE]->UsePixbuf(
- disabled_id_ ? rb.GetRTLEnabledPixbufNamed(disabled_id_) : NULL);
+ surfaces_[GTK_STATE_INSENSITIVE]->UsePixbuf(GetImage(disabled_id_));
}
}