summaryrefslogtreecommitdiffstats
path: root/ui/views/painter.cc
diff options
context:
space:
mode:
authorestade <estade@chromium.org>2016-03-21 17:48:22 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-22 00:50:13 +0000
commite9d92a8bc3c4c10dc6b68daa5c834a26c5db9ab1 (patch)
tree885c85a194d9a2c007f4b8112abbd356ad8e38f1 /ui/views/painter.cc
parent927577223c78bf91118825cf94a4725c4b7a810b (diff)
downloadchromium_src-e9d92a8bc3c4c10dc6b68daa5c834a26c5db9ab1.zip
chromium_src-e9d92a8bc3c4c10dc6b68daa5c834a26c5db9ab1.tar.gz
chromium_src-e9d92a8bc3c4c10dc6b68daa5c834a26c5db9ab1.tar.bz2
Iterate on MdTextButtons (call to action styling).
Right now the different styles are only used in views examples. This also fixes a bug that I ran into while running views_examples_exe --force-device-scale-factor=2 where DesktopScreenX11::GetCursorScreenPoint() wasn't accounting for the proper device scale. BUG=596238,571500 Review URL: https://codereview.chromium.org/1815923002 Cr-Commit-Position: refs/heads/master@{#382463}
Diffstat (limited to 'ui/views/painter.cc')
-rw-r--r--ui/views/painter.cc44
1 files changed, 43 insertions, 1 deletions
diff --git a/ui/views/painter.cc b/ui/views/painter.cc
index 8e0d3e6..9a67795 100644
--- a/ui/views/painter.cc
+++ b/ui/views/painter.cc
@@ -12,7 +12,9 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/point.h"
-#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/rect_f.h"
+#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
@@ -23,6 +25,41 @@ namespace views {
namespace {
+// SolidRoundRectPainter -------------------------------------------------------
+
+class SolidRoundRectPainter : public Painter {
+ public:
+ SolidRoundRectPainter(SkColor color, float radius);
+ ~SolidRoundRectPainter() override;
+
+ // Painter:
+ gfx::Size GetMinimumSize() const override;
+ void Paint(gfx::Canvas* canvas, const gfx::Size& size) override;
+
+ private:
+ const SkColor color_;
+ const float radius_;
+
+ DISALLOW_COPY_AND_ASSIGN(SolidRoundRectPainter);
+};
+
+SolidRoundRectPainter::SolidRoundRectPainter(SkColor color, float radius)
+ : color_(color), radius_(radius) {}
+
+SolidRoundRectPainter::~SolidRoundRectPainter() {}
+
+gfx::Size SolidRoundRectPainter::GetMinimumSize() const {
+ return gfx::Size();
+}
+
+void SolidRoundRectPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
+ gfx::RectF rect((gfx::SizeF(size)));
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setColor(color_);
+ canvas->DrawRoundRect(rect, radius_, paint);
+}
+
// DashedFocusPainter ----------------------------------------------------------
class DashedFocusPainter : public Painter {
@@ -235,6 +272,11 @@ void Painter::PaintFocusPainter(View* view,
}
// static
+Painter* Painter::CreateSolidRoundRectPainter(SkColor color, float radius) {
+ return new SolidRoundRectPainter(color, radius);
+}
+
+// static
Painter* Painter::CreateHorizontalGradient(SkColor c1, SkColor c2) {
SkColor colors[2];
colors[0] = c1;