| 1251 | //----------------------------------------------------------------------------- |
| 1252 | |
| 1253 | void GuiEditCtrl::cloneSelection() |
| 1254 | { |
| 1255 | Vector< GuiControl* > newSelection; |
| 1256 | |
| 1257 | // Clone the controls in the current selection. |
| 1258 | |
| 1259 | const U32 numOldControls = mSelectedControls.size(); |
| 1260 | for( U32 i = 0; i < numOldControls; ++ i ) |
| 1261 | { |
| 1262 | GuiControl* ctrl = mSelectedControls[ i ]; |
| 1263 | |
| 1264 | // If parent is in selection, too, skip to prevent multiple clones. |
| 1265 | |
| 1266 | if( ctrl->getParent() && selectionContains( ctrl->getParent() ) ) |
| 1267 | continue; |
| 1268 | |
| 1269 | // Clone and add to set. |
| 1270 | |
| 1271 | GuiControl* clone = dynamic_cast< GuiControl* >( ctrl->deepClone() ); |
| 1272 | if( clone ) |
| 1273 | newSelection.push_back( clone ); |
| 1274 | } |
| 1275 | |
| 1276 | // Exchange the selection set. |
| 1277 | |
| 1278 | clearSelection(); |
| 1279 | const U32 numNewControls = newSelection.size(); |
| 1280 | for( U32 i = 0; i < numNewControls; ++ i ) |
| 1281 | addSelection( newSelection[ i ] ); |
| 1282 | |
| 1283 | // Callback for undo. |
| 1284 | |
| 1285 | onSelectionCloned_callback( getSelectedSet() ); |
| 1286 | } |
| 1287 | |
| 1288 | //----------------------------------------------------------------------------- |
| 1289 |
nothing calls this directly
no test coverage detected