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

Unified Diff: athena/util/drag_handle.cc

Issue 863033002: Delete athena/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/util/drag_handle.h ('k') | athena/util/drag_handle_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/util/drag_handle.cc
diff --git a/athena/util/drag_handle.cc b/athena/util/drag_handle.cc
deleted file mode 100644
index ad19c9adb16ee375d4b6e53d9289dae2ec2ea966..0000000000000000000000000000000000000000
--- a/athena/util/drag_handle.cc
+++ /dev/null
@@ -1,145 +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);
- ~DragHandleView() override;
-
- 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;
- float velocity = 0.0f;
- if (event->type() == ui::ET_SCROLL_FLING_START)
- velocity = event->details().velocity_x();
- delegate_->HandleScrollEnd(velocity);
- 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
« no previous file with comments | « athena/util/drag_handle.h ('k') | athena/util/drag_handle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698