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

Side by Side Diff: ash/mus/frame/non_client_frame_view_mash.cc

Issue 2182633011: Replaces ::ui:: with ui:: in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « ash/mus/frame/non_client_frame_view_mash.h ('k') | ash/mus/layout_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ash/mus/frame/non_client_frame_view_mash.h" 5 #include "ash/mus/frame/non_client_frame_view_mash.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 19 matching lines...) Expand all
30 namespace ash { 30 namespace ash {
31 namespace mus { 31 namespace mus {
32 32
33 /////////////////////////////////////////////////////////////////////////////// 33 ///////////////////////////////////////////////////////////////////////////////
34 // NonClientFrameViewMash::HeaderView 34 // NonClientFrameViewMash::HeaderView
35 35
36 // View which paints the header. 36 // View which paints the header.
37 class NonClientFrameViewMash::HeaderView : public views::View { 37 class NonClientFrameViewMash::HeaderView : public views::View {
38 public: 38 public:
39 // |frame| is the widget that the caption buttons act on. 39 // |frame| is the widget that the caption buttons act on.
40 HeaderView(views::Widget* frame, ::ui::Window* window); 40 HeaderView(views::Widget* frame, ui::Window* window);
41 ~HeaderView() override; 41 ~HeaderView() override;
42 42
43 // Schedules a repaint for the entire title. 43 // Schedules a repaint for the entire title.
44 void SchedulePaintForTitle(); 44 void SchedulePaintForTitle();
45 45
46 // Tells the window controls to reset themselves to the normal state. 46 // Tells the window controls to reset themselves to the normal state.
47 void ResetWindowControls(); 47 void ResetWindowControls();
48 48
49 // Returns the view's preferred height. 49 // Returns the view's preferred height.
50 int GetPreferredHeight() const; 50 int GetPreferredHeight() const;
(...skipping 17 matching lines...) Expand all
68 private: 68 private:
69 // The widget that the caption buttons act on. 69 // The widget that the caption buttons act on.
70 views::Widget* frame_; 70 views::Widget* frame_;
71 71
72 // Helper for painting the header. 72 // Helper for painting the header.
73 std::unique_ptr<DefaultHeaderPainter> header_painter_; 73 std::unique_ptr<DefaultHeaderPainter> header_painter_;
74 74
75 // View which contains the window caption buttons. 75 // View which contains the window caption buttons.
76 FrameCaptionButtonContainerView* caption_button_container_; 76 FrameCaptionButtonContainerView* caption_button_container_;
77 77
78 ::ui::Window* window_; 78 ui::Window* window_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(HeaderView); 80 DISALLOW_COPY_AND_ASSIGN(HeaderView);
81 }; 81 };
82 82
83 NonClientFrameViewMash::HeaderView::HeaderView(views::Widget* frame, 83 NonClientFrameViewMash::HeaderView::HeaderView(views::Widget* frame,
84 ::ui::Window* window) 84 ui::Window* window)
85 : frame_(frame), 85 : frame_(frame),
86 header_painter_(new DefaultHeaderPainter), 86 header_painter_(new DefaultHeaderPainter),
87 caption_button_container_(nullptr), 87 caption_button_container_(nullptr),
88 window_(window) { 88 window_(window) {
89 caption_button_container_ = new FrameCaptionButtonContainerView(frame_); 89 caption_button_container_ = new FrameCaptionButtonContainerView(frame_);
90 caption_button_container_->UpdateSizeButtonVisibility(); 90 caption_button_container_->UpdateSizeButtonVisibility();
91 AddChildView(caption_button_container_); 91 AddChildView(caption_button_container_);
92 92
93 header_painter_->Init(frame_, this, caption_button_container_); 93 header_painter_->Init(frame_, this, caption_button_container_);
94 } 94 }
(...skipping 29 matching lines...) Expand all
124 } 124 }
125 125
126 /////////////////////////////////////////////////////////////////////////////// 126 ///////////////////////////////////////////////////////////////////////////////
127 // NonClientFrameViewMash::HeaderView, views::View overrides: 127 // NonClientFrameViewMash::HeaderView, views::View overrides:
128 128
129 void NonClientFrameViewMash::HeaderView::Layout() { 129 void NonClientFrameViewMash::HeaderView::Layout() {
130 header_painter_->LayoutHeader(); 130 header_painter_->LayoutHeader();
131 } 131 }
132 132
133 void NonClientFrameViewMash::HeaderView::OnPaint(gfx::Canvas* canvas) { 133 void NonClientFrameViewMash::HeaderView::OnPaint(gfx::Canvas* canvas) {
134 const ::ui::Window* focused_window = 134 const ui::Window* focused_window = window_->window_tree()->GetFocusedWindow();
135 window_->window_tree()->GetFocusedWindow();
136 const bool paint_as_active = 135 const bool paint_as_active =
137 focused_window && window_->Contains(focused_window); 136 focused_window && window_->Contains(focused_window);
138 caption_button_container_->SetPaintAsActive(paint_as_active); 137 caption_button_container_->SetPaintAsActive(paint_as_active);
139 138
140 HeaderPainter::Mode header_mode = paint_as_active 139 HeaderPainter::Mode header_mode = paint_as_active
141 ? HeaderPainter::MODE_ACTIVE 140 ? HeaderPainter::MODE_ACTIVE
142 : HeaderPainter::MODE_INACTIVE; 141 : HeaderPainter::MODE_INACTIVE;
143 header_painter_->PaintHeader(canvas, header_mode); 142 header_painter_->PaintHeader(canvas, header_mode);
144 } 143 }
145 144
146 void NonClientFrameViewMash::HeaderView::ChildPreferredSizeChanged( 145 void NonClientFrameViewMash::HeaderView::ChildPreferredSizeChanged(
147 views::View* child) { 146 views::View* child) {
148 // FrameCaptionButtonContainerView animates the visibility changes in 147 // FrameCaptionButtonContainerView animates the visibility changes in
149 // UpdateSizeButtonVisibility(false). Due to this a new size is not available 148 // UpdateSizeButtonVisibility(false). Due to this a new size is not available
150 // until the completion of the animation. Layout in response to the preferred 149 // until the completion of the animation. Layout in response to the preferred
151 // size changes. 150 // size changes.
152 if (child != caption_button_container_) 151 if (child != caption_button_container_)
153 return; 152 return;
154 parent()->Layout(); 153 parent()->Layout();
155 } 154 }
156 155
157 //////////////////////////////////////////////////////////////////////////////// 156 ////////////////////////////////////////////////////////////////////////////////
158 // NonClientFrameViewMash, public: 157 // NonClientFrameViewMash, public:
159 158
160 // static 159 // static
161 const char NonClientFrameViewMash::kViewClassName[] = "NonClientFrameViewMash"; 160 const char NonClientFrameViewMash::kViewClassName[] = "NonClientFrameViewMash";
162 161
163 NonClientFrameViewMash::NonClientFrameViewMash(views::Widget* frame, 162 NonClientFrameViewMash::NonClientFrameViewMash(views::Widget* frame,
164 ::ui::Window* window) 163 ui::Window* window)
165 : frame_(frame), 164 : frame_(frame),
166 window_(window), 165 window_(window),
167 header_view_(new HeaderView(frame, window)) { 166 header_view_(new HeaderView(frame, window)) {
168 // |header_view_| is set as the non client view's overlay view so that it can 167 // |header_view_| is set as the non client view's overlay view so that it can
169 // overlay the web contents in immersive fullscreen. 168 // overlay the web contents in immersive fullscreen.
170 AddChildView(header_view_); 169 AddChildView(header_view_);
171 window_->AddObserver(this); 170 window_->AddObserver(this);
172 window_->window_tree()->AddObserver(this); 171 window_->window_tree()->AddObserver(this);
173 } 172 }
174 173
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 NonClientFrameView::PaintChildren(context); 299 NonClientFrameView::PaintChildren(context);
301 300
302 // The client app draws the client area. Make ours totally transparent so 301 // The client app draws the client area. Make ours totally transparent so
303 // we only see the client apps client area. 302 // we only see the client apps client area.
304 ui::PaintRecorder recorder(context, size(), &paint_cache_); 303 ui::PaintRecorder recorder(context, size(), &paint_cache_);
305 recorder.canvas()->FillRect(GetBoundsForClientView(), SK_ColorBLACK, 304 recorder.canvas()->FillRect(GetBoundsForClientView(), SK_ColorBLACK,
306 SkXfermode::kSrc_Mode); 305 SkXfermode::kSrc_Mode);
307 } 306 }
308 307
309 void NonClientFrameViewMash::OnWindowClientAreaChanged( 308 void NonClientFrameViewMash::OnWindowClientAreaChanged(
310 ::ui::Window* window, 309 ui::Window* window,
311 const gfx::Insets& old_client_area, 310 const gfx::Insets& old_client_area,
312 const std::vector<gfx::Rect>& old_additional_client_area) { 311 const std::vector<gfx::Rect>& old_additional_client_area) {
313 // Only the insets effect the rendering. 312 // Only the insets effect the rendering.
314 if (old_client_area == window->client_area()) 313 if (old_client_area == window->client_area())
315 return; 314 return;
316 315
317 Layout(); 316 Layout();
318 // NonClientView (our parent) positions the client view based on bounds from 317 // NonClientView (our parent) positions the client view based on bounds from
319 // us. We need to layout from parent to trigger a layout of the client view. 318 // us. We need to layout from parent to trigger a layout of the client view.
320 if (parent()) 319 if (parent())
321 parent()->Layout(); 320 parent()->Layout();
322 SchedulePaint(); 321 SchedulePaint();
323 } 322 }
324 323
325 void NonClientFrameViewMash::OnWindowDestroyed(::ui::Window* window) { 324 void NonClientFrameViewMash::OnWindowDestroyed(ui::Window* window) {
326 RemoveObservers(); 325 RemoveObservers();
327 } 326 }
328 327
329 void NonClientFrameViewMash::OnWindowSharedPropertyChanged( 328 void NonClientFrameViewMash::OnWindowSharedPropertyChanged(
330 ::ui::Window* window, 329 ui::Window* window,
331 const std::string& name, 330 const std::string& name,
332 const std::vector<uint8_t>* old_data, 331 const std::vector<uint8_t>* old_data,
333 const std::vector<uint8_t>* new_data) { 332 const std::vector<uint8_t>* new_data) {
334 if (name == ::ui::mojom::WindowManager::kResizeBehavior_Property) 333 if (name == ui::mojom::WindowManager::kResizeBehavior_Property)
335 header_view_->SizeConstraintsChanged(); 334 header_view_->SizeConstraintsChanged();
336 else if (name == ::ui::mojom::WindowManager::kWindowTitle_Property) 335 else if (name == ui::mojom::WindowManager::kWindowTitle_Property)
337 header_view_->SchedulePaintForTitle(); 336 header_view_->SchedulePaintForTitle();
338 } 337 }
339 338
340 views::View* NonClientFrameViewMash::GetHeaderView() { 339 views::View* NonClientFrameViewMash::GetHeaderView() {
341 return header_view_; 340 return header_view_;
342 } 341 }
343 342
344 //////////////////////////////////////////////////////////////////////////////// 343 ////////////////////////////////////////////////////////////////////////////////
345 // NonClientFrameViewMash, private: 344 // NonClientFrameViewMash, private:
346 345
347 int NonClientFrameViewMash::NonClientTopBorderHeight() const { 346 int NonClientFrameViewMash::NonClientTopBorderHeight() const {
348 return header_view_->GetPreferredHeight(); 347 return header_view_->GetPreferredHeight();
349 } 348 }
350 349
351 void NonClientFrameViewMash::RemoveObservers() { 350 void NonClientFrameViewMash::RemoveObservers() {
352 if (!window_) 351 if (!window_)
353 return; 352 return;
354 353
355 window_->RemoveObserver(this); 354 window_->RemoveObserver(this);
356 window_->window_tree()->RemoveObserver(this); 355 window_->window_tree()->RemoveObserver(this);
357 window_ = nullptr; 356 window_ = nullptr;
358 } 357 }
359 358
360 void NonClientFrameViewMash::OnWindowTreeFocusChanged( 359 void NonClientFrameViewMash::OnWindowTreeFocusChanged(ui::Window* gained_focus,
361 ::ui::Window* gained_focus, 360 ui::Window* lost_focus) {
362 ::ui::Window* lost_focus) {
363 const bool had_focus = lost_focus && window_->Contains(lost_focus); 361 const bool had_focus = lost_focus && window_->Contains(lost_focus);
364 const bool has_focus = gained_focus && window_->Contains(gained_focus); 362 const bool has_focus = gained_focus && window_->Contains(gained_focus);
365 if (had_focus != has_focus) 363 if (had_focus != has_focus)
366 SchedulePaint(); 364 SchedulePaint();
367 } 365 }
368 366
369 } // namespace mus 367 } // namespace mus
370 } // namespace ash 368 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/frame/non_client_frame_view_mash.h ('k') | ash/mus/layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698