summaryrefslogtreecommitdiffstats
path: root/athena/util
diff options
context:
space:
mode:
authorthakis <thakis@chromium.org>2014-09-24 09:21:10 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-24 16:21:30 +0000
commitf1546bfaabc3492485219dfb51a270bae8da41b9 (patch)
tree6d941757e36111e8ae6f56b20f0bef94d674876a /athena/util
parent82b9096939b7e60095fc822c31975b25ee22e37b (diff)
downloadchromium_src-f1546bfaabc3492485219dfb51a270bae8da41b9.zip
chromium_src-f1546bfaabc3492485219dfb51a270bae8da41b9.tar.gz
chromium_src-f1546bfaabc3492485219dfb51a270bae8da41b9.tar.bz2
Revert of Adding split view divider widget. (patchset #15 id:280001 of https://codereview.chromium.org/545393002/)
Reason for revert: DragHandleTest.ScrollTest is failing on the bots: http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%283%29/builds/36880 Original issue's description: > Adding split view divider widget. > > Adding split view divider widget which could be dragged to exit the split view. > > BUG=403207,408691 > > Committed: https://crrev.com/b47c16517f0882cbabf8c9aa9ce66711f026fd5b > Cr-Commit-Position: refs/heads/master@{#296351} TBR=mukai@chromium.org,oshima@chromium.org,sadrul@chromium.org,tdanderson@chromium.org,pkotwicz@chromium.org,mfomitchev@chromium.org NOTREECHECKS=true NOTRY=true BUG=403207,408691 Review URL: https://codereview.chromium.org/602603003 Cr-Commit-Position: refs/heads/master@{#296433}
Diffstat (limited to 'athena/util')
-rw-r--r--athena/util/DEPS1
-rw-r--r--athena/util/drag_handle.cc142
-rw-r--r--athena/util/drag_handle.h41
-rw-r--r--athena/util/drag_handle_unittest.cc138
4 files changed, 0 insertions, 322 deletions
diff --git a/athena/util/DEPS b/athena/util/DEPS
index c30254d..8755565 100644
--- a/athena/util/DEPS
+++ b/athena/util/DEPS
@@ -2,5 +2,4 @@ include_rules = [
"+athena/athena_export.h",
"+ui/aura",
"+ui/compositor",
- "+ui/views",
]
diff --git a/athena/util/drag_handle.cc b/athena/util/drag_handle.cc
deleted file mode 100644
index 8515007..0000000
--- a/athena/util/drag_handle.cc
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright 2014 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 "athena/util/drag_handle.h"
-
-#include "ui/views/background.h"
-#include "ui/views/view.h"
-
-namespace athena {
-namespace {
-
-const SkColor kDragHandleColorNormal = SK_ColorGRAY;
-const SkColor kDragHandleColorHot = SK_ColorWHITE;
-
-// This view notifies its delegate of the touch scroll gestures performed on it.
-class DragHandleView : public views::View {
- public:
- DragHandleView(DragHandleScrollDirection scroll_direction,
- DragHandleScrollDelegate* delegate,
- int preferred_width,
- int preferred_height);
- virtual ~DragHandleView();
-
- private:
- void SetColor(SkColor color);
-
- void SetIsScrolling(bool scrolling);
-
- // views::View:
- virtual gfx::Size GetPreferredSize() const OVERRIDE;
- virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
-
- bool scroll_in_progress_;
- DragHandleScrollDelegate* delegate_;
- DragHandleScrollDirection scroll_direction_;
- SkColor color_;
- float scroll_start_location_;
- const int preferred_width_;
- const int preferred_height_;
-
- DISALLOW_COPY_AND_ASSIGN(DragHandleView);
-};
-
-DragHandleView::DragHandleView(DragHandleScrollDirection scroll_direction,
- DragHandleScrollDelegate* delegate,
- int preferred_width,
- int preferred_height)
- : scroll_in_progress_(false),
- delegate_(delegate),
- scroll_direction_(scroll_direction),
- color_(SK_ColorTRANSPARENT),
- preferred_width_(preferred_width),
- preferred_height_(preferred_height) {
- SetColor(kDragHandleColorNormal);
-}
-
-DragHandleView::~DragHandleView() {
-}
-
-void DragHandleView::SetColor(SkColor color) {
- if (color_ == color)
- return;
- color_ = color;
- set_background(views::Background::CreateSolidBackground(color_));
- SchedulePaint();
-}
-
-void DragHandleView::SetIsScrolling(bool scrolling) {
- if (scroll_in_progress_ == scrolling)
- return;
- scroll_in_progress_ = scrolling;
- if (!scroll_in_progress_)
- scroll_start_location_ = 0;
-}
-
-// views::View:
-gfx::Size DragHandleView::GetPreferredSize() const {
- return gfx::Size(preferred_width_, preferred_height_);
-}
-
-void DragHandleView::OnGestureEvent(ui::GestureEvent* event) {
- SkColor change_color = SK_ColorTRANSPARENT;
- if (event->type() == ui::ET_GESTURE_BEGIN &&
- event->details().touch_points() == 1) {
- change_color = kDragHandleColorHot;
- } else if (event->type() == ui::ET_GESTURE_END &&
- event->details().touch_points() == 1) {
- change_color = kDragHandleColorNormal;
- }
-
- if (change_color != SK_ColorTRANSPARENT) {
- SetColor(change_color);
- event->SetHandled();
- return;
- }
-
- if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN) {
- if (scroll_in_progress_)
- return;
- float delta;
- if (scroll_direction_ == DRAG_HANDLE_VERTICAL) {
- delta = event->details().scroll_y_hint();
- scroll_start_location_ = event->root_location().y();
- } else {
- delta = event->details().scroll_x_hint();
- scroll_start_location_ = event->root_location().x();
- }
- delegate_->HandleScrollBegin(delta);
- SetIsScrolling(true);
- event->SetHandled();
- } else if (event->type() == ui::ET_GESTURE_SCROLL_END ||
- event->type() == ui::ET_SCROLL_FLING_START) {
- if (!scroll_in_progress_)
- return;
- delegate_->HandleScrollEnd();
- SetColor(kDragHandleColorNormal);
- SetIsScrolling(false);
- event->SetHandled();
- } else if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE) {
- if (!scroll_in_progress_)
- return;
- float delta = scroll_direction_ == DRAG_HANDLE_VERTICAL
- ? event->root_location().y() - scroll_start_location_
- : event->root_location().x() - scroll_start_location_;
- delegate_->HandleScrollUpdate(delta);
- event->SetHandled();
- }
-}
-
-} // namespace
-
-views::View* CreateDragHandleView(DragHandleScrollDirection scroll_direction,
- DragHandleScrollDelegate* delegate,
- int preferred_width,
- int preferred_height) {
- views::View* view = new DragHandleView(
- scroll_direction, delegate, preferred_width, preferred_height);
- return view;
-}
-
-} // namespace athena
diff --git a/athena/util/drag_handle.h b/athena/util/drag_handle.h
deleted file mode 100644
index ad1b209..0000000
--- a/athena/util/drag_handle.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2014 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 ATHENA_UTIL_DRAG_HANDLE_H_
-#define ATHENA_UTIL_DRAG_HANDLE_H_
-
-#include "athena/athena_export.h"
-
-namespace views {
-class View;
-}
-
-namespace athena {
-class DragHandleScrollDelegate {
- public:
- virtual ~DragHandleScrollDelegate() {}
-
- // Beginning of a scroll gesture.
- virtual void HandleScrollBegin(float delta) = 0;
-
- // End of the current scroll gesture.
- virtual void HandleScrollEnd() = 0;
-
- // Update of the scroll position for the currently active scroll gesture.
- virtual void HandleScrollUpdate(float delta) = 0;
-};
-
-enum DragHandleScrollDirection { DRAG_HANDLE_VERTICAL, DRAG_HANDLE_HORIZONTAL };
-
-// Creates a handle view which notifies the delegate of the scrolls performed on
-// it.
-ATHENA_EXPORT views::View* CreateDragHandleView(
- DragHandleScrollDirection scroll_direction,
- DragHandleScrollDelegate* delegate,
- int preferred_width,
- int preferred_height);
-
-} // namespace athena
-
-#endif // ATHENA_UTIL_DRAG_HANDLE_H_
diff --git a/athena/util/drag_handle_unittest.cc b/athena/util/drag_handle_unittest.cc
deleted file mode 100644
index c86e2a0..0000000
--- a/athena/util/drag_handle_unittest.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright 2014 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 "athena/util/drag_handle.h"
-
-#include "ui/aura/test/aura_test_base.h"
-#include "ui/aura/window.h"
-#include "ui/views/view.h"
-#include "ui/views/widget/widget.h"
-
-namespace athena {
-
-class DragHandleDelegateTest : public DragHandleScrollDelegate {
- public:
- explicit DragHandleDelegateTest()
- : begin_delta_(0),
- got_scroll_end_(false),
- update_delta_(0) {}
-
- virtual ~DragHandleDelegateTest() {}
-
- void Reset() {
- begin_delta_ = 0;
- got_scroll_end_ = false;
- update_delta_ = 0;
- }
-
- float begin_delta() { return begin_delta_; }
- bool got_scroll_end() { return got_scroll_end_; }
- float update_delta() { return update_delta_; }
-
- private:
- // DragHandleScrollDelegate:
- virtual void HandleScrollBegin(float delta) OVERRIDE {
- begin_delta_ = delta;
- }
-
- virtual void HandleScrollEnd() OVERRIDE {
- got_scroll_end_ = true;
- }
-
- virtual void HandleScrollUpdate(float delta) OVERRIDE {
- update_delta_ = delta;
- }
-
- float begin_delta_;
- bool got_scroll_end_;
- float update_delta_;
-
- DISALLOW_COPY_AND_ASSIGN(DragHandleDelegateTest);
-};
-
-typedef aura::test::AuraTestBase DragHandleTest;
-
-const int kDragHandleWidth = 10;
-const int kDragHandleHeight = 100;
-
-ui::GestureEvent CreateGestureEvent(ui::EventType type,
- float x,
- float delta_x) {
- ui::GestureEvent event(
- x,
- 1,
- 0,
- base::TimeDelta::FromInternalValue(base::Time::Now().ToInternalValue()),
- ui::GestureEventDetails(type, delta_x, 0));
- event.set_root_location(gfx::PointF(x, 1));
- return event;
-}
-
-TEST_F(DragHandleTest, ScrollTest) {
- DragHandleDelegateTest delegate;
- scoped_ptr<views::View> drag_handle(
- CreateDragHandleView(DragHandleScrollDirection::DRAG_HANDLE_HORIZONTAL,
- &delegate,
- kDragHandleWidth,
- kDragHandleHeight));
-
- views::Widget widget;
- views::Widget::InitParams params(
- views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- params.parent = root_window();
- params.accept_events = true;
- params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- widget.Init(params);
- widget.SetContentsView(drag_handle.get());
- const gfx::Size& size = gfx::Size(kDragHandleWidth, kDragHandleHeight);
- widget.SetSize(size);
- widget.SetBounds(gfx::Rect(0, 0, size.width(), size.height()));
-
- const float begin_x = 4.0;
- const float begin_delta = 10.0;
- const float update_delta = 15.0;
-
- ui::GestureEvent scroll_begin_model =
- CreateGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, begin_x, begin_delta);
- ui::GestureEvent scroll_update_model =
- CreateGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE,
- begin_x + update_delta,
- update_delta - begin_delta);
- ui::GestureEvent scroll_end_model =
- CreateGestureEvent(ui::ET_GESTURE_SCROLL_END, begin_x + update_delta, 0);
- ui::GestureEvent fling_start_model =
- CreateGestureEvent(ui::ET_SCROLL_FLING_START, begin_x + update_delta, 0);
-
- // Normal scroll
- ui::GestureEvent e(scroll_begin_model);
- widget.OnGestureEvent(&e);
- EXPECT_EQ(begin_delta, delegate.begin_delta());
- EXPECT_EQ(0, delegate.update_delta());
- EXPECT_FALSE(delegate.got_scroll_end());
- e = ui::GestureEvent(scroll_update_model);
- widget.OnGestureEvent(&e);
- EXPECT_EQ(update_delta, delegate.update_delta());
- EXPECT_FALSE(delegate.got_scroll_end());
- e = ui::GestureEvent(scroll_end_model);
- widget.OnGestureEvent(&e);
- EXPECT_EQ(update_delta, delegate.update_delta());
- EXPECT_TRUE(delegate.got_scroll_end());
-
- delegate.Reset();
-
- // Scroll ending with a fling
- e = ui::GestureEvent(scroll_begin_model);
- widget.OnGestureEvent(&e);
- e = ui::GestureEvent(scroll_update_model);
- widget.OnGestureEvent(&e);
- e = ui::GestureEvent(fling_start_model);
- widget.OnGestureEvent(&e);
- EXPECT_TRUE(delegate.got_scroll_end());
-
- delegate.Reset();
-
- drag_handle.reset();
-}
-
-} // namespace athena