Mercurial > projects > doodle
view doodle/tk/types.d @ 63:20d6327c4a75
Event progress. Got key press/release working and panning via keyboard.
author | daveb |
---|---|
date | Thu, 12 Aug 2010 16:35:24 +0930 |
parents | 1b4c9ba58673 |
children | eb5436b47d13 |
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")); 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; } }