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 } |
| 61 |
| 62 void ActivityFrameView::ResetWindowControls() { |
| 63 } |
| 64 |
| 65 void ActivityFrameView::UpdateWindowIcon() { |
| 66 } |
| 67 |
| 68 void ActivityFrameView::UpdateWindowTitle() { |
| 69 SkColor bgcolor = view_model_->GetRepresentativeColor(); |
| 70 title_->set_background(views::Background::CreateSolidBackground(bgcolor)); |
| 71 title_->SetBackgroundColor(bgcolor); |
| 72 title_->SetText(frame_->widget_delegate()->GetWindowTitle()); |
| 73 } |
| 74 |
| 75 //////////////////////////////////////////////////////////////////////////////// |
| 76 // ActivityFrameView, views::View overrides: |
| 77 |
| 78 gfx::Size ActivityFrameView::GetPreferredSize() const { |
| 79 gfx::Size pref = frame_->client_view()->GetPreferredSize(); |
| 80 gfx::Rect bounds(0, 0, pref.width(), pref.height()); |
| 81 return frame_->non_client_view() |
| 82 ->GetWindowBoundsForClientBounds(bounds) |
| 83 .size(); |
| 84 } |
| 85 |
| 86 const char* ActivityFrameView::GetClassName() const { |
| 87 return kViewClassName; |
| 88 } |
| 89 |
| 90 void ActivityFrameView::Layout() { |
| 91 title_->SetBounds(0, 0, width(), NonClientTopBorderHeight()); |
| 92 } |
| 93 |
| 94 //////////////////////////////////////////////////////////////////////////////// |
| 95 // ActivityFrameView, private: |
| 96 |
| 97 int ActivityFrameView::NonClientTopBorderHeight() const { |
| 98 return frame_->IsFullscreen() ? 0 : title_->GetPreferredSize().height(); |
| 99 } |
| 100 |
| 101 } // namespace ash |
OLD | NEW |