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

Unified Diff: ui/views/controls/button/vector_icon_image_updater.h

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: wip: address high-level comments Created 3 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/views/controls/button/vector_icon_image_updater.h
diff --git a/ui/views/controls/button/vector_icon_image_updater.h b/ui/views/controls/button/vector_icon_image_updater.h
new file mode 100644
index 0000000000000000000000000000000000000000..6094adfb3647b1649bcb56e858ce4d6d1330a3fd
--- /dev/null
+++ b/ui/views/controls/button/vector_icon_image_updater.h
@@ -0,0 +1,62 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_VECTOR_ICON_IMAGE_UPDATER_H_
+#define UI_VIEWS_VECTOR_ICON_IMAGE_UPDATER_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/gfx/vector_icon_types.h"
+#include "ui/views/view_observer.h"
+
+namespace ui {
+class NativeTheme;
+}
+
+namespace views {
+
+class ButtonListener;
+class ImageButton;
+class View;
+
+// TODO: comments in this file
+class VIEWS_EXPORT VectorIconImageUpdater : public ViewObserver {
+ public:
+ VectorIconImageUpdater(const gfx::VectorIcon& icon);
+
+ void Attach(ImageButton* owner_button);
+
+ void SetIcon(const gfx::VectorIcon& icon);
+
+ protected:
+ virtual SkColor GetVectorIconColor() const;
+
+ private:
+ // ViewObserver:
+ void OnThemeChanged(View* observed_view) override;
+ void OnNativeThemeChanged(View* observed_view,
+ const ui::NativeTheme* theme) override;
+ void OnViewIsDeleting(View* observed_view) override;
+
+ void UpdateButtonImages();
+
+ ImageButton* owner_button_;
+ const gfx::VectorIcon* icon_;
+
+ DISALLOW_COPY_AND_ASSIGN(VectorIconImageUpdater);
+};
+
+VIEWS_EXPORT ImageButton* CreateImageButtonWithVectorIcon(
+ const gfx::VectorIcon& icon,
+ ButtonListener* listener);
+
+VIEWS_EXPORT ImageButton* CreateImageButtonWithImageUpdater(
+ VectorIconImageUpdater* updater,
+ ButtonListener* listener);
+
+} // namespace views
+
+#endif // UI_VIEWS_VECTOR_ICON_IMAGE_UPDATER_H_

Powered by Google App Engine
This is Rietveld 408576698