SDXFrameWork 0.12 SDXFrameWork

- Main Page
- Related Pages
- Classes

All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Gesture.h
1 //Copyright © 2014 SDXFramework
2 //[License]GNU Affero General Public License, version 3
3 //[Contact]http://sourceforge.jp/projects/dxframework/
4 #pragma once
5 #include <Multimedia/Key.h>
6 #include <Multimedia/Window.h>
7
8 namespace SDX
9 {
12 class Gesture
13 {
14 friend class Input;
15 private:
16 MONO_STATE(Gesture)
17
18 bool press = false;
19 double xBuffer = 0;
20 double yBuffer = 0;
21
22 void Position(double X座標, double Y座標)
23 {
24 const double aspA = Window::activeWindow->aspect;
25 const double aspB = (double)Window::GetWidth() / Window::GetHeight();
26
27 if (aspA == aspB)
28 {
29 xBuffer = int(X座標 * Window::GetWidth());
30 yBuffer = int(Y座標 * Window::GetHeight());
31 }
32 else if (aspA > aspB){
33 //横が余る
34 double rate = aspA / aspB;
35 double pos = (X座標 - (rate - 1) / rate / 2) * rate;
36 xBuffer = int(pos * Window::GetWidth());
37 yBuffer = int(Y座標 * Window::GetHeight());
38 }
39 else{
40 //上が余る
41 double rate = aspB / aspA;
42 double pos = (Y座標 - (rate - 1) / rate / 2) * rate;
43 xBuffer = int(X座標 * Window::GetWidth());
44 yBuffer = int(pos * Window::GetHeight());
45 }
46 }
47 public:
48 bool on = false;
49
50 double rotate = 0;
51 double pinche = 0;
52
53 double x = 0;
54 double y = 0;
55
56 int fingerCount = 0;
57
59 void Update()
60 {
61 on = press;
62 press = false;
63 }
64
66 void Reset()
67 {
68 press = false;
69 on = false;
70 rotate = 0;
71 pinche = 0;
72 x = 0;
73 y = 0;
74 fingerCount = 0;
75 }
76 };
77 }
SDX::Window::GetWidth
static int GetWidth()
ウィンドウ幅の取得.
Definition: Window.h:65
SDX::Window::GetHeight
static int GetHeight()
ウィンドウ高さの取得.
Definition: Window.h:71
SDX::Gesture::fingerCount
int fingerCount
ジェスチャーに使った指の本数
Definition: Gesture.h:56
SDX::Gesture::Update
void Update()
状態の更新.
Definition: Gesture.h:59
SDX::Gesture
タッチ操作の各種ジェスチャー.
Definition: Gesture.h:12
SDX::Gesture::on
bool on
何らかのジェスチャーが発生した時にtrue
Definition: Gesture.h:48
SDX::Gesture::pinche
double pinche
ピンチ操作
Definition: Gesture.h:51
SDX::Gesture::y
double y
ジェスチャー操作の中心点
Definition: Gesture.h:54
SDX::Gesture::rotate
double rotate
回転ジェスチャー
Definition: Gesture.h:50
SDX::Gesture::Reset
void Reset()
状態をリセット.
Definition: Gesture.h:66
SDX::Gesture::x
double x
ジェスチャー操作の中心点
Definition: Gesture.h:53
SDX::Input
キーやマウスによる入力をまとめて管理するクラス.
Definition: Input.h:17
SDX::Window::activeWindow
static SubWindow * activeWindow
現在アクティブなウィンドウ
Definition: Window.h:24