| 136 | } |
| 137 | |
| 138 | py::object get_next_keypress(image_window& win, bool get_keyboard_modifiers) |
| 139 | { |
| 140 | unsigned long key; |
| 141 | bool is_printable; |
| 142 | unsigned long state; |
| 143 | |
| 144 | auto state_to_list = [&]() { |
| 145 | py::list mods; |
| 146 | if (state&base_window::KBD_MOD_SHIFT) mods.append(base_window::KBD_MOD_SHIFT); |
| 147 | if (state&base_window::KBD_MOD_CONTROL) mods.append(base_window::KBD_MOD_CONTROL); |
| 148 | if (state&base_window::KBD_MOD_ALT) mods.append(base_window::KBD_MOD_ALT); |
| 149 | if (state&base_window::KBD_MOD_META) mods.append(base_window::KBD_MOD_META); |
| 150 | if (state&base_window::KBD_MOD_CAPS_LOCK) mods.append(base_window::KBD_MOD_CAPS_LOCK); |
| 151 | if (state&base_window::KBD_MOD_NUM_LOCK) mods.append(base_window::KBD_MOD_NUM_LOCK); |
| 152 | if (state&base_window::KBD_MOD_SCROLL_LOCK) mods.append(base_window::KBD_MOD_SCROLL_LOCK); |
| 153 | return mods; |
| 154 | }; |
| 155 | |
| 156 | if(win.get_next_keypress(key, is_printable, state)) |
| 157 | { |
| 158 | if (is_printable) |
| 159 | { |
| 160 | if (get_keyboard_modifiers) |
| 161 | return py::make_tuple((char)key, state_to_list()); |
| 162 | else |
| 163 | return py::cast((char)key); |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | if (get_keyboard_modifiers) |
| 168 | return py::make_tuple(static_cast<base_window::non_printable_keyboard_keys>(key), state_to_list()); |
| 169 | else |
| 170 | return py::cast(static_cast<base_window::non_printable_keyboard_keys>(key)); |
| 171 | } |
| 172 | } |
| 173 | else |
| 174 | { |
| 175 | if (get_keyboard_modifiers) |
| 176 | return py::make_tuple(py::none(), py::none()); |
| 177 | else |
| 178 | return py::none(); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | template <typename point_type> |
| 183 | void add_overlay_circle ( |
no test coverage detected