naelstrof пре 7 година
родитељ
комит
33adb69592
8 измењених фајлова са 91 додато и 204 уклоњено
  1. 2
    2
      CMakeLists.txt
  2. 12
    42
      src/glslop.cpp
  3. 2
    5
      src/main.cpp
  4. 4
    30
      src/slop.hpp
  5. 42
    0
      src/slopstates.cpp
  6. 19
    2
      src/slopstates.hpp
  7. 10
    43
      src/xslop.cpp
  8. 0
    80
      src/xslop.hpp

+ 2
- 2
CMakeLists.txt Прегледај датотеку

@@ -52,7 +52,7 @@ if ( SLOP_LEGACY_MODE )
52 52
     # Install targets
53 53
     install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )
54 54
     install( TARGETS ${LIBRARY_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" )
55
-    install( FILES ${CMAKE_SOURCE_DIR}/src/xslop.hpp DESTINATION "${CMAKE_INSTALL_PREFIX}/include" )
55
+    install( FILES ${CMAKE_SOURCE_DIR}/src/slop.hpp DESTINATION "${CMAKE_INSTALL_PREFIX}/include" )
56 56
 else()
57 57
     add_library(${LIBRARY_NAME} SHARED  src/mouse.cpp
58 58
                                         src/keyboard.cpp
@@ -87,5 +87,5 @@ else()
87 87
     # Install targets
88 88
     install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )
89 89
     install( TARGETS ${LIBRARY_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" )
90
-    install( FILES ${CMAKE_SOURCE_DIR}/src/glslop.hpp DESTINATION "${CMAKE_INSTALL_PREFIX}/include" )
90
+    install( FILES ${CMAKE_SOURCE_DIR}/src/slop.hpp DESTINATION "${CMAKE_INSTALL_PREFIX}/include" )
91 91
 endif()

+ 12
- 42
src/glslop.cpp Прегледај датотеку

@@ -1,4 +1,15 @@
1
-#include "glslop.hpp"
1
+#include "slop.hpp"
2
+
3
+#include "slopstates.hpp"
4
+#include "mouse.hpp"
5
+#include "resource.hpp"
6
+#include "keyboard.hpp"
7
+
8
+#include "window.hpp"
9
+#include "shader.hpp"
10
+#include "framebuffer.hpp"
11
+#include "rectangle.hpp"
12
+
2 13
 
3 14
 X11* x11;
4 15
 Mouse* mouse;
@@ -28,47 +39,6 @@ SlopSelection::SlopSelection( float x, float y, float w, float h, Window id ) {
28 39
     this->id = id;
29 40
 }
30 41
 
31
-SlopMemory::SlopMemory( SlopOptions* options ) {
32
-    running = true;
33
-    state = (SlopState*)new SlopStart();
34
-    nextState = NULL;
35
-    tolerance = options->tolerance;
36
-    nodecorations = options->nodecorations;
37
-    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);
38
-    selectedWindow = x11->root;
39
-    state->onEnter( *this );
40
-}
41
-
42
-SlopMemory::~SlopMemory() {
43
-    delete state;
44
-    if ( nextState ) {
45
-        delete nextState;
46
-    }
47
-    delete rectangle;
48
-}
49
-
50
-void SlopMemory::update( double dt ) {
51
-    state->update( *this, dt );
52
-    if ( nextState ) {
53
-        state->onExit( *this );
54
-        delete state;
55
-        state = nextState;
56
-        state->onEnter( *this );
57
-        nextState = NULL;
58
-    }
59
-}
60
-
61
-void SlopMemory::setState( SlopState* state ) {
62
-    if ( nextState ) {
63
-        delete nextState;
64
-    }
65
-    nextState = state;
66
-}
67
-
68
-void SlopMemory::draw( glm::mat4& matrix ) {
69
-    state->draw( *this, matrix );
70
-}
71
-
72 42
 SlopSelection SlopSelect( SlopOptions* options, bool* cancelled ) {
73 43
     bool deleteOptions = false;
74 44
     if ( !options ) {

+ 2
- 5
src/main.cpp Прегледај датотеку

@@ -20,11 +20,7 @@
20 20
 
21 21
 #include <iostream>
22 22
 #include <sstream>
23
-#ifdef SLOP_LEGACY_MODE
24
-#include "xslop.hpp"
25
-#else
26
-#include "glslop.hpp"
27
-#endif
23
+#include "slop.hpp"
28 24
 #include "options.hpp"
29 25
 
30 26
 SlopOptions* getOptions( Options& options ) {
@@ -34,6 +30,7 @@ SlopOptions* getOptions( Options& options ) {
34 30
     options.getFloat("tolerance", 't', foo->tolerance);
35 31
     glm::vec4 color = glm::vec4( foo->r, foo->g, foo->b, foo->a );
36 32
     options.getColor("color", 'c', color);
33
+    options.getBool("nokeyboard", 'k', foo->nokeyboard);
37 34
     options.getString( "xdisplay", 'x', foo->xdisplay );
38 35
 #ifndef SLOP_LEGACY_MODE
39 36
     options.getString( "shader", 's', foo->shader );

src/glslop.hpp → src/slop.hpp Прегледај датотеку

@@ -23,17 +23,6 @@
23 23
 
24 24
 #include <string>
25 25
 
26
-#include "window.hpp"
27
-#include "shader.hpp"
28
-#include "framebuffer.hpp"
29
-#include "rectangle.hpp"
30
-#include "slopstates.hpp"
31
-#include "keyboard.hpp"
32
-#include "mouse.hpp"
33
-#include "resource.hpp"
34
-
35
-class SlopState;
36
-
37 26
 class SlopOptions {
38 27
 public:
39 28
     SlopOptions();
@@ -41,6 +30,7 @@ public:
41 30
     float padding;
42 31
     float tolerance;
43 32
     bool highlight;
33
+    bool nokeyboard;
44 34
     bool nodecorations;
45 35
     std::string shader;
46 36
     float r;
@@ -52,29 +42,13 @@ public:
52 42
 
53 43
 class SlopSelection {
54 44
 public:
55
-    SlopSelection( float x, float y, float w, float h, Window id );
45
+    SlopSelection( float x, float y, float w, float h, int id );
56 46
     float x;
57 47
     float y;
58 48
     float w;
59 49
     float h;
60
-    Window id;
61
-};
62
-
63
-class SlopMemory {
64
-private:
65
-    SlopState* state;
66
-    SlopState* nextState;
67
-public:
68
-    SlopMemory( SlopOptions* options );
69
-    ~SlopMemory();
70
-    Window selectedWindow;
71
-    bool running;
72
-    float tolerance;
73
-    bool nodecorations;
74
-    Rectangle* rectangle;
75
-    void setState( SlopState* state );
76
-    void update( double dt );
77
-    void draw( glm::mat4& matrix );
50
+// This is an X11 Window ID
51
+    int id;
78 52
 };
79 53
 
80 54
 SlopSelection SlopSelect( SlopOptions* options = NULL, bool* cancelled = NULL );

+ 42
- 0
src/slopstates.cpp Прегледај датотеку

@@ -1,5 +1,47 @@
1 1
 #include "slopstates.hpp"
2 2
 
3
+SlopMemory::SlopMemory( SlopOptions* options ) {
4
+    running = true;
5
+    state = (SlopState*)new SlopStart();
6
+    nextState = NULL;
7
+    tolerance = options->tolerance;
8
+    nodecorations = options->nodecorations;
9
+    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);
10
+    selectedWindow = x11->root;
11
+    state->onEnter( *this );
12
+}
13
+
14
+SlopMemory::~SlopMemory() {
15
+    delete state;
16
+    if ( nextState ) {
17
+        delete nextState;
18
+    }
19
+    delete rectangle;
20
+}
21
+
22
+void SlopMemory::update( double dt ) {
23
+    state->update( *this, dt );
24
+    if ( nextState ) {
25
+        state->onExit( *this );
26
+        delete state;
27
+        state = nextState;
28
+        state->onEnter( *this );
29
+        nextState = NULL;
30
+    }
31
+}
32
+
33
+void SlopMemory::setState( SlopState* state ) {
34
+    if ( nextState ) {
35
+        delete nextState;
36
+    }
37
+    nextState = state;
38
+}
39
+
40
+void SlopMemory::draw( glm::mat4& matrix ) {
41
+    state->draw( *this, matrix );
42
+}
43
+
44
+
3 45
 SlopState::~SlopState() {
4 46
 }
5 47
 void SlopState::onEnter( SlopMemory& memory ) {

+ 19
- 2
src/slopstates.hpp Прегледај датотеку

@@ -23,12 +23,11 @@
23 23
 
24 24
 #include "mouse.hpp"
25 25
 #include "windowhelper.hpp"
26
+#include "slop.hpp"
26 27
 
27 28
 #ifdef SLOP_LEGACY_MODE
28
-#include "xslop.hpp"
29 29
 #include "xshaperectangle.hpp"
30 30
 #else
31
-#include "glslop.hpp"
32 31
 #include "rectangle.hpp"
33 32
 #endif
34 33
 
@@ -68,4 +67,22 @@ public:
68 67
     virtual void onEnter( SlopMemory& memory );
69 68
 };
70 69
 
70
+class SlopMemory {
71
+private:
72
+    SlopState* state;
73
+    SlopState* nextState;
74
+public:
75
+    SlopMemory( SlopOptions* options );
76
+    ~SlopMemory();
77
+    Window selectedWindow;
78
+    bool running;
79
+    float tolerance;
80
+    bool nodecorations;
81
+    Rectangle* rectangle;
82
+    void setState( SlopState* state );
83
+    void update( double dt );
84
+    void draw( glm::mat4& matrix );
85
+};
86
+
87
+
71 88
 #endif // N_SLOPSTATES_H_

+ 10
- 43
src/xslop.cpp Прегледај датотеку

@@ -1,4 +1,12 @@
1
-#include "xslop.hpp"
1
+#include "slop.hpp"
2
+
3
+#include "slopstates.hpp"
4
+#include "mouse.hpp"
5
+#include "resource.hpp"
6
+#include "keyboard.hpp"
7
+#include <chrono>
8
+#include <thread>
9
+#include "xshaperectangle.hpp"
2 10
 
3 11
 X11* x11;
4 12
 Mouse* mouse;
@@ -19,7 +27,7 @@ SlopOptions::SlopOptions() {
19 27
     a = 1;
20 28
 }
21 29
 
22
-SlopSelection::SlopSelection( float x, float y, float w, float h, Window id ) {
30
+SlopSelection::SlopSelection( float x, float y, float w, float h, int id ) {
23 31
     this->x = x;
24 32
     this->y = y;
25 33
     this->w = w;
@@ -27,47 +35,6 @@ SlopSelection::SlopSelection( float x, float y, float w, float h, Window id ) {
27 35
     this->id = id;
28 36
 }
29 37
 
30
-SlopMemory::SlopMemory( SlopOptions* options ) {
31
-    running = true;
32
-    state = (SlopState*)new SlopStart();
33
-    nextState = NULL;
34
-    tolerance = options->tolerance;
35
-    nodecorations = options->nodecorations;
36
-    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);
37
-    selectedWindow = x11->root;
38
-    state->onEnter( *this );
39
-}
40
-
41
-SlopMemory::~SlopMemory() {
42
-    delete state;
43
-    if ( nextState ) {
44
-        delete nextState;
45
-    }
46
-    delete rectangle;
47
-}
48
-
49
-void SlopMemory::update( double dt ) {
50
-    state->update( *this, dt );
51
-    if ( nextState ) {
52
-        state->onExit( *this );
53
-        delete state;
54
-        state = nextState;
55
-        state->onEnter( *this );
56
-        nextState = NULL;
57
-    }
58
-}
59
-
60
-void SlopMemory::setState( SlopState* state ) {
61
-    if ( nextState ) {
62
-        delete nextState;
63
-    }
64
-    nextState = state;
65
-}
66
-
67
-void SlopMemory::draw( glm::mat4& matrix ) {
68
-    state->draw( *this, matrix );
69
-}
70
-
71 38
 SlopSelection SlopSelect( SlopOptions* options, bool* cancelled ) {
72 39
     bool deleteOptions = false;
73 40
     if ( !options ) {

+ 0
- 80
src/xslop.hpp Прегледај датотеку

@@ -1,80 +0,0 @@
1
-/* slop.hpp: exposes a selection interface
2
- *
3
- * Copyright (C) 2014: Dalton Nell, Slop Contributors (https://github.com/naelstrof/slop/graphs/contributors).
4
- *
5
- * This file is part of Slop.
6
- *
7
- * Slop 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 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * Slop 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 Slop.  If not, see <http://www.gnu.org/licenses/>.
19
- */
20
-
21
-#ifndef N_SLOP_H_
22
-#define N_SLOP_H_
23
-
24
-#include <string>
25
-#include <chrono>
26
-#include <thread>
27
-
28
-#include "xshaperectangle.hpp"
29
-#include "slopstates.hpp"
30
-#include "keyboard.hpp"
31
-#include "mouse.hpp"
32
-#include "resource.hpp"
33
-
34
-class SlopState;
35
-
36
-class SlopOptions {
37
-public:
38
-    SlopOptions();
39
-    float borderSize;
40
-    float padding;
41
-    float tolerance;
42
-    bool highlight;
43
-    bool nodecorations;
44
-    float r;
45
-    float g;
46
-    float b;
47
-    float a;
48
-    std::string xdisplay;
49
-};
50
-
51
-class SlopSelection {
52
-public:
53
-    SlopSelection( float x, float y, float w, float h, Window id );
54
-    float x;
55
-    float y;
56
-    float w;
57
-    float h;
58
-    Window id;
59
-};
60
-
61
-class SlopMemory {
62
-private:
63
-    SlopState* state;
64
-    SlopState* nextState;
65
-public:
66
-    SlopMemory( SlopOptions* options );
67
-    ~SlopMemory();
68
-    Window selectedWindow;
69
-    bool running;
70
-    float tolerance;
71
-    bool nodecorations;
72
-    Rectangle* rectangle;
73
-    void setState( SlopState* state );
74
-    void update( double dt );
75
-    void draw( glm::mat4& matrix );
76
-};
77
-
78
-SlopSelection SlopSelect( SlopOptions* options = NULL, bool* cancelled = NULL );
79
-
80
-#endif // N_SLOP_H_