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

Side by Side Diff: athena/activity/activity_frame_view.cc

Issue 694413005: athena: Introduce ActivityView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 "athena/activity/activity_frame_view.h" 5 #include "athena/activity/activity_frame_view.h"
6 6
7 #include "athena/activity/public/activity_view_model.h" 7 #include "athena/activity/public/activity_view_model.h"
8 #include "athena/wm/public/window_manager.h" 8 #include "athena/wm/public/window_manager.h"
9 #include "ui/base/hit_test.h" 9 #include "ui/base/hit_test.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 icon_(new views::ImageView), 52 icon_(new views::ImageView),
53 in_overview_(false) { 53 in_overview_(false) {
54 title_->SetEnabledColor(SkColorSetA(SK_ColorBLACK, 0xe5)); 54 title_->SetEnabledColor(SkColorSetA(SK_ColorBLACK, 0xe5));
55 55
56 AddChildView(title_); 56 AddChildView(title_);
57 AddChildView(icon_); 57 AddChildView(icon_);
58 58
59 UpdateWindowTitle(); 59 UpdateWindowTitle();
60 UpdateWindowIcon(); 60 UpdateWindowIcon();
61 61
62 view_model_->SetActivityView(this);
63
62 WindowManager::Get()->AddObserver(this); 64 WindowManager::Get()->AddObserver(this);
63 } 65 }
64 66
65 ActivityFrameView::~ActivityFrameView() { 67 ActivityFrameView::~ActivityFrameView() {
66 WindowManager::Get()->RemoveObserver(this); 68 WindowManager::Get()->RemoveObserver(this);
69
70 // |view_model_| is already destroyed at this time. So do not attempt to reset
71 // the activity-view by calling SetActivityView(nullptr);
sadrul 2014/11/04 20:05:16 This seems unfortunate.
oshima 2014/11/04 22:17:04 Yep, I was once tried to fix this and failed :( I
67 } 72 }
68 73
69 gfx::Rect ActivityFrameView::GetBoundsForClientView() const { 74 gfx::Rect ActivityFrameView::GetBoundsForClientView() const {
70 gfx::Rect client_bounds = bounds(); 75 gfx::Rect client_bounds = bounds();
71 client_bounds.Inset(NonClientBorderInsets()); 76 client_bounds.Inset(NonClientBorderInsets());
72 return client_bounds; 77 return client_bounds;
73 } 78 }
74 79
75 gfx::Rect ActivityFrameView::GetWindowBoundsForClientBounds( 80 gfx::Rect ActivityFrameView::GetWindowBoundsForClientBounds(
76 const gfx::Rect& client_bounds) const { 81 const gfx::Rect& client_bounds) const {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 void ActivityFrameView::OnPaintBackground(gfx::Canvas* canvas) { 167 void ActivityFrameView::OnPaintBackground(gfx::Canvas* canvas) {
163 View::OnPaintBackground(canvas); 168 View::OnPaintBackground(canvas);
164 169
165 // Paint a border around the client view. 170 // Paint a border around the client view.
166 gfx::Rect border_bounds = GetLocalBounds(); 171 gfx::Rect border_bounds = GetLocalBounds();
167 border_bounds.Inset(NonClientBorderInsets()); 172 border_bounds.Inset(NonClientBorderInsets());
168 border_bounds.Inset(-1, -1, 0, 0); 173 border_bounds.Inset(-1, -1, 0, 0);
169 canvas->DrawRect(border_bounds, SkColorSetA(SK_ColorGRAY, 0x7f)); 174 canvas->DrawRect(border_bounds, SkColorSetA(SK_ColorGRAY, 0x7f));
170 } 175 }
171 176
177 void ActivityFrameView::UpdateTitle() {
178 UpdateWindowTitle();
179 }
180
181 void ActivityFrameView::UpdateIcon() {
182 UpdateWindowIcon();
183 }
184
185 void ActivityFrameView::UpdateRepresentativeColor() {
186 UpdateWindowTitle();
187 }
188
172 void ActivityFrameView::OnOverviewModeEnter() { 189 void ActivityFrameView::OnOverviewModeEnter() {
173 view_model_->PrepareContentsForOverview(); 190 view_model_->PrepareContentsForOverview();
174 in_overview_ = true; 191 in_overview_ = true;
175 InvalidateLayout(); 192 InvalidateLayout();
176 frame_->client_view()->InvalidateLayout(); 193 frame_->client_view()->InvalidateLayout();
177 frame_->GetRootView()->Layout(); 194 frame_->GetRootView()->Layout();
178 SchedulePaint(); 195 SchedulePaint();
179 } 196 }
180 197
181 void ActivityFrameView::OnOverviewModeExit() { 198 void ActivityFrameView::OnOverviewModeExit() {
(...skipping 23 matching lines...) Expand all
205 return in_overview_ ? kOverviewBorderThickness : 0; 222 return in_overview_ ? kOverviewBorderThickness : 0;
206 } 223 }
207 224
208 int ActivityFrameView::NonClientTopBorderHeight() const { 225 int ActivityFrameView::NonClientTopBorderHeight() const {
209 if (frame_->IsFullscreen() || !view_model_->UsesFrame()) 226 if (frame_->IsFullscreen() || !view_model_->UsesFrame())
210 return in_overview_ ? kOverviewShortTitleHeight : 0; 227 return in_overview_ ? kOverviewShortTitleHeight : 0;
211 return in_overview_ ? kOverviewTitleHeight : kDefaultTitleHeight; 228 return in_overview_ ? kOverviewTitleHeight : kDefaultTitleHeight;
212 } 229 }
213 230
214 } // namespace athena 231 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698