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

Side by Side Diff: ui/aura/window.cc

Issue 8247012: Positions the launcher in the bottom left corner. Adds ShellDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaks Created 9 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_observer.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/aura/desktop.h" 10 #include "ui/aura/desktop.h"
11 #include "ui/aura/desktop_delegate.h" 11 #include "ui/aura/desktop_delegate.h"
12 #include "ui/aura/event.h" 12 #include "ui/aura/event.h"
13 #include "ui/aura/event_filter.h" 13 #include "ui/aura/event_filter.h"
14 #include "ui/aura/layout_manager.h" 14 #include "ui/aura/layout_manager.h"
15 #include "ui/aura/window_delegate.h" 15 #include "ui/aura/window_delegate.h"
16 #include "ui/aura/window_observer.h"
16 #include "ui/aura/window_types.h" 17 #include "ui/aura/window_types.h"
17 #include "ui/base/animation/multi_animation.h" 18 #include "ui/base/animation/multi_animation.h"
18 #include "ui/gfx/canvas_skia.h" 19 #include "ui/gfx/canvas_skia.h"
19 #include "ui/gfx/compositor/compositor.h" 20 #include "ui/gfx/compositor/compositor.h"
20 #include "ui/gfx/compositor/layer.h" 21 #include "ui/gfx/compositor/layer.h"
21 #include "ui/gfx/screen.h" 22 #include "ui/gfx/screen.h"
22 23
23 namespace aura { 24 namespace aura {
24 25
25 using internal::RootWindow; 26 using internal::RootWindow;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 199 }
199 200
200 void Window::AddChild(Window* child) { 201 void Window::AddChild(Window* child) {
201 DCHECK(std::find(children_.begin(), children_.end(), child) == 202 DCHECK(std::find(children_.begin(), children_.end(), child) ==
202 children_.end()); 203 children_.end());
203 if (child->parent()) 204 if (child->parent())
204 child->parent()->RemoveChild(child); 205 child->parent()->RemoveChild(child);
205 child->parent_ = this; 206 child->parent_ = this;
206 layer_->Add(child->layer_.get()); 207 layer_->Add(child->layer_.get());
207 children_.push_back(child); 208 children_.push_back(child);
209 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowAdded(child));
208 } 210 }
209 211
210 void Window::RemoveChild(Window* child) { 212 void Window::RemoveChild(Window* child) {
211 Windows::iterator i = std::find(children_.begin(), children_.end(), child); 213 Windows::iterator i = std::find(children_.begin(), children_.end(), child);
212 DCHECK(i != children_.end()); 214 DCHECK(i != children_.end());
215 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWillRemoveWindow(child));
213 child->parent_ = NULL; 216 child->parent_ = NULL;
214 layer_->Remove(child->layer_.get()); 217 layer_->Remove(child->layer_.get());
215 children_.erase(i); 218 children_.erase(i);
216 } 219 }
217 220
218 Window* Window::GetChildById(int id) { 221 Window* Window::GetChildById(int id) {
219 return const_cast<Window*>(const_cast<const Window*>(this)->GetChildById(id)); 222 return const_cast<Window*>(const_cast<const Window*>(this)->GetChildById(id));
220 } 223 }
221 224
222 const Window* Window::GetChildById(int id) const { 225 const Window* Window::GetChildById(int id) const {
(...skipping 29 matching lines...) Expand all
252 if (!parent_->event_filter_.get()) 255 if (!parent_->event_filter_.get())
253 parent_->SetEventFilter(new EventFilter(parent_)); 256 parent_->SetEventFilter(new EventFilter(parent_));
254 return parent_->event_filter_->OnMouseEvent(this, event) || 257 return parent_->event_filter_->OnMouseEvent(this, event) ||
255 delegate_->OnMouseEvent(event); 258 delegate_->OnMouseEvent(event);
256 } 259 }
257 260
258 bool Window::OnKeyEvent(KeyEvent* event) { 261 bool Window::OnKeyEvent(KeyEvent* event) {
259 return IsVisible() && delegate_->OnKeyEvent(event); 262 return IsVisible() && delegate_->OnKeyEvent(event);
260 } 263 }
261 264
265 void Window::AddObserver(WindowObserver* observer) {
266 observers_.AddObserver(observer);
267 }
268
269 void Window::RemoveObserver(WindowObserver* observer) {
270 observers_.RemoveObserver(observer);
271 }
272
262 bool Window::HitTest(const gfx::Point& point) { 273 bool Window::HitTest(const gfx::Point& point) {
263 gfx::Rect local_bounds(gfx::Point(), bounds().size()); 274 gfx::Rect local_bounds(gfx::Point(), bounds().size());
264 // TODO(beng): hittest masks. 275 // TODO(beng): hittest masks.
265 return local_bounds.Contains(point); 276 return local_bounds.Contains(point);
266 } 277 }
267 278
268 Window* Window::GetEventHandlerForPoint(const gfx::Point& point) { 279 Window* Window::GetEventHandlerForPoint(const gfx::Point& point) {
269 Windows::const_reverse_iterator i = children_.rbegin(); 280 Windows::const_reverse_iterator i = children_.rbegin();
270 for (; i != children_.rend(); ++i) { 281 for (; i != children_.rend(); ++i) {
271 Window* child = *i; 282 Window* child = *i;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (restore_bounds_.IsEmpty()) 400 if (restore_bounds_.IsEmpty())
390 restore_bounds_ = bounds(); 401 restore_bounds_ = bounds();
391 return true; 402 return true;
392 } 403 }
393 404
394 void Window::OnPaintLayer(gfx::Canvas* canvas) { 405 void Window::OnPaintLayer(gfx::Canvas* canvas) {
395 delegate_->OnPaint(canvas); 406 delegate_->OnPaint(canvas);
396 } 407 }
397 408
398 } // namespace aura 409 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698