Chromium Code Reviews| 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 titlebar and frame for drawing attention under default |
| 25 const int kDrawAttentionR = 0xfa; | 32 // theme. It is also used in non-default theme since attention color is not |
| 26 const int kDrawAttentionG = 0x98; | 33 // defined in the theme. |
| 27 const int kDrawAttentionB = 0x3a; | 34 const SkColor kAttentionBackgroundDefaultColorStart = |
| 28 const float kDrawAttentionRFraction = kDrawAttentionR / 255.0; | 35 SkColorSetRGB(0xff, 0xab, 0x57); |
| 29 const float kDrawAttentionGFraction = kDrawAttentionG / 255.0; | 36 const SkColor kAttentionBackgroundDefaultColorEnd = |
| 30 const float kDrawAttentionBFraction = kDrawAttentionB / 255.0; | 37 SkColorSetRGB(0xff, 0xab, 0x57); |
| 31 | |
| 32 // Markup for title text in draw attention state. Set to color white. | |
| 33 const char* const kDrawAttentionTitleMarkupPrefix = | |
| 34 "<span fgcolor='#ffffff'>"; | |
| 35 const char* const kDrawAttentionTitleMarkupSuffix = "</span>"; | |
| 36 | 38 |
| 37 // Set minimium width for window really small. | 39 // Set minimium width for window really small. |
| 38 const int kMinWindowWidth = 26; | 40 const int kMinWindowWidth = 26; |
| 39 | 41 |
| 42 gfx::Image* CreateGradientImage(SkColor start_color, SkColor end_color) { | |
| 43 // Though the height of titlebar, used for creating gradient, cannot be | |
| 44 // pre-determined, we use a reasonably bigger value that is obtained from | |
| 45 // the experimentation and should work for most cases. | |
| 46 const int gradient_size = 32; | |
| 47 SkShader* shader = gfx::CreateGradientShader( | |
| 48 0, gradient_size, start_color, end_color); | |
| 49 SkPaint paint; | |
| 50 paint.setStyle(SkPaint::kFill_Style); | |
| 51 paint.setAntiAlias(true); | |
| 52 paint.setShader(shader); | |
| 53 shader->unref(); | |
| 54 gfx::Canvas canvas(gfx::Size(1, gradient_size), true); | |
| 55 canvas.DrawRect(gfx::Rect(0, 0, 1, gradient_size), paint); | |
| 56 return new gfx::Image(canvas.ExtractBitmap()); | |
| 57 } | |
| 58 | |
| 59 gfx::Image* GetAttentionBackgroundDefaultImage() { | |
| 60 static gfx::Image* image = NULL; | |
| 61 if (!image) { | |
| 62 image = CreateGradientImage(kAttentionBackgroundDefaultColorStart, | |
| 63 kAttentionBackgroundDefaultColorEnd); | |
| 64 } | |
| 65 return image; | |
| 66 } | |
| 67 | |
| 40 } // namespace | 68 } // namespace |
| 41 | 69 |
| 42 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, | 70 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, |
| 43 const gfx::Rect& bounds) { | 71 const gfx::Rect& bounds) { |
| 44 PanelBrowserWindowGtk* panel_browser_window_gtk = | 72 PanelBrowserWindowGtk* panel_browser_window_gtk = |
| 45 new PanelBrowserWindowGtk(browser, panel, bounds); | 73 new PanelBrowserWindowGtk(browser, panel, bounds); |
| 46 panel_browser_window_gtk->Init(); | 74 panel_browser_window_gtk->Init(); |
| 47 return panel_browser_window_gtk; | 75 return panel_browser_window_gtk; |
| 48 } | 76 } |
| 49 | 77 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 77 // window edge was hit. | 105 // window edge was hit. |
| 78 g_signal_connect(titlebar_widget(), "button-release-event", | 106 g_signal_connect(titlebar_widget(), "button-release-event", |
| 79 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); | 107 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); |
| 80 | 108 |
| 81 registrar_.Add( | 109 registrar_.Add( |
| 82 this, | 110 this, |
| 83 chrome::NOTIFICATION_WINDOW_CLOSED, | 111 chrome::NOTIFICATION_WINDOW_CLOSED, |
| 84 content::Source<GtkWindow>(window())); | 112 content::Source<GtkWindow>(window())); |
| 85 } | 113 } |
| 86 | 114 |
| 115 bool PanelBrowserWindowGtk::ShouldDrawContentDropShadow() const { | |
| 116 return !panel_->IsMinimized(); | |
| 117 } | |
| 118 | |
| 87 BrowserTitlebar* PanelBrowserWindowGtk::CreateBrowserTitlebar() { | 119 BrowserTitlebar* PanelBrowserWindowGtk::CreateBrowserTitlebar() { |
| 88 return new PanelBrowserTitlebarGtk(this, window()); | 120 return new PanelBrowserTitlebarGtk(this, window()); |
| 89 } | 121 } |
| 90 | 122 |
| 123 PanelBrowserTitlebarGtk* PanelBrowserWindowGtk::GetPanelTitlebar() const { | |
| 124 return static_cast<PanelBrowserTitlebarGtk*>(titlebar()); | |
| 125 } | |
| 126 | |
| 127 PanelBrowserWindowGtk::PaintState PanelBrowserWindowGtk::GetPaintState() const { | |
| 128 if (is_drawing_attention_) | |
| 129 return PAINT_FOR_ATTENTION; | |
| 130 return IsActive() ? PAINT_AS_ACTIVE : PAINT_AS_INACTIVE; | |
| 131 } | |
| 132 | |
| 91 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { | 133 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { |
| 92 // Only detect the window edge when panels can be resized by the user. | 134 // 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 | 135 // 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 | 136 // hit the window edge in order to change the cursor to a resize cursor |
| 95 // and to detect when to initiate a resize drag. | 137 // and to detect when to initiate a resize drag. |
| 96 panel::Resizability resizability = panel_->CanResizeByMouse(); | 138 panel::Resizability resizability = panel_->CanResizeByMouse(); |
| 97 if (panel::NOT_RESIZABLE == resizability) | 139 if (panel::NOT_RESIZABLE == resizability) |
| 98 return false; | 140 return false; |
| 99 | 141 |
| 100 if (!BrowserWindowGtk::GetWindowEdge(x, y, edge)) | 142 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); | 231 gtk_window_move(window_, left, top); |
| 190 StartBoundsAnimation(gfx::Rect(left, top, width, height), bounds_); | 232 StartBoundsAnimation(gfx::Rect(left, top, width, height), bounds_); |
| 191 panel_->OnWindowSizeAvailable(); | 233 panel_->OnWindowSizeAvailable(); |
| 192 | 234 |
| 193 content::NotificationService::current()->Notify( | 235 content::NotificationService::current()->Notify( |
| 194 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, | 236 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, |
| 195 content::Source<Panel>(panel_.get()), | 237 content::Source<Panel>(panel_.get()), |
| 196 content::NotificationService::NoDetails()); | 238 content::NotificationService::NoDetails()); |
| 197 } | 239 } |
| 198 | 240 |
| 199 bool PanelBrowserWindowGtk::UseCustomFrame() { | 241 bool PanelBrowserWindowGtk::UseCustomFrame() const { |
| 200 // We always use custom frame for panels. | 242 // We always use custom frame for panels. |
| 201 return TRUE; | 243 return true; |
| 244 } | |
| 245 | |
| 246 bool PanelBrowserWindowGtk::UsingCustomPopupFrame() const { | |
| 247 // We do not draw custom popup frame. | |
| 248 return false; | |
| 202 } | 249 } |
| 203 | 250 |
| 204 void PanelBrowserWindowGtk::DrawPopupFrame(cairo_t* cr, | 251 void PanelBrowserWindowGtk::DrawPopupFrame(cairo_t* cr, |
| 205 GtkWidget* widget, | 252 GtkWidget* widget, |
| 206 GdkEventExpose* event) { | 253 GdkEventExpose* event) { |
| 207 static_cast<PanelBrowserTitlebarGtk*>(titlebar())-> | 254 NOTREACHED(); |
| 208 UpdateMinimizeRestoreButtonVisibility(); | 255 } |
| 209 | 256 |
| 210 BrowserWindowGtk::DrawPopupFrame(cr, widget, event); | 257 const gfx::Image* PanelBrowserWindowGtk::GetThemeFrameImage() const { |
| 258 PaintState paint_state = GetPaintState(); | |
| 259 if (paint_state == PAINT_FOR_ATTENTION) | |
| 260 return GetAttentionBackgroundDefaultImage(); | |
|
Evan Stade
2012/04/30 23:07:21
this function appears to be used regardless of whe
| |
| 211 | 261 |
| 212 if (is_drawing_attention_) | 262 ThemeServiceGtk* theme_provider = ThemeServiceGtk::GetFrom( |
| 213 DrawAttentionFrame(cr, widget, event); | 263 browser()->profile()); |
| 264 if (theme_provider->UsingDefaultTheme()) { | |
| 265 // We choose to use the window frame theme to paint panels for the default | |
| 266 // theme. This is because the default tab theme does not work well for the | |
| 267 // user to recognize active and inactive panels. | |
| 268 return theme_provider->GetImageNamed((paint_state == PAINT_AS_ACTIVE) ? | |
|
Evan Stade
2012/04/30 23:07:21
get rid of unnecessary parens
| |
| 269 IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE); | |
| 270 } | |
| 271 | |
| 272 return theme_provider->GetImageNamed((paint_state == PAINT_AS_ACTIVE) ? | |
|
Evan Stade
2012/04/30 23:07:21
ditto
| |
| 273 IDR_THEME_TOOLBAR : IDR_THEME_TAB_BACKGROUND); | |
| 214 } | 274 } |
| 215 | 275 |
| 216 void PanelBrowserWindowGtk::DrawCustomFrame(cairo_t* cr, | 276 void PanelBrowserWindowGtk::DrawCustomFrame(cairo_t* cr, |
| 217 GtkWidget* widget, | 277 GtkWidget* widget, |
| 218 GdkEventExpose* event) { | 278 GdkEventExpose* event) { |
| 219 static_cast<PanelBrowserTitlebarGtk*>(titlebar())-> | 279 GetPanelTitlebar()->UpdateMinimizeRestoreButtonVisibility(); |
| 220 UpdateMinimizeRestoreButtonVisibility(); | |
| 221 | 280 |
| 222 BrowserWindowGtk::DrawCustomFrame(cr, widget, event); | 281 gfx::CairoCachedSurface* surface = GetThemeFrameImage()->ToCairo(); |
| 223 | 282 |
| 224 if (is_drawing_attention_) | 283 surface->SetSource(cr, widget, 0, 0); |
| 225 DrawAttentionFrame(cr, widget, event); | 284 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); |
| 226 } | 285 cairo_rectangle(cr, event->area.x, event->area.y, |
| 227 | 286 event->area.width, event->area.height); |
| 228 void PanelBrowserWindowGtk::DrawAttentionFrame(cairo_t* cr, | 287 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 } | 288 } |
| 245 | 289 |
| 246 void PanelBrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { | 290 void PanelBrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { |
| 247 bool was_active = IsActive(); | 291 bool was_active = IsActive(); |
| 248 BrowserWindowGtk::ActiveWindowChanged(active_window); | 292 BrowserWindowGtk::ActiveWindowChanged(active_window); |
| 249 bool is_active = IsActive(); | 293 bool is_active = IsActive(); |
| 250 if (!window() || was_active == is_active) // State didn't change. | 294 if (!window() || was_active == is_active) // State didn't change. |
| 251 return; | 295 return; |
| 252 | 296 |
| 253 panel_->OnActiveStateChanged(is_active); | 297 panel_->OnActiveStateChanged(is_active); |
| 254 } | 298 } |
| 255 | 299 |
| 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( | 300 void PanelBrowserWindowGtk::Observe( |
| 278 int type, | 301 int type, |
| 279 const content::NotificationSource& source, | 302 const content::NotificationSource& source, |
| 280 const content::NotificationDetails& details) { | 303 const content::NotificationDetails& details) { |
| 281 switch (type) { | 304 switch (type) { |
| 282 case chrome::NOTIFICATION_WINDOW_CLOSED: | 305 case chrome::NOTIFICATION_WINDOW_CLOSED: |
| 283 // Cleanup. | 306 // Cleanup. |
| 284 if (bounds_animator_.get()) | 307 if (bounds_animator_.get()) |
| 285 bounds_animator_.reset(); | 308 bounds_animator_.reset(); |
| 286 | 309 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 } | 427 } |
| 405 | 428 |
| 406 void PanelBrowserWindowGtk::DrawAttention(bool draw_attention) { | 429 void PanelBrowserWindowGtk::DrawAttention(bool draw_attention) { |
| 407 DCHECK((panel_->attention_mode() & Panel::USE_PANEL_ATTENTION) != 0); | 430 DCHECK((panel_->attention_mode() & Panel::USE_PANEL_ATTENTION) != 0); |
| 408 | 431 |
| 409 if (is_drawing_attention_ == draw_attention) | 432 if (is_drawing_attention_ == draw_attention) |
| 410 return; | 433 return; |
| 411 | 434 |
| 412 is_drawing_attention_ = draw_attention; | 435 is_drawing_attention_ = draw_attention; |
| 413 | 436 |
| 414 GdkRectangle rect = GetTitlebarRectForDrawAttention(); | 437 GetPanelTitlebar()->UpdateTextColor(); |
| 415 gdk_window_invalidate_rect( | 438 InvalidateWindow(); |
| 416 gtk_widget_get_window(GTK_WIDGET(window())), &rect, TRUE); | |
| 417 | |
| 418 UpdateTitleBar(); | |
| 419 | 439 |
| 420 if ((panel_->attention_mode() & Panel::USE_SYSTEM_ATTENTION) != 0) | 440 if ((panel_->attention_mode() & Panel::USE_SYSTEM_ATTENTION) != 0) |
| 421 ::BrowserWindowGtk::FlashFrame(draw_attention); | 441 ::BrowserWindowGtk::FlashFrame(draw_attention); |
| 422 } | 442 } |
| 423 | 443 |
| 424 bool PanelBrowserWindowGtk::IsDrawingAttention() const { | 444 bool PanelBrowserWindowGtk::IsDrawingAttention() const { |
| 425 return is_drawing_attention_; | 445 return is_drawing_attention_; |
| 426 } | 446 } |
| 427 | 447 |
| 428 bool PanelBrowserWindowGtk::PreHandlePanelKeyboardEvent( | 448 bool PanelBrowserWindowGtk::PreHandlePanelKeyboardEvent( |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 442 } | 462 } |
| 443 | 463 |
| 444 Browser* PanelBrowserWindowGtk::GetPanelBrowser() const { | 464 Browser* PanelBrowserWindowGtk::GetPanelBrowser() const { |
| 445 return browser(); | 465 return browser(); |
| 446 } | 466 } |
| 447 | 467 |
| 448 void PanelBrowserWindowGtk::DestroyPanelBrowser() { | 468 void PanelBrowserWindowGtk::DestroyPanelBrowser() { |
| 449 DestroyBrowser(); | 469 DestroyBrowser(); |
| 450 } | 470 } |
| 451 | 471 |
| 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() { | 472 void PanelBrowserWindowGtk::EnsurePanelFullyVisible() { |
| 459 gtk_window_present(window()); | 473 gtk_window_present(window()); |
| 460 } | 474 } |
| 461 | 475 |
| 462 void PanelBrowserWindowGtk::SetPanelAppIconVisibility(bool visible) { | 476 void PanelBrowserWindowGtk::SetPanelAppIconVisibility(bool visible) { |
| 463 return; | 477 return; |
| 464 } | 478 } |
| 465 | 479 |
| 466 void PanelBrowserWindowGtk::SetPanelAlwaysOnTop(bool on_top) { | 480 void PanelBrowserWindowGtk::SetPanelAlwaysOnTop(bool on_top) { |
| 467 gtk_window_set_keep_above(window(), on_top); | 481 gtk_window_set_keep_above(window(), on_top); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 498 | 512 |
| 499 bounds_animator_->Start(); | 513 bounds_animator_->Start(); |
| 500 last_animation_progressed_bounds_ = animation_start_bounds_; | 514 last_animation_progressed_bounds_ = animation_start_bounds_; |
| 501 } | 515 } |
| 502 | 516 |
| 503 bool PanelBrowserWindowGtk::IsAnimatingBounds() const { | 517 bool PanelBrowserWindowGtk::IsAnimatingBounds() const { |
| 504 return bounds_animator_.get() && bounds_animator_->is_animating(); | 518 return bounds_animator_.get() && bounds_animator_->is_animating(); |
| 505 } | 519 } |
| 506 | 520 |
| 507 void PanelBrowserWindowGtk::AnimationEnded(const ui::Animation* animation) { | 521 void PanelBrowserWindowGtk::AnimationEnded(const ui::Animation* animation) { |
| 508 titlebar()->SendEnterNotifyToCloseButtonIfUnderMouse(); | 522 GetPanelTitlebar()->SendEnterNotifyToCloseButtonIfUnderMouse(); |
| 509 panel_->manager()->OnPanelAnimationEnded(panel_.get()); | 523 panel_->manager()->OnPanelAnimationEnded(panel_.get()); |
| 510 } | 524 } |
| 511 | 525 |
| 512 void PanelBrowserWindowGtk::AnimationProgressed( | 526 void PanelBrowserWindowGtk::AnimationProgressed( |
| 513 const ui::Animation* animation) { | 527 const ui::Animation* animation) { |
| 514 DCHECK(!frame_size_.IsEmpty()); | 528 DCHECK(!frame_size_.IsEmpty()); |
| 515 | 529 |
| 516 gfx::Rect new_bounds = bounds_animator_->CurrentValueBetween( | 530 gfx::Rect new_bounds = bounds_animator_->CurrentValueBetween( |
| 517 animation_start_bounds_, bounds_); | 531 animation_start_bounds_, bounds_); |
| 518 | 532 |
| 519 gdk_window_move_resize(gtk_widget_get_window(GTK_WIDGET(window())), | 533 gdk_window_move_resize(gtk_widget_get_window(GTK_WIDGET(window())), |
| 520 new_bounds.x(), new_bounds.y(), | 534 new_bounds.x(), new_bounds.y(), |
| 521 new_bounds.width(), new_bounds.height()); | 535 new_bounds.width(), new_bounds.height()); |
| 522 | 536 |
| 523 last_animation_progressed_bounds_ = new_bounds; | 537 last_animation_progressed_bounds_ = new_bounds; |
| 524 } | 538 } |
| 525 | 539 |
| 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( | 540 gboolean PanelBrowserWindowGtk::OnTitlebarButtonReleaseEvent( |
| 545 GtkWidget* widget, GdkEventButton* event) { | 541 GtkWidget* widget, GdkEventButton* event) { |
| 546 if (event->button != 1) | 542 if (event->button != 1) |
| 547 return TRUE; | 543 return TRUE; |
| 548 | 544 |
| 549 panel_->OnTitlebarClicked((event->state & GDK_CONTROL_MASK) ? | 545 panel_->OnTitlebarClicked((event->state & GDK_CONTROL_MASK) ? |
| 550 panel::APPLY_TO_ALL : panel::NO_MODIFIER); | 546 panel::APPLY_TO_ALL : panel::NO_MODIFIER); |
| 551 return TRUE; | 547 return TRUE; |
| 552 } | 548 } |
| 553 | 549 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 } | 639 } |
| 644 | 640 |
| 645 void NativePanelTestingGtk::FinishDragTitlebar() { | 641 void NativePanelTestingGtk::FinishDragTitlebar() { |
| 646 if (!panel_browser_window_gtk_->drag_helper_.get()) | 642 if (!panel_browser_window_gtk_->drag_helper_.get()) |
| 647 return; | 643 return; |
| 648 | 644 |
| 649 panel_browser_window_gtk_->drag_helper_->EndDrag(false); | 645 panel_browser_window_gtk_->drag_helper_->EndDrag(false); |
| 650 } | 646 } |
| 651 | 647 |
| 652 bool NativePanelTestingGtk::VerifyDrawingAttention() const { | 648 bool NativePanelTestingGtk::VerifyDrawingAttention() const { |
| 653 std::string title; | 649 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 } | 650 } |
| 659 | 651 |
| 660 bool NativePanelTestingGtk::VerifyActiveState(bool is_active) { | 652 bool NativePanelTestingGtk::VerifyActiveState(bool is_active) { |
| 661 // TODO(jianli): to be implemented. http://crbug.com/102737 | 653 // TODO(jianli): to be implemented. http://crbug.com/102737 |
| 662 return false; | 654 return false; |
| 663 } | 655 } |
| 664 | 656 |
| 665 void NativePanelTestingGtk::WaitForWindowCreationToComplete() const { | 657 void NativePanelTestingGtk::WaitForWindowCreationToComplete() const { |
| 666 while (panel_browser_window_gtk_->frame_size_.IsEmpty()) | 658 while (panel_browser_window_gtk_->frame_size_.IsEmpty()) |
| 667 MessageLoopForUI::current()->RunAllPending(); | 659 MessageLoopForUI::current()->RunAllPending(); |
| 668 while (panel_browser_window_gtk_->IsAnimatingBounds()) | 660 while (panel_browser_window_gtk_->IsAnimatingBounds()) |
| 669 MessageLoopForUI::current()->RunAllPending(); | 661 MessageLoopForUI::current()->RunAllPending(); |
| 670 } | 662 } |
| 671 | 663 |
| 672 bool NativePanelTestingGtk::IsWindowSizeKnown() const { | 664 bool NativePanelTestingGtk::IsWindowSizeKnown() const { |
| 673 return !panel_browser_window_gtk_->frame_size_.IsEmpty(); | 665 return !panel_browser_window_gtk_->frame_size_.IsEmpty(); |
| 674 } | 666 } |
| 675 | 667 |
| 676 bool NativePanelTestingGtk::IsAnimatingBounds() const { | 668 bool NativePanelTestingGtk::IsAnimatingBounds() const { |
| 677 return panel_browser_window_gtk_->IsAnimatingBounds(); | 669 return panel_browser_window_gtk_->IsAnimatingBounds(); |
| 678 } | 670 } |
| 679 | 671 |
| 680 bool NativePanelTestingGtk::IsButtonVisible( | 672 bool NativePanelTestingGtk::IsButtonVisible( |
| 681 TitlebarButtonType button_type) const { | 673 TitlebarButtonType button_type) const { |
| 682 PanelBrowserTitlebarGtk* titlebar = static_cast<PanelBrowserTitlebarGtk*>( | 674 PanelBrowserTitlebarGtk* titlebar = |
| 683 panel_browser_window_gtk_->titlebar()); | 675 panel_browser_window_gtk_->GetPanelTitlebar(); |
| 684 CustomDrawButton* button; | 676 CustomDrawButton* button; |
| 685 switch (button_type) { | 677 switch (button_type) { |
| 686 case CLOSE_BUTTON: | 678 case CLOSE_BUTTON: |
| 687 button = titlebar->close_button(); | 679 button = titlebar->close_button(); |
| 688 break; | 680 break; |
| 689 case MINIMIZE_BUTTON: | 681 case MINIMIZE_BUTTON: |
| 690 button = titlebar->minimize_button(); | 682 button = titlebar->minimize_button(); |
| 691 break; | 683 break; |
| 692 case RESTORE_BUTTON: | 684 case RESTORE_BUTTON: |
| 693 button = titlebar->unminimize_button(); | 685 button = titlebar->unminimize_button(); |
| 694 break; | 686 break; |
| 695 default: | 687 default: |
| 696 NOTREACHED(); | 688 NOTREACHED(); |
| 697 return false; | 689 return false; |
| 698 } | 690 } |
| 699 return gtk_widget_get_visible(button->widget()); | 691 return gtk_widget_get_visible(button->widget()); |
| 700 } | 692 } |
| OLD | NEW |