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

Side by Side Diff: chrome/browser/chromeos/frame/bubble_frame_view.cc

Issue 4110010: Cloud Print Dialog work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Direct paths for prefs. Created 10 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
« no previous file with comments | « chrome/browser/chrome_plugin_host.cc ('k') | chrome/browser/chromeos/login/login_html_dialog.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/chromeos/frame/bubble_frame_view.h" 5 #include "chrome/browser/chromeos/frame/bubble_frame_view.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "gfx/canvas_skia.h" 8 #include "gfx/canvas_skia.h"
9 #include "gfx/font.h" 9 #include "gfx/font.h"
10 #include "gfx/insets.h" 10 #include "gfx/insets.h"
(...skipping 20 matching lines...) Expand all
31 namespace chromeos { 31 namespace chromeos {
32 32
33 BubbleFrameView::BubbleFrameView(views::Window* frame, 33 BubbleFrameView::BubbleFrameView(views::Window* frame,
34 BubbleWindow::Style style) 34 BubbleWindow::Style style)
35 : frame_(frame), 35 : frame_(frame),
36 style_(style), 36 style_(style),
37 title_(NULL), 37 title_(NULL),
38 close_button_(NULL) { 38 close_button_(NULL) {
39 set_border(new BubbleBorder(BubbleBorder::NONE)); 39 set_border(new BubbleBorder(BubbleBorder::NONE));
40 40
41 title_ = new views::Label(frame_->GetDelegate()->GetWindowTitle()); 41 if (frame_->GetDelegate()->ShouldShowWindowTitle()) {
42 title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 42 title_ = new views::Label(frame_->GetDelegate()->GetWindowTitle());
43 title_->SetFont(title_->font().DeriveFont(1, gfx::Font::BOLD)); 43 title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
44 AddChildView(title_); 44 title_->SetFont(title_->font().DeriveFont(1, gfx::Font::BOLD));
45 AddChildView(title_);
46 }
45 47
46 if (style_ & BubbleWindow::STYLE_XBAR) { 48 if (style_ & BubbleWindow::STYLE_XBAR) {
47 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 49 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
48 close_button_ = new views::ImageButton(this); 50 close_button_ = new views::ImageButton(this);
49 close_button_->SetImage(views::CustomButton::BS_NORMAL, 51 close_button_->SetImage(views::CustomButton::BS_NORMAL,
50 rb.GetBitmapNamed(IDR_CLOSE_BAR)); 52 rb.GetBitmapNamed(IDR_CLOSE_BAR));
51 close_button_->SetImage(views::CustomButton::BS_HOT, 53 close_button_->SetImage(views::CustomButton::BS_HOT,
52 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); 54 rb.GetBitmapNamed(IDR_CLOSE_BAR_H));
53 close_button_->SetImage(views::CustomButton::BS_PUSHED, 55 close_button_->SetImage(views::CustomButton::BS_PUSHED,
54 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); 56 rb.GetBitmapNamed(IDR_CLOSE_BAR_P));
55 AddChildView(close_button_); 57 AddChildView(close_button_);
56 } 58 }
57 } 59 }
58 60
59 BubbleFrameView::~BubbleFrameView() { 61 BubbleFrameView::~BubbleFrameView() {
60 } 62 }
61 63
62 gfx::Rect BubbleFrameView::GetBoundsForClientView() const { 64 gfx::Rect BubbleFrameView::GetBoundsForClientView() const {
63 return client_view_bounds_; 65 return client_view_bounds_;
64 } 66 }
65 67
66 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( 68 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds(
67 const gfx::Rect& client_bounds) const { 69 const gfx::Rect& client_bounds) const {
68 gfx::Insets insets = GetInsets(); 70 gfx::Insets insets = GetInsets();
69 gfx::Size title_size = title_->GetPreferredSize(); 71 gfx::Size title_size;
72 if (title_) {
73 title_size = title_->GetPreferredSize();
74 }
70 75
71 gfx::Size close_button_size = gfx::Size(); 76 gfx::Size close_button_size = gfx::Size();
72 if (close_button_) { 77 if (close_button_) {
73 close_button_size = close_button_->GetPreferredSize(); 78 close_button_size = close_button_->GetPreferredSize();
74 } 79 }
75 80
76 int top_height = insets.top() + 81 int top_height = insets.top();
77 std::max(title_size.height(), close_button_size.height()) + 82 if (title_size.height() > 0 || close_button_size.height() > 0)
78 kTitleContentPadding; 83 top_height += std::max(title_size.height(), close_button_size.height()) +
84 kTitleContentPadding;
79 return gfx::Rect(std::max(0, client_bounds.x() - insets.left()), 85 return gfx::Rect(std::max(0, client_bounds.x() - insets.left()),
80 std::max(0, client_bounds.y() - top_height), 86 std::max(0, client_bounds.y() - top_height),
81 client_bounds.width() + insets.width(), 87 client_bounds.width() + insets.width(),
82 client_bounds.height() + top_height + insets.bottom()); 88 client_bounds.height() + top_height + insets.bottom());
83 } 89 }
84 90
85 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { 91 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) {
86 return HTNOWHERE; 92 return HTNOWHERE;
87 } 93 }
88 94
(...skipping 22 matching lines...) Expand all
111 gfx::Size BubbleFrameView::GetPreferredSize() { 117 gfx::Size BubbleFrameView::GetPreferredSize() {
112 gfx::Size pref = frame_->GetClientView()->GetPreferredSize(); 118 gfx::Size pref = frame_->GetClientView()->GetPreferredSize();
113 gfx::Rect bounds(0, 0, pref.width(), pref.height()); 119 gfx::Rect bounds(0, 0, pref.width(), pref.height());
114 return frame_->GetNonClientView()->GetWindowBoundsForClientBounds( 120 return frame_->GetNonClientView()->GetWindowBoundsForClientBounds(
115 bounds).size(); 121 bounds).size();
116 } 122 }
117 123
118 void BubbleFrameView::Layout() { 124 void BubbleFrameView::Layout() {
119 gfx::Insets insets = GetInsets(); 125 gfx::Insets insets = GetInsets();
120 126
121 gfx::Size title_size = title_->GetPreferredSize(); 127 gfx::Size title_size;
128 if (title_) {
129 title_size = title_->GetPreferredSize();
130 }
122 131
123 gfx::Size close_button_size = gfx::Size(); 132 gfx::Size close_button_size = gfx::Size();
124 if (close_button_) { 133 if (close_button_) {
125 close_button_size = close_button_->GetPreferredSize(); 134 close_button_size = close_button_->GetPreferredSize();
126 } 135 }
127 136
128 title_->SetBounds( 137 if (title_) {
129 insets.left(), insets.top(), 138 title_->SetBounds(
130 std::max(0, width() - insets.width() - close_button_size.width()), 139 insets.left(), insets.top(),
131 title_size.height()); 140 std::max(0, width() - insets.width() - close_button_size.width()),
141 title_size.height());
142 }
132 143
133 if (close_button_) { 144 if (close_button_) {
134 close_button_->SetBounds( 145 close_button_->SetBounds(
135 width() - insets.right() - close_button_size.width(), insets.top(), 146 width() - insets.right() - close_button_size.width(), insets.top(),
136 close_button_size.width(), close_button_size.height()); 147 close_button_size.width(), close_button_size.height());
137 } 148 }
138 149
139 int top_height = insets.top() + 150 int top_height = insets.top();
140 std::max(title_size.height(), close_button_size.height()) + 151 if (title_size.height() > 0 || close_button_size.height() > 0)
141 kTitleContentPadding; 152 top_height += std::max(title_size.height(), close_button_size.height()) +
153 kTitleContentPadding;
142 client_view_bounds_.SetRect(insets.left(), top_height, 154 client_view_bounds_.SetRect(insets.left(), top_height,
143 std::max(0, width() - insets.width()), 155 std::max(0, width() - insets.width()),
144 std::max(0, height() - top_height - insets.bottom())); 156 std::max(0, height() - top_height - insets.bottom()));
145 } 157 }
146 158
147 void BubbleFrameView::Paint(gfx::Canvas* canvas) { 159 void BubbleFrameView::Paint(gfx::Canvas* canvas) {
148 // The border of this view creates an anti-aliased round-rect region for the 160 // The border of this view creates an anti-aliased round-rect region for the
149 // contents, which we need to fill with the background color. 161 // contents, which we need to fill with the background color.
150 SkPaint paint; 162 SkPaint paint;
151 paint.setAntiAlias(true); 163 paint.setAntiAlias(true);
(...skipping 12 matching lines...) Expand all
164 } 176 }
165 177
166 void BubbleFrameView::ButtonPressed(views::Button* sender, 178 void BubbleFrameView::ButtonPressed(views::Button* sender,
167 const views::Event& event) { 179 const views::Event& event) {
168 if (close_button_ != NULL && sender == close_button_) { 180 if (close_button_ != NULL && sender == close_button_) {
169 frame_->Close(); 181 frame_->Close();
170 } 182 }
171 } 183 }
172 184
173 } // namespace chromeos 185 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chrome_plugin_host.cc ('k') | chrome/browser/chromeos/login/login_html_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698