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

Side by Side Diff: chrome/browser/ui/panels/panel_browser_view.cc

Issue 8827011: Panel strip refactor cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac/linux compile Created 9 years 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
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/panels/panel_browser_view.h" 5 #include "chrome/browser/ui/panels/panel_browser_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/ui/panels/panel.h" 9 #include "chrome/browser/ui/panels/panel.h"
10 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" 10 #include "chrome/browser/ui/panels/panel_browser_frame_view.h"
11 #include "chrome/browser/ui/panels/panel_manager.h" 11 #include "chrome/browser/ui/panels/panel_manager.h"
12 #include "chrome/browser/ui/panels/panel_overflow_strip.h"
13 #include "chrome/browser/ui/panels/panel_strip.h"
14 #include "chrome/browser/ui/views/frame/browser_frame.h" 12 #include "chrome/browser/ui/views/frame/browser_frame.h"
15 #include "chrome/browser/ui/webui/task_manager_dialog.h" 13 #include "chrome/browser/ui/webui/task_manager_dialog.h"
16 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
18 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
19 #include "grit/chromium_strings.h" 17 #include "grit/chromium_strings.h"
20 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/views/controls/label.h" 19 #include "ui/views/controls/label.h"
22 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
23 21
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 141
144 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) { 142 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) {
145 SetBoundsInternal(bounds, true); 143 SetBoundsInternal(bounds, true);
146 } 144 }
147 145
148 void PanelBrowserView::SetBoundsInternal(const gfx::Rect& new_bounds, 146 void PanelBrowserView::SetBoundsInternal(const gfx::Rect& new_bounds,
149 bool animate) { 147 bool animate) {
150 if (bounds_ == new_bounds) 148 if (bounds_ == new_bounds)
151 return; 149 return;
152 150
153 // TODO(jianli): this is just a temporary hack to check if we need to show
154 // or hide the panel app icon in the taskbar. http://crbug.com/106227
155 int panel_strip_area_left =
156 panel()->manager()->panel_strip()->display_area().x();
157 bool app_icon_shown = bounds_.x() >= panel_strip_area_left;
158 bool app_icon_to_show = new_bounds.x() >= panel_strip_area_left;
159 if (app_icon_shown != app_icon_to_show)
160 ShowOrHidePanelAppIcon(app_icon_to_show);
161
162 bounds_ = new_bounds; 151 bounds_ = new_bounds;
163 152
164 // No animation if the panel is being dragged. 153 // No animation if the panel is being dragged.
165 if (!animate || mouse_dragging_state_ == DRAGGING_STARTED) { 154 if (!animate || mouse_dragging_state_ == DRAGGING_STARTED) {
166 ::BrowserView::SetBounds(new_bounds); 155 ::BrowserView::SetBounds(new_bounds);
167 return; 156 return;
168 } 157 }
169 158
170 animation_start_bounds_ = GetBounds(); 159 animation_start_bounds_ = GetBounds();
171 160
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 } 510 }
522 511
523 return EndDragging(false); 512 return EndDragging(false);
524 } 513 }
525 514
526 // If the panel drag was cancelled before the mouse is released, do not treat 515 // If the panel drag was cancelled before the mouse is released, do not treat
527 // this as a click. 516 // this as a click.
528 if (mouse_dragging_state_ != NO_DRAGGING) 517 if (mouse_dragging_state_ != NO_DRAGGING)
529 return true; 518 return true;
530 519
531 // If the panel is in overflow, move it to the normal strip.
532 if (panel_->expansion_state() == Panel::IN_OVERFLOW) {
533 panel_->MoveOutOfOverflow();
534 return true;
535 }
536
537 // Do not minimize the panel when we just clear the attention state. This is 520 // Do not minimize the panel when we just clear the attention state. This is
538 // a hack to prevent the panel from being minimized when the user clicks on 521 // a hack to prevent the panel from being minimized when the user clicks on
539 // the title-bar to clear the attention. 522 // the title-bar to clear the attention.
540 if (panel_->expansion_state() == Panel::EXPANDED && 523 if (panel_->expansion_state() == Panel::EXPANDED &&
541 base::TimeTicks::Now() - attention_cleared_time_ < 524 base::TimeTicks::Now() - attention_cleared_time_ <
542 base::TimeDelta::FromMilliseconds(kSuspendMinimizeOnClickIntervalMs)) { 525 base::TimeDelta::FromMilliseconds(kSuspendMinimizeOnClickIntervalMs)) {
543 return true; 526 return true;
544 } 527 }
545 528
546 // Do not minimize the panel if it is long click. 529 // Do not minimize the panel if it is long click.
547 if (base::TimeTicks::Now() - mouse_pressed_time_ > 530 if (base::TimeTicks::Now() - mouse_pressed_time_ >
jianli 2011/12/07 22:13:26 Do we want to skip expanding an overflow panel if
jennb 2011/12/07 23:35:40 Will update the comment. All long clicks will be i
548 base::TimeDelta::FromMilliseconds(kShortClickThresholdMs)) 531 base::TimeDelta::FromMilliseconds(kShortClickThresholdMs))
549 return true; 532 return true;
550 533
551 Panel::ExpansionState new_expansion_state = 534 Panel::ExpansionState new_expansion_state =
552 (panel_->expansion_state() != Panel::EXPANDED) ? Panel::EXPANDED 535 (panel_->expansion_state() != Panel::EXPANDED) ? Panel::EXPANDED
553 : Panel::MINIMIZED; 536 : Panel::MINIMIZED;
554 panel_->SetExpansionState(new_expansion_state); 537 panel_->SetExpansionState(new_expansion_state);
555 return true; 538 return true;
556 } 539 }
557 540
558 bool PanelBrowserView::OnTitlebarMouseCaptureLost() { 541 bool PanelBrowserView::OnTitlebarMouseCaptureLost() {
559 if (mouse_dragging_state_ == DRAGGING_STARTED) 542 if (mouse_dragging_state_ == DRAGGING_STARTED)
560 return EndDragging(true); 543 return EndDragging(true);
561 return true; 544 return true;
562 } 545 }
563 546
564 bool PanelBrowserView::EndDragging(bool cancelled) { 547 bool PanelBrowserView::EndDragging(bool cancelled) {
565 // Only handle clicks that started in our window. 548 // Only handle clicks that started in our window.
566 if (!mouse_pressed_) 549 if (!mouse_pressed_)
567 return false; 550 return false;
568 mouse_pressed_ = false; 551 mouse_pressed_ = false;
569 552
570 mouse_dragging_state_ = DRAGGING_ENDED; 553 mouse_dragging_state_ = DRAGGING_ENDED;
571 panel_->manager()->EndDragging(cancelled); 554 panel_->manager()->EndDragging(cancelled);
572 return true; 555 return true;
573 } 556 }
574 557
575 void PanelBrowserView::ShowOrHidePanelAppIcon(bool show) { 558 void PanelBrowserView::SetPanelAppIconVisibility(bool visible) {
576 #if defined(OS_WIN) && !defined(USE_AURA) 559 #if defined(OS_WIN) && !defined(USE_AURA)
577 gfx::NativeWindow native_window = GetNativeHandle(); 560 gfx::NativeWindow native_window = GetNativeHandle();
578 ::ShowWindow(native_window, SW_HIDE); 561 ::ShowWindow(native_window, SW_HIDE);
579 int style = ::GetWindowLong(native_window, GWL_EXSTYLE); 562 int style = ::GetWindowLong(native_window, GWL_EXSTYLE);
580 if (show) 563 if (visible)
581 style &= (~WS_EX_TOOLWINDOW); 564 style &= (~WS_EX_TOOLWINDOW);
582 else 565 else
583 style |= WS_EX_TOOLWINDOW; 566 style |= WS_EX_TOOLWINDOW;
584 ::SetWindowLong(native_window, GWL_EXSTYLE, style); 567 ::SetWindowLong(native_window, GWL_EXSTYLE, style);
585 ::ShowWindow(native_window, SW_SHOWNA); 568 ::ShowWindow(native_window, SW_SHOWNA);
586 #else 569 #else
587 NOTIMPLEMENTED(); 570 NOTIMPLEMENTED();
588 #endif 571 #endif
589 } 572 }
590 573
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 } 653 }
671 654
672 bool NativePanelTestingWin::IsWindowSizeKnown() const { 655 bool NativePanelTestingWin::IsWindowSizeKnown() const {
673 return true; 656 return true;
674 } 657 }
675 658
676 bool NativePanelTestingWin::IsAnimatingBounds() const { 659 bool NativePanelTestingWin::IsAnimatingBounds() const {
677 return panel_browser_view_->bounds_animator_.get() && 660 return panel_browser_view_->bounds_animator_.get() &&
678 panel_browser_view_->bounds_animator_->is_animating(); 661 panel_browser_view_->bounds_animator_->is_animating();
679 } 662 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698