screen_button.h
1 /*************************************************************************/
2 /* screen_button.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9 /* */
10 /* Permission is hereby granted, free of charge, to any person obtaining */
11 /* a copy of this software and associated documentation files (the */
12 /* "Software"), to deal in the Software without restriction, including */
13 /* without limitation the rights to use, copy, modify, merge, publish, */
14 /* distribute, sublicense, and/or sell copies of the Software, and to */
15 /* permit persons to whom the Software is furnished to do so, subject to */
16 /* the following conditions: */
17 /* */
18 /* The above copyright notice and this permission notice shall be */
19 /* included in all copies or substantial portions of the Software. */
20 /* */
21 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 /*************************************************************************/
29 #ifndef SCREEN_BUTTON_H
30 #define SCREEN_BUTTON_H
31 
32 #include "scene/2d/node_2d.h"
33 #include "scene/resources/texture.h"
34 #include "scene/resources/bit_mask.h"
35 
36 class TouchScreenButton : public Node2D {
37 
38  OBJ_TYPE(TouchScreenButton,Node2D);
39 public:
40 
41  enum VisibilityMode {
42  VISIBILITY_ALWAYS,
43  VISIBILITY_TOUCHSCREEN_ONLY
44  };
45 
46 private:
47  Ref<Texture> texture;
48  Ref<Texture> texture_pressed;
49  Ref<BitMap> bitmask;
50 
51  StringName action;
52  bool passby_press;
53  int finger_pressed;
54  int action_id;
55 
56  VisibilityMode visibility;
57 
58  void _input(const InputEvent& p_Event);
59 
60 protected:
61 
62  void _notification(int p_what);
63  static void _bind_methods();
64 public:
65 
66 
67  void set_texture(const Ref<Texture>& p_texture);
68  Ref<Texture> get_texture() const;
69 
70  void set_texture_pressed(const Ref<Texture>& p_texture_pressed);
71  Ref<Texture> get_texture_pressed() const;
72 
73  void set_bitmask(const Ref<BitMap>& p_bitmask);
74  Ref<BitMap> get_bitmask() const;
75 
76  void set_action(const String& p_action);
77  String get_action() const;
78 
79  void set_passby_press(bool p_enable);
80  bool is_passby_press_enabled() const;
81 
82  void set_visibility_mode(VisibilityMode p_mode);
83  VisibilityMode get_visibility_mode() const;
84 
85  bool is_pressed() const;
86 
87  Rect2 get_item_rect() const;
88 
89 
91 };
92 
93 VARIANT_ENUM_CAST(TouchScreenButton::VisibilityMode);
94 
95 #endif // SCREEN_BUTTON_H
Definition: math_2d.h:204
Definition: string_db.h:48
Definition: input_event.h:263
Definition: screen_button.h:36
Definition: node_2d.h:34
Definition: ustring.h:64