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

Unified Diff: ui/native_theme/native_theme_mac.mm

Issue 303543004: MacViews: views_examples_with_content_exe working! Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add files Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/native_theme/native_theme_mac.h ('k') | ui/views/accessibility/native_view_accessibility_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/native_theme/native_theme_mac.mm
diff --git a/ui/native_theme/native_theme_mac.mm b/ui/native_theme/native_theme_mac.mm
index c3152a8d14582fcd4275d808283e813769e68e6c..034e49739d38cc3be0191b0b2751e8dc2d78b6e4 100644
--- a/ui/native_theme/native_theme_mac.mm
+++ b/ui/native_theme/native_theme_mac.mm
@@ -4,14 +4,52 @@
#include "ui/native_theme/native_theme_mac.h"
+#include <Cocoa/Cocoa.h>
+
#include "base/basictypes.h"
+#include "base/mac/scoped_cftyperef.h"
#include "ui/native_theme/common_theme.h"
+#include "skia/ext/skia_utils_mac.h"
+
+#if !defined(MAC_OS_X_VERSION_10_8) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
+
+@interface NSColor (MountainLionAPI)
+- (CGColorRef)CGColor;
+@end
+
+#endif
namespace {
const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
const SkColor kDialogBackgroundColor = SkColorSetRGB(251, 251, 251);
+// System colors use NSNamedColorSpace System.
+SkColor SystemColor(NSColor* color) {
+ NSColor* deviceColor =
+ [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
+ if (!deviceColor) {
+ // Sometimes the conversion is not possible, but we can get an approximation
+ // by going through a CGColorRef.
+ if ([color respondsToSelector:@selector(CGColor)]) {
+ CGColorRef cg_color = ([color CGColor]);
+ if (CGColorGetNumberOfComponents(cg_color) == 2) {
+ const CGFloat* components = CGColorGetComponents(cg_color);
+ return SkColorSetARGB(SkScalarRoundToInt(255.0 * components[1]),
+ SkScalarRoundToInt(255.0 * components[0]),
+ SkScalarRoundToInt(255.0 * components[0]),
+ SkScalarRoundToInt(255.0 * components[0]));
+ }
+ return gfx::CGColorRefToSkColor(cg_color);
+ } else {
+ NOTIMPLEMENTED();
+ return SkColor();
+ }
+ }
+ return gfx::NSDeviceColorToSkColor(deviceColor);
+}
+
} // namespace
namespace ui {
@@ -33,10 +71,36 @@ SkColor NativeThemeMac::GetSystemColor(ColorId color_id) const {
return color;
switch (color_id) {
+ case kColorId_WindowBackground:
+ return SystemColor([NSColor windowBackgroundColor]);
case kColorId_DialogBackground:
return kDialogBackgroundColor;
+ case kColorId_ButtonBackgroundColor:
+ return SystemColor([NSColor controlBackgroundColor]);
+ case kColorId_LabelEnabledColor:
+ return SystemColor([NSColor controlTextColor]);
+ case kColorId_LabelDisabledColor:
+ return SystemColor([NSColor disabledControlTextColor]);
+ case kColorId_LabelBackgroundColor:
+ return SystemColor([NSColor textBackgroundColor]);
+ case kColorId_ButtonEnabledColor:
+ case kColorId_ButtonDisabledColor:
+ return SystemColor([NSColor controlColor]);
+ case kColorId_ButtonHighlightColor:
+ return SystemColor([NSColor selectedControlColor]);
+ case kColorId_ButtonHoverColor:
+ return SystemColor([NSColor controlHighlightColor]);
+ case kColorId_TextfieldDefaultColor:
+ return SystemColor([NSColor textColor]);
+ case kColorId_TextfieldDefaultBackground:
+ return SystemColor([NSColor textBackgroundColor]);
+ case kColorId_TextfieldSelectionColor:
+ return SystemColor([NSColor selectedTextColor]);
+ case kColorId_TextfieldSelectionBackgroundFocused:
+ return SystemColor([NSColor selectedTextBackgroundColor]);
default:
- NOTREACHED() << "Invalid color_id: " << color_id;
+ NOTIMPLEMENTED() << " Invalid color_id: " << color_id;
+ return FallbackTheme::GetSystemColor(color_id);
}
return kInvalidColorIdColor;
« no previous file with comments | « ui/native_theme/native_theme_mac.h ('k') | ui/views/accessibility/native_view_accessibility_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698