Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "athena/activity/activity_frame_view.h" | |
| 6 | |
| 7 #include <algorithm> | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "athena/activity/public/activity_view_model.h" | |
| 11 #include "ui/views/background.h" | |
| 12 #include "ui/views/controls/label.h" | |
| 13 #include "ui/views/view.h" | |
| 14 #include "ui/views/widget/widget.h" | |
| 15 #include "ui/views/widget/widget_delegate.h" | |
| 16 | |
| 17 namespace athena { | |
| 18 | |
| 19 //////////////////////////////////////////////////////////////////////////////// | |
| 20 // FrameViewAthena, public: | |
| 21 | |
| 22 // static | |
| 23 const char ActivityFrameView::kViewClassName[] = "ActivityFrameView"; | |
| 24 | |
| 25 ActivityFrameView::ActivityFrameView(views::Widget* frame, | |
| 26 ActivityViewModel* view_model) | |
| 27 : frame_(frame), view_model_(view_model), title_(new views::Label) { | |
| 28 title_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
| 29 const gfx::FontList& font_list = title_->font_list(); | |
| 30 title_->SetFontList(font_list.Derive(1, gfx::Font::BOLD)); | |
| 31 title_->SetEnabledColor(SK_ColorBLACK); | |
| 32 AddChildView(title_); | |
| 33 } | |
| 34 | |
| 35 ActivityFrameView::~ActivityFrameView() { | |
| 36 } | |
| 37 | |
| 38 //////////////////////////////////////////////////////////////////////////////// | |
| 39 // ActivityFrameView, views::NonClientFrameView overrides: | |
| 40 | |
| 41 gfx::Rect ActivityFrameView::GetBoundsForClientView() const { | |
| 42 gfx::Rect client_bounds = bounds(); | |
| 43 client_bounds.Inset(0, NonClientTopBorderHeight(), 0, 0); | |
| 44 return client_bounds; | |
| 45 } | |
| 46 | |
| 47 gfx::Rect ActivityFrameView::GetWindowBoundsForClientBounds( | |
| 48 const gfx::Rect& client_bounds) const { | |
| 49 gfx::Rect window_bounds = client_bounds; | |
| 50 window_bounds.Inset(0, -NonClientTopBorderHeight(), 0, 0); | |
| 51 return window_bounds; | |
| 52 } | |
| 53 | |
| 54 int ActivityFrameView::NonClientHitTest(const gfx::Point& point) { | |
| 55 return 0; | |
| 56 } | |
| 57 | |
| 58 void ActivityFrameView::GetWindowMask(const gfx::Size& size, | |
| 59 gfx::Path* window_mask) { | |
| 60 // No window masks in Aura. | |
|
Jun Mukai
2014/07/11 01:28:14
in Aura? in Athena, or just remove this comment?
oshima
2014/07/11 06:51:35
Removed.
| |
| 61 } | |
| 62 | |
| 63 void ActivityFrameView::ResetWindowControls() { | |
| 64 } | |
| 65 | |
| 66 void ActivityFrameView::UpdateWindowIcon() { | |
| 67 } | |
| 68 | |
| 69 void ActivityFrameView::UpdateWindowTitle() { | |
| 70 SkColor bgcolor = view_model_->GetRepresentativeColor(); | |
| 71 title_->set_background(views::Background::CreateSolidBackground(bgcolor)); | |
| 72 title_->SetBackgroundColor(bgcolor); | |
| 73 title_->SetText(frame_->widget_delegate()->GetWindowTitle()); | |
| 74 } | |
| 75 | |
| 76 //////////////////////////////////////////////////////////////////////////////// | |
| 77 // ActivityFrameView, views::View overrides: | |
| 78 | |
| 79 gfx::Size ActivityFrameView::GetPreferredSize() const { | |
| 80 gfx::Size pref = frame_->client_view()->GetPreferredSize(); | |
| 81 gfx::Rect bounds(0, 0, pref.width(), pref.height()); | |
| 82 return frame_->non_client_view() | |
| 83 ->GetWindowBoundsForClientBounds(bounds) | |
| 84 .size(); | |
| 85 } | |
| 86 | |
| 87 const char* ActivityFrameView::GetClassName() const { | |
| 88 return kViewClassName; | |
| 89 } | |
| 90 | |
| 91 void ActivityFrameView::Layout() { | |
| 92 title_->SetBounds(0, 0, width(), NonClientTopBorderHeight()); | |
| 93 } | |
| 94 | |
| 95 //////////////////////////////////////////////////////////////////////////////// | |
| 96 // ActivityFrameView, private: | |
| 97 | |
| 98 int ActivityFrameView::NonClientTopBorderHeight() const { | |
| 99 return frame_->IsFullscreen() ? 0 : title_->GetPreferredSize().height(); | |
| 100 } | |
| 101 | |
| 102 } // namespace ash | |
| OLD | NEW |