OLD | NEW |
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 "ash/frame/default_header_painter.h" | 5 #include "ash/frame/default_header_painter.h" |
6 | 6 |
7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
8 #include "ash/frame/header_painter_util.h" | 8 #include "ash/frame/header_painter_util.h" |
9 #include "base/debug/leak_annotations.h" | 9 #include "base/debug/leak_annotations.h" |
10 #include "base/logging.h" // DCHECK | 10 #include "base/logging.h" // DCHECK |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 namespace ash { | 69 namespace ash { |
70 | 70 |
71 /////////////////////////////////////////////////////////////////////////////// | 71 /////////////////////////////////////////////////////////////////////////////// |
72 // DefaultHeaderPainter, public: | 72 // DefaultHeaderPainter, public: |
73 | 73 |
74 DefaultHeaderPainter::DefaultHeaderPainter() | 74 DefaultHeaderPainter::DefaultHeaderPainter() |
75 : frame_(NULL), | 75 : frame_(NULL), |
76 view_(NULL), | 76 view_(NULL), |
77 window_icon_(NULL), | 77 window_icon_(NULL), |
| 78 window_icon_size_(HeaderPainterUtil::GetDefaultIconSize()), |
78 caption_button_container_(NULL), | 79 caption_button_container_(NULL), |
79 height_(0), | 80 height_(0), |
80 mode_(MODE_INACTIVE), | 81 mode_(MODE_INACTIVE), |
81 initial_paint_(true), | 82 initial_paint_(true), |
82 activation_animation_(new gfx::SlideAnimation(this)) { | 83 activation_animation_(new gfx::SlideAnimation(this)) { |
83 } | 84 } |
84 | 85 |
85 DefaultHeaderPainter::~DefaultHeaderPainter() { | 86 DefaultHeaderPainter::~DefaultHeaderPainter() { |
86 } | 87 } |
87 | 88 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 caption_button_container_->GetPreferredSize(); | 209 caption_button_container_->GetPreferredSize(); |
209 caption_button_container_->SetBounds( | 210 caption_button_container_->SetBounds( |
210 view_->width() - caption_button_container_size.width(), | 211 view_->width() - caption_button_container_size.width(), |
211 0, | 212 0, |
212 caption_button_container_size.width(), | 213 caption_button_container_size.width(), |
213 caption_button_container_size.height()); | 214 caption_button_container_size.height()); |
214 | 215 |
215 if (window_icon_) { | 216 if (window_icon_) { |
216 // Vertically center the window icon with respect to the caption button | 217 // Vertically center the window icon with respect to the caption button |
217 // container. | 218 // container. |
218 int icon_size = HeaderPainterUtil::GetIconSize(); | |
219 // Floor when computing the center of |caption_button_container_|. | 219 // Floor when computing the center of |caption_button_container_|. |
220 int icon_offset_y = caption_button_container_->height() / 2 - icon_size / 2; | 220 int icon_offset_y = |
| 221 caption_button_container_->height() / 2 - window_icon_size_ / 2; |
221 window_icon_->SetBounds(HeaderPainterUtil::GetIconXOffset(), icon_offset_y, | 222 window_icon_->SetBounds(HeaderPainterUtil::GetIconXOffset(), icon_offset_y, |
222 icon_size, icon_size); | 223 window_icon_size_, window_icon_size_); |
223 } | 224 } |
224 | 225 |
225 // The header/content separator line overlays the caption buttons. | 226 // The header/content separator line overlays the caption buttons. |
226 SetHeaderHeightForPainting(caption_button_container_->height()); | 227 SetHeaderHeightForPainting(caption_button_container_->height()); |
227 } | 228 } |
228 | 229 |
229 int DefaultHeaderPainter::GetHeaderHeightForPainting() const { | 230 int DefaultHeaderPainter::GetHeaderHeightForPainting() const { |
230 return height_; | 231 return height_; |
231 } | 232 } |
232 | 233 |
233 void DefaultHeaderPainter::SetHeaderHeightForPainting(int height) { | 234 void DefaultHeaderPainter::SetHeaderHeightForPainting(int height) { |
234 height_ = height; | 235 height_ = height; |
235 } | 236 } |
236 | 237 |
237 void DefaultHeaderPainter::SchedulePaintForTitle() { | 238 void DefaultHeaderPainter::SchedulePaintForTitle() { |
238 view_->SchedulePaintInRect(GetTitleBounds()); | 239 view_->SchedulePaintInRect(GetTitleBounds()); |
239 } | 240 } |
240 | 241 |
| 242 void DefaultHeaderPainter::UpdateWindowIcon(views::View* window_icon, |
| 243 int window_icon_size) { |
| 244 window_icon_ = window_icon; |
| 245 window_icon_size_ = window_icon_size; |
| 246 } |
| 247 |
241 /////////////////////////////////////////////////////////////////////////////// | 248 /////////////////////////////////////////////////////////////////////////////// |
242 // gfx::AnimationDelegate overrides: | 249 // gfx::AnimationDelegate overrides: |
243 | 250 |
244 void DefaultHeaderPainter::AnimationProgressed( | 251 void DefaultHeaderPainter::AnimationProgressed( |
245 const gfx::Animation* animation) { | 252 const gfx::Animation* animation) { |
246 view_->SchedulePaintInRect(GetLocalBounds()); | 253 view_->SchedulePaintInRect(GetLocalBounds()); |
247 } | 254 } |
248 | 255 |
249 /////////////////////////////////////////////////////////////////////////////// | 256 /////////////////////////////////////////////////////////////////////////////// |
250 // DefaultHeaderPainter, private: | 257 // DefaultHeaderPainter, private: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { | 319 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { |
313 return gfx::Rect(view_->width(), height_); | 320 return gfx::Rect(view_->width(), height_); |
314 } | 321 } |
315 | 322 |
316 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { | 323 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { |
317 return HeaderPainterUtil::GetTitleBounds( | 324 return HeaderPainterUtil::GetTitleBounds( |
318 window_icon_, caption_button_container_, GetTitleFontList()); | 325 window_icon_, caption_button_container_, GetTitleFontList()); |
319 } | 326 } |
320 | 327 |
321 } // namespace ash | 328 } // namespace ash |
OLD | NEW |