OLD | NEW |
---|---|
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 "chrome/browser/ui/panels/panel_browser_window_gtk.h" | 5 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
9 #include "chrome/browser/ui/gtk/browser_titlebar.h" | 9 #include "chrome/browser/ui/gtk/browser_titlebar.h" |
10 #include "chrome/browser/ui/gtk/custom_button.h" | 10 #include "chrome/browser/ui/gtk/custom_button.h" |
11 #include "chrome/browser/ui/gtk/theme_service_gtk.h" | |
11 #include "chrome/browser/ui/panels/panel.h" | 12 #include "chrome/browser/ui/panels/panel.h" |
12 #include "chrome/browser/ui/panels/panel_bounds_animation.h" | 13 #include "chrome/browser/ui/panels/panel_bounds_animation.h" |
13 #include "chrome/browser/ui/panels/panel_browser_titlebar_gtk.h" | 14 #include "chrome/browser/ui/panels/panel_browser_titlebar_gtk.h" |
14 #include "chrome/browser/ui/panels/panel_drag_gtk.h" | 15 #include "chrome/browser/ui/panels/panel_drag_gtk.h" |
15 #include "chrome/browser/ui/panels/panel_manager.h" | 16 #include "chrome/browser/ui/panels/panel_manager.h" |
16 #include "chrome/browser/ui/panels/panel_strip.h" | 17 #include "chrome/browser/ui/panels/panel_strip.h" |
17 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
18 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
20 #include "grit/theme_resources_standard.h" | |
21 #include "third_party/skia/include/core/SkShader.h" | |
22 #include "ui/gfx/canvas.h" | |
23 #include "ui/gfx/image/cairo_cached_surface.h" | |
24 #include "ui/gfx/image/image.h" | |
25 #include "ui/gfx/skia_util.h" | |
19 | 26 |
20 using content::WebContents; | 27 using content::WebContents; |
21 | 28 |
22 namespace { | 29 namespace { |
23 | 30 |
24 // RGB values for titlebar in draw attention state. A shade of orange. | 31 // Colors used to draw active titlebar and frame under default theme. |
25 const int kDrawAttentionR = 0xfa; | 32 const SkColor kActiveBackgroundDefaultColorStart = |
26 const int kDrawAttentionG = 0x98; | 33 SkColorSetRGB(0xf0, 0xf8, 0xfa); |
27 const int kDrawAttentionB = 0x3a; | 34 const SkColor kActiveBackgroundDefaultColorEnd = |
28 const float kDrawAttentionRFraction = kDrawAttentionR / 255.0; | 35 SkColorSetRGB(0xc1, 0xd2, 0xdd); |
29 const float kDrawAttentionGFraction = kDrawAttentionG / 255.0; | |
30 const float kDrawAttentionBFraction = kDrawAttentionB / 255.0; | |
31 | 36 |
32 // Markup for title text in draw attention state. Set to color white. | 37 // Colors used to draw inactive titlebar and frame under default theme. |
33 const char* const kDrawAttentionTitleMarkupPrefix = | 38 const SkColor kInactiveBackgroundDefaultColorStart = SK_ColorWHITE; |
34 "<span fgcolor='#ffffff'>"; | 39 const SkColor kInactiveBackgroundDefaultColorEnd = |
35 const char* const kDrawAttentionTitleMarkupSuffix = "</span>"; | 40 SkColorSetRGB(0xe7, 0xed, 0xf1); |
41 | |
42 // Colors used to draw titlebar and frame for drawing attention under default | |
43 // theme. It is also used in non-default theme since attention color is not | |
44 // defined in the theme. | |
45 const SkColor kAttentionBackgroundDefaultColorStart = | |
46 SkColorSetRGB(0xff, 0xab, 0x57); | |
47 const SkColor kAttentionBackgroundDefaultColorEnd = | |
48 SkColorSetRGB(0xff, 0xab, 0x57); | |
36 | 49 |
37 // Set minimium width for window really small. | 50 // Set minimium width for window really small. |
38 const int kMinWindowWidth = 26; | 51 const int kMinWindowWidth = 26; |
39 | 52 |
53 gfx::Image* CreateGradientImage(SkColor start_color, SkColor end_color) { | |
54 // Though the height of titlebar, used for creating gradient, cannot be | |
55 // pre-determined, we use a reasonablly bigger value that is obtained from | |
56 // the experiment and should work for most of cases. | |
jennb
2012/04/27 20:37:24
s/the experiment/experimentation
jianli
2012/04/27 20:44:24
Done.
| |
57 const int gradient_size = 32; | |
58 SkShader* shader = gfx::CreateGradientShader( | |
59 0, gradient_size, start_color, end_color); | |
60 SkPaint paint; | |
61 paint.setStyle(SkPaint::kFill_Style); | |
62 paint.setAntiAlias(true); | |
63 paint.setShader(shader); | |
64 shader->unref(); | |
65 gfx::Canvas canvas(gfx::Size(1, gradient_size), true); | |
66 canvas.DrawRect(gfx::Rect(0, 0, 1, gradient_size), paint); | |
67 return new gfx::Image(canvas.ExtractBitmap()); | |
68 } | |
69 | |
70 gfx::Image* GetActiveBackgroundDefaultImage() { | |
71 static gfx::Image* image = NULL; | |
72 if (!image) { | |
73 image = CreateGradientImage(kActiveBackgroundDefaultColorStart, | |
74 kActiveBackgroundDefaultColorEnd); | |
75 } | |
76 return image; | |
77 } | |
78 | |
79 gfx::Image* GetInactiveBackgroundDefaultImage() { | |
80 static gfx::Image* image = NULL; | |
81 if (!image) { | |
82 image = CreateGradientImage(kInactiveBackgroundDefaultColorStart, | |
83 kInactiveBackgroundDefaultColorEnd); | |
84 } | |
85 return image; | |
86 } | |
87 | |
88 gfx::Image* GetAttentionBackgroundDefaultImage() { | |
89 static gfx::Image* image = NULL; | |
90 if (!image) { | |
91 image = CreateGradientImage(kAttentionBackgroundDefaultColorStart, | |
92 kAttentionBackgroundDefaultColorEnd); | |
93 } | |
94 return image; | |
95 } | |
96 | |
40 } // namespace | 97 } // namespace |
41 | 98 |
42 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, | 99 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, |
43 const gfx::Rect& bounds) { | 100 const gfx::Rect& bounds) { |
44 PanelBrowserWindowGtk* panel_browser_window_gtk = | 101 PanelBrowserWindowGtk* panel_browser_window_gtk = |
45 new PanelBrowserWindowGtk(browser, panel, bounds); | 102 new PanelBrowserWindowGtk(browser, panel, bounds); |
46 panel_browser_window_gtk->Init(); | 103 panel_browser_window_gtk->Init(); |
47 return panel_browser_window_gtk; | 104 return panel_browser_window_gtk; |
48 } | 105 } |
49 | 106 |
(...skipping 27 matching lines...) Expand all Loading... | |
77 // window edge was hit. | 134 // window edge was hit. |
78 g_signal_connect(titlebar_widget(), "button-release-event", | 135 g_signal_connect(titlebar_widget(), "button-release-event", |
79 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); | 136 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); |
80 | 137 |
81 registrar_.Add( | 138 registrar_.Add( |
82 this, | 139 this, |
83 chrome::NOTIFICATION_WINDOW_CLOSED, | 140 chrome::NOTIFICATION_WINDOW_CLOSED, |
84 content::Source<GtkWindow>(window())); | 141 content::Source<GtkWindow>(window())); |
85 } | 142 } |
86 | 143 |
144 bool PanelBrowserWindowGtk::ShouldDrawContentDropShadow() const { | |
145 return panel_->IsMinimized(); | |
jennb
2012/04/27 20:37:24
!IsMinimized ?
jianli
2012/04/27 20:44:24
Done.
| |
146 } | |
147 | |
87 BrowserTitlebar* PanelBrowserWindowGtk::CreateBrowserTitlebar() { | 148 BrowserTitlebar* PanelBrowserWindowGtk::CreateBrowserTitlebar() { |
88 return new PanelBrowserTitlebarGtk(this, window()); | 149 return new PanelBrowserTitlebarGtk(this, window()); |
89 } | 150 } |
90 | 151 |
152 PanelBrowserTitlebarGtk* PanelBrowserWindowGtk::GetPanelTitlebar() const { | |
153 return static_cast<PanelBrowserTitlebarGtk*>(titlebar()); | |
154 } | |
155 | |
156 PanelBrowserWindowGtk::PaintState PanelBrowserWindowGtk::GetPaintState() const { | |
157 if (is_drawing_attention_) | |
158 return PAINT_FOR_ATTENTION; | |
159 return IsActive() ? PAINT_AS_ACTIVE : PAINT_AS_INACTIVE; | |
160 } | |
161 | |
91 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { | 162 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { |
92 // Only detect the window edge when panels can be resized by the user. | 163 // Only detect the window edge when panels can be resized by the user. |
93 // This method is used by the base class to detect when the cursor has | 164 // This method is used by the base class to detect when the cursor has |
94 // hit the window edge in order to change the cursor to a resize cursor | 165 // hit the window edge in order to change the cursor to a resize cursor |
95 // and to detect when to initiate a resize drag. | 166 // and to detect when to initiate a resize drag. |
96 panel::Resizability resizability = panel_->CanResizeByMouse(); | 167 panel::Resizability resizability = panel_->CanResizeByMouse(); |
97 if (panel::NOT_RESIZABLE == resizability) | 168 if (panel::NOT_RESIZABLE == resizability) |
98 return false; | 169 return false; |
99 | 170 |
100 if (!BrowserWindowGtk::GetWindowEdge(x, y, edge)) | 171 if (!BrowserWindowGtk::GetWindowEdge(x, y, edge)) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 gtk_window_move(window_, left, top); | 260 gtk_window_move(window_, left, top); |
190 StartBoundsAnimation(gfx::Rect(left, top, width, height), bounds_); | 261 StartBoundsAnimation(gfx::Rect(left, top, width, height), bounds_); |
191 panel_->OnWindowSizeAvailable(); | 262 panel_->OnWindowSizeAvailable(); |
192 | 263 |
193 content::NotificationService::current()->Notify( | 264 content::NotificationService::current()->Notify( |
194 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, | 265 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, |
195 content::Source<Panel>(panel_.get()), | 266 content::Source<Panel>(panel_.get()), |
196 content::NotificationService::NoDetails()); | 267 content::NotificationService::NoDetails()); |
197 } | 268 } |
198 | 269 |
199 bool PanelBrowserWindowGtk::UseCustomFrame() { | 270 bool PanelBrowserWindowGtk::UseCustomFrame() const { |
200 // We always use custom frame for panels. | 271 // We always use custom frame for panels. |
201 return TRUE; | 272 return true; |
273 } | |
274 | |
275 bool PanelBrowserWindowGtk::UsingCustomPopupFrame() const { | |
276 // We do not draw custom popup frame. | |
277 return false; | |
202 } | 278 } |
203 | 279 |
204 void PanelBrowserWindowGtk::DrawPopupFrame(cairo_t* cr, | 280 void PanelBrowserWindowGtk::DrawPopupFrame(cairo_t* cr, |
205 GtkWidget* widget, | 281 GtkWidget* widget, |
206 GdkEventExpose* event) { | 282 GdkEventExpose* event) { |
207 static_cast<PanelBrowserTitlebarGtk*>(titlebar())-> | 283 NOTREACHED(); |
208 UpdateMinimizeRestoreButtonVisibility(); | 284 } |
209 | 285 |
210 BrowserWindowGtk::DrawPopupFrame(cr, widget, event); | 286 const gfx::Image* PanelBrowserWindowGtk::GetFrameTheme() const { |
287 PaintState paint_state = GetPaintState(); | |
288 if (paint_state == PAINT_FOR_ATTENTION) | |
289 return GetAttentionBackgroundDefaultImage(); | |
211 | 290 |
212 if (is_drawing_attention_) | 291 ThemeServiceGtk* theme_provider = ThemeServiceGtk::GetFrom( |
213 DrawAttentionFrame(cr, widget, event); | 292 browser()->profile()); |
293 if (theme_provider->UsingDefaultTheme()) { | |
294 return (paint_state == PAINT_AS_ACTIVE) ? | |
295 GetActiveBackgroundDefaultImage(): GetInactiveBackgroundDefaultImage(); | |
296 } | |
297 | |
298 return theme_provider->GetImageNamed((paint_state == PAINT_AS_ACTIVE) ? | |
299 IDR_THEME_TOOLBAR : IDR_THEME_TAB_BACKGROUND); | |
214 } | 300 } |
215 | 301 |
216 void PanelBrowserWindowGtk::DrawCustomFrame(cairo_t* cr, | 302 void PanelBrowserWindowGtk::DrawCustomFrame(cairo_t* cr, |
217 GtkWidget* widget, | 303 GtkWidget* widget, |
218 GdkEventExpose* event) { | 304 GdkEventExpose* event) { |
219 static_cast<PanelBrowserTitlebarGtk*>(titlebar())-> | 305 GetPanelTitlebar()->UpdateMinimizeRestoreButtonVisibility(); |
220 UpdateMinimizeRestoreButtonVisibility(); | |
221 | 306 |
222 BrowserWindowGtk::DrawCustomFrame(cr, widget, event); | 307 gfx::CairoCachedSurface* surface = GetFrameTheme()->ToCairo(); |
223 | 308 |
224 if (is_drawing_attention_) | 309 surface->SetSource(cr, widget, 0, 0); |
225 DrawAttentionFrame(cr, widget, event); | 310 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); |
226 } | 311 cairo_rectangle(cr, event->area.x, event->area.y, |
227 | 312 event->area.width, event->area.height); |
228 void PanelBrowserWindowGtk::DrawAttentionFrame(cairo_t* cr, | 313 cairo_fill(cr); |
229 GtkWidget* widget, | |
230 GdkEventExpose* event) { | |
231 cairo_set_source_rgb(cr, kDrawAttentionRFraction, | |
232 kDrawAttentionGFraction, | |
233 kDrawAttentionBFraction); | |
234 | |
235 GdkRectangle dest_rectangle = GetTitlebarRectForDrawAttention(); | |
236 GdkRegion* dest_region = gdk_region_rectangle(&dest_rectangle); | |
237 | |
238 gdk_region_intersect(dest_region, event->region); | |
239 gdk_cairo_region(cr, dest_region); | |
240 | |
241 cairo_clip(cr); | |
242 cairo_paint(cr); | |
243 gdk_region_destroy(dest_region); | |
244 } | 314 } |
245 | 315 |
246 void PanelBrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { | 316 void PanelBrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { |
247 bool was_active = IsActive(); | 317 bool was_active = IsActive(); |
248 BrowserWindowGtk::ActiveWindowChanged(active_window); | 318 BrowserWindowGtk::ActiveWindowChanged(active_window); |
249 bool is_active = IsActive(); | 319 bool is_active = IsActive(); |
250 if (!window() || was_active == is_active) // State didn't change. | 320 if (!window() || was_active == is_active) // State didn't change. |
251 return; | 321 return; |
252 | 322 |
253 panel_->OnActiveStateChanged(is_active); | 323 panel_->OnActiveStateChanged(is_active); |
254 } | 324 } |
255 | 325 |
256 BrowserWindowGtk::TitleDecoration PanelBrowserWindowGtk::GetWindowTitle( | |
257 std::string* title) const { | |
258 if (is_drawing_attention_) { | |
259 std::string title_original; | |
260 BrowserWindowGtk::TitleDecoration title_decoration = | |
261 BrowserWindowGtk::GetWindowTitle(&title_original); | |
262 DCHECK_EQ(BrowserWindowGtk::PLAIN_TEXT, title_decoration); | |
263 gchar* title_escaped = g_markup_escape_text(title_original.c_str(), -1); | |
264 gchar* title_with_markup = g_strconcat(kDrawAttentionTitleMarkupPrefix, | |
265 title_escaped, | |
266 kDrawAttentionTitleMarkupSuffix, | |
267 NULL); | |
268 *title = title_with_markup; | |
269 g_free(title_escaped); | |
270 g_free(title_with_markup); | |
271 return BrowserWindowGtk::PANGO_MARKUP; | |
272 } else { | |
273 return BrowserWindowGtk::GetWindowTitle(title); | |
274 } | |
275 } | |
276 | |
277 void PanelBrowserWindowGtk::Observe( | 326 void PanelBrowserWindowGtk::Observe( |
278 int type, | 327 int type, |
279 const content::NotificationSource& source, | 328 const content::NotificationSource& source, |
280 const content::NotificationDetails& details) { | 329 const content::NotificationDetails& details) { |
281 switch (type) { | 330 switch (type) { |
282 case chrome::NOTIFICATION_WINDOW_CLOSED: | 331 case chrome::NOTIFICATION_WINDOW_CLOSED: |
283 // Cleanup. | 332 // Cleanup. |
284 if (bounds_animator_.get()) | 333 if (bounds_animator_.get()) |
285 bounds_animator_.reset(); | 334 bounds_animator_.reset(); |
286 | 335 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 } | 453 } |
405 | 454 |
406 void PanelBrowserWindowGtk::DrawAttention(bool draw_attention) { | 455 void PanelBrowserWindowGtk::DrawAttention(bool draw_attention) { |
407 DCHECK((panel_->attention_mode() & Panel::USE_PANEL_ATTENTION) != 0); | 456 DCHECK((panel_->attention_mode() & Panel::USE_PANEL_ATTENTION) != 0); |
408 | 457 |
409 if (is_drawing_attention_ == draw_attention) | 458 if (is_drawing_attention_ == draw_attention) |
410 return; | 459 return; |
411 | 460 |
412 is_drawing_attention_ = draw_attention; | 461 is_drawing_attention_ = draw_attention; |
413 | 462 |
414 GdkRectangle rect = GetTitlebarRectForDrawAttention(); | 463 GetPanelTitlebar()->UpdateTextColor(); |
415 gdk_window_invalidate_rect( | 464 InvalidateWindow(); |
416 gtk_widget_get_window(GTK_WIDGET(window())), &rect, TRUE); | |
417 | |
418 UpdateTitleBar(); | |
419 | 465 |
420 if ((panel_->attention_mode() & Panel::USE_SYSTEM_ATTENTION) != 0) | 466 if ((panel_->attention_mode() & Panel::USE_SYSTEM_ATTENTION) != 0) |
421 ::BrowserWindowGtk::FlashFrame(draw_attention); | 467 ::BrowserWindowGtk::FlashFrame(draw_attention); |
422 } | 468 } |
423 | 469 |
424 bool PanelBrowserWindowGtk::IsDrawingAttention() const { | 470 bool PanelBrowserWindowGtk::IsDrawingAttention() const { |
425 return is_drawing_attention_; | 471 return is_drawing_attention_; |
426 } | 472 } |
427 | 473 |
428 bool PanelBrowserWindowGtk::PreHandlePanelKeyboardEvent( | 474 bool PanelBrowserWindowGtk::PreHandlePanelKeyboardEvent( |
(...skipping 13 matching lines...) Expand all Loading... | |
442 } | 488 } |
443 | 489 |
444 Browser* PanelBrowserWindowGtk::GetPanelBrowser() const { | 490 Browser* PanelBrowserWindowGtk::GetPanelBrowser() const { |
445 return browser(); | 491 return browser(); |
446 } | 492 } |
447 | 493 |
448 void PanelBrowserWindowGtk::DestroyPanelBrowser() { | 494 void PanelBrowserWindowGtk::DestroyPanelBrowser() { |
449 DestroyBrowser(); | 495 DestroyBrowser(); |
450 } | 496 } |
451 | 497 |
452 gfx::Size PanelBrowserWindowGtk::IconOnlySize() const { | |
453 GtkAllocation allocation; | |
454 gtk_widget_get_allocation(titlebar_widget(), &allocation); | |
455 return gfx::Size(titlebar()->IconOnlyWidth(), allocation.height); | |
456 } | |
457 | |
458 void PanelBrowserWindowGtk::EnsurePanelFullyVisible() { | 498 void PanelBrowserWindowGtk::EnsurePanelFullyVisible() { |
459 gtk_window_present(window()); | 499 gtk_window_present(window()); |
460 } | 500 } |
461 | 501 |
462 void PanelBrowserWindowGtk::SetPanelAppIconVisibility(bool visible) { | 502 void PanelBrowserWindowGtk::SetPanelAppIconVisibility(bool visible) { |
463 return; | 503 return; |
464 } | 504 } |
465 | 505 |
466 void PanelBrowserWindowGtk::SetPanelAlwaysOnTop(bool on_top) { | 506 void PanelBrowserWindowGtk::SetPanelAlwaysOnTop(bool on_top) { |
467 gtk_window_set_keep_above(window(), on_top); | 507 gtk_window_set_keep_above(window(), on_top); |
(...skipping 30 matching lines...) Expand all Loading... | |
498 | 538 |
499 bounds_animator_->Start(); | 539 bounds_animator_->Start(); |
500 last_animation_progressed_bounds_ = animation_start_bounds_; | 540 last_animation_progressed_bounds_ = animation_start_bounds_; |
501 } | 541 } |
502 | 542 |
503 bool PanelBrowserWindowGtk::IsAnimatingBounds() const { | 543 bool PanelBrowserWindowGtk::IsAnimatingBounds() const { |
504 return bounds_animator_.get() && bounds_animator_->is_animating(); | 544 return bounds_animator_.get() && bounds_animator_->is_animating(); |
505 } | 545 } |
506 | 546 |
507 void PanelBrowserWindowGtk::AnimationEnded(const ui::Animation* animation) { | 547 void PanelBrowserWindowGtk::AnimationEnded(const ui::Animation* animation) { |
508 titlebar()->SendEnterNotifyToCloseButtonIfUnderMouse(); | 548 GetPanelTitlebar()->SendEnterNotifyToCloseButtonIfUnderMouse(); |
509 panel_->manager()->OnPanelAnimationEnded(panel_.get()); | 549 panel_->manager()->OnPanelAnimationEnded(panel_.get()); |
510 } | 550 } |
511 | 551 |
512 void PanelBrowserWindowGtk::AnimationProgressed( | 552 void PanelBrowserWindowGtk::AnimationProgressed( |
513 const ui::Animation* animation) { | 553 const ui::Animation* animation) { |
514 DCHECK(!frame_size_.IsEmpty()); | 554 DCHECK(!frame_size_.IsEmpty()); |
515 | 555 |
516 gfx::Rect new_bounds = bounds_animator_->CurrentValueBetween( | 556 gfx::Rect new_bounds = bounds_animator_->CurrentValueBetween( |
517 animation_start_bounds_, bounds_); | 557 animation_start_bounds_, bounds_); |
518 | 558 |
519 gdk_window_move_resize(gtk_widget_get_window(GTK_WIDGET(window())), | 559 gdk_window_move_resize(gtk_widget_get_window(GTK_WIDGET(window())), |
520 new_bounds.x(), new_bounds.y(), | 560 new_bounds.x(), new_bounds.y(), |
521 new_bounds.width(), new_bounds.height()); | 561 new_bounds.width(), new_bounds.height()); |
522 | 562 |
523 last_animation_progressed_bounds_ = new_bounds; | 563 last_animation_progressed_bounds_ = new_bounds; |
524 } | 564 } |
525 | 565 |
526 GdkRectangle PanelBrowserWindowGtk::GetTitlebarRectForDrawAttention() const { | |
527 GdkRectangle rect; | |
528 rect.x = 0; | |
529 rect.y = 0; | |
530 // We get the window width and not the titlebar_widget() width because we'd | |
531 // like for the window borders on either side of the title bar to be the same | |
532 // color. | |
533 GtkAllocation window_allocation; | |
534 gtk_widget_get_allocation(GTK_WIDGET(window()), &window_allocation); | |
535 rect.width = window_allocation.width; | |
536 | |
537 GtkAllocation titlebar_allocation; | |
538 gtk_widget_get_allocation(titlebar_widget(), &titlebar_allocation); | |
539 rect.height = titlebar_allocation.height; | |
540 | |
541 return rect; | |
542 } | |
543 | |
544 gboolean PanelBrowserWindowGtk::OnTitlebarButtonReleaseEvent( | 566 gboolean PanelBrowserWindowGtk::OnTitlebarButtonReleaseEvent( |
545 GtkWidget* widget, GdkEventButton* event) { | 567 GtkWidget* widget, GdkEventButton* event) { |
546 if (event->button != 1) | 568 if (event->button != 1) |
547 return TRUE; | 569 return TRUE; |
548 | 570 |
549 panel_->OnTitlebarClicked((event->state & GDK_CONTROL_MASK) ? | 571 panel_->OnTitlebarClicked((event->state & GDK_CONTROL_MASK) ? |
550 panel::APPLY_TO_ALL : panel::NO_MODIFIER); | 572 panel::APPLY_TO_ALL : panel::NO_MODIFIER); |
551 return TRUE; | 573 return TRUE; |
552 } | 574 } |
553 | 575 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
643 } | 665 } |
644 | 666 |
645 void NativePanelTestingGtk::FinishDragTitlebar() { | 667 void NativePanelTestingGtk::FinishDragTitlebar() { |
646 if (!panel_browser_window_gtk_->drag_helper_.get()) | 668 if (!panel_browser_window_gtk_->drag_helper_.get()) |
647 return; | 669 return; |
648 | 670 |
649 panel_browser_window_gtk_->drag_helper_->EndDrag(false); | 671 panel_browser_window_gtk_->drag_helper_->EndDrag(false); |
650 } | 672 } |
651 | 673 |
652 bool NativePanelTestingGtk::VerifyDrawingAttention() const { | 674 bool NativePanelTestingGtk::VerifyDrawingAttention() const { |
653 std::string title; | 675 return panel_browser_window_gtk_->IsDrawingAttention(); |
654 BrowserWindowGtk::TitleDecoration decoration = | |
655 panel_browser_window_gtk_->GetWindowTitle(&title); | |
656 return panel_browser_window_gtk_->IsDrawingAttention() && | |
657 decoration == BrowserWindowGtk::PANGO_MARKUP; | |
658 } | 676 } |
659 | 677 |
660 bool NativePanelTestingGtk::VerifyActiveState(bool is_active) { | 678 bool NativePanelTestingGtk::VerifyActiveState(bool is_active) { |
661 // TODO(jianli): to be implemented. http://crbug.com/102737 | 679 // TODO(jianli): to be implemented. http://crbug.com/102737 |
662 return false; | 680 return false; |
663 } | 681 } |
664 | 682 |
665 void NativePanelTestingGtk::WaitForWindowCreationToComplete() const { | 683 void NativePanelTestingGtk::WaitForWindowCreationToComplete() const { |
666 while (panel_browser_window_gtk_->frame_size_.IsEmpty()) | 684 while (panel_browser_window_gtk_->frame_size_.IsEmpty()) |
667 MessageLoopForUI::current()->RunAllPending(); | 685 MessageLoopForUI::current()->RunAllPending(); |
668 while (panel_browser_window_gtk_->IsAnimatingBounds()) | 686 while (panel_browser_window_gtk_->IsAnimatingBounds()) |
669 MessageLoopForUI::current()->RunAllPending(); | 687 MessageLoopForUI::current()->RunAllPending(); |
670 } | 688 } |
671 | 689 |
672 bool NativePanelTestingGtk::IsWindowSizeKnown() const { | 690 bool NativePanelTestingGtk::IsWindowSizeKnown() const { |
673 return !panel_browser_window_gtk_->frame_size_.IsEmpty(); | 691 return !panel_browser_window_gtk_->frame_size_.IsEmpty(); |
674 } | 692 } |
675 | 693 |
676 bool NativePanelTestingGtk::IsAnimatingBounds() const { | 694 bool NativePanelTestingGtk::IsAnimatingBounds() const { |
677 return panel_browser_window_gtk_->IsAnimatingBounds(); | 695 return panel_browser_window_gtk_->IsAnimatingBounds(); |
678 } | 696 } |
679 | 697 |
680 bool NativePanelTestingGtk::IsButtonVisible( | 698 bool NativePanelTestingGtk::IsButtonVisible( |
681 TitlebarButtonType button_type) const { | 699 TitlebarButtonType button_type) const { |
682 PanelBrowserTitlebarGtk* titlebar = static_cast<PanelBrowserTitlebarGtk*>( | 700 PanelBrowserTitlebarGtk* titlebar = |
683 panel_browser_window_gtk_->titlebar()); | 701 panel_browser_window_gtk_->GetPanelTitlebar(); |
684 CustomDrawButton* button; | 702 CustomDrawButton* button; |
685 switch (button_type) { | 703 switch (button_type) { |
686 case CLOSE_BUTTON: | 704 case CLOSE_BUTTON: |
687 button = titlebar->close_button(); | 705 button = titlebar->close_button(); |
688 break; | 706 break; |
689 case MINIMIZE_BUTTON: | 707 case MINIMIZE_BUTTON: |
690 button = titlebar->minimize_button(); | 708 button = titlebar->minimize_button(); |
691 break; | 709 break; |
692 case RESTORE_BUTTON: | 710 case RESTORE_BUTTON: |
693 button = titlebar->unminimize_button(); | 711 button = titlebar->unminimize_button(); |
694 break; | 712 break; |
695 default: | 713 default: |
696 NOTREACHED(); | 714 NOTREACHED(); |
697 return false; | 715 return false; |
698 } | 716 } |
699 return gtk_widget_get_visible(button->widget()); | 717 return gtk_widget_get_visible(button->widget()); |
700 } | 718 } |
OLD | NEW |