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

Unified Diff: ui/views/controls/image_view.h

Issue 1214693005: Introduce some util code for drawing vector assets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 6 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/views/controls/image_view.h
diff --git a/ui/views/controls/image_view.h b/ui/views/controls/image_view.h
index 272aec0f156adf44578a6ff0179c53952b550866..f03b2c6a2b9cdec1fb161dea60daebb90338b14f 100644
--- a/ui/views/controls/image_view.h
+++ b/ui/views/controls/image_view.h
@@ -5,7 +5,9 @@
#ifndef UI_VIEWS_CONTROLS_IMAGE_VIEW_H_
#define UI_VIEWS_CONTROLS_IMAGE_VIEW_H_
+#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/vector_icons.h"
#include "ui/views/view.h"
namespace gfx {
@@ -52,6 +54,10 @@ class VIEWS_EXPORT ImageView : public View {
// The returned image is still owned by the ImageView.
const gfx::ImageSkia& GetImage();
+ // Tells the view to draw a monochrome vector image identified by |id| using
+ // |color|.
+ void SetVectorIcon(gfx::VectorIconId id, SkColor color);
sky 2015/07/01 16:42:35 Maybe this should take the image_size to reinforce
Evan Stade 2015/07/01 21:52:59 sure
+
// Set the desired image size for the receiving ImageView.
void SetImageSize(const gfx::Size& image_size);
@@ -96,6 +102,8 @@ class VIEWS_EXPORT ImageView : public View {
private:
void OnPaintImage(gfx::Canvas* canvas);
+ void OnPaintVectorIcon(gfx::Canvas* canvas);
+
// Returns true if |img| is the same as the last image we painted. This is
// intended to be a quick check, not exhaustive. In other words it's possible
// for this to return false even though the images are in fact equal.
@@ -114,6 +122,14 @@ class VIEWS_EXPORT ImageView : public View {
// The underlying image.
gfx::ImageSkia image_;
+ // The ID of the vector icon that should be drawn, or gfx::VECTOR_ICON_NONE.
+ // This is drawn in addition to |image_|, but in most cases you probably want
+ // one or the other and not both.
+ gfx::VectorIconId vector_id_;
+
+ // The color to use when drawing the vector icon.
+ SkColor vector_color_;
+
// Horizontal alignment.
Alignment horiz_alignment_;

Powered by Google App Engine
This is Rietveld 408576698