Mercurial > projects > doodle
comparison tk/types.d @ 26:06c30d250c0a
Cleanup
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Thu, 16 Jul 2009 00:12:02 +0930 |
parents | 9e63308b749c |
children |
comparison
equal
deleted
inserted
replaced
25:8f58a8f88735 | 26:06c30d250c0a |
---|---|
9 import std.algorithm; | 9 import std.algorithm; |
10 } | 10 } |
11 | 11 |
12 mixin(defineEnum!("ButtonAction", | 12 mixin(defineEnum!("ButtonAction", |
13 "SINGLE_PRESS", "DOUBLE_PRESS", "TRIPLE_PRESS", "RELEASE")); | 13 "SINGLE_PRESS", "DOUBLE_PRESS", "TRIPLE_PRESS", "RELEASE")); |
14 | |
14 mixin(defineEnum!("ButtonName", | 15 mixin(defineEnum!("ButtonName", |
15 "LEFT", "MIDDLE", "RIGHT", "FOUR", "FIVE")); | 16 "LEFT", "MIDDLE", "RIGHT", "FOUR", "FIVE")); |
17 | |
16 mixin(defineEnum!("ScrollDirection", | 18 mixin(defineEnum!("ScrollDirection", |
17 "UP", "DOWN", "LEFT", "RIGHT")); | 19 "UP", "DOWN", "LEFT", "RIGHT")); |
20 | |
18 mixin(defineEnum!("Modifier", | 21 mixin(defineEnum!("Modifier", |
19 "SHIFT", "CAPS_LOCK", "CONTROL", "ALT", "NUM_LOCK", "META", | 22 "SHIFT", "CAPS_LOCK", "CONTROL", "ALT", "NUM_LOCK", "META", |
20 "SCROLL_LOCK", "LEFT_BUTTON", "MIDDLE_BUTTON", "RIGHT_BUTTON", "UNUSED_BUTTON_1", "UNUSED_BUTTON_2")); | 23 "SCROLL_LOCK", "LEFT_BUTTON", "MIDDLE_BUTTON", "RIGHT_BUTTON", |
24 "UNUSED_BUTTON_1", "UNUSED_BUTTON_2")); | |
21 | 25 |
22 struct Mask { | 26 struct Mask { |
23 this(in Modifier[] modifiers) { | 27 this(in Modifier[] modifiers) { |
24 foreach (ref m; modifiers) { | 28 foreach (ref m; modifiers) { |
25 _bits |= 1 << m; | 29 _bits |= 1 << m; |
27 } | 31 } |
28 | 32 |
29 string toString() { | 33 string toString() { |
30 string s; | 34 string s; |
31 | 35 |
36 // FIXME this is terrible | |
32 for (int i = 0; i < uint.sizeof * 8; ++i) { | 37 for (int i = 0; i < uint.sizeof * 8; ++i) { |
33 if (_bits & (1 << i)) { | 38 if (_bits & (1 << i)) { |
34 if (s != "") s ~= "|"; | 39 if (s != "") s ~= "|"; |
35 s ~= enumToString(cast(Modifier)i); | 40 s ~= enumToString(cast(Modifier)i); |
36 } | 41 } |
37 } | 42 } |
38 | 43 |
39 return s; | 44 return s; |
40 } | 45 } |
41 | 46 |
42 bool is_set(Modifier m) const { | 47 bool is_set(in Modifier m) const { |
43 return _bits & (1 << m); | 48 return _bits & (1 << m); |
44 } | 49 } |
45 | 50 |
46 bool is_unset(Modifier m) const { | 51 bool is_unset(in Modifier m) const { |
47 return !is_set(m); | 52 return !is_set(m); |
48 } | 53 } |
49 | 54 |
50 private { | 55 private { |
51 uint _bits; | 56 uint _bits; |