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

Side by Side Diff: chrome/browser/ui/views/bubble/bubble.cc

Issue 7529038: chromeos: Minor changes to volume/brightness bubble UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months 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/chromeos/setting_level_bubble_view.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/views/bubble/bubble.h" 5 #include "chrome/browser/ui/views/bubble/bubble.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "chrome/browser/ui/views/bubble/border_contents.h" 9 #include "chrome/browser/ui/views/bubble/border_contents.h"
10 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } else { 99 } else {
100 #if defined(OS_WIN) 100 #if defined(OS_WIN)
101 // When fading in we need to remove the layered window style flag, since 101 // When fading in we need to remove the layered window style flag, since
102 // that style prevents some bubble content from working properly. 102 // that style prevents some bubble content from working properly.
103 SetWindowLong(GWL_EXSTYLE, GetWindowLong(GWL_EXSTYLE) & ~WS_EX_LAYERED); 103 SetWindowLong(GWL_EXSTYLE, GetWindowLong(GWL_EXSTYLE) & ~WS_EX_LAYERED);
104 #endif 104 #endif
105 } 105 }
106 } 106 }
107 107
108 void Bubble::AnimationProgressed(const ui::Animation* animation) { 108 void Bubble::AnimationProgressed(const ui::Animation* animation) {
109 #if defined(OS_WIN)
110 // Set the opacity for the main contents window. 109 // Set the opacity for the main contents window.
111 unsigned char opacity = static_cast<unsigned char>( 110 unsigned char opacity = static_cast<unsigned char>(
112 animation_->GetCurrentValue() * 255); 111 animation_->GetCurrentValue() * 255);
112 #if defined(OS_WIN)
113 SetLayeredWindowAttributes(GetNativeView(), 0, 113 SetLayeredWindowAttributes(GetNativeView(), 0,
114 static_cast<byte>(opacity), LWA_ALPHA); 114 static_cast<byte>(opacity), LWA_ALPHA);
115 contents_->SchedulePaint(); 115 contents_->SchedulePaint();
116 116
117 // Also fade in/out the bubble border window. 117 // Also fade in/out the bubble border window.
118 border_->SetOpacity(opacity); 118 border_->SetOpacity(opacity);
119 border_->border_contents()->SchedulePaint(); 119 border_->border_contents()->SchedulePaint();
120 #else 120 #else
121 NOTIMPLEMENTED(); 121 SetOpacity(opacity);
122 border_contents_->SchedulePaint();
122 #endif 123 #endif
123 } 124 }
124 125
125 Bubble::Bubble() 126 Bubble::Bubble()
126 : 127 :
127 #if defined(OS_WIN) 128 #if defined(OS_WIN)
128 views::NativeWidgetWin(new views::Widget), 129 views::NativeWidgetWin(new views::Widget),
129 #elif defined(TOOLKIT_USES_GTK) 130 #elif defined(TOOLKIT_USES_GTK)
130 views::NativeWidgetGtk(new views::Widget), 131 views::NativeWidgetGtk(new views::Widget),
131 #endif 132 #endif
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 169
169 void Bubble::InitBubble(views::Widget* parent, 170 void Bubble::InitBubble(views::Widget* parent,
170 const gfx::Rect& position_relative_to, 171 const gfx::Rect& position_relative_to,
171 BubbleBorder::ArrowLocation arrow_location, 172 BubbleBorder::ArrowLocation arrow_location,
172 views::View* contents, 173 views::View* contents,
173 BubbleDelegate* delegate) { 174 BubbleDelegate* delegate) {
174 delegate_ = delegate; 175 delegate_ = delegate;
175 position_relative_to_ = position_relative_to; 176 position_relative_to_ = position_relative_to;
176 arrow_location_ = arrow_location; 177 arrow_location_ = arrow_location;
177 contents_ = contents; 178 contents_ = contents;
179 const bool fade_in = delegate_ && delegate_->FadeInOnShow();
178 180
179 // Create the main window. 181 // Create the main window.
180 #if defined(OS_WIN) 182 #if defined(OS_WIN)
181 views::Widget* parent_window = parent->GetTopLevelWidget(); 183 views::Widget* parent_window = parent->GetTopLevelWidget();
182 if (parent_window) 184 if (parent_window)
183 parent_window->DisableInactiveRendering(); 185 parent_window->DisableInactiveRendering();
184 set_window_style(WS_POPUP | WS_CLIPCHILDREN); 186 set_window_style(WS_POPUP | WS_CLIPCHILDREN);
185 int extended_style = WS_EX_TOOLWINDOW; 187 int extended_style = WS_EX_TOOLWINDOW;
186 // During FadeIn we need to turn on the layered window style to deal with 188 // During FadeIn we need to turn on the layered window style to deal with
187 // transparency. This flag needs to be reset after fading in is complete. 189 // transparency. This flag needs to be reset after fading in is complete.
188 bool fade_in = delegate_ && delegate_->FadeInOnShow();
189 if (fade_in) 190 if (fade_in)
190 extended_style |= WS_EX_LAYERED; 191 extended_style |= WS_EX_LAYERED;
191 set_window_ex_style(extended_style); 192 set_window_ex_style(extended_style);
192 193
193 DCHECK(!border_); 194 DCHECK(!border_);
194 border_ = new BorderWidgetWin(); 195 border_ = new BorderWidgetWin();
195 196
196 border_->InitBorderWidgetWin(CreateBorderContents(), parent->GetNativeView()); 197 border_->InitBorderWidgetWin(CreateBorderContents(), parent->GetNativeView());
197 border_->border_contents()->SetBackgroundColor(kBackgroundColor); 198 border_->border_contents()->SetBackgroundColor(kBackgroundColor);
198 199
199 // We make the BorderWidgetWin the owner of the Bubble HWND, so that the 200 // We make the BorderWidgetWin the owner of the Bubble HWND, so that the
200 // latter is displayed on top of the former. 201 // latter is displayed on top of the former.
201 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 202 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
202 params.parent = border_->GetNativeView(); 203 params.parent = border_->GetNativeView();
203 params.native_widget = this; 204 params.native_widget = this;
204 GetWidget()->Init(params); 205 GetWidget()->Init(params);
205 206
206 if (fade_in) { 207 if (fade_in) {
207 border_->SetOpacity(0); 208 border_->SetOpacity(0);
208 GetWidget()->SetOpacity(0); 209 GetWidget()->SetOpacity(0);
209 } 210 }
210 SetWindowText(GetNativeView(), delegate_->accessible_name().c_str()); 211 SetWindowText(GetNativeView(), delegate_->accessible_name().c_str());
211 #elif defined(TOOLKIT_USES_GTK) 212 #elif defined(TOOLKIT_USES_GTK)
212 views::Widget::InitParams params(type_); 213 views::Widget::InitParams params(type_);
213 params.transparent = true; 214 params.transparent = true;
214 params.parent_widget = parent; 215 params.parent_widget = parent;
215 params.native_widget = this; 216 params.native_widget = this;
216 GetWidget()->Init(params); 217 GetWidget()->Init(params);
218 if (fade_in)
219 SetOpacity(0);
217 #if defined(OS_CHROMEOS) 220 #if defined(OS_CHROMEOS)
218 { 221 {
219 vector<int> params; 222 vector<int> params;
220 params.push_back(show_while_screen_is_locked_ ? 1 : 0); 223 params.push_back(show_while_screen_is_locked_ ? 1 : 0);
221 chromeos::WmIpc::instance()->SetWindowType( 224 chromeos::WmIpc::instance()->SetWindowType(
222 GetNativeView(), 225 GetNativeView(),
223 chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, 226 chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE,
224 &params); 227 &params);
225 } 228 }
226 #endif 229 #endif
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 278
276 // Done creating the bubble. 279 // Done creating the bubble.
277 NotificationService::current()->Notify( 280 NotificationService::current()->Notify(
278 chrome::NOTIFICATION_INFO_BUBBLE_CREATED, Source<Bubble>(this), 281 chrome::NOTIFICATION_INFO_BUBBLE_CREATED, Source<Bubble>(this),
279 NotificationService::NoDetails()); 282 NotificationService::NoDetails());
280 283
281 // Show the window. 284 // Show the window.
282 #if defined(OS_WIN) 285 #if defined(OS_WIN)
283 border_->ShowWindow(SW_SHOW); 286 border_->ShowWindow(SW_SHOW);
284 ShowWindow(SW_SHOW); 287 ShowWindow(SW_SHOW);
285 if (fade_in)
286 FadeIn();
287 #elif defined(TOOLKIT_USES_GTK) 288 #elif defined(TOOLKIT_USES_GTK)
288 GetWidget()->Show(); 289 GetWidget()->Show();
289 #endif 290 #endif
291
292 if (fade_in)
293 FadeIn();
290 } 294 }
291 295
292 void Bubble::RegisterEscapeAccelerator() { 296 void Bubble::RegisterEscapeAccelerator() {
293 GetWidget()->GetFocusManager()->RegisterAccelerator( 297 GetWidget()->GetFocusManager()->RegisterAccelerator(
294 views::Accelerator(ui::VKEY_ESCAPE, false, false, false), this); 298 views::Accelerator(ui::VKEY_ESCAPE, false, false, false), this);
295 accelerator_registered_ = true; 299 accelerator_registered_ = true;
296 } 300 }
297 301
298 void Bubble::UnregisterEscapeAccelerator() { 302 void Bubble::UnregisterEscapeAccelerator() {
299 DCHECK(accelerator_registered_); 303 DCHECK(accelerator_registered_);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 animation_->Hide(); 398 animation_->Hide();
395 } 399 }
396 400
397 bool Bubble::AcceleratorPressed(const views::Accelerator& accelerator) { 401 bool Bubble::AcceleratorPressed(const views::Accelerator& accelerator) {
398 if (!delegate_ || delegate_->CloseOnEscape()) { 402 if (!delegate_ || delegate_->CloseOnEscape()) {
399 DoClose(true); 403 DoClose(true);
400 return true; 404 return true;
401 } 405 }
402 return false; 406 return false;
403 } 407 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/setting_level_bubble_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698