Blame view

build2/epsilon-master/ion/src/shared/events_modifier.cpp 2.41 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  #include <ion.h>
  #include <assert.h>
  
  namespace Ion {
  namespace Events {
  
  static ShiftAlphaStatus sShiftAlphaStatus = ShiftAlphaStatus::Default;
  
  ShiftAlphaStatus shiftAlphaStatus() {
    return sShiftAlphaStatus;
  }
  
  bool isShiftActive() {
    return sShiftAlphaStatus == ShiftAlphaStatus::Shift || sShiftAlphaStatus == ShiftAlphaStatus::ShiftAlpha || sShiftAlphaStatus == ShiftAlphaStatus::ShiftAlphaLock;
  }
  
  bool isAlphaActive() {
    return sShiftAlphaStatus == ShiftAlphaStatus::Alpha || sShiftAlphaStatus == ShiftAlphaStatus::ShiftAlpha || sShiftAlphaStatus == ShiftAlphaStatus::AlphaLock || sShiftAlphaStatus == ShiftAlphaStatus::ShiftAlphaLock;
  ;
  }
  
  void setShiftAlphaStatus(ShiftAlphaStatus s) {
    sShiftAlphaStatus = s;
  }
  
  void updateModifiersFromEvent(Event e) {
    assert(e.isKeyboardEvent());
    switch (sShiftAlphaStatus) {
      case ShiftAlphaStatus::Default:
        if (e == Shift) {
          sShiftAlphaStatus = ShiftAlphaStatus::Shift;
        } else if (e == Alpha) {
          sShiftAlphaStatus = ShiftAlphaStatus::Alpha;
        }
        break;
      case ShiftAlphaStatus::Shift:
        if (e == Shift) {
          sShiftAlphaStatus = ShiftAlphaStatus::Default;
        } else if (e == Alpha) {
          sShiftAlphaStatus = ShiftAlphaStatus::ShiftAlpha;
        } else {
          sShiftAlphaStatus = ShiftAlphaStatus::Default;
        }
        break;
      case ShiftAlphaStatus::Alpha:
        if (e == Shift) {
            sShiftAlphaStatus = ShiftAlphaStatus::ShiftAlpha;
          } else if (e == Alpha) {
            sShiftAlphaStatus = ShiftAlphaStatus::AlphaLock;
          } else {
            sShiftAlphaStatus = ShiftAlphaStatus::Default;
          }
          break;
        case ShiftAlphaStatus::ShiftAlpha:
          if (e == Shift) {
            sShiftAlphaStatus = ShiftAlphaStatus::Alpha;
          } else if (e == Alpha) {
            sShiftAlphaStatus = ShiftAlphaStatus::ShiftAlphaLock;
          } else {
            sShiftAlphaStatus = ShiftAlphaStatus::Default;
          }
          break;
        case ShiftAlphaStatus::AlphaLock:
          if (e == Shift) {
            sShiftAlphaStatus = ShiftAlphaStatus::ShiftAlphaLock;
          } else if (e == Alpha) {
            sShiftAlphaStatus = ShiftAlphaStatus::Default;
          }
          break;
        case ShiftAlphaStatus::ShiftAlphaLock:
          if (e == Shift) {
            sShiftAlphaStatus = ShiftAlphaStatus::AlphaLock;
          } else if (e == Alpha) {
            sShiftAlphaStatus = ShiftAlphaStatus::Default;
          }
          break;
      }
  }
  
  }
  }