TGUI  0.8-dev
Callback.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2017 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef TGUI_CALLBACK_HPP
27 #define TGUI_CALLBACK_HPP
28 
29 #include <TGUI/Config.hpp>
30 #include <SFML/System/Vector2.hpp>
31 #include <SFML/System/String.hpp>
32 #include <string>
33 
35 
36 namespace tgui
37 {
38  class Widget;
39 
41  // @brief Struct that tells more about the callback that happened
43  struct TGUI_API Callback
44  {
45  // The callback id that was passed to the widget. It is used to identify from what widget the callback came from
46  unsigned int id = 0;
47 
48  // How did the callback occur?
49  std::string trigger;
50 
51  // Pointer to the widget
52  Widget* widget = nullptr;
53 
54  // The type of the widget
55  std::string widgetType = "Unknown";
56 
57  // When the mouse has something to do with the callback then this data will be filled
58  sf::Vector2i mouse;
59 
60  // This text is only used by some widgets, but it can be set together with some other member
61  sf::String text;
62 
63  // Used to identify an item
64  sf::String itemId;
65 
66  // Only one of these things can be filled at a given time
67  bool checked = false;
68  int value = 0;
69  unsigned int index = 0;
70  sf::Vector2f value2d;
71  sf::Vector2f position;
72  sf::Vector2f size;
73  };
74 
76 }
77 
79 
80 #endif // TGUI_CALLBACK_HPP
81 
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
The parent class for every widget.
Definition: Widget.hpp:72
Definition: Callback.hpp:43