Chromium Code Reviews| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 | 70 |
| 71 namespace ash { | 71 namespace ash { |
| 72 | 72 |
| 73 /////////////////////////////////////////////////////////////////////////////// | 73 /////////////////////////////////////////////////////////////////////////////// |
| 74 // DefaultHeaderPainter, public: | 74 // DefaultHeaderPainter, public: |
| 75 | 75 |
| 76 DefaultHeaderPainter::DefaultHeaderPainter() | 76 DefaultHeaderPainter::DefaultHeaderPainter() |
| 77 : frame_(NULL), | 77 : frame_(NULL), |
| 78 view_(NULL), | 78 view_(NULL), |
| 79 window_icon_(NULL), | 79 window_icon_(NULL), |
| 80 window_icon_size_(HeaderPainterUtil::GetIconSize()), | |
|
pkotwicz
2014/03/18 15:29:44
It might make sense to rename HeaderPainterUtil::G
oshima
2014/03/18 16:59:50
Done.
| |
| 80 caption_button_container_(NULL), | 81 caption_button_container_(NULL), |
| 81 height_(0), | 82 height_(0), |
| 82 mode_(MODE_INACTIVE), | 83 mode_(MODE_INACTIVE), |
| 83 initial_paint_(true), | 84 initial_paint_(true), |
| 84 activation_animation_(new gfx::SlideAnimation(this)) { | 85 activation_animation_(new gfx::SlideAnimation(this)) { |
| 85 } | 86 } |
| 86 | 87 |
| 87 DefaultHeaderPainter::~DefaultHeaderPainter() { | 88 DefaultHeaderPainter::~DefaultHeaderPainter() { |
| 88 } | 89 } |
| 89 | 90 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 caption_button_container_->GetPreferredSize(); | 211 caption_button_container_->GetPreferredSize(); |
| 211 caption_button_container_->SetBounds( | 212 caption_button_container_->SetBounds( |
| 212 view_->width() - caption_button_container_size.width(), | 213 view_->width() - caption_button_container_size.width(), |
| 213 0, | 214 0, |
| 214 caption_button_container_size.width(), | 215 caption_button_container_size.width(), |
| 215 caption_button_container_size.height()); | 216 caption_button_container_size.height()); |
| 216 | 217 |
| 217 if (window_icon_) { | 218 if (window_icon_) { |
| 218 // Vertically center the window icon with respect to the caption button | 219 // Vertically center the window icon with respect to the caption button |
| 219 // container. | 220 // container. |
| 220 int icon_size = HeaderPainterUtil::GetIconSize(); | 221 int icon_offset_y = |
| 221 int icon_offset_y = (caption_button_container_->height() - icon_size) / 2; | 222 (caption_button_container_->height() - window_icon_size_) / 2; |
| 222 window_icon_->SetBounds(HeaderPainterUtil::GetIconXOffset(), icon_offset_y, | 223 window_icon_->SetBounds(HeaderPainterUtil::GetIconXOffset(), icon_offset_y, |
| 223 icon_size, icon_size); | 224 window_icon_size_, window_icon_size_); |
| 224 } | 225 } |
| 225 | 226 |
| 226 SetHeaderHeightForPainting(caption_button_container_->height() + | 227 SetHeaderHeightForPainting(caption_button_container_->height() + |
| 227 kHeaderContentSeparatorSize); | 228 kHeaderContentSeparatorSize); |
| 228 } | 229 } |
| 229 | 230 |
| 230 int DefaultHeaderPainter::GetHeaderHeightForPainting() const { | 231 int DefaultHeaderPainter::GetHeaderHeightForPainting() const { |
| 231 return height_; | 232 return height_; |
| 232 } | 233 } |
| 233 | 234 |
| 234 void DefaultHeaderPainter::SetHeaderHeightForPainting(int height) { | 235 void DefaultHeaderPainter::SetHeaderHeightForPainting(int height) { |
| 235 height_ = height; | 236 height_ = height; |
| 236 } | 237 } |
| 237 | 238 |
| 238 void DefaultHeaderPainter::SchedulePaintForTitle() { | 239 void DefaultHeaderPainter::SchedulePaintForTitle() { |
| 239 view_->SchedulePaintInRect(GetTitleBounds()); | 240 view_->SchedulePaintInRect(GetTitleBounds()); |
| 240 } | 241 } |
| 241 | 242 |
| 243 void DefaultHeaderPainter::UpdateWindowIcon(views::View* window_icon, | |
| 244 int window_icon_size) { | |
| 245 window_icon_ = window_icon; | |
| 246 window_icon_size_ = window_icon_size; | |
| 247 } | |
| 248 | |
| 242 /////////////////////////////////////////////////////////////////////////////// | 249 /////////////////////////////////////////////////////////////////////////////// |
| 243 // gfx::AnimationDelegate overrides: | 250 // gfx::AnimationDelegate overrides: |
| 244 | 251 |
| 245 void DefaultHeaderPainter::AnimationProgressed( | 252 void DefaultHeaderPainter::AnimationProgressed( |
| 246 const gfx::Animation* animation) { | 253 const gfx::Animation* animation) { |
| 247 view_->SchedulePaintInRect(GetLocalBounds()); | 254 view_->SchedulePaintInRect(GetLocalBounds()); |
| 248 } | 255 } |
| 249 | 256 |
| 250 /////////////////////////////////////////////////////////////////////////////// | 257 /////////////////////////////////////////////////////////////////////////////// |
| 251 // DefaultHeaderPainter, private: | 258 // DefaultHeaderPainter, private: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { | 317 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { |
| 311 return gfx::Rect(view_->width(), height_); | 318 return gfx::Rect(view_->width(), height_); |
| 312 } | 319 } |
| 313 | 320 |
| 314 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { | 321 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { |
| 315 return HeaderPainterUtil::GetTitleBounds( | 322 return HeaderPainterUtil::GetTitleBounds( |
| 316 window_icon_, caption_button_container_, GetTitleFontList()); | 323 window_icon_, caption_button_container_, GetTitleFontList()); |
| 317 } | 324 } |
| 318 | 325 |
| 319 } // namespace ash | 326 } // namespace ash |
| OLD | NEW |