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/panels/panel.h" | 10 #include "chrome/browser/ui/panels/panel.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace { | 21 namespace { |
22 | 22 |
23 // RGB values for titlebar in draw attention state. A shade of orange. | 23 // RGB values for titlebar in draw attention state. A shade of orange. |
24 const int kDrawAttentionR = 0xfa; | 24 const int kDrawAttentionR = 0xfa; |
25 const int kDrawAttentionG = 0x98; | 25 const int kDrawAttentionG = 0x98; |
26 const int kDrawAttentionB = 0x3a; | 26 const int kDrawAttentionB = 0x3a; |
27 const float kDrawAttentionRFraction = kDrawAttentionR / 255.0; | 27 const float kDrawAttentionRFraction = kDrawAttentionR / 255.0; |
28 const float kDrawAttentionGFraction = kDrawAttentionG / 255.0; | 28 const float kDrawAttentionGFraction = kDrawAttentionG / 255.0; |
29 const float kDrawAttentionBFraction = kDrawAttentionB / 255.0; | 29 const float kDrawAttentionBFraction = kDrawAttentionB / 255.0; |
30 | 30 |
31 // Delay before click on a titlebar is allowed to minimize the panel after | |
32 // the 'draw attention' mode has been cleared. | |
33 const int kSuspendMinimizeOnClickIntervalMs = 500; | |
34 | |
35 // Markup for title text in draw attention state. Set to color white. | 31 // Markup for title text in draw attention state. Set to color white. |
36 const char* const kDrawAttentionTitleMarkupPrefix = | 32 const char* const kDrawAttentionTitleMarkupPrefix = |
37 "<span fgcolor='#ffffff'>"; | 33 "<span fgcolor='#ffffff'>"; |
38 const char* const kDrawAttentionTitleMarkupSuffix = "</span>"; | 34 const char* const kDrawAttentionTitleMarkupSuffix = "</span>"; |
39 | 35 |
40 // Set minimium width for window really small. | 36 // Set minimium width for window really small. |
41 const int kMinWindowWidth = 26; | 37 const int kMinWindowWidth = 26; |
42 | 38 |
43 } // namespace | 39 } // namespace |
44 | 40 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 gdk_cairo_region(cr, dest_region); | 236 gdk_cairo_region(cr, dest_region); |
241 | 237 |
242 cairo_clip(cr); | 238 cairo_clip(cr); |
243 cairo_paint(cr); | 239 cairo_paint(cr); |
244 gdk_region_destroy(dest_region); | 240 gdk_region_destroy(dest_region); |
245 } | 241 } |
246 | 242 |
247 void PanelBrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { | 243 void PanelBrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { |
248 bool was_active = IsActive(); | 244 bool was_active = IsActive(); |
249 BrowserWindowGtk::ActiveWindowChanged(active_window); | 245 BrowserWindowGtk::ActiveWindowChanged(active_window); |
250 if (!window() || was_active == IsActive()) // State didn't change. | 246 bool is_active = IsActive(); |
| 247 if (!window() || was_active == is_active) // State didn't change. |
251 return; | 248 return; |
252 | 249 |
253 content::NotificationService::current()->Notify( | 250 panel_->OnActiveStateChanged(is_active); |
254 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, | |
255 content::Source<Panel>(panel_.get()), | |
256 content::NotificationService::NoDetails()); | |
257 panel_->OnActiveStateChanged(); | |
258 } | 251 } |
259 | 252 |
260 BrowserWindowGtk::TitleDecoration PanelBrowserWindowGtk::GetWindowTitle( | 253 BrowserWindowGtk::TitleDecoration PanelBrowserWindowGtk::GetWindowTitle( |
261 std::string* title) const { | 254 std::string* title) const { |
262 if (is_drawing_attention_) { | 255 if (is_drawing_attention_) { |
263 std::string title_original; | 256 std::string title_original; |
264 BrowserWindowGtk::TitleDecoration title_decoration = | 257 BrowserWindowGtk::TitleDecoration title_decoration = |
265 BrowserWindowGtk::GetWindowTitle(&title_original); | 258 BrowserWindowGtk::GetWindowTitle(&title_original); |
266 DCHECK_EQ(BrowserWindowGtk::PLAIN_TEXT, title_decoration); | 259 DCHECK_EQ(BrowserWindowGtk::PLAIN_TEXT, title_decoration); |
267 gchar* title_escaped = g_markup_escape_text(title_original.c_str(), -1); | 260 gchar* title_escaped = g_markup_escape_text(title_original.c_str(), -1); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 rect.height = titlebar_allocation.height; | 561 rect.height = titlebar_allocation.height; |
569 | 562 |
570 return rect; | 563 return rect; |
571 } | 564 } |
572 | 565 |
573 gboolean PanelBrowserWindowGtk::OnTitlebarButtonReleaseEvent( | 566 gboolean PanelBrowserWindowGtk::OnTitlebarButtonReleaseEvent( |
574 GtkWidget* widget, GdkEventButton* event) { | 567 GtkWidget* widget, GdkEventButton* event) { |
575 if (event->button != 1) | 568 if (event->button != 1) |
576 return TRUE; | 569 return TRUE; |
577 | 570 |
578 if (event->state & GDK_CONTROL_MASK) { | 571 panel_->OnTitlebarClicked((event->state & GDK_CONTROL_MASK) ? |
579 panel_->OnTitlebarClicked(panel::APPLY_TO_ALL); | 572 panel::APPLY_TO_ALL : panel::NO_MODIFIER); |
580 return TRUE; | |
581 } | |
582 | |
583 // TODO(jennb): Move remaining titlebar click handling out of here. | |
584 // (http://crbug.com/118431) | |
585 PanelStrip* panel_strip = panel_->panel_strip(); | |
586 if (!panel_strip) | |
587 return TRUE; | |
588 | |
589 if (panel_strip->type() == PanelStrip::DOCKED && | |
590 panel_->expansion_state() == Panel::EXPANDED) { | |
591 if (base::Time::Now() < disableMinimizeUntilTime_) | |
592 return TRUE; | |
593 | |
594 panel_->SetExpansionState(Panel::MINIMIZED); | |
595 } else { | |
596 panel_->Activate(); | |
597 } | |
598 | |
599 return TRUE; | 573 return TRUE; |
600 } | 574 } |
601 | 575 |
602 void PanelBrowserWindowGtk::HandleFocusIn(GtkWidget* widget, | |
603 GdkEventFocus* event) { | |
604 BrowserWindowGtk::HandleFocusIn(widget, event); | |
605 | |
606 // Do not clear draw attention if user cannot see contents of panel. | |
607 if (!is_drawing_attention_ || panel_->IsMinimized()) | |
608 return; | |
609 | |
610 panel_->FlashFrame(false); | |
611 | |
612 disableMinimizeUntilTime_ = base::Time::Now() + | |
613 base::TimeDelta::FromMilliseconds(kSuspendMinimizeOnClickIntervalMs); | |
614 } | |
615 | |
616 // NativePanelTesting implementation. | 576 // NativePanelTesting implementation. |
617 class NativePanelTestingGtk : public NativePanelTesting { | 577 class NativePanelTestingGtk : public NativePanelTesting { |
618 public: | 578 public: |
619 explicit NativePanelTestingGtk( | 579 explicit NativePanelTestingGtk( |
620 PanelBrowserWindowGtk* panel_browser_window_gtk); | 580 PanelBrowserWindowGtk* panel_browser_window_gtk); |
621 | 581 |
622 private: | 582 private: |
623 virtual void PressLeftMouseButtonTitlebar( | 583 virtual void PressLeftMouseButtonTitlebar( |
624 const gfx::Point& mouse_location, panel::ClickModifier modifier) OVERRIDE; | 584 const gfx::Point& mouse_location, panel::ClickModifier modifier) OVERRIDE; |
625 virtual void ReleaseMouseButtonTitlebar( | 585 virtual void ReleaseMouseButtonTitlebar( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 | 697 |
738 bool NativePanelTestingGtk::IsAnimatingBounds() const { | 698 bool NativePanelTestingGtk::IsAnimatingBounds() const { |
739 return panel_browser_window_gtk_->IsAnimatingBounds(); | 699 return panel_browser_window_gtk_->IsAnimatingBounds(); |
740 } | 700 } |
741 | 701 |
742 bool NativePanelTestingGtk::IsButtonVisible( | 702 bool NativePanelTestingGtk::IsButtonVisible( |
743 TitlebarButtonType button_type) const { | 703 TitlebarButtonType button_type) const { |
744 NOTIMPLEMENTED(); | 704 NOTIMPLEMENTED(); |
745 return true; | 705 return true; |
746 } | 706 } |
OLD | NEW |