Commit 93105ef0 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Use callbacks instead of ButtonPressed overrides: apps/

Bug: 772945
Change-Id: I56e6861493cf4c28f655c4eab277b4172911bf91
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425152Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809822}
parent 02c27a64
...@@ -53,7 +53,9 @@ AppWindowFrameView::~AppWindowFrameView() = default; ...@@ -53,7 +53,9 @@ AppWindowFrameView::~AppWindowFrameView() = default;
void AppWindowFrameView::Init() { void AppWindowFrameView::Init() {
if (draw_frame_) { if (draw_frame_) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
auto close_button = std::make_unique<views::ImageButton>(this); auto close_button = std::make_unique<views::ImageButton>();
close_button->set_callback(
base::BindRepeating(&views::Widget::Close, base::Unretained(widget_)));
close_button->SetImage( close_button->SetImage(
views::Button::STATE_NORMAL, views::Button::STATE_NORMAL,
rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia()); rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia());
...@@ -67,7 +69,9 @@ void AppWindowFrameView::Init() { ...@@ -67,7 +69,9 @@ void AppWindowFrameView::Init() {
l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE));
close_button_ = AddChildView(std::move(close_button)); close_button_ = AddChildView(std::move(close_button));
// STATE_NORMAL images are set in SetButtonImagesForFrame, not here. // STATE_NORMAL images are set in SetButtonImagesForFrame, not here.
auto maximize_button = std::make_unique<views::ImageButton>(this); auto maximize_button = std::make_unique<views::ImageButton>();
maximize_button->set_callback(base::BindRepeating(
&views::Widget::Maximize, base::Unretained(widget_)));
maximize_button->SetImage( maximize_button->SetImage(
views::Button::STATE_HOVERED, views::Button::STATE_HOVERED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_MAXIMIZE_H).ToImageSkia()); rb.GetNativeImageNamed(IDR_APP_WINDOW_MAXIMIZE_H).ToImageSkia());
...@@ -80,7 +84,9 @@ void AppWindowFrameView::Init() { ...@@ -80,7 +84,9 @@ void AppWindowFrameView::Init() {
maximize_button->SetAccessibleName( maximize_button->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MAXIMIZE)); l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MAXIMIZE));
maximize_button_ = AddChildView(std::move(maximize_button)); maximize_button_ = AddChildView(std::move(maximize_button));
auto restore_button = std::make_unique<views::ImageButton>(this); auto restore_button = std::make_unique<views::ImageButton>();
restore_button->set_callback(base::BindRepeating(
&views::Widget::Restore, base::Unretained(widget_)));
restore_button->SetImage( restore_button->SetImage(
views::Button::STATE_HOVERED, views::Button::STATE_HOVERED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_RESTORE_H).ToImageSkia()); rb.GetNativeImageNamed(IDR_APP_WINDOW_RESTORE_H).ToImageSkia());
...@@ -90,7 +96,9 @@ void AppWindowFrameView::Init() { ...@@ -90,7 +96,9 @@ void AppWindowFrameView::Init() {
restore_button->SetAccessibleName( restore_button->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_APP_ACCNAME_RESTORE)); l10n_util::GetStringUTF16(IDS_APP_ACCNAME_RESTORE));
restore_button_ = AddChildView(std::move(restore_button)); restore_button_ = AddChildView(std::move(restore_button));
auto minimize_button = std::make_unique<views::ImageButton>(this); auto minimize_button = std::make_unique<views::ImageButton>();
minimize_button->set_callback(base::BindRepeating(
&views::Widget::Minimize, base::Unretained(widget_)));
minimize_button->SetImage( minimize_button->SetImage(
views::Button::STATE_HOVERED, views::Button::STATE_HOVERED,
rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_H).ToImageSkia()); rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_H).ToImageSkia());
...@@ -345,19 +353,6 @@ gfx::Size AppWindowFrameView::GetMaximumSize() const { ...@@ -345,19 +353,6 @@ gfx::Size AppWindowFrameView::GetMaximumSize() const {
return max_size; return max_size;
} }
void AppWindowFrameView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
DCHECK(draw_frame_);
if (sender == close_button_)
widget_->Close();
else if (sender == maximize_button_)
widget_->Maximize();
else if (sender == restore_button_)
widget_->Restore();
else if (sender == minimize_button_)
widget_->Minimize();
}
SkColor AppWindowFrameView::CurrentFrameColor() { SkColor AppWindowFrameView::CurrentFrameColor() {
return widget_->IsActive() ? active_frame_color_ : inactive_frame_color_; return widget_->IsActive() ? active_frame_color_ : inactive_frame_color_;
} }
......
...@@ -22,10 +22,6 @@ class Canvas; ...@@ -22,10 +22,6 @@ class Canvas;
class Point; class Point;
} }
namespace ui {
class Event;
}
namespace views { namespace views {
class ImageButton; class ImageButton;
class Widget; class Widget;
...@@ -34,8 +30,7 @@ class Widget; ...@@ -34,8 +30,7 @@ class Widget;
namespace apps { namespace apps {
// A frameless or non-Ash, non-panel NonClientFrameView for app windows. // A frameless or non-Ash, non-panel NonClientFrameView for app windows.
class AppWindowFrameView : public views::NonClientFrameView, class AppWindowFrameView : public views::NonClientFrameView {
public views::ButtonListener {
public: public:
static const char kViewClassName[]; static const char kViewClassName[];
...@@ -81,9 +76,6 @@ class AppWindowFrameView : public views::NonClientFrameView, ...@@ -81,9 +76,6 @@ class AppWindowFrameView : public views::NonClientFrameView,
gfx::Size GetMinimumSize() const override; gfx::Size GetMinimumSize() const override;
gfx::Size GetMaximumSize() const override; gfx::Size GetMaximumSize() const override;
// views::ButtonListener implementation.
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// Some button images we use depend on the color of the frame. This // Some button images we use depend on the color of the frame. This
// will set these images based on the color of the frame. // will set these images based on the color of the frame.
void SetButtonImagesForFrame(); void SetButtonImagesForFrame();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment