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

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: Synced 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_slide_animation.h" 12 #include "chrome/browser/ui/panels/panel_slide_animation.h"
14 #include "chrome/browser/ui/panels/panel_strip.h"
15 #include "chrome/browser/ui/views/frame/browser_frame.h" 13 #include "chrome/browser/ui/views/frame/browser_frame.h"
16 #include "chrome/browser/ui/webui/task_manager_dialog.h" 14 #include "chrome/browser/ui/webui/task_manager_dialog.h"
17 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
19 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
20 #include "grit/chromium_strings.h" 18 #include "grit/chromium_strings.h"
21 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/views/controls/label.h" 20 #include "ui/views/controls/label.h"
23 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
24 22
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 118
121 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) { 119 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) {
122 SetBoundsInternal(bounds, true); 120 SetBoundsInternal(bounds, true);
123 } 121 }
124 122
125 void PanelBrowserView::SetBoundsInternal(const gfx::Rect& new_bounds, 123 void PanelBrowserView::SetBoundsInternal(const gfx::Rect& new_bounds,
126 bool animate) { 124 bool animate) {
127 if (bounds_ == new_bounds) 125 if (bounds_ == new_bounds)
128 return; 126 return;
129 127
130 // TODO(jianli): this is just a temporary hack to check if we need to show
131 // or hide the panel app icon in the taskbar. http://crbug.com/106227
132 int panel_strip_area_left =
133 panel()->manager()->panel_strip()->display_area().x();
134 bool app_icon_shown = bounds_.x() >= panel_strip_area_left;
135 bool app_icon_to_show = new_bounds.x() >= panel_strip_area_left;
136 if (app_icon_shown != app_icon_to_show)
137 ShowOrHidePanelAppIcon(app_icon_to_show);
138
139 bounds_ = new_bounds; 128 bounds_ = new_bounds;
140 129
141 // No animation if the panel is being dragged. 130 // No animation if the panel is being dragged.
142 if (!animate || mouse_dragging_state_ == DRAGGING_STARTED) { 131 if (!animate || mouse_dragging_state_ == DRAGGING_STARTED) {
143 ::BrowserView::SetBounds(new_bounds); 132 ::BrowserView::SetBounds(new_bounds);
144 return; 133 return;
145 } 134 }
146 135
147 animation_start_bounds_ = GetBounds(); 136 animation_start_bounds_ = GetBounds();
148 137
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 } 471 }
483 472
484 return EndDragging(false); 473 return EndDragging(false);
485 } 474 }
486 475
487 // If the panel drag was cancelled before the mouse is released, do not treat 476 // If the panel drag was cancelled before the mouse is released, do not treat
488 // this as a click. 477 // this as a click.
489 if (mouse_dragging_state_ != NO_DRAGGING) 478 if (mouse_dragging_state_ != NO_DRAGGING)
490 return true; 479 return true;
491 480
492 // If the panel is in overflow, move it to the normal strip.
493 if (panel_->expansion_state() == Panel::IN_OVERFLOW) {
494 panel_->MoveOutOfOverflow();
495 return true;
496 }
497
498 // Do not minimize the panel when we just clear the attention state. This is 481 // Do not minimize the panel when we just clear the attention state. This is
499 // a hack to prevent the panel from being minimized when the user clicks on 482 // a hack to prevent the panel from being minimized when the user clicks on
500 // the title-bar to clear the attention. 483 // the title-bar to clear the attention.
501 if (panel_->expansion_state() == Panel::EXPANDED && 484 if (panel_->expansion_state() == Panel::EXPANDED &&
502 base::TimeTicks::Now() - attention_cleared_time_ < 485 base::TimeTicks::Now() - attention_cleared_time_ <
503 base::TimeDelta::FromMilliseconds(kSuspendMinimizeOnClickIntervalMs)) { 486 base::TimeDelta::FromMilliseconds(kSuspendMinimizeOnClickIntervalMs)) {
504 return true; 487 return true;
505 } 488 }
506 489
507 // Do not minimize the panel if it is long click. 490 // Ignore long clicks. Treated as a canceled click to be consistent with Mac.
508 if (base::TimeTicks::Now() - mouse_pressed_time_ > 491 if (base::TimeTicks::Now() - mouse_pressed_time_ >
509 base::TimeDelta::FromMilliseconds(kShortClickThresholdMs)) 492 base::TimeDelta::FromMilliseconds(kShortClickThresholdMs))
510 return true; 493 return true;
511 494
512 Panel::ExpansionState new_expansion_state = 495 Panel::ExpansionState new_expansion_state =
513 (panel_->expansion_state() != Panel::EXPANDED) ? Panel::EXPANDED 496 (panel_->expansion_state() != Panel::EXPANDED) ? Panel::EXPANDED
514 : Panel::MINIMIZED; 497 : Panel::MINIMIZED;
515 panel_->SetExpansionState(new_expansion_state); 498 panel_->SetExpansionState(new_expansion_state);
516 return true; 499 return true;
517 } 500 }
518 501
519 bool PanelBrowserView::OnTitlebarMouseCaptureLost() { 502 bool PanelBrowserView::OnTitlebarMouseCaptureLost() {
520 if (mouse_dragging_state_ == DRAGGING_STARTED) 503 if (mouse_dragging_state_ == DRAGGING_STARTED)
521 return EndDragging(true); 504 return EndDragging(true);
522 return true; 505 return true;
523 } 506 }
524 507
525 bool PanelBrowserView::EndDragging(bool cancelled) { 508 bool PanelBrowserView::EndDragging(bool cancelled) {
526 // Only handle clicks that started in our window. 509 // Only handle clicks that started in our window.
527 if (!mouse_pressed_) 510 if (!mouse_pressed_)
528 return false; 511 return false;
529 mouse_pressed_ = false; 512 mouse_pressed_ = false;
530 513
531 mouse_dragging_state_ = DRAGGING_ENDED; 514 mouse_dragging_state_ = DRAGGING_ENDED;
532 panel_->manager()->EndDragging(cancelled); 515 panel_->manager()->EndDragging(cancelled);
533 return true; 516 return true;
534 } 517 }
535 518
536 void PanelBrowserView::ShowOrHidePanelAppIcon(bool show) { 519 void PanelBrowserView::SetPanelAppIconVisibility(bool visible) {
537 #if defined(OS_WIN) && !defined(USE_AURA) 520 #if defined(OS_WIN) && !defined(USE_AURA)
538 gfx::NativeWindow native_window = GetNativeHandle(); 521 gfx::NativeWindow native_window = GetNativeHandle();
539 ::ShowWindow(native_window, SW_HIDE); 522 ::ShowWindow(native_window, SW_HIDE);
540 int style = ::GetWindowLong(native_window, GWL_EXSTYLE); 523 int style = ::GetWindowLong(native_window, GWL_EXSTYLE);
541 if (show) 524 if (visible)
542 style &= (~WS_EX_TOOLWINDOW); 525 style &= (~WS_EX_TOOLWINDOW);
543 else 526 else
544 style |= WS_EX_TOOLWINDOW; 527 style |= WS_EX_TOOLWINDOW;
545 ::SetWindowLong(native_window, GWL_EXSTYLE, style); 528 ::SetWindowLong(native_window, GWL_EXSTYLE, style);
546 ::ShowWindow(native_window, SW_SHOWNA); 529 ::ShowWindow(native_window, SW_SHOWNA);
547 #else 530 #else
548 NOTIMPLEMENTED(); 531 NOTIMPLEMENTED();
549 #endif 532 #endif
550 } 533 }
551 534
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 614 }
632 615
633 bool NativePanelTestingWin::IsWindowSizeKnown() const { 616 bool NativePanelTestingWin::IsWindowSizeKnown() const {
634 return true; 617 return true;
635 } 618 }
636 619
637 bool NativePanelTestingWin::IsAnimatingBounds() const { 620 bool NativePanelTestingWin::IsAnimatingBounds() const {
638 return panel_browser_view_->bounds_animator_.get() && 621 return panel_browser_view_->bounds_animator_.get() &&
639 panel_browser_view_->bounds_animator_->is_animating(); 622 panel_browser_view_->bounds_animator_->is_animating();
640 } 623 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_view.h ('k') | chrome/browser/ui/panels/panel_browser_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698