]> git.tdb.fi Git - libs/gltk.git/blob - source/state.h
Rework how widget ownership works in Container
[libs/gltk.git] / source / state.h
1 #ifndef MSP_GLTK_STATE_H_
2 #define MSP_GLTK_STATE_H_
3
4 #include <istream>
5 #include <msp/datafile/value.h>
6
7 namespace Msp {
8 namespace GLtk {
9
10 enum State
11 {
12         NORMAL = 0,   //< Default state
13         HOVER = 1,    //< Pointer over the widget
14         ACTIVE = 2,   //< Widget is active (e.g. pressed button)
15         FOCUS = 4,    //< Widget has input focus
16         DISABLED = 8, //< Widget is unresponsive
17         N_STATES_ = 16 //< Sentry value
18 };
19
20 inline State operator|(State a, State b)
21 { return static_cast<State>(static_cast<int>(a)|static_cast<int>(b)); }
22
23 inline State operator|=(State &a, State b)
24 { a = a|b; return a; }
25
26 inline State operator&(State a, State b)
27 { return static_cast<State>(static_cast<int>(a)&static_cast<int>(b)); }
28
29 inline State operator&=(State &a, State b)
30 { a = a&b; return a; }
31
32 inline State operator~(State a)
33 { return static_cast<State>(~static_cast<int>(a)); }
34
35 extern std::istream &operator>>(std::istream &, State &);
36
37 } // namespace GLtk
38 } // namespace Msp
39
40 #endif