Browse Source

selecting windows works now

naelstrof 7 years ago
parent
commit
bdd433c1f7
3 changed files with 17 additions and 3 deletions
  1. 1
    0
      src/slop.cpp
  2. 12
    3
      src/slopstates.cpp
  3. 4
    0
      src/slopstates.hpp

+ 1
- 0
src/slop.cpp View File

29
     state = (SlopState*)new SlopStart();
29
     state = (SlopState*)new SlopStart();
30
     nextState = NULL;
30
     nextState = NULL;
31
     rectangle = new Rectangle(glm::vec2(0,0), glm::vec2(0,0), options->borderSize, options->padding, glm::vec4( options->r, options->g, options->b, options->a ), options->highlight);
31
     rectangle = new Rectangle(glm::vec2(0,0), glm::vec2(0,0), options->borderSize, options->padding, glm::vec4( options->r, options->g, options->b, options->a ), options->highlight);
32
+    state->onEnter( *this );
32
 }
33
 }
33
 
34
 
34
 SlopMemory::~SlopMemory() {
35
 SlopMemory::~SlopMemory() {

+ 12
- 3
src/slopstates.cpp View File

11
 void SlopState::draw( SlopMemory& memory, glm::mat4 matrix ) {
11
 void SlopState::draw( SlopMemory& memory, glm::mat4 matrix ) {
12
 }
12
 }
13
 
13
 
14
-// Start
14
+void SlopStart::onEnter( SlopMemory& memory ) {
15
+    setStartPos = false;
16
+}
15
 void SlopStart::update( SlopMemory& memory, double dt ) {
17
 void SlopStart::update( SlopMemory& memory, double dt ) {
16
-    if ( mouse->getButton( 1 ) ) {
17
-        memory.setState( (SlopState*)new SlopStartDrag( mouse->getMousePos() ) );
18
+    if ( mouse->getButton( 1 ) && !setStartPos ) {
19
+        startPos = mouse->getMousePos();
20
+        setStartPos = true;
21
+    }
22
+    if ( setStartPos && glm::distance( startPos, mouse->getMousePos() ) > 4 ) {
23
+        memory.setState( (SlopState*)new SlopStartDrag( startPos ) );
18
     }
24
     }
19
     if ( mouse->hoverWindow != None ) {
25
     if ( mouse->hoverWindow != None ) {
20
         glm::vec4 rect = getWindowGeometry( mouse->hoverWindow, true );
26
         glm::vec4 rect = getWindowGeometry( mouse->hoverWindow, true );
21
         memory.rectangle->setPoints( glm::vec2( (float)rect.x, (float)rect.y ), glm::vec2( (float)rect.x+rect.z, (float)rect.y+rect.w ) );
27
         memory.rectangle->setPoints( glm::vec2( (float)rect.x, (float)rect.y ), glm::vec2( (float)rect.x+rect.z, (float)rect.y+rect.w ) );
22
     }
28
     }
29
+    if ( setStartPos && !mouse->getButton( 1 ) ) {
30
+        memory.setState( (SlopState*)new SlopEndDrag() );
31
+    }
23
 }
32
 }
24
 
33
 
25
 void SlopStart::draw( SlopMemory& memory, glm::mat4 matrix ) {
34
 void SlopStart::draw( SlopMemory& memory, glm::mat4 matrix ) {

+ 4
- 0
src/slopstates.hpp View File

38
 };
38
 };
39
 
39
 
40
 class SlopStart : SlopState {
40
 class SlopStart : SlopState {
41
+private:
42
+    bool setStartPos;
43
+    glm::vec2 startPos;
41
 public:
44
 public:
45
+    virtual void onEnter( SlopMemory& memory );
42
     virtual void update( SlopMemory& memory, double dt );
46
     virtual void update( SlopMemory& memory, double dt );
43
     virtual void draw( SlopMemory& memory, glm::mat4 matrix );
47
     virtual void draw( SlopMemory& memory, glm::mat4 matrix );
44
 };
48
 };