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

Side by Side Diff: mash/wm/non_client_frame_view_impl.cc

Issue 1459653002: Gets mustash frames looking like that of ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update test Created 5 years, 1 month 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 | « mash/wm/non_client_frame_view_impl.h ('k') | mash/wm/window_manager_application.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mash/wm/non_client_frame_view_impl.h"
6
7 #include "components/mus/public/cpp/window.h"
8 #include "mash/wm/move_loop.h"
9 #include "mojo/converters/input_events/input_events_type_converters.h"
10 #include "ui/compositor/paint_recorder.h"
11 #include "ui/gfx/canvas.h"
12
13 NonClientFrameViewImpl::NonClientFrameViewImpl(mus::Window* window)
14 : window_(window) {
15 window_->AddObserver(this);
16 }
17
18 NonClientFrameViewImpl::~NonClientFrameViewImpl() {
19 if (window_)
20 window_->RemoveObserver(this);
21 }
22
23 gfx::Rect NonClientFrameViewImpl::GetBoundsForClientView() const {
24 gfx::Rect result(GetLocalBounds());
25 result.Inset(window_->client_area());
26 return result;
27 }
28
29 void NonClientFrameViewImpl::OnPaint(gfx::Canvas* canvas) {
30 canvas->Save();
31 CustomFrameView::OnPaint(canvas);
32 canvas->Restore();
33
34 // The client app draws the client area. Make ours totally transparent so
35 // we only see the client apps client area.
36 canvas->FillRect(GetBoundsForClientView(), SK_ColorBLACK,
37 SkXfermode::kSrc_Mode);
38 }
39
40 void NonClientFrameViewImpl::PaintChildren(const ui::PaintContext& context) {
41 CustomFrameView::PaintChildren(context);
42
43 // The client app draws the client area. Make ours totally transparent so
44 // we only see the client apps client area.
45 ui::PaintRecorder recorder(context, size(), &paint_cache_);
46 recorder.canvas()->FillRect(GetBoundsForClientView(), SK_ColorBLACK,
47 SkXfermode::kSrc_Mode);
48 }
49
50 bool NonClientFrameViewImpl::OnMousePressed(const ui::MouseEvent& event) {
51 return StartMoveLoopIfNecessary(event);
52 }
53
54 bool NonClientFrameViewImpl::OnMouseDragged(const ui::MouseEvent& event) {
55 ContinueMove(event);
56 return move_loop_.get() != nullptr;
57 }
58
59 void NonClientFrameViewImpl::OnMouseReleased(const ui::MouseEvent& event) {
60 ContinueMove(event);
61 }
62
63 void NonClientFrameViewImpl::OnMouseCaptureLost() {
64 StopMove();
65 }
66
67 void NonClientFrameViewImpl::OnWindowClientAreaChanged(
68 mus::Window* window,
69 const gfx::Insets& old_client_area) {
70 Layout();
71 // NonClientView (our parent) positions the client view based on bounds from
72 // us. We need to layout from parent to trigger a layout of the client view.
73 if (parent())
74 parent()->Layout();
75 SchedulePaint();
76 }
77
78 void NonClientFrameViewImpl::OnWindowDestroyed(mus::Window* window) {
79 window_->RemoveObserver(this);
80 window_ = nullptr;
81 }
82
83 bool NonClientFrameViewImpl::StartMoveLoopIfNecessary(const ui::Event& event) {
84 if (move_loop_)
85 return false;
86 // TODO(sky): convert MoveLoop to take ui::Event.
87 move_loop_ = MoveLoop::Create(window_, *mus::mojom::Event::From(event));
88 return true;
89 }
90
91 void NonClientFrameViewImpl::ContinueMove(const ui::Event& event) {
92 // TODO(sky): convert MoveLoop to take ui::Event.
93 if (move_loop_ &&
94 move_loop_->Move(*mus::mojom::Event::From(event)) == MoveLoop::DONE) {
95 move_loop_.reset();
96 }
97 }
98
99 void NonClientFrameViewImpl::StopMove() {
100 move_loop_.reset();
101 }
OLDNEW
« no previous file with comments | « mash/wm/non_client_frame_view_impl.h ('k') | mash/wm/window_manager_application.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698