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

Unified Diff: ui/native_theme/native_theme_mac.mm

Issue 1819443002: MacViews: draw combobox arrow backgrounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix linux build Created 4 years, 9 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
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 f9627ff3cb75d417b719cf57873b6a7a6b481501..32e6cbdb616e7e45a73fa117eef401bf326d8987 100644
--- a/ui/native_theme/native_theme_mac.mm
+++ b/ui/native_theme/native_theme_mac.mm
@@ -13,6 +13,7 @@
#include "base/macros.h"
#import "skia/ext/skia_utils_mac.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
+#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/skia_util.h"
#include "ui/native_theme/common_theme.h"
@@ -266,6 +267,38 @@ void NativeThemeMac::PaintMenuItemBackground(
}
}
+// static
+skia::RefPtr<SkShader> NativeThemeMac::GetButtonBackgroundShader(
+ NativeTheme::State state, int height) {
+ typedef SkColor ColorByState[NativeTheme::State::kNumStates];
+ SkPoint gradient_points[2];
+ gradient_points[0].iset(0, 0);
+ gradient_points[1].iset(0, height);
+
+ SkScalar gradient_positions[] = { 0.0, 0.38, 1.0 };
+
+ ColorByState start_colors;
+ start_colors[NativeTheme::State::kDisabled] = gfx::kMaterialGrey300;
+ start_colors[NativeTheme::State::kHovered] = gfx::kMaterialBlue300;
+ start_colors[NativeTheme::State::kNormal] = gfx::kMaterialBlue300;
+ start_colors[NativeTheme::State::kPressed] = gfx::kMaterialBlue300;
+ ColorByState end_colors;
+ end_colors[NativeTheme::State::kDisabled] = gfx::kMaterialGrey300;
+ end_colors[NativeTheme::State::kHovered] = gfx::kMaterialBlue700;
+ end_colors[NativeTheme::State::kNormal] = gfx::kMaterialBlue700;
+ end_colors[NativeTheme::State::kPressed] = gfx::kMaterialBlue700;
+
+ SkColor gradient_colors[] = {
+ start_colors[state], start_colors[state], end_colors[state]
+ };
+
+ skia::RefPtr<SkShader> gradient_shader = skia::AdoptRef(
+ SkGradientShader::CreateLinear(
+ gradient_points, gradient_colors, gradient_positions, 3,
+ SkShader::kClamp_TileMode));
+ return gradient_shader;
+}
+
NativeThemeMac::NativeThemeMac() {
}

Powered by Google App Engine
This is Rietveld 408576698