Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: ash/wm/panel_frame_view.cc

Issue 11363250: Allow Chrome apps to create Ash Panels (apps v2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "ash/wm/panel_frame_view.h" 6 #include "ash/wm/panel_frame_view.h"
7 #include "grit/ash_resources.h" 7 #include "grit/ash_resources.h"
8 #include "grit/ui_strings.h" // Accessibility names 8 #include "grit/ui_strings.h" // Accessibility names
9 #include "third_party/skia/include/core/SkPaint.h" 9 #include "third_party/skia/include/core/SkPaint.h"
10 #include "ui/base/animation/throb_animation.h" 10 #include "ui/base/animation/throb_animation.h"
11 #include "ui/base/cursor/cursor.h" 11 #include "ui/base/cursor/cursor.h"
12 #include "ui/base/hit_test.h" 12 #include "ui/base/hit_test.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/font.h" 16 #include "ui/gfx/font.h"
17 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
18 #include "ui/views/controls/button/image_button.h" 18 #include "ui/views/controls/button/image_button.h"
19 #include "ui/views/widget/native_widget_aura.h" 19 #include "ui/views/widget/native_widget_aura.h"
20 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
21 #include "ui/views/widget/widget_delegate.h" 21 #include "ui/views/widget/widget_delegate.h"
22 22
23 namespace ash { 23 namespace ash {
24 24
25 PanelFrameView::PanelFrameView(views::Widget* frame) 25 PanelFrameView::PanelFrameView(views::Widget* frame, bool show_header) {
26 : frame_painter_(new FramePainter) { 26 if (show_header)
27 InitFramePainter(frame);
28 }
29
30 PanelFrameView::~PanelFrameView() {
31 }
32
33 void PanelFrameView::InitFramePainter(views::Widget* frame) {
34 frame_painter_.reset(new FramePainter);
35
27 close_button_ = new views::ImageButton(this); 36 close_button_ = new views::ImageButton(this);
28 close_button_->SetAccessibleName( 37 close_button_->SetAccessibleName(
29 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); 38 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE));
30 AddChildView(close_button_); 39 AddChildView(close_button_);
31 40
32 minimize_button_ = new views::ImageButton(this); 41 minimize_button_ = new views::ImageButton(this);
33 minimize_button_->SetAccessibleName( 42 minimize_button_->SetAccessibleName(
34 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE)); 43 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE));
35 AddChildView(minimize_button_); 44 AddChildView(minimize_button_);
36 45
37 frame_painter_->Init(frame, NULL, minimize_button_, close_button_, 46 frame_painter_->Init(frame, NULL, minimize_button_, close_button_,
38 FramePainter::SIZE_BUTTON_MINIMIZES); 47 FramePainter::SIZE_BUTTON_MINIMIZES);
39 } 48 }
40 49
41 PanelFrameView::~PanelFrameView() {
42 }
43
44 void PanelFrameView::Layout() { 50 void PanelFrameView::Layout() {
51 if (!frame_painter_.get())
52 return;
45 frame_painter_->LayoutHeader(this, true); 53 frame_painter_->LayoutHeader(this, true);
46 } 54 }
47 55
48 void PanelFrameView::ResetWindowControls() { 56 void PanelFrameView::ResetWindowControls() {
49 NOTIMPLEMENTED(); 57 NOTIMPLEMENTED();
50 } 58 }
51 59
52 void PanelFrameView::UpdateWindowIcon() { 60 void PanelFrameView::UpdateWindowIcon() {
53 NOTIMPLEMENTED(); 61 NOTIMPLEMENTED();
54 } 62 }
55 63
56 void PanelFrameView::UpdateWindowTitle() { 64 void PanelFrameView::UpdateWindowTitle() {
57 NOTIMPLEMENTED(); 65 NOTIMPLEMENTED();
58 } 66 }
59 67
60 void PanelFrameView::GetWindowMask(const gfx::Size&, gfx::Path*) { 68 void PanelFrameView::GetWindowMask(const gfx::Size&, gfx::Path*) {
61 // Nothing. 69 // Nothing.
62 } 70 }
63 71
64 int PanelFrameView::NonClientHitTest(const gfx::Point& point) { 72 int PanelFrameView::NonClientHitTest(const gfx::Point& point) {
73 if (!frame_painter_.get())
74 return HTNOWHERE;
65 return frame_painter_->NonClientHitTest(this, point); 75 return frame_painter_->NonClientHitTest(this, point);
66 } 76 }
67 77
68 void PanelFrameView::OnPaint(gfx::Canvas* canvas) { 78 void PanelFrameView::OnPaint(gfx::Canvas* canvas) {
79 if (!frame_painter_.get())
80 return;
69 bool paint_as_active = ShouldPaintAsActive(); 81 bool paint_as_active = ShouldPaintAsActive();
70 int theme_image_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE : 82 int theme_image_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE :
71 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; 83 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE;
72 frame_painter_->PaintHeader( 84 frame_painter_->PaintHeader(
73 this, 85 this,
74 canvas, 86 canvas,
75 paint_as_active ? FramePainter::ACTIVE : FramePainter::INACTIVE, 87 paint_as_active ? FramePainter::ACTIVE : FramePainter::INACTIVE,
76 theme_image_id, 88 theme_image_id,
77 NULL); 89 NULL);
78 frame_painter_->PaintHeaderContentSeparator(this, canvas); 90 frame_painter_->PaintHeaderContentSeparator(this, canvas);
79 } 91 }
80 92
81 gfx::Rect PanelFrameView::GetBoundsForClientView() const { 93 gfx::Rect PanelFrameView::GetBoundsForClientView() const {
94 if (!frame_painter_.get())
95 return bounds();
82 return frame_painter_->GetBoundsForClientView( 96 return frame_painter_->GetBoundsForClientView(
83 close_button_->bounds().bottom(), 97 close_button_->bounds().bottom(),
84 bounds()); 98 bounds());
85 } 99 }
86 100
87 gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds( 101 gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds(
88 const gfx::Rect& client_bounds) const { 102 const gfx::Rect& client_bounds) const {
103 if (!frame_painter_.get())
104 return client_bounds;
89 return frame_painter_->GetWindowBoundsForClientBounds( 105 return frame_painter_->GetWindowBoundsForClientBounds(
90 close_button_->bounds().bottom(), client_bounds); 106 close_button_->bounds().bottom(), client_bounds);
91 } 107 }
92 108
93 void PanelFrameView::ButtonPressed(views::Button* sender, 109 void PanelFrameView::ButtonPressed(views::Button* sender,
94 const ui::Event& event) { 110 const ui::Event& event) {
95 if (sender == close_button_) 111 if (sender == close_button_)
96 GetWidget()->Close(); 112 GetWidget()->Close();
113 if (sender == minimize_button_)
114 GetWidget()->Minimize();
97 } 115 }
98 116
99 } // namespace ash 117 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698