~azzar1/unity/fix-1028810

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/GesturalWindowSwitcher.h

  • Committer: Andrea Azzarone
  • Date: 2012-08-22 13:14:18 UTC
  • mfrom: (2516.1.92 unity)
  • Revision ID: azzaronea@gmail.com-20120822131418-mrfwx82k39xnvl9e
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * GesturalWindowSwitcher.h
 
3
 * This file is part of Unity
 
4
 *
 
5
 * Copyright (C) 2012 - Canonical Ltd.
 
6
 *
 
7
 * Unity is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * Unity is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 *
 
20
 * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
 
21
 */
 
22
 
 
23
#ifndef GESTURAL_WINDOW_SWITCHER_H
 
24
#define GESTURAL_WINDOW_SWITCHER_H
 
25
 
 
26
#include <Nux/Gesture.h>
 
27
#include "CompoundGestureRecognizer.h"
 
28
#include "SwitcherController.h"
 
29
#include <core/timer.h>
 
30
 
 
31
namespace unity
 
32
{
 
33
 
 
34
class UnityScreen;
 
35
class GesturalWindowSwitcherPrivate;
 
36
 
 
37
/*
 
38
  Manipulates the window switcher according to multi-touch gestures
 
39
 
 
40
  The following gestural interactions with the window switcher are implemented:
 
41
 
 
42
  1. 3-fingers double tap -> switches to previous window
 
43
 
 
44
  2. 3-fingers tap followed by 3-fingers hold -> shows window switcher
 
45
     - drag those 3-fingers -> change selected window icon
 
46
     - release fingers -> selects window and closes switcher
 
47
 
 
48
  3. 3-fingers tap followed by 3-fingers hold -> shows window switcher
 
49
     - release fingers -> switcher will kept being shown for some seconds still
 
50
     - drag with one or three fingers -> change selected window
 
51
     - release finger(s) -> selects window and closes switcher
 
52
 
 
53
  4. 3-fingers tap followed by 3-fingers hold -> shows window switcher
 
54
     - release fingers -> switcher will kept being shown for some seconds still
 
55
     - tap on some window icon -> selects that icon and closes the switcher
 
56
 
 
57
 */
 
58
class GesturalWindowSwitcher : public nux::GestureTarget
 
59
{
 
60
  public:
 
61
    GesturalWindowSwitcher();
 
62
    virtual ~GesturalWindowSwitcher();
 
63
 
 
64
    // in milliseconds
 
65
    static const int SWITCHER_TIME_AFTER_DOUBLE_TAP = 350;
 
66
    static const int SWITCHER_TIME_AFTER_HOLD_RELEASED = 7000;
 
67
 
 
68
    // How far, in screen pixels, a drag gesture must go in order
 
69
    // to trigger a change in the selected window.
 
70
    static const float DRAG_DELTA_FOR_CHANGING_SELECTION;
 
71
 
 
72
    // How far, in screen pixels, a mouse pointer must move in order
 
73
    // to be considered dragging the switcher.
 
74
    static const float MOUSE_DRAG_THRESHOLD;
 
75
 
 
76
    virtual nux::GestureDeliveryRequest GestureEvent(nux::GestureEvent const& event);
 
77
 
 
78
  private:
 
79
    GesturalWindowSwitcherPrivate* p;
 
80
};
 
81
typedef std::shared_ptr<GesturalWindowSwitcher> ShPtGesturalWindowSwitcher;
 
82
 
 
83
} // namespace unity
 
84
 
 
85
#endif // GESTURAL_WINDOW_SWITCHER_H