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

Side by Side Diff: chrome/browser/ui/views/desktop_media_picker_views.cc

Issue 317783007: Handle tap gestures in desktop media picker's source list (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/media/desktop_media_picker.h" 5 #include "chrome/browser/media/desktop_media_picker.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "chrome/browser/media/desktop_media_list.h" 8 #include "chrome/browser/media/desktop_media_list.h"
9 #include "chrome/browser/media/desktop_media_list_observer.h" 9 #include "chrome/browser/media/desktop_media_list_observer.h"
10 #include "chrome/browser/ui/ash/ash_util.h" 10 #include "chrome/browser/ui/ash/ash_util.h"
11 #include "components/web_modal/web_contents_modal_dialog_host.h" 11 #include "components/web_modal/web_contents_modal_dialog_host.h"
12 #include "components/web_modal/web_contents_modal_dialog_manager.h" 12 #include "components/web_modal/web_contents_modal_dialog_manager.h"
13 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 13 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/events/event_constants.h"
18 #include "ui/events/keycodes/keyboard_codes.h" 19 #include "ui/events/keycodes/keyboard_codes.h"
19 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
20 #include "ui/native_theme/native_theme.h" 21 #include "ui/native_theme/native_theme.h"
21 #include "ui/views/background.h" 22 #include "ui/views/background.h"
22 #include "ui/views/controls/image_view.h" 23 #include "ui/views/controls/image_view.h"
23 #include "ui/views/controls/label.h" 24 #include "ui/views/controls/label.h"
24 #include "ui/views/controls/scroll_view.h" 25 #include "ui/views/controls/scroll_view.h"
25 #include "ui/views/layout/box_layout.h" 26 #include "ui/views/layout/box_layout.h"
26 #include "ui/views/layout/layout_constants.h" 27 #include "ui/views/layout/layout_constants.h"
27 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 91
91 // views::View interface. 92 // views::View interface.
92 virtual const char* GetClassName() const OVERRIDE; 93 virtual const char* GetClassName() const OVERRIDE;
93 virtual void Layout() OVERRIDE; 94 virtual void Layout() OVERRIDE;
94 virtual views::View* GetSelectedViewForGroup(int group) OVERRIDE; 95 virtual views::View* GetSelectedViewForGroup(int group) OVERRIDE;
95 virtual bool IsGroupFocusTraversable() const OVERRIDE; 96 virtual bool IsGroupFocusTraversable() const OVERRIDE;
96 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 97 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
97 virtual void OnFocus() OVERRIDE; 98 virtual void OnFocus() OVERRIDE;
98 virtual void OnBlur() OVERRIDE; 99 virtual void OnBlur() OVERRIDE;
99 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; 100 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
101 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
100 102
101 private: 103 private:
102 DesktopMediaListView* parent_; 104 DesktopMediaListView* parent_;
103 DesktopMediaID source_id_; 105 DesktopMediaID source_id_;
104 106
105 views::ImageView* image_view_; 107 views::ImageView* image_view_;
106 views::Label* label_; 108 views::Label* label_;
107 109
108 bool selected_; 110 bool selected_;
109 111
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 bool DesktopMediaSourceView::OnMousePressed(const ui::MouseEvent& event) { 331 bool DesktopMediaSourceView::OnMousePressed(const ui::MouseEvent& event) {
330 if (event.GetClickCount() == 1) { 332 if (event.GetClickCount() == 1) {
331 RequestFocus(); 333 RequestFocus();
332 } else if (event.GetClickCount() == 2) { 334 } else if (event.GetClickCount() == 2) {
333 RequestFocus(); 335 RequestFocus();
334 parent_->OnDoubleClick(); 336 parent_->OnDoubleClick();
335 } 337 }
336 return true; 338 return true;
337 } 339 }
338 340
341 void DesktopMediaSourceView::OnGestureEvent(ui::GestureEvent* event) {
342 if (event->type() == ui::ET_GESTURE_TAP &&
343 event->details().tap_count() == 2) {
344 RequestFocus();
345 parent_->OnDoubleClick();
346 event->SetHandled();
347 return;
348 }
349
350 // Detect tap gesture using ET_GESTURE_TAP_DOWN so the view also gets focused
351 // on the long tap (when the tap gesture starts).
352 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
353 RequestFocus();
354 event->SetHandled();
355 }
356 }
357
339 DesktopMediaListView::DesktopMediaListView( 358 DesktopMediaListView::DesktopMediaListView(
340 DesktopMediaPickerDialogView* parent, 359 DesktopMediaPickerDialogView* parent,
341 scoped_ptr<DesktopMediaList> media_list) 360 scoped_ptr<DesktopMediaList> media_list)
342 : parent_(parent), 361 : parent_(parent),
343 media_list_(media_list.Pass()) { 362 media_list_(media_list.Pass()) {
344 media_list_->SetThumbnailSize(gfx::Size(kThumbnailWidth, kThumbnailHeight)); 363 media_list_->SetThumbnailSize(gfx::Size(kThumbnailWidth, kThumbnailHeight));
345 } 364 }
346 365
347 DesktopMediaListView::~DesktopMediaListView() {} 366 DesktopMediaListView::~DesktopMediaListView() {}
348 367
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 base::Bind(callback_, source)); 697 base::Bind(callback_, source));
679 callback_.Reset(); 698 callback_.Reset();
680 } 699 }
681 700
682 } // namespace 701 } // namespace
683 702
684 // static 703 // static
685 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 704 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
686 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 705 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
687 } 706 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698