OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/wm/frame_painter.h" | 5 #include "ash/wm/frame_painter.h" |
6 | 6 |
7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/property_util.h" | 10 #include "ash/wm/property_util.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 crossfade_opacity_(0), | 140 crossfade_opacity_(0), |
141 crossfade_animation_(NULL), | 141 crossfade_animation_(NULL), |
142 size_button_behavior_(SIZE_BUTTON_MAXIMIZES) { | 142 size_button_behavior_(SIZE_BUTTON_MAXIMIZES) { |
143 if (!instances_) | 143 if (!instances_) |
144 instances_ = new std::set<FramePainter*>(); | 144 instances_ = new std::set<FramePainter*>(); |
145 instances_->insert(this); | 145 instances_->insert(this); |
146 } | 146 } |
147 | 147 |
148 FramePainter::~FramePainter() { | 148 FramePainter::~FramePainter() { |
149 // Sometimes we are destroyed before the window closes, so ensure we clean up. | 149 // Sometimes we are destroyed before the window closes, so ensure we clean up. |
150 if (window_) | 150 if (window_) { |
| 151 aura::RootWindow* root = window_->GetRootWindow(); |
| 152 if (root && |
| 153 root->GetProperty(internal::kSoloWindowFramePainterKey) == this) { |
| 154 root->SetProperty(internal::kSoloWindowFramePainterKey, |
| 155 static_cast<FramePainter*>(NULL)); |
| 156 } |
151 window_->RemoveObserver(this); | 157 window_->RemoveObserver(this); |
| 158 } |
152 instances_->erase(this); | 159 instances_->erase(this); |
153 } | 160 } |
154 | 161 |
155 void FramePainter::Init(views::Widget* frame, | 162 void FramePainter::Init(views::Widget* frame, |
156 views::View* window_icon, | 163 views::View* window_icon, |
157 views::ImageButton* size_button, | 164 views::ImageButton* size_button, |
158 views::ImageButton* close_button, | 165 views::ImageButton* close_button, |
159 SizeButtonBehavior behavior) { | 166 SizeButtonBehavior behavior) { |
160 DCHECK(frame); | 167 DCHECK(frame); |
161 // window_icon may be NULL. | 168 // window_icon may be NULL. |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 void FramePainter::UpdateSoloWindowFramePainter( | 755 void FramePainter::UpdateSoloWindowFramePainter( |
749 aura::Window* ignorable_window) { | 756 aura::Window* ignorable_window) { |
750 aura::RootWindow* root = window_->GetRootWindow(); | 757 aura::RootWindow* root = window_->GetRootWindow(); |
751 if (!root) | 758 if (!root) |
752 return; | 759 return; |
753 | 760 |
754 FramePainter* old_solo_painter = root->GetProperty( | 761 FramePainter* old_solo_painter = root->GetProperty( |
755 internal::kSoloWindowFramePainterKey); | 762 internal::kSoloWindowFramePainterKey); |
756 FramePainter* new_solo_painter = GetSoloPainterInRoot(ignorable_window); | 763 FramePainter* new_solo_painter = GetSoloPainterInRoot(ignorable_window); |
757 if (old_solo_painter != new_solo_painter) { | 764 if (old_solo_painter != new_solo_painter) { |
758 if (old_solo_painter) | 765 if (old_solo_painter && old_solo_painter->frame_ && |
| 766 old_solo_painter->frame_->non_client_view()) { |
759 old_solo_painter->frame_->non_client_view()->SchedulePaint(); | 767 old_solo_painter->frame_->non_client_view()->SchedulePaint(); |
| 768 } |
760 window_->GetRootWindow()->SetProperty( | 769 window_->GetRootWindow()->SetProperty( |
761 internal::kSoloWindowFramePainterKey, new_solo_painter); | 770 internal::kSoloWindowFramePainterKey, new_solo_painter); |
762 if (new_solo_painter) | 771 if (new_solo_painter && new_solo_painter->frame_ && |
| 772 new_solo_painter->frame_->non_client_view()) { |
763 new_solo_painter->frame_->non_client_view()->SchedulePaint(); | 773 new_solo_painter->frame_->non_client_view()->SchedulePaint(); |
| 774 } |
764 } | 775 } |
765 } | 776 } |
766 | 777 |
767 void FramePainter::SchedulePaintForHeader() { | 778 void FramePainter::SchedulePaintForHeader() { |
768 int top_left_height = top_left_corner_->height(); | 779 int top_left_height = top_left_corner_->height(); |
769 int top_right_height = top_right_corner_->height(); | 780 int top_right_height = top_right_corner_->height(); |
770 frame_->non_client_view()->SchedulePaintInRect( | 781 frame_->non_client_view()->SchedulePaintInRect( |
771 gfx::Rect(0, 0, frame_->non_client_view()->width(), | 782 gfx::Rect(0, 0, frame_->non_client_view()->width(), |
772 std::max(top_left_height, top_right_height))); | 783 std::max(top_left_height, top_right_height))); |
773 } | 784 } |
774 | 785 |
775 gfx::Rect FramePainter::GetTitleBounds(views::NonClientFrameView* view, | 786 gfx::Rect FramePainter::GetTitleBounds(views::NonClientFrameView* view, |
776 const gfx::Font& title_font) { | 787 const gfx::Font& title_font) { |
777 int title_x = GetTitleOffsetX(); | 788 int title_x = GetTitleOffsetX(); |
778 // Center the text in the middle of the caption - this way it adapts | 789 // Center the text in the middle of the caption - this way it adapts |
779 // automatically to the caption height (which is given by the owner). | 790 // automatically to the caption height (which is given by the owner). |
780 int title_y = | 791 int title_y = |
781 (view->GetBoundsForClientView().y() - title_font.GetHeight()) / 2; | 792 (view->GetBoundsForClientView().y() - title_font.GetHeight()) / 2; |
782 return gfx::Rect( | 793 return gfx::Rect( |
783 title_x, | 794 title_x, |
784 std::max(0, title_y), | 795 std::max(0, title_y), |
785 std::max(0, size_button_->x() - kTitleLogoSpacing - title_x), | 796 std::max(0, size_button_->x() - kTitleLogoSpacing - title_x), |
786 title_font.GetHeight()); | 797 title_font.GetHeight()); |
787 } | 798 } |
788 | 799 |
789 } // namespace ash | 800 } // namespace ash |
OLD | NEW |