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

Side by Side Diff: mojo/examples/wm_flow/wm/frame_controller.cc

Issue 623573002: Mojo: Convert the remaining OVERRIDEs to override in mojo/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/examples/wm_flow/wm/frame_controller.h" 5 #include "mojo/examples/wm_flow/wm/frame_controller.h"
6 6
7 #include "base/macros.h"
7 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
8 #include "mojo/services/public/cpp/view_manager/view.h" 9 #include "mojo/services/public/cpp/view_manager/view.h"
9 #include "mojo/services/window_manager/window_manager_app.h" 10 #include "mojo/services/window_manager/window_manager_app.h"
10 #include "mojo/views/native_widget_view_manager.h" 11 #include "mojo/views/native_widget_view_manager.h"
11 #include "ui/views/background.h" 12 #include "ui/views/background.h"
12 #include "ui/views/controls/button/label_button.h" 13 #include "ui/views/controls/button/label_button.h"
13 #include "ui/views/layout/layout_manager.h" 14 #include "ui/views/layout/layout_manager.h"
14 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
15 #include "ui/wm/public/activation_client.h" 16 #include "ui/wm/public/activation_client.h"
16 17
17 class FrameController::LayoutManager : public views::LayoutManager, 18 class FrameController::LayoutManager : public views::LayoutManager,
18 public views::ButtonListener { 19 public views::ButtonListener {
19 public: 20 public:
20 explicit LayoutManager(FrameController* controller) 21 explicit LayoutManager(FrameController* controller)
21 : controller_(controller), 22 : controller_(controller),
22 close_button_( 23 close_button_(
23 new views::LabelButton(this, base::ASCIIToUTF16("Begone"))), 24 new views::LabelButton(this, base::ASCIIToUTF16("Begone"))),
24 maximize_button_( 25 maximize_button_(
25 new views::LabelButton(this, base::ASCIIToUTF16("Embiggen"))) {} 26 new views::LabelButton(this, base::ASCIIToUTF16("Embiggen"))) {}
26 virtual ~LayoutManager() {} 27 virtual ~LayoutManager() {}
27 28
28 private: 29 private:
29 static const int kButtonFrameMargin = 5; 30 static const int kButtonFrameMargin = 5;
30 static const int kButtonFrameSpacing = 2; 31 static const int kButtonFrameSpacing = 2;
31 static const int kFrameSize = 10; 32 static const int kFrameSize = 10;
32 33
33 // Overridden from views::LayoutManager: 34 // Overridden from views::LayoutManager:
34 virtual void Installed(views::View* host) OVERRIDE { 35 virtual void Installed(views::View* host) override {
35 host->AddChildView(close_button_); 36 host->AddChildView(close_button_);
36 host->AddChildView(maximize_button_); 37 host->AddChildView(maximize_button_);
37 } 38 }
38 virtual void Layout(views::View* host) OVERRIDE { 39 virtual void Layout(views::View* host) override {
39 gfx::Size ps = close_button_->GetPreferredSize(); 40 gfx::Size ps = close_button_->GetPreferredSize();
40 gfx::Rect bounds = host->GetLocalBounds(); 41 gfx::Rect bounds = host->GetLocalBounds();
41 close_button_->SetBounds(bounds.right() - kButtonFrameMargin - ps.width(), 42 close_button_->SetBounds(bounds.right() - kButtonFrameMargin - ps.width(),
42 kButtonFrameMargin, ps.width(), ps.height()); 43 kButtonFrameMargin, ps.width(), ps.height());
43 44
44 ps = maximize_button_->GetPreferredSize(); 45 ps = maximize_button_->GetPreferredSize();
45 maximize_button_->SetBounds( 46 maximize_button_->SetBounds(
46 close_button_->x() - kButtonFrameSpacing - ps.width(), 47 close_button_->x() - kButtonFrameSpacing - ps.width(),
47 kButtonFrameMargin, ps.width(), ps.height()); 48 kButtonFrameMargin, ps.width(), ps.height());
48 49
49 bounds.Inset(kFrameSize, 50 bounds.Inset(kFrameSize,
50 close_button_->bounds().bottom() + kButtonFrameMargin, 51 close_button_->bounds().bottom() + kButtonFrameMargin,
51 kFrameSize, kFrameSize); 52 kFrameSize, kFrameSize);
52 controller_->app_view_->SetBounds(bounds); 53 controller_->app_view_->SetBounds(bounds);
53 } 54 }
54 virtual gfx::Size GetPreferredSize(const views::View* host) const OVERRIDE { 55 virtual gfx::Size GetPreferredSize(const views::View* host) const override {
55 return gfx::Size(); 56 return gfx::Size();
56 } 57 }
57 58
58 // Overridden from views::ButtonListener: 59 // Overridden from views::ButtonListener:
59 virtual void ButtonPressed(views::Button* sender, 60 virtual void ButtonPressed(views::Button* sender,
60 const ui::Event& event) OVERRIDE { 61 const ui::Event& event) override {
61 if (sender == close_button_) 62 if (sender == close_button_)
62 controller_->CloseWindow(); 63 controller_->CloseWindow();
63 else if (sender == maximize_button_) 64 else if (sender == maximize_button_)
64 controller_->ToggleMaximize(); 65 controller_->ToggleMaximize();
65 } 66 }
66 67
67 FrameController* controller_; 68 FrameController* controller_;
68 views::Button* close_button_; 69 views::Button* close_button_;
69 views::Button* maximize_button_; 70 views::Button* maximize_button_;
70 71
71 DISALLOW_COPY_AND_ASSIGN(LayoutManager); 72 DISALLOW_COPY_AND_ASSIGN(LayoutManager);
72 }; 73 };
73 74
74 class FrameController::FrameEventHandler : public ui::EventHandler { 75 class FrameController::FrameEventHandler : public ui::EventHandler {
75 public: 76 public:
76 explicit FrameEventHandler(FrameController* frame_controller) 77 explicit FrameEventHandler(FrameController* frame_controller)
77 : frame_controller_(frame_controller) {} 78 : frame_controller_(frame_controller) {}
78 virtual ~FrameEventHandler() {} 79 virtual ~FrameEventHandler() {}
79 80
80 private: 81 private:
81 82
82 // Overriden from ui::EventHandler: 83 // Overriden from ui::EventHandler:
83 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { 84 virtual void OnMouseEvent(ui::MouseEvent* event) override {
84 if (event->type() == ui::ET_MOUSE_PRESSED) 85 if (event->type() == ui::ET_MOUSE_PRESSED)
85 frame_controller_->ActivateWindow(); 86 frame_controller_->ActivateWindow();
86 } 87 }
87 88
88 FrameController* frame_controller_; 89 FrameController* frame_controller_;
89 90
90 DISALLOW_COPY_AND_ASSIGN(FrameEventHandler); 91 DISALLOW_COPY_AND_ASSIGN(FrameEventHandler);
91 }; 92 };
92 93
93 //////////////////////////////////////////////////////////////////////////////// 94 ////////////////////////////////////////////////////////////////////////////////
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 activation_client_->ActivateWindow(window); 146 activation_client_->ActivateWindow(window);
146 } 147 }
147 148
148 //////////////////////////////////////////////////////////////////////////////// 149 ////////////////////////////////////////////////////////////////////////////////
149 // FrameController, mojo::ViewObserver implementation: 150 // FrameController, mojo::ViewObserver implementation:
150 151
151 void FrameController::OnViewDestroyed(mojo::View* view) { 152 void FrameController::OnViewDestroyed(mojo::View* view) {
152 view_->RemoveObserver(this); 153 view_->RemoveObserver(this);
153 delete this; 154 delete this;
154 } 155 }
OLDNEW
« no previous file with comments | « mojo/examples/wm_flow/embedded/embedded.cc ('k') | mojo/services/clipboard/clipboard_standalone_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698