| 111 | } |
| 112 | |
| 113 | bool |
| 114 | MoveService::key_event (unsigned int key, unsigned int buttons) |
| 115 | { |
| 116 | if (lay::EditorServiceBase::key_event (key, buttons)) { |
| 117 | return true; |
| 118 | } |
| 119 | |
| 120 | if (buttons == 0 && (key == lay::KeyEnter || key == lay::KeyReturn)) { |
| 121 | finish_move (); |
| 122 | return true; |
| 123 | } |
| 124 | |
| 125 | double dx = 0.0, dy = 0.0; |
| 126 | if (int (key) == lay::KeyDown) { |
| 127 | dy = -1.0; |
| 128 | } else if (int (key) == lay::KeyUp) { |
| 129 | dy = 1.0; |
| 130 | } else if (int (key) == lay::KeyLeft) { |
| 131 | dx = -1.0; |
| 132 | } else if (int (key) == lay::KeyRight) { |
| 133 | dx = 1.0; |
| 134 | } |
| 135 | |
| 136 | if (! m_dragging && fabs (dx + dy) > 0.0 && mp_editables->has_selection ()) { |
| 137 | |
| 138 | // determine a shift distance which is 2, 5 or 10 times the grid and is more than 5 pixels |
| 139 | double dmin = double (5 /*pixels min shift*/) / ui ()->mouse_event_trans ().mag (); |
| 140 | double d = m_global_grid; |
| 141 | while (d < dmin) { |
| 142 | d *= 2.0; |
| 143 | if (d < dmin) { |
| 144 | d *= 2.5; |
| 145 | if (d < dmin) { |
| 146 | d *= 2.0; |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | db::DVector s = db::DVector (dx * d, dy * d); |
| 152 | m_shift += s; |
| 153 | |
| 154 | std::string pos = std::string ("dx: ") + tl::micron_to_string (m_shift.x ()) + " dy: " + tl::micron_to_string (m_shift.y ()); |
| 155 | mp_view->message (pos); |
| 156 | |
| 157 | mp_editables->transform (db::DCplxTrans (s)); |
| 158 | |
| 159 | return true; |
| 160 | |
| 161 | } else { |
| 162 | return false; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | bool |
| 167 | MoveService::shortcut_override_event (unsigned int key, unsigned int buttons) |
no test coverage detected