Select - Patch67/Graphics GitHub Wiki
####Use Case A user could press [Ctrl]A for Select All and to press it again would deselect all.
Once is Select mode the user can : -
- Click on individual graphics objects pick to select a single object. Note: This will remove all previous items from the selection list.
- Click and Drag to create a selection box and to select every graphics object within the box. Note: This will remove all previous items from the selection list.
The Shift and Control keys can be used as modifiers to the above operations
- Shift Click will pick objects to add the selection list.
- Control Click will add them to the selection list or to remove them if already present.
- Shift Click Drag will add the objects within the selection box to the selection list.
- Control Click Drag should add the objects within the selection box to the selection list and remove any objects already in the selection list. I don't see this as a useful feature.
######Update: 01/06/2015 I am going to add a subcommand to SELECT; SELECT ... BOX. This will be triggered by the user pressing the B key whilst in SELECT mode. This will result in the next two left_clicks being interpreted as defining a Selection Box. Once this box is complete operations will resort to single pick mode. Pressing B again will allow another Selection box, etc. Pressing Escape whilst in Selection Box Mode will resort to single pick mode.
####Pick This will require each graphics object to have a pick method ... graph.pick(v, d):
Where v is a vector corresponding to the mouse click and d is the allowable distance.
Note that v and d at present are screen space but when we implement pan and zoom they will both need transforming to world space.
Circle.Pick is complete. Compare the distance between the click and the centre of the circle to the radius. if the difference between the two is less than the given pick distance then we have picked it.
Rectangle.Pick is complete. Look at each line in turn to see if the click was near to it. This is made much easier as the lines are either horizontal or vertical.
This method will not work if the rectangle is rotated.
####Selection Box
This will require each graphics object to have a bounding box and a method to decide if that bounding box is within the selection box.
Left Click or Left Release that is the question. So far everything I've done has been based on Left clicks. But now I've come to implement a Selection Box I find the most intuitive way to do it is to drag the box with the left mouse button held down.
This raises an interesting situation because there are now three interesting events, not just one.
- control.cmd_left_click(x, y) # start sequence
- control.cmd_left_drag(x, y) # multiple occurences
- control.cmd_left_release(x, y) # end sequence
####Selection List This will be a list containing references to the selected graphics objects. Any object in the selection list will be draw in a different way, i.e. dotted line or coloured line to indicate they are selected. Once the selection list has multiple elements it's context menu can be set to the basic editing options such as Cut, Copy, Paste, Delete, Move, etc. If all the items in the selection list are the same type then you could edit common properties, for example if all the elements were text then you could change all font sizes to the same value.
#####Update: 2nd June 2015 There is no need for a separate selection list. Just add a selected Boolean field to the Graph class from which all graphics elements derive. This could be implemented as a property. This then has implications when drawing the view. The application will need to question whether the element is selected or not and draw the element in a different style to indicate if selected. This also has implications for the way the code works. Canvas elements are static, i.e. once created they stay there until removed. Until now I have left them, as they are but when an item is selected it will need to be redrawn and that has problems as there is no direct link between the Model representation of the data and the Canvas visualisation. It would be easiest to use something like canvas.delete(ALL) and then to redraw the entire model.
#####Update: 5th June 2015 I've added a selected field the the Graph class which all its descendants pull down. If its true, it's selected. I've also changed the drawing code within View to colour the selected items blue. I am concentrating on select all and paste for now as this will get me very far, the other features such as delete and Cut should be really easy to implement once this is done.
####Implementation
- Implement Selection Box. See Issue 11: Implement Selection Box
- Implement Pick. See issue blah blah
####History Select was first added in [Version 0.2](Version 0.2)