diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-07 18:38:30 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-07 18:38:30 +0000 |
commit | 0a4fb36fe33699992ba423269544b076532991f5 (patch) | |
tree | d02aacc48c3354db57b5ac5c68f68f0b41dff728 /ui | |
parent | a4ea1f1bb8965f37be0d9fcb39796096fd178a30 (diff) | |
download | chromium_src-0a4fb36fe33699992ba423269544b076532991f5.zip chromium_src-0a4fb36fe33699992ba423269544b076532991f5.tar.gz chromium_src-0a4fb36fe33699992ba423269544b076532991f5.tar.bz2 |
Revert 204146 "Introduces a new scrollbar for message_center."
> Introduces a new scrollbar for message_center.
>
> The new one overlaps with the scroll contents.
>
> BUG=239559
> R=sadrul@chromium.org, dewittj@chromium.org
>
> Review URL: https://chromiumcodereview.appspot.com/16171010
Revert reason: not working on windows, see crbug.com/247401
TBR=mukai@chromium.org
BUG=239559, 247401
Review URL: https://codereview.chromium.org/16434004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204875 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/message_center/views/message_center_view.cc | 4 | ||||
-rw-r--r-- | ui/message_center/views/notifier_settings_view.cc | 4 | ||||
-rw-r--r-- | ui/views/controls/scroll_view.cc | 26 | ||||
-rw-r--r-- | ui/views/controls/scroll_view.h | 2 | ||||
-rw-r--r-- | ui/views/controls/scrollbar/overlay_scroll_bar.cc | 148 | ||||
-rw-r--r-- | ui/views/controls/scrollbar/overlay_scroll_bar.h | 41 | ||||
-rw-r--r-- | ui/views/controls/scrollbar/scroll_bar.cc | 10 | ||||
-rw-r--r-- | ui/views/controls/scrollbar/scroll_bar.h | 7 | ||||
-rw-r--r-- | ui/views/views.gyp | 2 |
9 files changed, 8 insertions, 236 deletions
diff --git a/ui/message_center/views/message_center_view.cc b/ui/message_center/views/message_center_view.cc index 2d72653..8e87df5 100644 --- a/ui/message_center/views/message_center_view.cc +++ b/ui/message_center/views/message_center_view.cc @@ -31,7 +31,7 @@ #include "ui/views/controls/button/label_button.h" #include "ui/views/controls/label.h" #include "ui/views/controls/scroll_view.h" -#include "ui/views/controls/scrollbar/overlay_scroll_bar.h" +#include "ui/views/controls/scrollbar/kennedy_scroll_bar.h" #include "ui/views/layout/box_layout.h" #include "ui/views/layout/grid_layout.h" #include "ui/views/painter.h" @@ -304,7 +304,7 @@ BoundedScrollView::BoundedScrollView(int min_height, int max_height) if (IsRichNotificationEnabled()) { set_background(views::Background::CreateSolidBackground( kMessageCenterBackgroundColor)); - SetVerticalScrollBar(new views::OverlayScrollBar(false)); + SetVerticalScrollBar(new views::KennedyScrollBar(false)); } } diff --git a/ui/message_center/views/notifier_settings_view.cc b/ui/message_center/views/notifier_settings_view.cc index ba8c50b..eeef62d 100644 --- a/ui/message_center/views/notifier_settings_view.cc +++ b/ui/message_center/views/notifier_settings_view.cc @@ -20,7 +20,7 @@ #include "ui/views/controls/image_view.h" #include "ui/views/controls/label.h" #include "ui/views/controls/scroll_view.h" -#include "ui/views/controls/scrollbar/overlay_scroll_bar.h" +#include "ui/views/controls/scrollbar/kennedy_scroll_bar.h" #include "ui/views/layout/box_layout.h" #include "ui/views/widget/widget.h" @@ -290,7 +290,7 @@ NotifierSettingsView::NotifierSettingsView( scroller_ = new views::ScrollView(); scroller_->set_border(new Separator()); - scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); + scroller_->SetVerticalScrollBar(new views::KennedyScrollBar(false)); AddChildView(scroller_); views::View* contents_view = new views::View(); diff --git a/ui/views/controls/scroll_view.cc b/ui/views/controls/scroll_view.cc index 11ffc02..3659c35 100644 --- a/ui/views/controls/scroll_view.cc +++ b/ui/views/controls/scroll_view.cc @@ -117,8 +117,6 @@ ScrollView::ScrollView() vert_sb_(new NativeScrollBar(false)), resize_corner_(NULL), hide_horizontal_scrollbar_(false) { - set_notify_enter_exit_on_child(true); - AddChildView(contents_viewport_); AddChildView(header_viewport_); @@ -254,17 +252,15 @@ void ScrollView::Layout() { } if (horiz_sb_required) { - int height_offset = horiz_sb_->GetContentOverlapSize(); horiz_sb_->SetBounds(0, - viewport_bounds.bottom() - height_offset, + viewport_bounds.bottom(), viewport_bounds.right(), - horiz_sb_height + height_offset); + horiz_sb_height); } if (vert_sb_required) { - int width_offset = vert_sb_->GetContentOverlapSize(); - vert_sb_->SetBounds(viewport_bounds.right() - width_offset, + vert_sb_->SetBounds(viewport_bounds.right(), 0, - vert_sb_width + width_offset, + vert_sb_width, viewport_bounds.bottom()); } if (resize_corner_required) { @@ -316,20 +312,6 @@ bool ScrollView::OnMouseWheel(const ui::MouseWheelEvent& e) { return processed; } -void ScrollView::OnMouseEntered(const ui::MouseEvent& event) { - if (horiz_sb_) - horiz_sb_->OnMouseEnteredScrollView(event); - if (vert_sb_) - vert_sb_->OnMouseEnteredScrollView(event); -} - -void ScrollView::OnMouseExited(const ui::MouseEvent& event) { - if (horiz_sb_) - horiz_sb_->OnMouseExitedScrollView(event); - if (vert_sb_) - vert_sb_->OnMouseExitedScrollView(event); -} - void ScrollView::OnGestureEvent(ui::GestureEvent* event) { // If the event happened on one of the scrollbars, then those events are // sent directly to the scrollbars. Otherwise, only scroll events are sent to diff --git a/ui/views/controls/scroll_view.h b/ui/views/controls/scroll_view.h index da87ffd..857ddac 100644 --- a/ui/views/controls/scroll_view.h +++ b/ui/views/controls/scroll_view.h @@ -70,8 +70,6 @@ class VIEWS_EXPORT ScrollView : public View, public ScrollBarController { virtual void Layout() OVERRIDE; virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; virtual bool OnMouseWheel(const ui::MouseWheelEvent& e) OVERRIDE; - virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual const char* GetClassName() const OVERRIDE; diff --git a/ui/views/controls/scrollbar/overlay_scroll_bar.cc b/ui/views/controls/scrollbar/overlay_scroll_bar.cc deleted file mode 100644 index 4fdfda2..0000000 --- a/ui/views/controls/scrollbar/overlay_scroll_bar.cc +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/views/controls/scrollbar/overlay_scroll_bar.h" - -#include "third_party/skia/include/core/SkColor.h" -#include "third_party/skia/include/core/SkXfermode.h" -#include "ui/gfx/canvas.h" -#include "ui/views/background.h" -#include "ui/views/border.h" -#include "ui/views/controls/scrollbar/base_scroll_bar_thumb.h" - -namespace views { -namespace { - -const int kScrollbarWidth = 10; -const int kThumbInsetInside = 3; -const int kThumbInsetFromEdge = 1; -const int kThumbCornerRadius = 2; -const int kThumbMinimumSize = kScrollbarWidth; -const int kThumbHoverAlpha = 128; -const int kThumbDefaultAlpha = 64; - -class OverlayScrollBarThumb : public BaseScrollBarThumb, - public ui::AnimationDelegate { - public: - explicit OverlayScrollBarThumb(BaseScrollBar* scroll_bar); - virtual ~OverlayScrollBarThumb(); - - protected: - // View overrides: - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - - // ui::AnimationDelegate overrides: - virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; - - private: - double animation_opacity_; - DISALLOW_COPY_AND_ASSIGN(OverlayScrollBarThumb); -}; - -OverlayScrollBarThumb::OverlayScrollBarThumb(BaseScrollBar* scroll_bar) - : BaseScrollBarThumb(scroll_bar), - animation_opacity_(0.0) { - if (get_use_acceleration_when_possible()) { - // This is necessary, otherwise the thumb will be rendered below the views - // if those views paint to their own layers. - SetPaintToLayer(true); - SetFillsBoundsOpaquely(false); - } -} - -OverlayScrollBarThumb::~OverlayScrollBarThumb() { -} - -gfx::Size OverlayScrollBarThumb::GetPreferredSize() { - return gfx::Size(kThumbMinimumSize, kThumbMinimumSize); -} - -void OverlayScrollBarThumb::OnPaint(gfx::Canvas* canvas) { - gfx::Rect local_bounds(GetLocalBounds()); - SkPaint paint; - int alpha = (GetState() == CustomButton::STATE_HOVERED || - GetState() == CustomButton::STATE_PRESSED) ? - kThumbHoverAlpha : kThumbDefaultAlpha; - alpha *= animation_opacity_; - paint.setStyle(SkPaint::kFill_Style); - paint.setColor(SkColorSetARGB(alpha, 0, 0, 0)); - canvas->DrawRoundRect(local_bounds, kThumbCornerRadius, paint); -} - -void OverlayScrollBarThumb::AnimationProgressed( - const ui::Animation* animation) { - animation_opacity_ = animation->GetCurrentValue(); - SchedulePaint(); -} - -} // namespace - -OverlayScrollBar::OverlayScrollBar(bool horizontal) - : BaseScrollBar(horizontal, new OverlayScrollBarThumb(this)), - animation_(static_cast<OverlayScrollBarThumb*>(GetThumb())) { - set_notify_enter_exit_on_child(true); -} - -OverlayScrollBar::~OverlayScrollBar() { -} - -gfx::Rect OverlayScrollBar::GetTrackBounds() const { - gfx::Rect local_bounds(GetLocalBounds()); - if (IsHorizontal()) { - local_bounds.Inset(kThumbInsetFromEdge, kThumbInsetInside, - kThumbInsetFromEdge, kThumbInsetFromEdge); - } else { - local_bounds.Inset(kThumbInsetInside, kThumbInsetFromEdge, - kThumbInsetFromEdge, kThumbInsetFromEdge); - } - gfx::Size track_size = local_bounds.size(); - track_size.SetToMax(GetThumb()->size()); - local_bounds.set_size(track_size); - return local_bounds; -} - -int OverlayScrollBar::GetLayoutSize() const { - return 0; -} - -int OverlayScrollBar::GetContentOverlapSize() const { - return kScrollbarWidth; -} - -void OverlayScrollBar::OnMouseEnteredScrollView(const ui::MouseEvent& event) { - if (GetThumb()->layer()) - animation_.Show(); - else - GetThumb()->SetVisible(true); -} - -void OverlayScrollBar::OnMouseExitedScrollView(const ui::MouseEvent& event) { - if (GetThumb()->layer()) - animation_.Hide(); - else - GetThumb()->SetVisible(false); -} - -gfx::Size OverlayScrollBar::GetPreferredSize() { - return gfx::Size(); -} - -void OverlayScrollBar::Layout() { - gfx::Rect thumb_bounds = GetTrackBounds(); - BaseScrollBarThumb* thumb = GetThumb(); - if (IsHorizontal()) { - thumb_bounds.set_x(thumb->x()); - thumb_bounds.set_width(thumb->width()); - } else { - thumb_bounds.set_y(thumb->y()); - thumb_bounds.set_height(thumb->height()); - } - thumb->SetBoundsRect(thumb_bounds); -} - -void OverlayScrollBar::OnPaint(gfx::Canvas* canvas) { -} - -} // namespace views diff --git a/ui/views/controls/scrollbar/overlay_scroll_bar.h b/ui/views/controls/scrollbar/overlay_scroll_bar.h deleted file mode 100644 index 043f5f7..0000000 --- a/ui/views/controls/scrollbar/overlay_scroll_bar.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_VIEWS_CONTROLS_SCROLLBAR_OVERLAY_SCROLL_BAR_H_ -#define UI_VIEWS_CONTROLS_SCROLLBAR_OVERLAY_SCROLL_BAR_H_ - -#include "ui/base/animation/slide_animation.h" -#include "ui/views/controls/scrollbar/base_scroll_bar.h" - -namespace views { - -// The transparent scrollbar which overlays its contents. -class VIEWS_EXPORT OverlayScrollBar : public BaseScrollBar { - public: - explicit OverlayScrollBar(bool horizontal); - virtual ~OverlayScrollBar(); - - protected: - // BaseScrollBar overrides: - virtual gfx::Rect GetTrackBounds() const OVERRIDE; - - // ScrollBar overrides: - virtual int GetLayoutSize() const OVERRIDE; - virtual int GetContentOverlapSize() const OVERRIDE; - virtual void OnMouseEnteredScrollView(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseExitedScrollView(const ui::MouseEvent& event) OVERRIDE; - - // View overrides: - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void Layout() OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - - private: - ui::SlideAnimation animation_; - DISALLOW_COPY_AND_ASSIGN(OverlayScrollBar); -}; - -} // namespace views - -#endif // UI_VIEWS_CONTROLS_SCROLLBAR_OVERLAY_SCROLL_BAR_H_ diff --git a/ui/views/controls/scrollbar/scroll_bar.cc b/ui/views/controls/scrollbar/scroll_bar.cc index 5374d32..7719d86 100644 --- a/ui/views/controls/scrollbar/scroll_bar.cc +++ b/ui/views/controls/scrollbar/scroll_bar.cc @@ -31,16 +31,6 @@ int ScrollBar::GetMinPosition() const { return 0; } -int ScrollBar::GetContentOverlapSize() const { - return 0; -} - -void ScrollBar::OnMouseEnteredScrollView(const ui::MouseEvent& event) { -} - -void ScrollBar::OnMouseExitedScrollView(const ui::MouseEvent& event) { -} - ScrollBar::ScrollBar(bool is_horiz) : is_horiz_(is_horiz), controller_(NULL), diff --git a/ui/views/controls/scrollbar/scroll_bar.h b/ui/views/controls/scrollbar/scroll_bar.h index aa3800e..5b534d6 100644 --- a/ui/views/controls/scrollbar/scroll_bar.h +++ b/ui/views/controls/scrollbar/scroll_bar.h @@ -86,13 +86,6 @@ class VIEWS_EXPORT ScrollBar : public View { // is the height for a horizontal scrollbar. virtual int GetLayoutSize() const = 0; - // Get the width or height for this scrollbar which overlaps with the content. - // Default is 0. - virtual int GetContentOverlapSize() const; - - virtual void OnMouseEnteredScrollView(const ui::MouseEvent& event); - virtual void OnMouseExitedScrollView(const ui::MouseEvent& event); - protected: // Create new scrollbar, either horizontal or vertical. These are protected // since you need to be creating either a NativeScrollBar or a diff --git a/ui/views/views.gyp b/ui/views/views.gyp index 555103f..3d13414 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -188,8 +188,6 @@ 'controls/scrollbar/native_scroll_bar_wrapper.h', 'controls/scrollbar/native_scroll_bar.cc', 'controls/scrollbar/native_scroll_bar.h', - 'controls/scrollbar/overlay_scroll_bar.cc', - 'controls/scrollbar/overlay_scroll_bar.h', 'controls/scrollbar/scroll_bar.cc', 'controls/scrollbar/scroll_bar.h', 'controls/separator.cc', |