Mercurial > projects > doodle
view doodle/tk/types.d @ 64:eb5436b47d13
Implemented crossing events
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Thu, 12 Aug 2010 22:21:12 +0930 |
parents | 20d6327c4a75 |
children | 43cc2135ced0 |
line wrap: on
line source
module doodle.tk.types; public { import std.string; } private { import std.typecons; import std.algorithm; } mixin(defineEnum!("ButtonAction", "SINGLE_PRESS", "DOUBLE_PRESS", "TRIPLE_PRESS", "RELEASE")); mixin(defineEnum!("ButtonName", "LEFT", "MIDDLE", "RIGHT", "FOUR", "FIVE")); mixin(defineEnum!("ScrollDirection", "UP", "DOWN", "LEFT", "RIGHT")); mixin(defineEnum!("Modifier", "SHIFT", "CAPS_LOCK", "CONTROL", "ALT", "NUM_LOCK", "META", "SCROLL_LOCK", "LEFT_BUTTON", "MIDDLE_BUTTON", "RIGHT_BUTTON", "UNUSED_BUTTON_1", "UNUSED_BUTTON_2")); mixin(defineEnum!("CrossingMode", // FIXME what to do about GRAB2/UNGRAB2 "NORMAL", "GRAB", "UNGRAB", "GRAB2", "UNGRAB2", "STATE_CHANGED")); struct Mask { this(in Modifier[] modifiers) { foreach (ref m; modifiers) { _bits |= 1 << m; } } string toString() { string s; // FIXME this is terrible for (int i = 0; i < uint.sizeof * 8; ++i) { if (_bits & (1 << i)) { if (s != "") s ~= "|"; s ~= enumToString(cast(Modifier)i); } } return s; } bool isSet(in Modifier m) const { return _bits & (1 << m); } bool isUnset(in Modifier m) const { return !isSet(m); } private { uint _bits; } }