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

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: sadrul review Created 5 years, 5 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..136689256d5a7c0fd644362beef140c834ba1171 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,14 +54,15 @@ 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|. The size of the view and the image will be set to |image_size|.
+ void SetVectorIcon(gfx::VectorIconId id,
+ SkColor color,
+ const gfx::Size& image_size);
+
// Set the desired image size for the receiving ImageView.
void SetImageSize(const gfx::Size& image_size);
- // Return the preferred size for the receiving view. Returns false if the
- // preferred size is not defined, which means that the view uses the image
- // size.
- bool GetImageSize(gfx::Size* image_size) const;
-
// Returns the actual bounds of the visible image inside the view.
gfx::Rect GetImageBounds() const;
@@ -96,6 +99,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 +119,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