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

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

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: WIP: use observer 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_button_observer.h
diff --git a/ui/views/controls/button/vector_icon_image_button_observer.h b/ui/views/controls/button/vector_icon_image_button_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..ccc5b3306d96133684c209a8ab5b6fd33bc81b1b
--- /dev/null
+++ b/ui/views/controls/button/vector_icon_image_button_observer.h
@@ -0,0 +1,45 @@
+// 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_BUTTON_OBSERVER_H_
+#define UI_VIEWS_VECTOR_ICON_IMAGE_BUTTON_OBSERVER_H_
+
+#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;
+
+class VIEWS_EXPORT VectorIconImageButtonObserver : public ViewObserver {
sky 2017/03/13 16:21:57 How about naming this VectorIconImageUpdater or so
Evan Stade 2017/03/15 15:04:02 with ViewObserver I'm no longer sure this interfac
bruthig 2017/03/15 15:53:20 I think the value of this class will grow as it ge
Evan Stade 2017/03/15 16:59:25 I see. I think this is breaking the Chromium inher
Peter Kasting 2017/03/15 18:03:02 FWIW, our UI code defies that rule in 8 billion pl
Peter Kasting 2017/03/15 18:16:45 Evan sez: we've fixed a lot of these and are tryin
bruthig 2017/03/15 21:41:21 The FindBarViewButtonObserver found in find_bar_vi
Evan Stade 2017/03/15 22:46:20 That's kind of an elaborate way to get around mult
Bret 2017/03/15 23:39:20 To bruthig's suggestion, I thought about doing som
+ public:
+ VectorIconImageButtonObserver() = default;
+
+ // ViewObserver:
+ void OnThemeChanged(View* view) override;
+ void OnNativeThemeChanged(View* view, const ui::NativeTheme* theme) override;
+
+ private:
+ void UpdateButtonImages(View* view);
+ virtual const gfx::VectorIcon& GetVectorIcon(View* view) const = 0;
sky 2017/03/13 16:21:57 Having these two functions private certainly works
+ virtual SkColor GetVectorIconColor() const;
sky 2017/03/13 16:21:57 Add descriptions of these functions.
+
+ DISALLOW_COPY_AND_ASSIGN(VectorIconImageButtonObserver);
+};
+
+VIEWS_EXPORT ImageButton* CreateDefaultVectorIconButton(
sky 2017/03/13 16:21:57 Please add a comment. Also, make this return a uni
Bret 2017/03/15 00:07:13 The name is good. I'm not sure how unique_ptr inte
sky 2017/03/15 15:05:11 Calling release() still makes ownership clear. But
+ const gfx::VectorIcon& icon,
+ VectorIconImageButtonObserver* observer,
sky 2017/03/13 16:21:57 WDYT of making the button own the observer? I real
Bret 2017/03/15 00:07:13 I wanted to avoid giving ImageButton knowledge of
sky 2017/03/15 15:05:11 Sorry for not being clear. I was suggesting owners
Bret 2017/03/15 23:39:19 I did this and it works well.
+ ButtonListener* listener);
+}
+
+#endif // UI_VIEWS_VECTOR_ICON_IMAGE_BUTTON_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698